/packages/amunits/src/otherlibs/guigfx.pas

https://github.com/slibre/freepascal · Pascal · 787 lines · 620 code · 80 blank · 87 comment · 6 complexity · af7c0d4912577079ab61958cc09cd453 MD5 · raw file

  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 2003 by Nils Sjöholm.
  5. member of the Amiga RTL development team.
  6. This is a unit for guigfx.library
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {
  14. History:
  15. First version of this unit.
  16. 15 Jan 2003.
  17. Changed cardinal > longword.
  18. Changed startcode for unit.
  19. 12 Feb 2003.
  20. nils.sjoholm@mailbox.swipnet.se Nils Sjoholm
  21. }
  22. {$mode objfpc}
  23. {$I useamigasmartlink.inc}
  24. {$ifdef use_amiga_smartlink}
  25. {$smartlink on}
  26. {$endif use_amiga_smartlink}
  27. UNIT GUIGFX;
  28. INTERFACE
  29. USES Exec,utility,graphics;
  30. VAR GuiGFXBase : pLibrary;
  31. const
  32. GUIGFXNAME : PChar = 'guigfx.library';
  33. {
  34. $VER: guigfx.h 17.2 (9.2.2000)
  35. guigfx.library definitions
  36. © 1997-2000 TEK neoscientists
  37. }
  38. {
  39. Tags
  40. }
  41. const
  42. GGFX_Dummy = 4567 + TAG_USER;
  43. { strictly private }
  44. GGFX_Owner = GGFX_Dummy + 0;
  45. GGFX_HSType = GGFX_Dummy + 1;
  46. GGFX_DitherMode = GGFX_Dummy + 2;
  47. GGFX_DitherAmount = GGFX_Dummy + 3;
  48. GGFX_AutoDither = GGFX_Dummy + 4;
  49. GGFX_DitherThreshold = GGFX_Dummy + 5;
  50. GGFX_AspectX = GGFX_Dummy + 6;
  51. GGFX_AspectY = GGFX_Dummy + 7;
  52. GGFX_PixelFormat = GGFX_Dummy + 8;
  53. GGFX_Palette = GGFX_Dummy + 9;
  54. GGFX_PaletteFormat = GGFX_Dummy + 10;
  55. GGFX_NumColors = GGFX_Dummy + 11;
  56. GGFX_Precision = GGFX_Dummy + 12;
  57. GGFX_Weight = GGFX_Dummy + 13;
  58. GGFX_Ratio = GGFX_Dummy + 14;
  59. GGFX_SourceWidth = GGFX_Dummy + 15;
  60. GGFX_SourceHeight = GGFX_Dummy + 16;
  61. GGFX_SourceX = GGFX_Dummy + 17;
  62. GGFX_SourceY = GGFX_Dummy + 18;
  63. GGFX_DestWidth = GGFX_Dummy + 19;
  64. GGFX_DestHeight = GGFX_Dummy + 20;
  65. GGFX_DestX = GGFX_Dummy + 21;
  66. GGFX_DestY = GGFX_Dummy + 22;
  67. GGFX_CallBackHook = GGFX_Dummy + 23;
  68. GGFX_ErrorCode = GGFX_Dummy + 24;
  69. GGFX_MaxAllocPens = GGFX_Dummy + 25;
  70. GGFX_BufferSize = GGFX_Dummy + 26;
  71. GGFX_AlphaPresent = GGFX_Dummy + 27;
  72. GGFX_Independent = GGFX_Dummy + 28;
  73. GGFX_ModeID = GGFX_Dummy + 29;
  74. GGFX_PenTable = GGFX_Dummy + 30;
  75. { obsolete }
  76. GGFX_License = GGFX_Dummy + 31;
  77. GGFX_BGColor = GGFX_Dummy + 32;
  78. GGFX_UseMask = GGFX_Dummy + 33;
  79. GGFX_RastLock = GGFX_Dummy + 34;
  80. GGFX_FormatName = GGFX_Dummy + 35;
  81. {
  82. Picture Attributes
  83. }
  84. PICATTR_Dummy = 123 + TAG_USER;
  85. PICATTR_Width = PICATTR_Dummy + 0;
  86. PICATTR_Height = PICATTR_Dummy + 1;
  87. PICATTR_RawData = PICATTR_Dummy + 2;
  88. PICATTR_PixelFormat = PICATTR_Dummy + 3;
  89. PICATTR_AspectX = PICATTR_Dummy + 4;
  90. PICATTR_AspectY = PICATTR_Dummy + 5;
  91. PICATTR_AlphaPresent = PICATTR_Dummy + 6;
  92. {
  93. Picture Methods
  94. }
  95. PICMTHD_CROP = 1;
  96. PICMTHD_RENDER = 2;
  97. PICMTHD_SCALE = 3;
  98. PICMTHD_MIX = 4;
  99. PICMTHD_SETALPHA = 5;
  100. PICMTHD_MIXALPHA = 6;
  101. PICMTHD_MAPDRAWHANDLE = 7;
  102. PICMTHD_CREATEALPHAMASK = 8;
  103. PICMTHD_TINT = 9;
  104. PICMTHD_TEXTURE = 10;
  105. PICMTHD_SET = 11;
  106. PICMTHD_TINTALPHA = 12;
  107. PICMTHD_INSERT = 13;
  108. PICMTHD_FLIPX = 14;
  109. PICMTHD_FLIPY = 15;
  110. PICMTHD_CHECKAUTODITHER = 16;
  111. PICMTHD_NEGATIVE = 17;
  112. PICMTHD_AUTOCROP = 18;
  113. PICMTHD_CONVOLVE = 19;
  114. {
  115. hook message types
  116. }
  117. GGFX_MSGTYPE_LINEDRAWN = 1;
  118. {
  119. picture locking
  120. }
  121. LOCKMODE_DRAWHANDLE = 1;
  122. LOCKMODE_FORCE = 1 shl 8;
  123. LOCKMODE_MASK = $ff;
  124. {
  125. bitmap attributes
  126. (strictly internal)
  127. }
  128. const
  129. BMAPATTR_Width = 0 + TAG_USER;
  130. BMAPATTR_Height = 1 + TAG_USER;
  131. BMAPATTR_Depth = 2 + TAG_USER;
  132. BMAPATTR_CyberGFX = 3 + TAG_USER;
  133. BMAPATTR_BitMapFormat = 4 + TAG_USER;
  134. BMAPATTR_PixelFormat = 5 + TAG_USER;
  135. BMAPATTR_Flags = 6 + TAG_USER;
  136. FUNCTION AddPaletteA(psm : POINTER; palette : POINTER; tags : pTagItem) : POINTER;
  137. FUNCTION AddPictureA(psm : POINTER; pic : POINTER; tags : pTagItem) : POINTER;
  138. FUNCTION AddPixelArrayA(psm : POINTER; _array : POINTER; width : WORD; height : WORD; tags : pTagItem) : POINTER;
  139. FUNCTION ClonePictureA(pic : POINTER; tags : pTagItem) : POINTER;
  140. FUNCTION CreateDirectDrawHandleA(drawhandle : POINTER; sw : WORD; sh : WORD; dw : WORD; dh : WORD; tags : pTagItem) : POINTER;
  141. FUNCTION CreatePenShareMapA(tags : pTagItem) : POINTER;
  142. FUNCTION CreatePictureBitMapA(drawhandle : POINTER; pic : POINTER; tags : pTagItem) : pBitMap;
  143. FUNCTION CreatePictureMaskA(pic : POINTER; mask : pCHAR; maskwidth : WORD; tags : pTagItem) : BOOLEAN;
  144. PROCEDURE DeleteDirectDrawHandle(ddh : POINTER);
  145. PROCEDURE DeletePenShareMap(psm : POINTER);
  146. PROCEDURE DeletePicture(pic : POINTER);
  147. FUNCTION DirectDrawTrueColorA(ddh : POINTER; _array : pULONG; x : WORD; y : WORD; tags : pTagItem) : BOOLEAN;
  148. FUNCTION DoPictureMethodA(pic : POINTER; method : longword; arguments : pULONG) : longword;
  149. FUNCTION DrawPictureA(drawhandle : POINTER; pic : POINTER; x : WORD; y : WORD; tags : pTagItem) : BOOLEAN;
  150. FUNCTION GetPictureAttrsA(pic : POINTER; tags : pTagItem) : longword;
  151. FUNCTION IsPictureA(filename : pCHAR; tags : pTagItem) : BOOLEAN;
  152. FUNCTION LoadPictureA(filename : pCHAR; tags : pTagItem) : POINTER;
  153. FUNCTION LockPictureA(pic : POINTER; mode : longword; args : pULONG) : longword;
  154. FUNCTION MakePictureA(_array : POINTER; width : WORD; height : WORD; tags : pTagItem) : POINTER;
  155. FUNCTION MapPaletteA(drawhandle : POINTER; palette : POINTER; pentab : pCHAR; tags : pTagItem) : BOOLEAN;
  156. FUNCTION MapPenA(drawhandle : POINTER; rgb : longword; tags : pTagItem) : LONGINT;
  157. FUNCTION ObtainDrawHandleA(psm : POINTER; a1arg : pRastPort; cm : pColorMap; tags : pTagItem) : POINTER;
  158. FUNCTION ReadPictureA(a0arg : pRastPort; colormap : pColorMap; x : WORD; y : WORD; width : WORD; height : WORD; tags : pTagItem) : POINTER;
  159. PROCEDURE ReleaseDrawHandle(drawhandle : POINTER);
  160. PROCEDURE RemColorHandle(colorhandle : POINTER);
  161. PROCEDURE UnLockPicture(pic : POINTER; mode : longword);
  162. {
  163. Functions and procedures with array of const go here
  164. }
  165. FUNCTION AddPalette(psm : POINTER; palette : POINTER; const tags : Array Of Const) : POINTER;
  166. FUNCTION AddPicture(psm : POINTER; pic : POINTER; const tags : Array Of Const) : POINTER;
  167. FUNCTION AddPixelArray(psm : POINTER; _array : POINTER; width : WORD; height : WORD; const tags : Array Of Const) : POINTER;
  168. FUNCTION ClonePicture(pic : POINTER; const tags : Array Of Const) : POINTER;
  169. FUNCTION CreateDirectDrawHandle(drawhandle : POINTER; sw : WORD; sh : WORD; dw : WORD; dh : WORD; const tags : Array Of Const) : POINTER;
  170. FUNCTION CreatePenShareMap(const tags : Array Of Const) : POINTER;
  171. FUNCTION CreatePictureBitMap(drawhandle : POINTER; pic : POINTER; const tags : Array Of Const) : pBitMap;
  172. FUNCTION CreatePictureMask(pic : POINTER; mask : pCHAR; maskwidth : WORD; const tags : Array Of Const) : BOOLEAN;
  173. FUNCTION DirectDrawTrueColor(ddh : POINTER; _array : pULONG; x : WORD; y : WORD; const tags : Array Of Const) : BOOLEAN;
  174. FUNCTION DoPictureMethod(pic : POINTER; method : longword; const arguments : Array Of Const) : longword;
  175. FUNCTION DrawPicture(drawhandle : POINTER; pic : POINTER; x : WORD; y : WORD; const tags : Array Of Const) : BOOLEAN;
  176. FUNCTION GetPictureAttrs(pic : POINTER; const tags : Array Of Const) : longword;
  177. FUNCTION IsPicture(filename : pCHAR; const tags : Array Of Const) : BOOLEAN;
  178. FUNCTION LoadPicture(filename : pCHAR; const tags : Array Of Const) : POINTER;
  179. FUNCTION LockPicture(pic : POINTER; mode : longword; const args : Array Of Const) : longword;
  180. FUNCTION MakePicture(_array : POINTER; width : WORD; height : WORD; const tags : Array Of Const) : POINTER;
  181. FUNCTION MapPalette(drawhandle : POINTER; palette : POINTER; pentab : pCHAR; const tags : Array Of Const) : BOOLEAN;
  182. FUNCTION MapPen(drawhandle : POINTER; rgb : longword; const tags : Array Of Const) : LONGINT;
  183. FUNCTION ObtainDrawHandle(psm : POINTER; a1arg : pRastPort; cm : pColorMap; const tags : Array Of Const) : POINTER;
  184. FUNCTION ReadPicture(a0arg : pRastPort; colormap : pColorMap; x : WORD; y : WORD; width : WORD; height : WORD; const tags : Array Of Const) : POINTER;
  185. {You can remove this include and use a define instead}
  186. {$I useautoopenlib.inc}
  187. {$ifdef use_init_openlib}
  188. procedure InitGUIGFXLibrary;
  189. {$endif use_init_openlib}
  190. {This is a variable that knows how the unit is compiled}
  191. var
  192. GUIGFXIsCompiledHow : longint;
  193. IMPLEMENTATION
  194. uses
  195. {$ifndef dont_use_openlib}
  196. msgbox,
  197. {$endif dont_use_openlib}
  198. tagsarray,longarray;
  199. FUNCTION AddPaletteA(psm : POINTER; palette : POINTER; tags : pTagItem) : POINTER;
  200. BEGIN
  201. ASM
  202. MOVE.L A6,-(A7)
  203. MOVEA.L psm,A0
  204. MOVEA.L palette,A1
  205. MOVEA.L tags,A2
  206. MOVEA.L GuiGFXBase,A6
  207. JSR -072(A6)
  208. MOVEA.L (A7)+,A6
  209. MOVE.L D0,@RESULT
  210. END;
  211. END;
  212. FUNCTION AddPictureA(psm : POINTER; pic : POINTER; tags : pTagItem) : POINTER;
  213. BEGIN
  214. ASM
  215. MOVE.L A6,-(A7)
  216. MOVEA.L psm,A0
  217. MOVEA.L pic,A1
  218. MOVEA.L tags,A2
  219. MOVEA.L GuiGFXBase,A6
  220. JSR -066(A6)
  221. MOVEA.L (A7)+,A6
  222. MOVE.L D0,@RESULT
  223. END;
  224. END;
  225. FUNCTION AddPixelArrayA(psm : POINTER; _array : POINTER; width : WORD; height : WORD; tags : pTagItem) : POINTER;
  226. BEGIN
  227. ASM
  228. MOVE.L A6,-(A7)
  229. MOVEA.L psm,A0
  230. MOVEA.L _array,A1
  231. MOVE.L width,D0
  232. MOVE.L height,D1
  233. MOVEA.L tags,A2
  234. MOVEA.L GuiGFXBase,A6
  235. JSR -078(A6)
  236. MOVEA.L (A7)+,A6
  237. MOVE.L D0,@RESULT
  238. END;
  239. END;
  240. FUNCTION ClonePictureA(pic : POINTER; tags : pTagItem) : POINTER;
  241. BEGIN
  242. ASM
  243. MOVE.L A6,-(A7)
  244. MOVEA.L pic,A0
  245. MOVEA.L tags,A1
  246. MOVEA.L GuiGFXBase,A6
  247. JSR -048(A6)
  248. MOVEA.L (A7)+,A6
  249. MOVE.L D0,@RESULT
  250. END;
  251. END;
  252. FUNCTION CreateDirectDrawHandleA(drawhandle : POINTER; sw : WORD; sh : WORD; dw : WORD; dh : WORD; tags : pTagItem) : POINTER;
  253. BEGIN
  254. ASM
  255. MOVE.L A6,-(A7)
  256. MOVEA.L drawhandle,A0
  257. MOVE.L sw,D0
  258. MOVE.L sh,D1
  259. MOVE.L dw,D2
  260. MOVE.L dh,D3
  261. MOVEA.L tags,A1
  262. MOVEA.L GuiGFXBase,A6
  263. JSR -168(A6)
  264. MOVEA.L (A7)+,A6
  265. MOVE.L D0,@RESULT
  266. END;
  267. END;
  268. FUNCTION CreatePenShareMapA(tags : pTagItem) : POINTER;
  269. BEGIN
  270. ASM
  271. MOVE.L A6,-(A7)
  272. MOVEA.L tags,A0
  273. MOVEA.L GuiGFXBase,A6
  274. JSR -090(A6)
  275. MOVEA.L (A7)+,A6
  276. MOVE.L D0,@RESULT
  277. END;
  278. END;
  279. FUNCTION CreatePictureBitMapA(drawhandle : POINTER; pic : POINTER; tags : pTagItem) : pBitMap;
  280. BEGIN
  281. ASM
  282. MOVE.L A6,-(A7)
  283. MOVEA.L drawhandle,A0
  284. MOVEA.L pic,A1
  285. MOVEA.L tags,A2
  286. MOVEA.L GuiGFXBase,A6
  287. JSR -132(A6)
  288. MOVEA.L (A7)+,A6
  289. MOVE.L D0,@RESULT
  290. END;
  291. END;
  292. FUNCTION CreatePictureMaskA(pic : POINTER; mask : pCHAR; maskwidth : WORD; tags : pTagItem) : BOOLEAN;
  293. BEGIN
  294. ASM
  295. MOVE.L A6,-(A7)
  296. MOVEA.L pic,A0
  297. MOVEA.L mask,A1
  298. MOVE.L maskwidth,D0
  299. MOVEA.L tags,A2
  300. MOVEA.L GuiGFXBase,A6
  301. JSR -186(A6)
  302. MOVEA.L (A7)+,A6
  303. TST.W D0
  304. BEQ.B @end
  305. MOVEQ #1,D0
  306. @end: MOVE.B D0,@RESULT
  307. END;
  308. END;
  309. PROCEDURE DeleteDirectDrawHandle(ddh : POINTER);
  310. BEGIN
  311. ASM
  312. MOVE.L A6,-(A7)
  313. MOVEA.L ddh,A0
  314. MOVEA.L GuiGFXBase,A6
  315. JSR -174(A6)
  316. MOVEA.L (A7)+,A6
  317. END;
  318. END;
  319. PROCEDURE DeletePenShareMap(psm : POINTER);
  320. BEGIN
  321. ASM
  322. MOVE.L A6,-(A7)
  323. MOVEA.L psm,A0
  324. MOVEA.L GuiGFXBase,A6
  325. JSR -096(A6)
  326. MOVEA.L (A7)+,A6
  327. END;
  328. END;
  329. PROCEDURE DeletePicture(pic : POINTER);
  330. BEGIN
  331. ASM
  332. MOVE.L A6,-(A7)
  333. MOVEA.L pic,A0
  334. MOVEA.L GuiGFXBase,A6
  335. JSR -054(A6)
  336. MOVEA.L (A7)+,A6
  337. END;
  338. END;
  339. FUNCTION DirectDrawTrueColorA(ddh : POINTER; _array : pULONG; x : WORD; y : WORD; tags : pTagItem) : BOOLEAN;
  340. BEGIN
  341. ASM
  342. MOVE.L A6,-(A7)
  343. MOVEA.L ddh,A0
  344. MOVEA.L _array,A1
  345. MOVE.L x,D0
  346. MOVE.L y,D1
  347. MOVEA.L tags,A2
  348. MOVEA.L GuiGFXBase,A6
  349. JSR -180(A6)
  350. MOVEA.L (A7)+,A6
  351. TST.W D0
  352. BEQ.B @end
  353. MOVEQ #1,D0
  354. @end: MOVE.B D0,@RESULT
  355. END;
  356. END;
  357. FUNCTION DoPictureMethodA(pic : POINTER; method : longword; arguments : pULONG) : longword;
  358. BEGIN
  359. ASM
  360. MOVE.L A6,-(A7)
  361. MOVEA.L pic,A0
  362. MOVE.L method,D0
  363. MOVEA.L arguments,A1
  364. MOVEA.L GuiGFXBase,A6
  365. JSR -138(A6)
  366. MOVEA.L (A7)+,A6
  367. MOVE.L D0,@RESULT
  368. END;
  369. END;
  370. FUNCTION DrawPictureA(drawhandle : POINTER; pic : POINTER; x : WORD; y : WORD; tags : pTagItem) : BOOLEAN;
  371. BEGIN
  372. ASM
  373. MOVE.L A6,-(A7)
  374. MOVEA.L drawhandle,A0
  375. MOVEA.L pic,A1
  376. MOVE.L x,D0
  377. MOVE.L y,D1
  378. MOVEA.L tags,A2
  379. MOVEA.L GuiGFXBase,A6
  380. JSR -114(A6)
  381. MOVEA.L (A7)+,A6
  382. TST.W D0
  383. BEQ.B @end
  384. MOVEQ #1,D0
  385. @end: MOVE.B D0,@RESULT
  386. END;
  387. END;
  388. FUNCTION GetPictureAttrsA(pic : POINTER; tags : pTagItem) : longword;
  389. BEGIN
  390. ASM
  391. MOVE.L A6,-(A7)
  392. MOVEA.L pic,A0
  393. MOVEA.L tags,A1
  394. MOVEA.L GuiGFXBase,A6
  395. JSR -144(A6)
  396. MOVEA.L (A7)+,A6
  397. MOVE.L D0,@RESULT
  398. END;
  399. END;
  400. FUNCTION IsPictureA(filename : pCHAR; tags : pTagItem) : BOOLEAN;
  401. BEGIN
  402. ASM
  403. MOVE.L A6,-(A7)
  404. MOVEA.L filename,A0
  405. MOVEA.L tags,A1
  406. MOVEA.L GuiGFXBase,A6
  407. JSR -162(A6)
  408. MOVEA.L (A7)+,A6
  409. TST.W D0
  410. BEQ.B @end
  411. MOVEQ #1,D0
  412. @end: MOVE.B D0,@RESULT
  413. END;
  414. END;
  415. FUNCTION LoadPictureA(filename : pCHAR; tags : pTagItem) : POINTER;
  416. BEGIN
  417. ASM
  418. MOVE.L A6,-(A7)
  419. MOVEA.L filename,A0
  420. MOVEA.L tags,A1
  421. MOVEA.L GuiGFXBase,A6
  422. JSR -036(A6)
  423. MOVEA.L (A7)+,A6
  424. MOVE.L D0,@RESULT
  425. END;
  426. END;
  427. FUNCTION LockPictureA(pic : POINTER; mode : longword; args : pULONG) : longword;
  428. BEGIN
  429. ASM
  430. MOVE.L A6,-(A7)
  431. MOVEA.L pic,A0
  432. MOVE.L mode,D0
  433. MOVEA.L args,A1
  434. MOVEA.L GuiGFXBase,A6
  435. JSR -150(A6)
  436. MOVEA.L (A7)+,A6
  437. MOVE.L D0,@RESULT
  438. END;
  439. END;
  440. FUNCTION MakePictureA(_array : POINTER; width : WORD; height : WORD; tags : pTagItem) : POINTER;
  441. BEGIN
  442. ASM
  443. MOVE.L A6,-(A7)
  444. MOVEA.L _array,A0
  445. MOVE.L width,D0
  446. MOVE.L height,D1
  447. MOVEA.L tags,A1
  448. MOVEA.L GuiGFXBase,A6
  449. JSR -030(A6)
  450. MOVEA.L (A7)+,A6
  451. MOVE.L D0,@RESULT
  452. END;
  453. END;
  454. FUNCTION MapPaletteA(drawhandle : POINTER; palette : POINTER; pentab : pCHAR; tags : pTagItem) : BOOLEAN;
  455. BEGIN
  456. ASM
  457. MOVE.L A6,-(A7)
  458. MOVEA.L drawhandle,A0
  459. MOVEA.L palette,A1
  460. MOVEA.L pentab,A2
  461. MOVEA.L tags,A3
  462. MOVEA.L GuiGFXBase,A6
  463. JSR -120(A6)
  464. MOVEA.L (A7)+,A6
  465. TST.W D0
  466. BEQ.B @end
  467. MOVEQ #1,D0
  468. @end: MOVE.B D0,@RESULT
  469. END;
  470. END;
  471. FUNCTION MapPenA(drawhandle : POINTER; rgb : longword; tags : pTagItem) : LONGINT;
  472. BEGIN
  473. ASM
  474. MOVE.L A6,-(A7)
  475. MOVEA.L drawhandle,A0
  476. MOVEA.L rgb,A1
  477. MOVEA.L tags,A2
  478. MOVEA.L GuiGFXBase,A6
  479. JSR -126(A6)
  480. MOVEA.L (A7)+,A6
  481. MOVE.L D0,@RESULT
  482. END;
  483. END;
  484. FUNCTION ObtainDrawHandleA(psm : POINTER; a1arg : pRastPort; cm : pColorMap; tags : pTagItem) : POINTER;
  485. BEGIN
  486. ASM
  487. MOVE.L A6,-(A7)
  488. MOVEA.L psm,A0
  489. MOVEA.L a1arg,A1
  490. MOVEA.L cm,A2
  491. MOVEA.L tags,A3
  492. MOVEA.L GuiGFXBase,A6
  493. JSR -102(A6)
  494. MOVEA.L (A7)+,A6
  495. MOVE.L D0,@RESULT
  496. END;
  497. END;
  498. FUNCTION ReadPictureA(a0arg : pRastPort; colormap : pColorMap; x : WORD; y : WORD; width : WORD; height : WORD; tags : pTagItem) : POINTER;
  499. BEGIN
  500. ASM
  501. MOVE.L A6,-(A7)
  502. MOVEA.L a0arg,A0
  503. MOVEA.L colormap,A1
  504. MOVE.L x,D0
  505. MOVE.L y,D1
  506. MOVE.L width,D2
  507. MOVE.L height,D3
  508. MOVEA.L tags,A2
  509. MOVEA.L GuiGFXBase,A6
  510. JSR -042(A6)
  511. MOVEA.L (A7)+,A6
  512. MOVE.L D0,@RESULT
  513. END;
  514. END;
  515. PROCEDURE ReleaseDrawHandle(drawhandle : POINTER);
  516. BEGIN
  517. ASM
  518. MOVE.L A6,-(A7)
  519. MOVEA.L drawhandle,A0
  520. MOVEA.L GuiGFXBase,A6
  521. JSR -108(A6)
  522. MOVEA.L (A7)+,A6
  523. END;
  524. END;
  525. PROCEDURE RemColorHandle(colorhandle : POINTER);
  526. BEGIN
  527. ASM
  528. MOVE.L A6,-(A7)
  529. MOVEA.L colorhandle,A0
  530. MOVEA.L GuiGFXBase,A6
  531. JSR -084(A6)
  532. MOVEA.L (A7)+,A6
  533. END;
  534. END;
  535. PROCEDURE UnLockPicture(pic : POINTER; mode : longword);
  536. BEGIN
  537. ASM
  538. MOVE.L A6,-(A7)
  539. MOVEA.L pic,A0
  540. MOVE.L mode,D0
  541. MOVEA.L GuiGFXBase,A6
  542. JSR -156(A6)
  543. MOVEA.L (A7)+,A6
  544. END;
  545. END;
  546. {
  547. Functions and procedures with array of const go here
  548. }
  549. FUNCTION AddPalette(psm : POINTER; palette : POINTER; const tags : Array Of Const) : POINTER;
  550. begin
  551. AddPalette := AddPaletteA(psm , palette , readintags(tags));
  552. end;
  553. FUNCTION AddPicture(psm : POINTER; pic : POINTER; const tags : Array Of Const) : POINTER;
  554. begin
  555. AddPicture := AddPictureA(psm , pic , readintags(tags));
  556. end;
  557. FUNCTION AddPixelArray(psm : POINTER; _array : POINTER; width : WORD; height : WORD; const tags : Array Of Const) : POINTER;
  558. begin
  559. AddPixelArray := AddPixelArrayA(psm , _array , width , height , readintags(tags));
  560. end;
  561. FUNCTION ClonePicture(pic : POINTER; const tags : Array Of Const) : POINTER;
  562. begin
  563. ClonePicture := ClonePictureA(pic , readintags(tags));
  564. end;
  565. FUNCTION CreateDirectDrawHandle(drawhandle : POINTER; sw : WORD; sh : WORD; dw : WORD; dh : WORD; const tags : Array Of Const) : POINTER;
  566. begin
  567. CreateDirectDrawHandle := CreateDirectDrawHandleA(drawhandle , sw , sh , dw , dh , readintags(tags));
  568. end;
  569. FUNCTION CreatePenShareMap(const tags : Array Of Const) : POINTER;
  570. begin
  571. CreatePenShareMap := CreatePenShareMapA(readintags(tags));
  572. end;
  573. FUNCTION CreatePictureBitMap(drawhandle : POINTER; pic : POINTER; const tags : Array Of Const) : pBitMap;
  574. begin
  575. CreatePictureBitMap := CreatePictureBitMapA(drawhandle , pic , readintags(tags));
  576. end;
  577. FUNCTION CreatePictureMask(pic : POINTER; mask : pCHAR; maskwidth : WORD; const tags : Array Of Const) : BOOLEAN;
  578. begin
  579. CreatePictureMask := CreatePictureMaskA(pic , mask , maskwidth , readintags(tags));
  580. end;
  581. FUNCTION DirectDrawTrueColor(ddh : POINTER; _array : pULONG; x : WORD; y : WORD; const tags : Array Of Const) : BOOLEAN;
  582. begin
  583. DirectDrawTrueColor := DirectDrawTrueColorA(ddh , _array , x , y , readintags(tags));
  584. end;
  585. FUNCTION DoPictureMethod(pic : POINTER; method : longword; const arguments : Array Of Const) : longword;
  586. begin
  587. DoPictureMethod := DoPictureMethodA(pic , method , readinlongs(arguments));
  588. end;
  589. FUNCTION DrawPicture(drawhandle : POINTER; pic : POINTER; x : WORD; y : WORD; const tags : Array Of Const) : BOOLEAN;
  590. begin
  591. DrawPicture := DrawPictureA(drawhandle , pic , x , y , readintags(tags));
  592. end;
  593. FUNCTION GetPictureAttrs(pic : POINTER; const tags : Array Of Const) : longword;
  594. begin
  595. GetPictureAttrs := GetPictureAttrsA(pic , readintags(tags));
  596. end;
  597. FUNCTION IsPicture(filename : pCHAR; const tags : Array Of Const) : BOOLEAN;
  598. begin
  599. IsPicture := IsPictureA(filename , readintags(tags));
  600. end;
  601. FUNCTION LoadPicture(filename : pCHAR; const tags : Array Of Const) : POINTER;
  602. begin
  603. LoadPicture := LoadPictureA(filename , readintags(tags));
  604. end;
  605. FUNCTION LockPicture(pic : POINTER; mode : longword; const args : Array Of Const) : longword;
  606. begin
  607. LockPicture := LockPictureA(pic , mode , readinlongs(args));
  608. end;
  609. FUNCTION MakePicture(_array : POINTER; width : WORD; height : WORD; const tags : Array Of Const) : POINTER;
  610. begin
  611. MakePicture := MakePictureA(_array , width , height , readintags(tags));
  612. end;
  613. FUNCTION MapPalette(drawhandle : POINTER; palette : POINTER; pentab : pCHAR; const tags : Array Of Const) : BOOLEAN;
  614. begin
  615. MapPalette := MapPaletteA(drawhandle , palette , pentab , readintags(tags));
  616. end;
  617. FUNCTION MapPen(drawhandle : POINTER; rgb : longword; const tags : Array Of Const) : LONGINT;
  618. begin
  619. MapPen := MapPenA(drawhandle , rgb , readintags(tags));
  620. end;
  621. FUNCTION ObtainDrawHandle(psm : POINTER; a1arg : pRastPort; cm : pColorMap; const tags : Array Of Const) : POINTER;
  622. begin
  623. ObtainDrawHandle := ObtainDrawHandleA(psm , a1arg , cm , readintags(tags));
  624. end;
  625. FUNCTION ReadPicture(a0arg : pRastPort; colormap : pColorMap; x : WORD; y : WORD; width : WORD; height : WORD; const tags : Array Of Const) : POINTER;
  626. begin
  627. ReadPicture := ReadPictureA(a0arg , colormap , x , y , width , height , readintags(tags));
  628. end;
  629. const
  630. { Change VERSION and LIBVERSION to proper values }
  631. VERSION : string[2] = '0';
  632. LIBVERSION : longword = 0;
  633. {$ifdef use_init_openlib}
  634. {$Info Compiling initopening of guigfx.library}
  635. {$Info don't forget to use InitGUIGFXLibrary in the beginning of your program}
  636. var
  637. guigfx_exit : Pointer;
  638. procedure CloseguigfxLibrary;
  639. begin
  640. ExitProc := guigfx_exit;
  641. if GuiGFXBase <> nil then begin
  642. CloseLibrary(GuiGFXBase);
  643. GuiGFXBase := nil;
  644. end;
  645. end;
  646. procedure InitGUIGFXLibrary;
  647. begin
  648. GuiGFXBase := nil;
  649. GuiGFXBase := OpenLibrary(GUIGFXNAME,LIBVERSION);
  650. if GuiGFXBase <> nil then begin
  651. guigfx_exit := ExitProc;
  652. ExitProc := @CloseguigfxLibrary;
  653. end else begin
  654. MessageBox('FPC Pascal Error',
  655. 'Can''t open guigfx.library version ' + VERSION + #10 +
  656. 'Deallocating resources and closing down',
  657. 'Oops');
  658. halt(20);
  659. end;
  660. end;
  661. begin
  662. GUIGFXIsCompiledHow := 2;
  663. {$endif use_init_openlib}
  664. {$ifdef use_auto_openlib}
  665. {$Info Compiling autoopening of guigfx.library}
  666. var
  667. guigfx_exit : Pointer;
  668. procedure CloseguigfxLibrary;
  669. begin
  670. ExitProc := guigfx_exit;
  671. if GuiGFXBase <> nil then begin
  672. CloseLibrary(GuiGFXBase);
  673. GuiGFXBase := nil;
  674. end;
  675. end;
  676. begin
  677. GuiGFXBase := nil;
  678. GuiGFXBase := OpenLibrary(GUIGFXNAME,LIBVERSION);
  679. if GuiGFXBase <> nil then begin
  680. guigfx_exit := ExitProc;
  681. ExitProc := @CloseguigfxLibrary;
  682. GUIGFXIsCompiledHow := 1;
  683. end else begin
  684. MessageBox('FPC Pascal Error',
  685. 'Can''t open guigfx.library version ' + VERSION + #10 +
  686. 'Deallocating resources and closing down',
  687. 'Oops');
  688. halt(20);
  689. end;
  690. {$endif use_auto_openlib}
  691. {$ifdef dont_use_openlib}
  692. begin
  693. GUIGFXIsCompiledHow := 3;
  694. {$Warning No autoopening of guigfx.library compiled}
  695. {$Warning Make sure you open guigfx.library yourself}
  696. {$endif dont_use_openlib}
  697. END. (* UNIT GUIGFX *)