[9698] | 1 | /* $Id: divewrap.cpp,v 1.1 2003-01-21 11:20:35 sandervl Exp $ */
|
---|
| 2 |
|
---|
| 3 | /*
|
---|
| 4 | * Wrapper for DIVE functions calls
|
---|
| 5 | *
|
---|
| 6 | * Copyright 2003 Sander van Leeuwen <sandervl@innotek.de>
|
---|
| 7 | *
|
---|
| 8 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
| 9 | *
|
---|
| 10 | */
|
---|
| 11 | #define INCL_DOSMODULEMGR
|
---|
| 12 | #define INCL_DOSERRORS
|
---|
| 13 | #define INCL_MM_OS2
|
---|
| 14 | #include <os2.h>
|
---|
| 15 | #include <os2sel.h>
|
---|
| 16 | #include <dive.h>
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 | typedef ULONG (* APIENTRY PFNDIVEALLOCIMAGEBUFFER)(HDIVE a, PULONG b, FOURCC c, ULONG d, ULONG e, ULONG f, PBYTE g );
|
---|
| 20 | typedef ULONG (* APIENTRY PFNDIVEBLITIMAGE)(HDIVE a, ULONG b, ULONG c );
|
---|
| 21 | typedef ULONG (* APIENTRY PFNDIVECLOSE)(HDIVE a );
|
---|
| 22 | typedef ULONG (* APIENTRY PFNDIVEBEGINIMAGEBUFFERACCESS)(HDIVE a, ULONG b, PBYTE *c, PULONG d, PULONG e );
|
---|
| 23 | typedef ULONG (* APIENTRY PFNDIVEENDIMAGEBUFFERACCESS)(HDIVE a, ULONG b );
|
---|
| 24 | typedef ULONG (* APIENTRY PFNDIVEFREEIMAGEBUFFER)(HDIVE a, ULONG b );
|
---|
| 25 | typedef ULONG (* APIENTRY PFNDIVEOPEN)(HDIVE *a, BOOL b, PVOID c );
|
---|
| 26 | typedef ULONG (* APIENTRY PFNDIVEQUERYCAPS)(PDIVE_CAPS a, ULONG b );
|
---|
| 27 | typedef ULONG (* APIENTRY PFNDIVESETUPBLITTER)(HDIVE a, PSETUP_BLITTER b );
|
---|
| 28 |
|
---|
| 29 |
|
---|
| 30 | static PFNDIVEALLOCIMAGEBUFFER pfnDiveAllocImageBuffer = NULL;
|
---|
| 31 | static PFNDIVEBLITIMAGE pfnDiveBlitImage = NULL;
|
---|
| 32 | static PFNDIVECLOSE pfnDiveClose = NULL;
|
---|
| 33 | static PFNDIVEBEGINIMAGEBUFFERACCESS pfnDiveBeginImageBufferAccess = NULL;
|
---|
| 34 | static PFNDIVEENDIMAGEBUFFERACCESS pfnDiveEndImageBufferAccess = NULL;
|
---|
| 35 | static PFNDIVEFREEIMAGEBUFFER pfnDiveFreeImageBuffer = NULL;
|
---|
| 36 | static PFNDIVEOPEN pfnDiveOpen = NULL;
|
---|
| 37 | static PFNDIVEQUERYCAPS pfnDiveQueryCaps = NULL;
|
---|
| 38 | static PFNDIVESETUPBLITTER pfnDiveSetupBlitter = NULL;
|
---|
| 39 |
|
---|
| 40 | static HMODULE hLibDive = 0;
|
---|
| 41 | //******************************************************************************
|
---|
| 42 | //******************************************************************************
|
---|
| 43 | BOOL DiveLoad()
|
---|
| 44 | {
|
---|
| 45 | char szError[CCHMAXPATH];
|
---|
| 46 |
|
---|
| 47 | if (DosLoadModule(szError, sizeof(szError),
|
---|
| 48 | "DIVE.DLL", &hLibDive) != NO_ERROR)
|
---|
| 49 | {
|
---|
| 50 | return FALSE;
|
---|
| 51 | }
|
---|
| 52 | // 0000:00000000 Imp DiveAllocImageBuffer (dive.12)
|
---|
| 53 | if(DosQueryProcAddr(hLibDive, 12, NULL,
|
---|
| 54 | (PFN*)&pfnDiveAllocImageBuffer) != NO_ERROR)
|
---|
| 55 | return FALSE;
|
---|
| 56 |
|
---|
| 57 | // 0000:00000000 Imp DiveBlitImage (dive.5)
|
---|
| 58 | if(DosQueryProcAddr(hLibDive, 5, NULL,
|
---|
| 59 | (PFN*)&pfnDiveBlitImage) != NO_ERROR)
|
---|
| 60 | return FALSE;
|
---|
| 61 |
|
---|
| 62 | // 0000:00000000 Imp DiveClose (dive.3)
|
---|
| 63 | if(DosQueryProcAddr(hLibDive, 3, NULL,
|
---|
| 64 | (PFN*)&pfnDiveClose) != NO_ERROR)
|
---|
| 65 | return FALSE;
|
---|
| 66 |
|
---|
| 67 | // 0000:00000000 Imp DiveEndImageBufferAccess (dive.15)
|
---|
| 68 | if(DosQueryProcAddr(hLibDive, 15, NULL,
|
---|
| 69 | (PFN*)&pfnDiveEndImageBufferAccess) != NO_ERROR)
|
---|
| 70 | return FALSE;
|
---|
| 71 |
|
---|
| 72 | // 0000:00000000 Imp DiveFreeImageBuffer (dive.13)
|
---|
| 73 | if(DosQueryProcAddr(hLibDive, 13, NULL,
|
---|
| 74 | (PFN*)&pfnDiveFreeImageBuffer) != NO_ERROR)
|
---|
| 75 | return FALSE;
|
---|
| 76 |
|
---|
| 77 | // 0000:00000000 Imp DiveOpen (dive.2)
|
---|
| 78 | if(DosQueryProcAddr(hLibDive, 2, NULL,
|
---|
| 79 | (PFN*)&pfnDiveOpen) != NO_ERROR)
|
---|
| 80 | return FALSE;
|
---|
| 81 |
|
---|
| 82 | // 0000:00000000 Imp DiveQueryCaps (dive.1)
|
---|
| 83 | if(DosQueryProcAddr(hLibDive, 1, NULL,
|
---|
| 84 | (PFN*)&pfnDiveQueryCaps) != NO_ERROR)
|
---|
| 85 | return FALSE;
|
---|
| 86 |
|
---|
| 87 | // 0000:00000000 Imp DiveSetupBlitter (dive.4)
|
---|
| 88 | if(DosQueryProcAddr(hLibDive, 4, NULL,
|
---|
| 89 | (PFN*)&pfnDiveSetupBlitter) != NO_ERROR)
|
---|
| 90 | return FALSE;
|
---|
| 91 |
|
---|
| 92 | //success!
|
---|
| 93 | return TRUE;
|
---|
| 94 | }
|
---|
| 95 | //******************************************************************************
|
---|
| 96 | //******************************************************************************
|
---|
| 97 | void DiveUnload()
|
---|
| 98 | {
|
---|
| 99 | if(hLibDive) {
|
---|
| 100 | DosFreeModule(hLibDive);
|
---|
| 101 | }
|
---|
| 102 | pfnDiveAllocImageBuffer = NULL;
|
---|
| 103 | pfnDiveBlitImage = NULL;
|
---|
| 104 | pfnDiveClose = NULL;
|
---|
| 105 | pfnDiveEndImageBufferAccess = NULL;
|
---|
| 106 | pfnDiveFreeImageBuffer = NULL;
|
---|
| 107 | pfnDiveOpen = NULL;
|
---|
| 108 | pfnDiveQueryCaps = NULL;
|
---|
| 109 | pfnDiveSetupBlitter = NULL;
|
---|
| 110 | return;
|
---|
| 111 | }
|
---|
| 112 | //******************************************************************************
|
---|
| 113 | //******************************************************************************
|
---|
| 114 | ULONG APIENTRY _DiveOpen ( HDIVE *a, BOOL b, PVOID c )
|
---|
| 115 | {
|
---|
| 116 | ULONG yyrc;
|
---|
| 117 | USHORT sel = RestoreOS2FS();
|
---|
| 118 |
|
---|
| 119 | yyrc = (pfnDiveOpen) ? pfnDiveOpen(a, b, c) : DIVE_ERR_INVALID_INSTANCE;
|
---|
| 120 | SetFS(sel);
|
---|
| 121 |
|
---|
| 122 | return yyrc;
|
---|
| 123 | }
|
---|
| 124 | //******************************************************************************
|
---|
| 125 | //******************************************************************************
|
---|
| 126 | ULONG APIENTRY _DiveQueryCaps ( PDIVE_CAPS a, ULONG b )
|
---|
| 127 | {
|
---|
| 128 | ULONG yyrc;
|
---|
| 129 | USHORT sel = RestoreOS2FS();
|
---|
| 130 |
|
---|
| 131 | yyrc = (pfnDiveQueryCaps) ? pfnDiveQueryCaps(a, b) : DIVE_ERR_INVALID_INSTANCE;
|
---|
| 132 | SetFS(sel);
|
---|
| 133 |
|
---|
| 134 | return yyrc;
|
---|
| 135 | }
|
---|
| 136 | //******************************************************************************
|
---|
| 137 | //******************************************************************************
|
---|
| 138 | ULONG APIENTRY _DiveSetupBlitter ( HDIVE a, PSETUP_BLITTER b )
|
---|
| 139 | {
|
---|
| 140 | ULONG yyrc;
|
---|
| 141 | USHORT sel = RestoreOS2FS();
|
---|
| 142 |
|
---|
| 143 | yyrc = (pfnDiveSetupBlitter) ? pfnDiveSetupBlitter(a, b) : DIVE_ERR_INVALID_INSTANCE;
|
---|
| 144 | SetFS(sel);
|
---|
| 145 |
|
---|
| 146 | return yyrc;
|
---|
| 147 | }
|
---|
| 148 | //******************************************************************************
|
---|
| 149 | //******************************************************************************
|
---|
| 150 | ULONG APIENTRY _DiveBlitImage ( HDIVE a, ULONG b, ULONG c )
|
---|
| 151 | {
|
---|
| 152 | ULONG yyrc;
|
---|
| 153 | USHORT sel = RestoreOS2FS();
|
---|
| 154 |
|
---|
| 155 | yyrc = (pfnDiveBlitImage) ? pfnDiveBlitImage(a, b, c) : DIVE_ERR_INVALID_INSTANCE;
|
---|
| 156 | SetFS(sel);
|
---|
| 157 |
|
---|
| 158 | return yyrc;
|
---|
| 159 | }
|
---|
| 160 | //******************************************************************************
|
---|
| 161 | //******************************************************************************
|
---|
| 162 | #if 0
|
---|
| 163 | ULONG APIENTRY _DiveBlitImageLines ( HDIVE a, ULONG b,
|
---|
| 164 | ULONG c, PBYTE d )
|
---|
| 165 | {
|
---|
| 166 | ULONG yyrc;
|
---|
| 167 | USHORT sel = RestoreOS2FS();
|
---|
| 168 |
|
---|
| 169 | yyrc = (pfnDiveBlitImageLines) ? pfnDiveBlitImageLines(a, b, c, d) : DIVE_ERR_INVALID_INSTANCE;
|
---|
| 170 | SetFS(sel);
|
---|
| 171 |
|
---|
| 172 | return yyrc;
|
---|
| 173 | }
|
---|
| 174 | #endif
|
---|
| 175 | //******************************************************************************
|
---|
| 176 | //******************************************************************************
|
---|
| 177 | ULONG APIENTRY _DiveClose ( HDIVE a )
|
---|
| 178 | {
|
---|
| 179 | ULONG yyrc;
|
---|
| 180 | USHORT sel = RestoreOS2FS();
|
---|
| 181 |
|
---|
| 182 | yyrc = (pfnDiveClose) ? pfnDiveClose(a) : DIVE_ERR_INVALID_INSTANCE;
|
---|
| 183 | SetFS(sel);
|
---|
| 184 |
|
---|
| 185 | return yyrc;
|
---|
| 186 | }
|
---|
| 187 | #if 0
|
---|
| 188 | //******************************************************************************
|
---|
| 189 | //******************************************************************************
|
---|
| 190 | ULONG APIENTRY _DiveAcquireFrameBuffer ( HDIVE a, PRECTL b )
|
---|
| 191 | {
|
---|
| 192 | ULONG yyrc;
|
---|
| 193 | USHORT sel = RestoreOS2FS();
|
---|
| 194 |
|
---|
| 195 | yyrc = (pfnDiveAcquireFrameBuffer) ? pfnDiveAcquireFrameBuffer(a, b) : DIVE_ERR_INVALID_INSTANCE;
|
---|
| 196 | SetFS(sel);
|
---|
| 197 |
|
---|
| 198 | return yyrc;
|
---|
| 199 | }
|
---|
| 200 | //******************************************************************************
|
---|
| 201 | //******************************************************************************
|
---|
| 202 | ULONG APIENTRY _DiveSwitchBank ( HDIVE a, ULONG b )
|
---|
| 203 | {
|
---|
| 204 | ULONG yyrc;
|
---|
| 205 | USHORT sel = RestoreOS2FS();
|
---|
| 206 |
|
---|
| 207 | yyrc = (pfnDiveSwitchBank) ? pfnDiveSwitchBank(a, b) : DIVE_ERR_INVALID_INSTANCE;
|
---|
| 208 | SetFS(sel);
|
---|
| 209 |
|
---|
| 210 | return yyrc;
|
---|
| 211 | }
|
---|
| 212 | //******************************************************************************
|
---|
| 213 | //******************************************************************************
|
---|
| 214 | ULONG APIENTRY _DiveDeacquireFrameBuffer ( HDIVE a )
|
---|
| 215 | {
|
---|
| 216 | ULONG yyrc;
|
---|
| 217 | USHORT sel = RestoreOS2FS();
|
---|
| 218 |
|
---|
| 219 | yyrc = (pfnDiveDeacquireFrameBuffer) ? pfnDiveDeacquireFrameBuffer(a) : DIVE_ERR_INVALID_INSTANCE;
|
---|
| 220 | SetFS(sel);
|
---|
| 221 |
|
---|
| 222 | return yyrc;
|
---|
| 223 | }
|
---|
| 224 | //******************************************************************************
|
---|
| 225 | //******************************************************************************
|
---|
| 226 | ULONG APIENTRY _DiveCalcFrameBufferAddress ( HDIVE a, PRECTL b,
|
---|
| 227 | PBYTE *c, PULONG d,
|
---|
| 228 | PULONG e )
|
---|
| 229 | {
|
---|
| 230 | ULONG yyrc;
|
---|
| 231 | USHORT sel = RestoreOS2FS();
|
---|
| 232 |
|
---|
| 233 | yyrc = (pfnDiveCalcFrameBufferAddress) ? pfnDiveCalcFrameBufferAddress(a, b, c, d, e) : DIVE_ERR_INVALID_INSTANCE;
|
---|
| 234 | SetFS(sel);
|
---|
| 235 |
|
---|
| 236 | return yyrc;
|
---|
| 237 | }
|
---|
| 238 | #endif
|
---|
| 239 | //******************************************************************************
|
---|
| 240 | //******************************************************************************
|
---|
| 241 | ULONG APIENTRY _DiveAllocImageBuffer ( HDIVE a, PULONG b,
|
---|
| 242 | FOURCC c, ULONG d,
|
---|
| 243 | ULONG e, ULONG f,
|
---|
| 244 | PBYTE g )
|
---|
| 245 | {
|
---|
| 246 | ULONG yyrc;
|
---|
| 247 | USHORT sel = RestoreOS2FS();
|
---|
| 248 |
|
---|
| 249 | yyrc = (pfnDiveAllocImageBuffer) ? pfnDiveAllocImageBuffer(a, b, c, d, e, f, g) : DIVE_ERR_INVALID_INSTANCE;
|
---|
| 250 | SetFS(sel);
|
---|
| 251 |
|
---|
| 252 | return yyrc;
|
---|
| 253 | }
|
---|
| 254 | //******************************************************************************
|
---|
| 255 | //******************************************************************************
|
---|
| 256 | ULONG APIENTRY _DiveFreeImageBuffer ( HDIVE a, ULONG b )
|
---|
| 257 | {
|
---|
| 258 | ULONG yyrc;
|
---|
| 259 | USHORT sel = RestoreOS2FS();
|
---|
| 260 |
|
---|
| 261 | yyrc = (pfnDiveFreeImageBuffer) ? pfnDiveFreeImageBuffer(a, b) : DIVE_ERR_INVALID_INSTANCE;
|
---|
| 262 | SetFS(sel);
|
---|
| 263 |
|
---|
| 264 | return yyrc;
|
---|
| 265 | }
|
---|
| 266 | //******************************************************************************
|
---|
| 267 | //******************************************************************************
|
---|
| 268 | ULONG APIENTRY _DiveBeginImageBufferAccess ( HDIVE a, ULONG b,
|
---|
| 269 | PBYTE *c, PULONG d,
|
---|
| 270 | PULONG e )
|
---|
| 271 | {
|
---|
| 272 | ULONG yyrc;
|
---|
| 273 | USHORT sel = RestoreOS2FS();
|
---|
| 274 |
|
---|
| 275 | yyrc = (pfnDiveBeginImageBufferAccess) ? pfnDiveBeginImageBufferAccess(a, b, c, d, e) : DIVE_ERR_INVALID_INSTANCE;
|
---|
| 276 | SetFS(sel);
|
---|
| 277 |
|
---|
| 278 | return yyrc;
|
---|
| 279 | }
|
---|
| 280 | //******************************************************************************
|
---|
| 281 | //******************************************************************************
|
---|
| 282 | ULONG APIENTRY _DiveEndImageBufferAccess ( HDIVE a, ULONG b )
|
---|
| 283 | {
|
---|
| 284 | ULONG yyrc;
|
---|
| 285 | USHORT sel = RestoreOS2FS();
|
---|
| 286 |
|
---|
| 287 | yyrc = (pfnDiveEndImageBufferAccess) ? pfnDiveEndImageBufferAccess(a, b) : DIVE_ERR_INVALID_INSTANCE;
|
---|
| 288 | SetFS(sel);
|
---|
| 289 |
|
---|
| 290 | return yyrc;
|
---|
| 291 | }
|
---|
| 292 | #if 0
|
---|
| 293 | //******************************************************************************
|
---|
| 294 | //******************************************************************************
|
---|
| 295 | ULONG APIENTRY _DiveSetDestinationPalette ( HDIVE a, ULONG b,
|
---|
| 296 | ULONG c, PBYTE d )
|
---|
| 297 | {
|
---|
| 298 | ULONG yyrc;
|
---|
| 299 | USHORT sel = RestoreOS2FS();
|
---|
| 300 |
|
---|
| 301 | yyrc = (pfnDiveSetDestinationPalette) ? pfnDiveSetDestinationPalette(a, b, c, d) : DIVE_ERR_INVALID_INSTANCE;
|
---|
| 302 | SetFS(sel);
|
---|
| 303 |
|
---|
| 304 | return yyrc;
|
---|
| 305 | }
|
---|
| 306 | //******************************************************************************
|
---|
| 307 | //******************************************************************************
|
---|
| 308 | ULONG APIENTRY _DiveSetSourcePalette ( HDIVE a, ULONG b,
|
---|
| 309 | ULONG c, PBYTE d )
|
---|
| 310 | {
|
---|
| 311 | ULONG yyrc;
|
---|
| 312 | USHORT sel = RestoreOS2FS();
|
---|
| 313 |
|
---|
| 314 | yyrc = (pfnDiveSetSourcePalette) ? pfnDiveSetSourcePalette(a, b, c, d) : DIVE_ERR_INVALID_INSTANCE;
|
---|
| 315 | SetFS(sel);
|
---|
| 316 |
|
---|
| 317 | return yyrc;
|
---|
| 318 | }
|
---|
| 319 | //******************************************************************************
|
---|
| 320 | //******************************************************************************
|
---|
| 321 | ULONG APIENTRY _DiveSetTransparentBlitMode ( HDIVE a, ULONG b,
|
---|
| 322 | ULONG c, ULONG d )
|
---|
| 323 | {
|
---|
| 324 | ULONG yyrc;
|
---|
| 325 | USHORT sel = RestoreOS2FS();
|
---|
| 326 |
|
---|
| 327 | yyrc = (pfnDiveSetTransparentBlitMode) ? pfnDiveSetTransparentBlitMode(a, b, c, d) : DIVE_ERR_INVALID_INSTANCE;
|
---|
| 328 | SetFS(sel);
|
---|
| 329 |
|
---|
| 330 | return yyrc;
|
---|
| 331 | }
|
---|
| 332 | //******************************************************************************
|
---|
| 333 | //******************************************************************************
|
---|
| 334 | #endif
|
---|