PageRenderTime 18ms CodeModel.GetById 11ms app.highlight 4ms RepoModel.GetById 0ms app.codeStats 1ms

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