1
{****************************************************************************
3
$Id: dive.pas,v 1.3 2003/02/15 18:44:55 hajny Exp $
6
FPC Pascal Runtime Library for OS/2
7
Copyright (c) 1999-2000 by Karoly Balogh (aka Charlie/INQ)
9
The FPC Pascal runtime library is distributed under the Library GNU Public
10
License v2. So is this unit. The Library GNU Public License requires you to
11
distribute the source code of this unit with any product that uses it.
12
Because the EMX library isn't under the LGPL, we grant you an exception to
13
this, and that is, when you compile a program with the Free Pascal Compiler,
14
you do not need to ship source code with that program, AS LONG AS YOU ARE
15
USING UNMODIFIED CODE! If you modify this code, you MUST change the next
18
<This an official, unmodified Free Pascal source code file.>
20
Send us your modified files, we can work together if you want!
22
Free Pascal is distributed in the hope that it will be useful,
23
but WITHOUT ANY WARRANTY; without even the implied warranty of
24
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
Library GNU General Public License for more details.
27
You should have received a copy of the Library GNU General Public License
28
along with Free Pascal; see the file COPYING.LIB. If not, write to
29
the Free Software Foundation, 59 Temple Place - Suite 330,
30
Boston, MA 02111-1307, USA.
32
****************************************************************************}
36
{Warning: This code is alfa. Future versions of this unit will propably
41
Uses OS2Def, PMWin, MMBase;
43
Const Max_Dive_Instances = 64;
45
DIVE_Success = $00000000;
46
DIVE_Err_Invalid_Instance = $00001000;
47
DIVE_Err_Source_Format = $00001001;
48
DIVE_Err_Destination_Format = $00001002;
49
DIVE_Err_Blitter_Not_Setup = $00001003;
50
DIVE_Err_Insufficient_Length = $00001004;
51
DIVE_Err_Too_Many_Instances = $00001005;
52
DIVE_Err_No_Direct_Access = $00001006;
53
DIVE_Err_Not_Bank_Switched = $00001007;
54
DIVE_Err_Invalid_Bank_Number = $00001008;
55
DIVE_Err_FB_Not_Acquired = $00001009;
56
DIVE_Err_FB_Already_Acquired = $0000100A;
57
DIVE_Err_Acquire_Failed = $0000100B;
58
DIVE_Err_Bank_Switch_Failed = $0000100C;
59
DIVE_Err_Deacquire_Failed = $0000100D;
60
DIVE_Err_Invalid_Palette = $0000100E;
61
DIVE_Err_Invalid_Destination_RECTL = $0000100F;
62
DIVE_Err_Invalid_Buffer_Number = $00001010;
63
DIVE_Err_SSMDD_Not_Installed = $00001011;
64
DIVE_Err_Buffer_Already_Accessed = $00001012;
65
DIVE_Err_Buffer_Not_Accessed = $00001013;
66
DIVE_Err_Too_Many_Bufffers = $00001014;
67
DIVE_Err_Allocation_Error = $00001015;
68
DIVE_Err_Invalid_Linesize = $00001016;
69
DIVE_Err_Fatal_Exception = $00001017;
70
DIVE_Err_Invalid_Conversion = $00001018;
71
DIVE_Err_VSD_Error = $00001019;
72
DIVE_Err_Color_Support = $0000101A;
73
DIVE_Err_Out_Of_Range = $0000101B;
74
DIVE_Warn_No_Size = $00001100;
76
DIVE_Buffer_Screen = $00000000;
77
DIVE_Buffer_Graphics_Plane = $00000001;
78
DIVE_Buffer_Alternate_Plane = $00000002;
80
DIVE_Fully_Visible = $FFFFFFFF;
82
{ * Use either of the two defines as the bRGB2Entries pointer to have DIVE * }
83
{ * query and set the physical or default palette as source or destination. * }
85
DIVE_Palette_Physical = $00000000;
86
DIVE_Palette_Default = $FFFFFFFF;
88
Type HDIVE = cardinal;
90
{ * Blitter setup structures * }
91
TSetup_Blitter = Record
92
ulStructLen : cardinal; { * ulStructLen tells how much of the structure is used. * }
93
{ * Comments here show appropriate values, so don't count ;) * }
95
fInvert : cardinal; { * Image is inverted on blit * }
97
{ * %0001 = 01 = $01 horizontal flip * }
98
{ * %0010 = 02 = $02 vertical flip * }
100
{ * This is the mark for 8 bytes * }
102
fccSrcColorFormat : FourCC; { * Source data format * }
103
ulSrcWidth : cardinal; { * Width in pels * }
104
ulSrcHeight : cardinal; { * Height in pels * }
105
{ * The following are for displaying a sub-portion of the image. * }
106
ulSrcPosX : cardinal; { * X Position of source data * }
107
ulSrcPosY : cardinal; { * Y Position of source data * }
109
{ * This is the mark for 28 bytes * }
111
ulDitherType : cardinal; { * Dither type * }
115
fccDstColorFormat : FourCC; { * Destination color format * }
116
ulDstWidth : cardinal; { * Destination width in pels * }
117
ulDstHeight : cardinal; { * Destination height in pels * }
123
lScreenPosX : LongInt;
124
lScreenPosY : LongInt;
128
ulNumDstRects : cardinal;
129
pVisDstRects : PRectl; { * This is a pointer to an array of visible rectangles. * }
131
{ * 68 bytes = fully used * }
134
PSetup_Blitter = ^TSetup_Blitter;
136
{ * Stuff for DiveQueryCaps() * }
138
ulStructLen : cardinal; { * SizeOf(TDIVE_CAPS) * }
139
ulPlaneCount : cardinal; { * Number of defined planes * }
141
{ * Following info applies to ulPlaneID * }
142
fScreenDirect : Boolean; { * Direct screen access (was type BOOL in C) * }
143
fBankSwitched : Boolean; { * VRAM bank-switched? (was type BOOL in C) * }
144
ulDepth : cardinal; { * Number of bits per pixel * }
145
ulHorizontalResolution : cardinal;
146
ulVerticalResolution : cardinal;
147
ulScanLineBytes : cardinal;
148
fccColorEncoding : FourCC;
149
ulApertureSize : cardinal;
151
ulInputFormats : cardinal; { * Number of input color formats * }
152
ulOutputFormats : cardinal;
153
ulFormatLength : cardinal; { * Length of format buffer * }
154
pFormatData : Pointer; { * Pointer to format buffer of FOURCC's * }
157
PDIVE_CAPS = ^TDIVE_CAPS;
159
Function DiveQueryCaps(DiveCaps: PDIVE_CAPS; ulPlaneBufNum : cardinal) : cardinal; cdecl;
161
Function DiveOpen(Var phDiveInst : cardinal; fNonScreenInstance : cardinal;
162
Var ppFrameBuffer : Pointer) : cardinal; cdecl;
163
Function DiveClose(hDiveInst : cardinal) : cardinal; cdecl;
165
Function DiveSetupBlitter(hDiveInst : cardinal; pSetupBlitter : PSetup_Blitter) : cardinal; cdecl;
166
Function DiveBlitImage(hDiveInst : cardinal; ulSrcBufNumber : cardinal; ulDstBufNumber : cardinal) : cardinal; cdecl;
168
Function DiveAcquireFrameBuffer(hDiveInst : cardinal; prectlDst : PRectl) : cardinal; cdecl;
169
Function DiveDeacquireFrameBuffer(hDiveInst : cardinal) : cardinal; cdecl;
170
Function DiveCalcFrameBufferAddress(hDiveInst : cardinal;
172
Var pDestinationAddress : Pointer;
173
Var ulBankNumber : cardinal;
174
Var ulRemLinesInBank : cardinal) : cardinal; cdecl;
175
Function DiveSwitchBank(hDiveInst : cardinal; ulBankNumber : cardinal) : cardinal; cdecl;
177
{ Notes on DiveAllocImageBuffer:
178
If pbImageBuffer is not NULL, the buffer is associated rather than
179
allocated. If pbImageBuffer is not NULL and the buffer number
180
pointed to by pulBufferNumber is non-zero, a new buffer pointer is
181
associated with the buffer number. Even though no memory is
182
allocated by DiveAllocImageBuffer when user-allocated buffers are
183
associated, DiveFreeImageBuffer should be called to release the
184
buffer association to avoid using up available buffer indexes.
185
The specified line size will be used if a buffer is allocated in
186
system memory, or if a user buffer is associated. If the
187
specified line size is zero, the allocated line size is rounded up
188
to the nearest DWORD boundry. }
190
Function DiveAllocImageBuffer(hDiveInst : cardinal;
191
Var ulBufferNumber : cardinal;
192
fccColorSpace : FourCC;
195
ulLineSizeBytes : cardinal;
196
Var bImageBuffer : Pointer) : cardinal; cdecl;
197
Function DiveFreeImageBuffer(hDiveInst : cardinal; ulBufferNumber : cardinal) : cardinal; cdecl;
199
Function DiveBeginImageBufferAccess(hDiveInst : cardinal;
200
ulBufferNumber : cardinal;
201
Var pbImageBuffer : Pointer;
202
Var ulBufferScanLineBytes : cardinal;
203
Var ulBufferScanLines : cardinal) : cardinal; cdecl;
204
Function DiveEndImageBufferAccess(hDiveInst : cardinal; ulBufferNumber : cardinal) : cardinal; cdecl;
207
{/* Notes on palettes:
208
Neither DiveSetSourcePalette nor DiveSetDestinationPalette API's will set
209
the physical palette. If your application MUST set the PHYSICAL palette,
210
try using no more than 236 entries (the middle 236: 10-245, thus leaving
211
the top and bottom 10 entries for the Workplace Shell). If your
212
application MUST use ALL 256 entries, it must do so as a full-screen
213
(i.e. maximized) application. Remember, No WM_REALIZEPALETTE message
214
will be sent to other running applications, meaning they will not redraw
215
and their colors will be all wrong. It is not recommended that a
216
developer use these commands:
218
To set physical palette, do the following:
219
hps = WinGetPS ( HWND_DESKTOP );
220
hdc = GpiQueryDevice ( hps );
221
GpiCreateLogColorTable ( hps, LCOL_PURECOLOR | LCOL_REALIZABLE,
222
LCOLF_CONSECRGB, 0, 256, (PLONG)plRGB2Entries );
223
Gre32EntrY3 ( hdc, 0L, 0x000060C6L );
224
WinInvalidateRect ( HWND_DESKTOP, (PRECTL)NULL, TRUE );
225
WinReleasePS ( hps );
227
To reset physical palette, do the following:
228
hps = WinGetPS ( HWND_DESKTOP );
229
hdc = GpiQueryDevice ( hps );
230
Gre32EntrY3 ( hdc, 0L, 0x000060C7L );
231
WinInvalidateRect ( HWND_DESKTOP, (PRECTL)NULL, TRUE );
232
WinReleasePS ( hps );
235
Function DiveSetDestinationPalette(hDiveInst : cardinal;
236
ulStartIndex : cardinal;
237
ulNumEntries : cardinal;
238
Var bRGB2Entries : Pointer) : cardinal; cdecl;
240
Function DiveSetSourcePalette(hDiveInst : cardinal;
241
ulStartIndex : cardinal;
242
ulNumEntries : cardinal;
243
Var bRGB2Entries : Pointer) : cardinal; cdecl;
245
Function DiveSetTransparentBlitMode(hDiveInst : cardinal;
246
ulStartIndex : cardinal;
248
ulValue2 : cardinal) : cardinal; cdecl;
252
Function DiveQueryCaps(DiveCaps : PDIVE_CAPS; ulPlaneBufNum : cardinal) : cardinal; cdecl;
253
External 'DIVE' Index 1;
255
Function DiveOpen(Var phDiveInst : cardinal; fNonScreenInstance : cardinal; Var ppFrameBuffer : Pointer) : cardinal; cdecl;
256
External 'DIVE' Index 2;
258
Function DiveClose(hDiveInst : cardinal) : cardinal; cdecl;
259
External 'DIVE' Index 3;
261
Function DiveSetupBlitter(hDiveInst : cardinal; pSetupBlitter : PSetup_Blitter) : cardinal; cdecl;
262
External 'DIVE' Index 4;
264
Function DiveBlitImage(hDiveInst : cardinal; ulSrcBufNumber : cardinal; ulDstBufNumber : cardinal) : cardinal; cdecl;
265
External 'DIVE' Index 5;
267
Function DiveAcquireFrameBuffer(hDiveInst : cardinal; prectlDst : PRectl) : cardinal; cdecl;
268
External 'DIVE' Index 6;
270
Function DiveDeacquireFrameBuffer(hDiveInst : cardinal) : cardinal; cdecl;
271
External 'DIVE' Index 8;
273
Function DiveCalcFrameBufferAddress(hDiveInst : cardinal;
275
Var pDestinationAddress : Pointer;
276
Var ulBankNumber : cardinal;
277
Var ulRemLinesInBank : cardinal) : cardinal; cdecl;
278
External 'DIVE' Index 11;
280
Function DiveSwitchBank(hDiveInst : cardinal; ulBankNumber : cardinal) : cardinal; cdecl;
281
External 'DIVE' Index 7;
284
Function DiveAllocImageBuffer(hDiveInst : cardinal;
285
Var ulBufferNumber : cardinal;
286
fccColorSpace : FourCC;
289
ulLineSizeBytes : cardinal;
290
Var bImageBuffer : Pointer) : cardinal; cdecl;
291
External 'DIVE' Index 12;
293
Function DiveFreeImageBuffer(hDiveInst : cardinal;
294
ulBufferNumber : cardinal) : cardinal; cdecl;
295
External 'DIVE' Index 13;
297
Function DiveBeginImageBufferAccess(hDiveInst : cardinal;
298
ulBufferNumber : cardinal;
299
Var pbImageBuffer : Pointer;
300
Var ulBufferScanLineBytes : cardinal;
301
Var ulBufferScanLines : cardinal) : cardinal; cdecl;
302
External 'DIVE' Index 14;
304
Function DiveEndImageBufferAccess(hDiveInst : cardinal; ulBufferNumber : cardinal) : cardinal; cdecl;
305
External 'DIVE' Index 15;
307
Function DiveSetDestinationPalette(hDiveInst : cardinal;
308
ulStartIndex : cardinal;
309
ulNumEntries : cardinal;
310
Var bRGB2Entries : Pointer) : cardinal; cdecl;
311
External 'DIVE' Index 9;
313
Function DiveSetSourcePalette(hDiveInst : cardinal;
314
ulStartIndex : cardinal;
315
ulNumEntries : cardinal;
316
Var bRGB2Entries : Pointer) : cardinal; cdecl;
317
External 'DIVE' Index 10;
319
Function DiveSetTransparentBlitMode(hDiveInst : cardinal;
320
ulStartIndex : cardinal;
322
ulValue2 : cardinal) : cardinal; cdecl;
323
External 'DIVE' Index 18;
329
Revision 1.3 2003/02/15 18:44:55 hajny
330
* mmtk directory corrected to lowercase
332
Revision 1.1 2003/02/15 16:59:09 hajny
333
* mmtk directory corrected to lowercase
335
Revision 1.1 2003/02/09 13:49:06 hajny