1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
|
{
This file is part of the Free Pascal MorphOS support package
Copyright (c) 2015 Karoly Balogh
member of the Free Pascal Development Team
cybergraphics.library interface unit
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
{$mode fpc}
{$packrecords 2}
UNIT CYBERGRAPHICS;
INTERFACE
USES
exec,agraphics,utility;
VAR CyberGfxBase : pLibrary = nil;
const
CYBERGRAPHICSNAME : PChar = 'cybergraphics.library';
{
Contents of this file is based on cybergraphics.h from the MorphOS SDK:
$VER: cybergraphics.h 50.12 (13.08.2008)
include file for cybergraphics.library
Copyright (c) 1996-2008 by Vision Factory Development
All Rights reserved.
}
const
CYBERGFXNAME = 'cybergraphics.library';
CYBERGFX_INCLUDE_VERSION = 41;
{
Definition of CyberModeNode (Returned in AllocModeList)
}
type
PCyberModeNode = ^tCyberModeNode;
tCyberModeNode = record
Node : tNode;
ModeText : array[0..(DISPLAYNAMELEN)-1] of char; { name for this mode }
DisplayID : ULONG; { display id associated with the node }
Width : UWORD; { visible width }
Height : UWORD; { visible height }
Depth : UWORD; { display depth }
DisplayTagList : PTagItem; { taglist with extended ModeID information }
end;
{
Parameters for GetCyberMapAttr()
}
const
{ function returns BytesPerRow if its called with this parameter }
CYBRMATTR_XMOD = $80000001;
{ BytesPerPixel shall be returned }
CYBRMATTR_BPPIX = $80000002;
{ do not use this ! private tag }
CYBRMATTR_DISPADR = $80000003;
{ the pixel format is returned }
CYBRMATTR_PIXFMT = $80000004;
{ returns width in pixels }
CYBRMATTR_WIDTH = $80000005;
{ returns height in lines }
CYBRMATTR_HEIGHT = $80000006;
{ returns bits per pixel }
CYBRMATTR_DEPTH = $80000007;
{ returns -1 if supplied bitmap is a cybergfx one }
CYBRMATTR_ISCYBERGFX = $80000008;
{ returns -1 if supplied bitmap is linear accessable }
CYBRMATTR_ISLINEARMEM = $80000009;
{ returns colormap associated with that bitmap (v50) }
CYBRMATTR_COLORMAP = $8000000A;
{
Parameters for GetCyberIDAttr()
}
{ the pixel format is returned }
CYBRIDATTR_PIXFMT = $80000001;
{ returns visible width in pixels }
CYBRIDATTR_WIDTH = $80000002;
{ returns visible height in lines }
CYBRIDATTR_HEIGHT = $80000003;
{ returns bits per pixel }
CYBRIDATTR_DEPTH = $80000004;
{ BytesPerPixel shall be returned }
CYBRIDATTR_BPPIX = $80000005;
{
Tags for CyberModeRequest()
}
CYBRMREQ_TB = TAG_USER + $40000;
{
FilterTags
}
{ Minimum depth for displayed screenmode }
CYBRMREQ_MinDepth = CYBRMREQ_TB + 0;
{ Maximum depth " " " }
CYBRMREQ_MaxDepth = CYBRMREQ_TB + 1;
{ Minumum width " " " }
CYBRMREQ_MinWidth = CYBRMREQ_TB + 2;
{ Maximum width " " " }
CYBRMREQ_MaxWidth = CYBRMREQ_TB + 3;
{ Minumum height " " " }
CYBRMREQ_MinHeight = CYBRMREQ_TB + 4;
{ Minumum height " " " }
CYBRMREQ_MaxHeight = CYBRMREQ_TB + 5;
CYBRMREQ_CModelArray = CYBRMREQ_TB + 6;
CYBRMREQ_WinTitle = CYBRMREQ_TB + 20;
CYBRMREQ_OKText = CYBRMREQ_TB + 21;
CYBRMREQ_CancelText = CYBRMREQ_TB + 22;
{ Screen you wish the Requester to open on }
CYBRMREQ_Screen = CYBRMREQ_TB + 30;
{
Tags for BestCyberModeID()
}
CYBRBIDTG_TB = TAG_USER + $50000;
{ FilterTags }
CYBRBIDTG_Depth = CYBRBIDTG_TB + 0;
CYBRBIDTG_NominalWidth = CYBRBIDTG_TB + 1;
CYBRBIDTG_NominalHeight = CYBRBIDTG_TB + 2;
CYBRBIDTG_MonitorID = CYBRBIDTG_TB + 3;
CYBRBIDTG_BoardName = CYBRBIDTG_TB + 5;
{
definition of divers pixel formats
}
PIXFMT_LUT8 = 0;
PIXFMT_RGB15 = 1;
PIXFMT_RGB15X = 2;
PIXFMT_BGR15 = 2;
PIXFMT_RGB15PC = 3;
PIXFMT_BGR15PC = 4;
PIXFMT_RGB16 = 5;
PIXFMT_BGR16 = 6;
PIXFMT_RGB16PC = 7;
PIXFMT_BGR16PC = 8;
PIXFMT_RGB24 = 9;
PIXFMT_BGR24 = 10;
PIXFMT_ARGB32 = 11;
PIXFMT_BGRA32 = 12;
PIXFMT_RGBA32 = 13;
{
SrcRectangle formats defines for xxxPixelArray calls()
}
RECTFMT_RGB = 0;
RECTFMT_RGBA = 1;
RECTFMT_ARGB = 2;
RECTFMT_LUT8 = 3;
RECTFMT_GREY8 = 4;
RECTFMT_RAW = 5;
{
Parameters for CVideoCtrlTagList()
}
SETVC_DPMSLevel = $88002001;
{ Full operation }
DPMS_ON = 0;
{ Optional state of minimal power reduction }
DPMS_STANDBY = 1;
{ Significant reduction of power consumption }
DPMS_SUSPEND = 2;
{ Lowest level of power consumption }
DPMS_OFF = 3;
{
Tags for LockBitMapTagList()
}
LBMI_WIDTH = $84001001;
LBMI_HEIGHT = $84001002;
LBMI_DEPTH = $84001003;
LBMI_PIXFMT = $84001004;
LBMI_BYTESPERPIX = $84001005;
LBMI_BYTESPERROW = $84001006;
LBMI_BASEADDRESS = $84001007;
{
Tags for UnLockBitMapTagList()
}
UBMI_UPDATERECTS = $85001001;
UBMI_REALLYUNLOCK = $85001002;
{
Message passed to the DoCDrawMethodTagList() hook function
}
type
PCDrawMsg = ^tCDrawMsg;
tCDrawMsg = record
cdm_MemPtr : APTR;
cdm_offx : ULONG;
cdm_offy : ULONG;
cdm_xsize : ULONG;
cdm_ysize : ULONG;
cdm_BytesPerRow : UWORD;
cdm_BytesPerPix : UWORD;
cdm_ColorModel : UWORD;
end;
{
Colour Table source formats for WriteLUTPixelArray()
}
{ ULONG [] table }
const
CTABFMT_XRGB8 = 0;
{
graphics.library/AllocBitMap() extended flags
}
BMB_SPECIALFMT = 7;
BMF_SPECIALFMT = 1 shl BMB_SPECIALFMT;
BMF_REQUESTVMEM = (BMF_MINPLANES or BMF_DISPLAYABLE);
BMB_ROOTMAP = 5;
BMF_ROOTMAP = 1 shl BMB_ROOTMAP;
BMB_3DTARGET = 8;
BMF_3DTARGET = 1 shl BMB_3DTARGET;
{*
* Operations for ProcessPixelArray() (v50)
*
*}
const
POP_BRIGHTEN = 0;
POP_DARKEN = 1;
POP_SETALPHA = 2;
POP_TINT = 3;
POP_BLUR = 4;
POP_COLOR2GREY = 5;
POP_NEGATIVE = 6;
POP_NEGFADE = 7;
POP_TINTFADE = 8;
POP_GRADIENT = 9;
POP_SHIFTRGB = 10;
{*
* Values for POP_SHIFTRGB
*
*}
const
RGBSHIFT_BGR = 1;
RGBSHIFT_BRG = 2;
RGBSHIFT_GBR = 3;
RGBSHIFT_GRB = 4;
RGBSHIFT_RBG = 5;
{*
* Tags for ProcessPixelArray() ops
*
*}
const
PPAOPTAG_FADEFULLSCALE = $85231020;
PPAOPTAG_FADEOFFSET = $85231021;
PPAOPTAG_GRADIENTTYPE = $85231022;
GRADTYPE_HORIZONTAL = 0;
GRADTYPE_VERTICAL = 1;
{* yet unsupported gradient types follow *}
GRADTYPE_RECTANGLE = 2;
GRADTYPE_LINEAR_ANGLE = 3;
GRADTYPE_RADIAL = 4; {* "circle" center-based *}
GRADIENT_NUMTYPES = 2;
PPAOPTAG_GRADCOLOR1 = $85231023;
PPAOPTAG_GRADCOLOR2 = $85231024;
PPAOPTAG_GRADFULLSCALE = PPAOPTAG_FADEFULLSCALE;
PPAOPTAG_GRADOFFSET = PPAOPTAG_FADEOFFSET;
PPAOPTAG_RGBMASK = $85231025;
PPAOPTAG_GRADSYMCENTER = $85231026;
{*
* Tags for BltBitMap(RastPort)Alpha() (v50)
*
*}
const
BLTBMA_MIXLEVEL = $88802000; {* from 0(0%) to 0xFFFFFFFF (100%) *}
BLTBMA_USESOURCEALPHA = $88802001;
BLTBMA_GLOBALALPHA = BLTBMA_MIXLEVEL;
BLTBMA_DESTALPHAVALUE = $88802002;
DESTALPHAVALUE_UNDEFINED = 0; {* default *}
DESTALPHAVALUE_ONE = 1;
DESTALPHAVALUE_USESOURCE = 2;
DESTALPHAVALUE_USEDEST = 3;
FUNCTION AllocCModeListTagList(ModeListTags : pTagItem location 'a1') : pList; syscall CyberGfxBase 072;
FUNCTION BestCModeIDTagList(BestModeIDTags : pTagItem location 'a0') : longword; syscall CyberGfxBase 060;
FUNCTION CModeRequestTagList(ModeRequest : POINTER location 'a0'; ModeRequestTags : pTagItem location 'a1') : longword; syscall CyberGfxBase 066;
PROCEDURE CVideoCtrlTagList(ViewPort : pViewPort location 'a0'; TagList : pTagItem location 'a1'); syscall CyberGfxBase 162;
PROCEDURE DoCDrawMethodTagList(Hook : pHook location 'a0'; a1arg : pRastPort location 'a1'; TagList : pTagItem location 'a2'); syscall CyberGfxBase 156;
FUNCTION ExtractColor(a0arg : pRastPort location 'a0'; BitMap : pBitMap location 'a1'; Colour : longword location 'd0'; SrcX : longword location 'd1'; SrcY : longword location 'd2'; Width : longword location 'd3'; Height : longword location 'd4') : longword; syscall CyberGfxBase 186;
FUNCTION FillPixelArray(a1arg : pRastPort location 'a1'; DestX : WORD location 'd0'; DestY : WORD location 'd1'; SizeX : WORD location 'd2'; SizeY : WORD location 'd3'; ARGB : longword location 'd4') : longword; syscall CyberGfxBase 150;
PROCEDURE FreeCModeList(ModeList : pList location 'a0'); syscall CyberGfxBase 078;
FUNCTION GetCyberIDAttr(CyberIDAttr : longword location 'd0'; CyberDisplayModeID : longword location 'd1') : longword; syscall CyberGfxBase 102;
FUNCTION GetCyberMapAttr(CyberGfxBitmap : pBitMap location 'a0'; CyberAttrTag : longword location 'd0') : longword; syscall CyberGfxBase 096;
FUNCTION InvertPixelArray(a1arg : pRastPort location 'a1'; DestX : WORD location 'd0'; DestY : WORD location 'd1'; SizeX : WORD location 'd2'; SizeY : WORD location 'd3') : longword; syscall CyberGfxBase 144;
FUNCTION IsCyberModeID(displayID : longword location 'd0') : wordbool; syscall CyberGfxBase 054;
FUNCTION LockBitMapTagList(BitMap : POINTER location 'a0'; TagList : pTagItem location 'a1') : POINTER; syscall CyberGfxBase 168;
FUNCTION MovePixelArray(SrcX : WORD location 'd0'; SrcY : WORD location 'd1'; a1arg : pRastPort location 'a1'; DestX : WORD location 'd2'; DestY : WORD location 'd3'; SizeX : WORD location 'd4'; SizeY : WORD location 'd5') : longword; syscall CyberGfxBase 132;
FUNCTION ReadPixelArray(destRect : POINTER location 'a0'; destX : WORD location 'd0'; destY : WORD location 'd1'; destMod : WORD location 'd2'; a1arg : pRastPort location 'a1'; SrcX : WORD location 'd3'; SrcY : WORD location 'd4'; SizeX : WORD location 'd5'; SizeY : WORD location 'd6'; DestFormat : byte location 'd7') : longword; syscall CyberGfxBase 120;
FUNCTION ReadRGBPixel(a1arg : pRastPort location 'a1'; x : WORD location 'd0'; y : WORD location 'd1') : longword; syscall CyberGfxBase 108;
FUNCTION ScalePixelArray(srcRect : POINTER location 'a0'; SrcW : WORD location 'd0'; SrcH : WORD location 'd1'; SrcMod : WORD location 'd2'; a1arg : pRastPort location 'a1'; DestX : WORD location 'd3'; DestY : WORD location 'd4'; DestW : WORD location 'd5'; DestH : WORD location 'd6'; SrcFormat : byte location 'd7') : LONGINT; syscall CyberGfxBase 090;
PROCEDURE UnLockBitMap(Handle : POINTER location 'a0'); syscall CyberGfxBase 174;
PROCEDURE UnLockBitMapTagList(Handle : POINTER location 'a0'; TagList : pTagItem location 'a1'); syscall CyberGfxBase 180;
FUNCTION WriteLUTPixelArray(srcRect : POINTER location 'a0'; SrcX : WORD location 'd0'; SrcY : WORD location 'd1'; SrcMod : WORD location 'd2'; a1arg : pRastPort location 'a1'; ColorTab : POINTER location 'a2'; DestX : WORD location 'd3'; DestY : WORD location 'd4'; SizeX : WORD location 'd5'; SizeY : WORD location 'd6'; CTFormat : byte location 'd7') : longword; syscall CyberGfxBase 198;
FUNCTION WritePixelArray(srcRect : POINTER location 'a0'; SrcX : WORD location 'd0'; SrcY : WORD location 'd1'; SrcMod : WORD location 'd2'; a1arg : pRastPort location 'a1'; DestX : WORD location 'd3'; DestY : WORD location 'd4'; SizeX : WORD location 'd5'; SizeY : WORD location 'd6'; SrcFormat : byte location 'd7') : longword; syscall CyberGfxBase 126;
FUNCTION WriteRGBPixel(a1arg : pRastPort location 'a1'; x : WORD location 'd0'; y : WORD location 'd1'; argb : longword location 'd2') : LONGINT; syscall CyberGfxBase 114;
{*** v43 ***}
FUNCTION WritePixelArrayAlpha(srcRect : POINTER location 'a0'; SrcX : WORD location 'd0'; SrcY : WORD location 'd1'; SrcMod : WORD location 'd2'; a1arg : pRastPort location 'a1'; DestX : WORD location 'd3'; DestY : WORD location 'd4'; SizeX : WORD location 'd5'; SizeY : WORD location 'd6'; globalAlpha : LongWord location 'd7') : longword; syscall CyberGfxBase 216;
PROCEDURE BltTemplateAlpha(source : pWORD location 'a0'; xSrc : LongInt location 'd0'; srcMod : LongInt location 'd1'; destRP : pRastPort location 'a1'; xDest : LongInt location 'd2'; yDest : LongInt location 'd3'; xSize : LongInt location 'd4'; ySize : LongInt location 'd5'); SysCall CyberGfxBase 222;
PROCEDURE ProcessPixelArray(rastPort: pRastPort location 'a0'; destX: LongWord location 'd0'; destY: LongWord location 'd1'; sizeX: LongWord location 'd2'; sizeY: LongWord location 'd3'; operation: LongWord location 'd4'; value: LongInt location 'd5'; taglist: pTagItem location 'a2'); syscall CyberGfxBase 228;
{*** v50 ***}
FUNCTION BltBitMapAlpha(srcBitMap : pBitMap location 'a0'; xSrc : LongInt location 'd0'; ySrc : LongInt location 'd1'; destBitMap : pBitMap location 'a1'; xDest : LongInt location 'd2'; yDest : LongInt location 'd3'; xSize : LongInt location 'd4'; ySize : LongInt location 'd5'; tagList : pTagItem location 'a2') : LongWord; syscall CyberGfxBase 234;
FUNCTION BltBitMapRastPortAlpha(srcBitMap : pBitMap location 'a0'; xSrc : LongInt location 'd0'; ySrc : LongInt location 'd1'; destRP : pRastPort location 'a1'; xDest : LongInt location 'd2'; yDest : LongInt location 'd3'; xSize : LongInt location 'd4'; ySize : LongInt location 'd5'; tagList : pTagItem location 'd2') : LongWord; SysCall CyberGfxBase 240;
FUNCTION ScalePixelArrayAlpha(srcRect : POINTER location 'a0'; SrcW : WORD location 'd0'; SrcH : WORD location 'd1'; SrcMod : WORD location 'd2'; a1arg : pRastPort location 'a1'; DestX : WORD location 'd3'; DestY : WORD location 'd4'; DestW : WORD location 'd5'; DestH : WORD location 'd6'; globalAlpha : LongWord location 'd7') : LONGINT; syscall CyberGfxBase 252;
{
Functions and procedures with array of const go here
}
{
FUNCTION AllocCModeListTags(const ModeListTags : Array Of Const) : pList;
FUNCTION BestCModeIDTags(const BestModeIDTags : Array Of Const) : longword;
FUNCTION CModeRequestTags(ModeRequest : POINTER; const ModeRequestTags : Array Of Const) : longword;
PROCEDURE CVideoCtrlTags(ViewPort : pViewPort; const TagList : Array Of Const);
PROCEDURE DoCDrawMethodTags(Hook : pHook; a1arg : pRastPort; const TagList : Array Of Const);
FUNCTION LockBitMapTags(BitMap : POINTER; const TagList : Array Of Const) : POINTER;
PROCEDURE UnLockBitMapTags(Handle : POINTER; const TagList : Array Of Const);
}
function SHIFT_PIXFMT(fmt : longint) : longint;
function InitCyberGfxLibrary: boolean;
IMPLEMENTATION
{uses
tagsarray;}
{
Functions and procedures with array of const go here
}
{
FUNCTION AllocCModeListTags(const ModeListTags : Array Of Const) : pList;
begin
AllocCModeListTags := AllocCModeListTagList(readintags(ModeListTags));
end;
FUNCTION BestCModeIDTags(const BestModeIDTags : Array Of Const) : longword;
begin
BestCModeIDTags := BestCModeIDTagList(readintags(BestModeIDTags));
end;
FUNCTION CModeRequestTags(ModeRequest : POINTER; const ModeRequestTags : Array Of Const) : longword;
begin
CModeRequestTags := CModeRequestTagList(ModeRequest , readintags(ModeRequestTags));
end;
PROCEDURE CVideoCtrlTags(ViewPort : pViewPort; const TagList : Array Of Const);
begin
CVideoCtrlTagList(ViewPort , readintags(TagList));
end;
PROCEDURE DoCDrawMethodTags(Hook : pHook; a1arg : pRastPort; const TagList : Array Of Const);
begin
DoCDrawMethodTagList(Hook , a1arg , readintags(TagList));
end;
FUNCTION LockBitMapTags(BitMap : POINTER; const TagList : Array Of Const) : POINTER;
begin
LockBitMapTags := LockBitMapTagList(BitMap , readintags(TagList));
end;
PROCEDURE UnLockBitMapTags(Handle : POINTER; const TagList : Array Of Const);
begin
UnLockBitMapTagList(Handle , readintags(TagList));
end;
}
function SHIFT_PIXFMT(fmt : longint) : longint; inline;
begin
SHIFT_PIXFMT:=(ULONG(fmt)) shl 24;
end;
const
{ Change VERSION and LIBVERSION to proper values }
VERSION : string[2] = '0';
LIBVERSION : longword = 0;
function InitCyberGfxLibrary: boolean;
begin
InitCyberGfxLibrary := Assigned(CyberGfxBase);
end;
initialization
CyberGfxBase := OpenLibrary(CYBERGFXNAME,LIBVERSION);
finalization
if Assigned(CyberGfxBase) then
CloseLibrary(CyberGfxBase);
END. (* UNIT CYBERGRAPHICS *)
|