updated on Thu Jan 19 20:01:47 UTC 2012
[aur-mirror.git] / dosbox-svn-patched / glide.patch
blob0dbf04b64db0ef1cc8fb844b4c6824704c6e09d8
1 diff -urN dosbox.orig/include/glide.h dosbox/include/glide.h
2 --- dosbox.orig/include/glide.h 1969-12-31 21:00:00.000000000 -0300
3 +++ dosbox/include/glide.h 2011-01-11 20:01:45.194832103 -0300
4 @@ -0,0 +1,331 @@
5 +/*
6 + * Copyright (C) 2002-2007 The DOSBox Team
7 + *
8 + * This program is free software; you can redistribute it and/or modify
9 + * it under the terms of the GNU General Public License as published by
10 + * the Free Software Foundation; either version 2 of the License, or
11 + * (at your option) any later version.
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. See the
16 + * GNU General Public License for more details.
17 + *
18 + * You should have received a copy of the GNU General Public License
19 + * along with this program; if not, write to the Free Software
20 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 + */
23 +#ifndef DOSBOX_GLIDE_H
24 +#define DOSBOX_GLIDE_H
26 +#define __3DFX_H__
28 +/*
29 +** basic data types
30 +*/
31 +typedef Bit8u FxU8;
32 +typedef Bit8s FxI8;
33 +typedef Bit16u FxU16;
34 +typedef Bit16s FxI16;
35 +typedef Bit32u FxU32;
36 +typedef Bit32s FxI32;
37 +typedef Bit32s FxBool;
38 +typedef float FxFloat;
39 +typedef double FxDouble;
41 +/*
42 +** color types
43 +*/
44 +typedef Bit32u FxColor_t;
45 +typedef struct { float r, g, b, a; } FxColor4;
47 +/*
48 +** fundamental types
49 +*/
50 +#define FXTRUE 1
51 +#define FXFALSE 0
53 +/*
54 +** helper macros
55 +*/
56 +#define FXUNUSED( a ) ((void)(a))
57 +#define FXBIT( i ) ( 1L << (i) )
59 +#define FX_ENTRY
60 +#define FX_GLIDE_NO_FUNC_PROTO
62 +#if defined (WIN32)
63 +#define FX_CALL __stdcall
64 +#else
65 +#define FX_CALL
66 +#endif
68 +#include <sdk2_glide.h>
69 +#include "glidedef.h"
71 +// Careful with structures containing pointers
72 +//
73 +// GrTexInfo; GrLfbInfo_t; Gu3dfInfo; GrMipMapInfo;
74 +//
76 +// Some glide structs might have different size in guest 32-bit DOS (pointers)
77 +typedef struct {
78 + Bit32s smallLod;
79 + Bit32s largeLod;
80 + Bit32s aspectRatio;
81 + Bit32s format;
82 + PhysPt data;
83 +} DBGrTexInfo;
85 +typedef struct {
86 + Bit32s size;
87 + PhysPt lfbPtr;
88 + Bit32u strideInBytes;
89 + Bit32s writeMode;
90 + Bit32s origin;
91 +} DBGrLfbInfo_t;
93 +typedef struct {
94 + Gu3dfHeader header;
95 + GuTexTable table;
96 + PhysPt data;
97 + Bit32u mem_required;
98 +} DBGu3dfInfo;
100 +typedef struct {
101 + const char * name;
102 + const Bit8u parms;
103 +} GLIDE_TABLE;
105 +typedef void (FX_CALL *pfunc0) (void);
106 +typedef void (FX_CALL *pfunc1i) (FxU32);
107 +typedef void (FX_CALL *pfunc1p) (void*);
108 +typedef void (FX_CALL *pfunc1f) (float);
109 +typedef void (FX_CALL *pfunc2i) (FxU32, FxU32);
110 +typedef void (FX_CALL *pfunc1i1p) (FxU32, void*);
111 +typedef void (FX_CALL *pfunc2p) (void*, void*);
112 +typedef void (FX_CALL *pfunc1i1f) (FxU32, float);
113 +typedef void (FX_CALL *pfunc1p1f) (void*, float);
114 +typedef void (FX_CALL *pfunc3i) (FxU32, FxU32, FxU32);
115 +typedef void (FX_CALL *pfunc2i1p) (FxU32, FxU32, void*);
116 +typedef void (FX_CALL *pfunc1i2p) (FxU32, void*, void*);
117 +typedef void (FX_CALL *pfunc3p) (void*, void*, void*);
118 +typedef void (FX_CALL *pfunc1p2f) (void*, float, float);
119 +typedef void (FX_CALL *pfunc4i) (FxU32, FxU32, FxU32, FxU32);
120 +typedef void (FX_CALL *pfunc3i1p) (FxU32, FxU32, FxU32, void*);
121 +typedef void (FX_CALL *pfunc3i1f) (FxU32, FxU32, FxU32, float);
122 +typedef void (FX_CALL *pfunc4f) (float, float, float, float);
123 +typedef void (FX_CALL *pfunc5i) (FxU32, FxU32, FxU32, FxU32, FxU32);
124 +typedef void (FX_CALL *pfunc2i1p2i) (FxU32, FxU32, void*, FxU32, FxU32);
125 +typedef void (FX_CALL *pfunc4f1i) (float, float, float, float, FxU32);
126 +typedef void (FX_CALL *pfunc3p3i) (void*, void*, void*, FxU32, FxU32, FxU32);
127 +typedef void (FX_CALL *pfunc7i) (FxU32, FxU32, FxU32, FxU32, FxU32, FxU32, FxU32);
128 +typedef void (FX_CALL *pfunc7i1p) (FxU32, FxU32, FxU32, FxU32, FxU32, FxU32, FxU32, void*);
129 +typedef void (FX_CALL *pfunc7i1p2i) (FxU32, FxU32, FxU32, FxU32, FxU32, FxU32, FxU32, void*,
130 + FxU32, FxU32);
131 +typedef void (FX_CALL *pfunc7i1p7i1p) (FxU32, FxU32, FxU32, FxU32, FxU32, FxU32, FxU32, void*,
132 + FxU32, FxU32, FxU32, FxU32, FxU32, FxU32, FxU32, void*);
134 +typedef FxU32 (FX_CALL *prfunc0) (void);
135 +typedef FxU32 (FX_CALL *prfunc1i) (FxU32);
136 +typedef FxU32 (FX_CALL *prfunc1p) (void*);
137 +typedef FxU32 (FX_CALL *prfunc2i) (FxU32, FxU32);
138 +typedef FxU32 (FX_CALL *prfunc1i1p) (FxU32, void*);
139 +typedef FxU32 (FX_CALL *prfunc2p) (void*, void*);
140 +typedef FxU32 (FX_CALL *prfunc4i) (FxU32, FxU32, FxU32, FxU32);
141 +typedef FxU32 (FX_CALL *prfunc5i1p) (FxU32, FxU32, FxU32, FxU32, FxU32, void*);
142 +typedef FxU32 (FX_CALL *prfunc7i) (FxU32, FxU32, FxU32, FxU32, FxU32, FxU32, FxU32);
143 +typedef FxU32 (FX_CALL *prfunc1p6i) (void*, FxU32, FxU32, FxU32, FxU32, FxU32, FxU32);
144 +typedef FxU32 (FX_CALL *prfunc6i1p) (FxU32, FxU32, FxU32, FxU32, FxU32, FxU32, void*);
145 +typedef FxU32 (FX_CALL *prfunc7i1p) (FxU32, FxU32, FxU32, FxU32, FxU32, FxU32, FxU32, void*);
146 +typedef FxU32 (FX_CALL *prfunc12i) (FxU32, FxU32, FxU32, FxU32, FxU32, FxU32, FxU32,
147 + FxU32, FxU32, FxU32, FxU32, FxU32);
148 +typedef FxU32 (FX_CALL *prfunc13i1f1i) (FxU32, FxU32, FxU32, FxU32, FxU32, FxU32, FxU32, FxU32,
149 + FxU32, FxU32, FxU32, FxU32, FxU32, float, FxU32);
151 +typedef void* (FX_CALL *prptfunc1i) (FxU32);
152 +typedef float (FX_CALL *pffunc1i) (FxU32);
154 +typedef union {
155 + pfunc0 grFunction0;
156 + pfunc1i grFunction1i;
157 + pfunc1p grFunction1p;
158 + pfunc1f grFunction1f;
159 + pfunc2i grFunction2i;
160 + pfunc1i1p grFunction1i1p;
161 + pfunc2p grFunction2p;
162 + pfunc1i1f grFunction1i1f;
163 + pfunc1p1f grFunction1p1f;
164 + pfunc3i grFunction3i;
165 + pfunc2i1p grFunction2i1p;
166 + pfunc1i2p grFunction1i2p;
167 + pfunc3p grFunction3p;
168 + pfunc1p2f grFunction1p2f;
169 + pfunc4i grFunction4i;
170 + pfunc3i1p grFunction3i1p;
171 + pfunc3i1f grFunction3i1f;
172 + pfunc4f grFunction4f;
173 + pfunc5i grFunction5i;
174 + pfunc2i1p2i grFunction2i1p2i;
175 + pfunc4f1i grFunction4f1i;
176 + pfunc3p3i grFunction3p3i;
177 + pfunc7i grFunction7i;
178 + pfunc7i1p grFunction7i1p;
179 + pfunc7i1p2i grFunction7i1p2i;
180 + pfunc7i1p7i1p grFunction7i1p7i1p;
182 + prfunc0 grRFunction0;
183 + prfunc1i grRFunction1i;
184 + prfunc1p grRFunction1p;
185 + prfunc2i grRFunction2i;
186 + prfunc1i1p grRFunction1i1p;
187 + prfunc2p grRFunction2p;
188 + prfunc4i grRFunction4i;
189 + prfunc5i1p grRFunction5i1p;
190 + prfunc7i grRFunction7i;
191 + prfunc1p6i grRFunction1p6i;
192 + prfunc6i1p grRFunction6i1p;
193 + prfunc7i1p grRFunction7i1p;
194 + prfunc12i grRFunction12i;
195 + prfunc13i1f1i grRFunction13i1f1i;
197 + prptfunc1i grRPTFunction1i;
199 + pffunc1i grFFunction1i;
200 +} FncPointers;
202 +static const GLIDE_TABLE grTable[] = {
203 + { "grAADrawLine", 8 },
204 + { "grAADrawPoint", 4 },
205 + { "grAADrawPolygon", 12 },
206 + { "grAADrawPolygonVertexList", 8 },
207 + { "grAADrawTriangle", 24 },
208 + { "grAlphaBlendFunction", 16 },
209 + { "grAlphaCombine", 20 },
210 + { "grAlphaControlsITRGBLighting", 4 },
211 + { "grAlphaTestFunction", 4 },
212 + { "grAlphaTestReferenceValue", 4 },
213 + { "grBufferClear", 12 },
214 + { "grBufferNumPending", 0 },
215 + { "grBufferSwap", 4 },
216 + { "grCheckForRoom", 4 },
217 + { "grChromakeyMode", 4 },
218 + { "grChromakeyValue", 4 },
219 + { "grClipWindow", 16 },
220 + { "grColorCombine", 20 },
221 + { "grColorMask", 8 },
222 + { "grConstantColorValue4", 16 },
223 + { "grConstantColorValue", 4 },
224 + { "grCullMode", 4 },
225 + { "grDepthBiasLevel", 4 },
226 + { "grDepthBufferFunction", 4 },
227 + { "grDepthBufferMode", 4 },
228 + { "grDepthMask", 4 },
229 + { "grDisableAllEffects", 0 },
230 + { "grDitherMode", 4 },
231 + { "grDrawLine", 8 },
232 + { "grDrawPlanarPolygon", 12 },
233 + { "grDrawPlanarPolygonVertexList", 8 },
234 + { "grDrawPoint", 4 },
235 + { "grDrawPolygon", 12 },
236 + { "grDrawPolygonVertexList", 8 },
237 + { "grDrawTriangle", 12 },
238 + { "grErrorSetCallback", 4 },
239 + { "grFogColorValue", 4 },
240 + { "grFogMode", 4 },
241 + { "grFogTable", 4 },
242 + { "grGammaCorrectionValue", 4 },
243 + { "grGlideGetState", 4 },
244 + { "grGlideGetVersion", 4 },
245 + { "grGlideInit", 0 },
246 + { "grGlideSetState", 4 },
247 + { "grGlideShamelessPlug", 4 },
248 + { "grGlideShutdown", 0 },
249 + { "grHints", 8 },
250 + { "grLfbConstantAlpha", 4 },
251 + { "grLfbConstantDepth", 4 },
252 + { "grLfbLock", 24 },
253 + { "grLfbReadRegion", 28 },
254 + { "grLfbUnlock", 8 },
255 + { "grLfbWriteColorFormat", 4 },
256 + { "grLfbWriteColorSwizzle", 8 },
257 + { "grLfbWriteRegion", 32 },
258 + { "grRenderBuffer", 4 },
259 + { "grResetTriStats", 0 },
260 + { "grSplash", 20 },
261 + { "grSstConfigPipeline", 12 },
262 + { "grSstControl", 4 },
263 + { "grSstIdle", 0 },
264 + { "grSstIsBusy", 0 },
265 + { "grSstOrigin", 4 },
266 + { "grSstPerfStats", 4 },
267 + { "grSstQueryBoards", 4 },
268 + { "grSstQueryHardware", 4 },
269 + { "grSstResetPerfStats", 0 },
270 + { "grSstScreenHeight", 0 },
271 + { "grSstScreenWidth", 0 },
272 + { "grSstSelect", 4 },
273 + { "grSstStatus", 0 },
274 + { "grSstVRetraceOn", 0 },
275 + { "grSstVidMode", 8 },
276 + { "grSstVideoLine", 0 },
277 + { "grSstWinClose", 0 },
278 + { "grSstWinOpen", 28 },
279 + { "grTexCalcMemRequired", 16 },
280 + { "grTexClampMode", 12 },
281 + { "grTexCombine", 28 },
282 + { "grTexCombineFunction", 8 },
283 + { "grTexDetailControl", 16 },
284 + { "grTexDownloadMipMap", 16 },
285 + { "grTexDownloadMipMapLevel", 32 },
286 + { "grTexDownloadMipMapLevelPartial", 40 },
287 + { "grTexDownloadTable", 12 },
288 + { "grTexDownloadTablePartial", 20 },
289 + { "grTexFilterMode", 12 },
290 + { "grTexLodBiasValue", 8 },
291 + { "grTexMaxAddress", 4 },
292 + { "grTexMinAddress", 4 },
293 + { "grTexMipMapMode", 12 },
294 + { "grTexMultibase", 8 },
295 + { "grTexMultibaseAddress", 20 },
296 + { "grTexNCCTable", 8 },
297 + { "grTexSource", 16 },
298 + { "grTexTextureMemRequired", 8 },
299 + { "grTriStats", 8 },
300 + { "gu3dfGetInfo", 8 },
301 + { "gu3dfLoad", 8 },
302 + { "guAADrawTriangleWithClip", 12 },
303 + { "guAlphaSource", 4 },
304 + { "guColorCombineFunction", 4 },
305 + { "guDrawPolygonVertexListWithClip", 8 },
306 + { "guDrawTriangleWithClip", 12 },
307 + { "guEncodeRLE16", 16 },
308 + { "guEndianSwapBytes", 4 },
309 + { "guEndianSwapWords", 4 },
310 + { "guFogGenerateExp2", 8 },
311 + { "guFogGenerateExp", 8 },
312 + { "guFogGenerateLinear", 12 },
313 + { "guFogTableIndexToW", 4 },
314 + { "guMPDrawTriangle", 12 },
315 + { "guMPInit", 0 },
316 + { "guMPTexCombineFunction", 4 },
317 + { "guMPTexSource", 8 },
318 + { "guMovieSetName", 4 },
319 + { "guMovieStart", 0 },
320 + { "guMovieStop", 0 },
321 + { "guTexAllocateMemory", 60 },
322 + { "guTexChangeAttributes", 48 },
323 + { "guTexCombineFunction", 8 },
324 + { "guTexCreateColorMipMap", 0 },
325 + { "guTexDownloadMipMap", 12 },
326 + { "guTexDownloadMipMapLevel", 12 },
327 + { "guTexGetCurrentMipMap", 4 },
328 + { "guTexGetMipMapInfo", 4 },
329 + { "guTexMemQueryAvail", 4 },
330 + { "guTexMemReset", 0 },
331 + { "guTexSource", 4 },
332 + { "ConvertAndDownloadRle", 64 }
335 +#endif // DOSBOX_GLIDE_H
336 diff -urN dosbox.orig/include/glidedef.h dosbox/include/glidedef.h
337 --- dosbox.orig/include/glidedef.h 1969-12-31 21:00:00.000000000 -0300
338 +++ dosbox/include/glidedef.h 2011-01-11 20:01:45.194832103 -0300
339 @@ -0,0 +1,176 @@
341 + * Copyright (C) 2002-2007 The DOSBox Team
343 + * This program is free software; you can redistribute it and/or modify
344 + * it under the terms of the GNU General Public License as published by
345 + * the Free Software Foundation; either version 2 of the License, or
346 + * (at your option) any later version.
348 + * This program is distributed in the hope that it will be useful,
349 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
350 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
351 + * GNU General Public License for more details.
353 + * You should have received a copy of the GNU General Public License
354 + * along with this program; if not, write to the Free Software
355 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
356 + */
358 +#ifndef GLIDEDEF_H
359 +#define GLIDEDEF_H
361 +#ifdef DOSBOX_DOSBOX_H
362 +struct GLIDE_Block
364 + bool splash;
365 + bool enabled;
366 + bool * fullscreen;
367 + Bit16u width, height;
368 + class GLIDE_PageHandler * lfb_pagehandler;
369 + GLIDE_Block():enabled(false),fullscreen(0),width(0),height(0),lfb_pagehandler((GLIDE_PageHandler*)0) { }
371 +extern GLIDE_Block glide;
372 +extern void GLIDE_ResetScreen(bool update=false);
373 +#endif
375 +#define GLIDE_LFB 0x60000000
376 +#define GLIDE_PAGES 384 /* Should be enough for 1024x768x2 */
378 +#ifdef __3DFX_H__
379 +/* If you change these defines, don't forget to change the table in glide.h and compile a matching GLIDE2X.OVL */
381 +#define _grAADrawLine8 0 // void grAADrawLine(GrVertex *va, GrVertex *vb)
382 +#define _grAADrawPoint4 1 // void grAADrawPoint(GrVertex *p)
383 +#define _grAADrawPolygon12 2 // void grAADrawPolygon(int nVerts, const int ilist[], const GrVertex vlist[])
384 +#define _grAADrawPolygonVertexList8 3 // void grAADrawPolygonVertexList(int nVerts, const GrVertex vlist[])
385 +#define _grAADrawTriangle24 4 // void grAADrawTriangle(GrVertex *a, GrVertex *b, GrVertex *c, FxBool antialiasAB, FxBool antialiasBC, FxBool antialiasCA)
386 +#define _grAlphaBlendFunction16 5 // void grAlphaBlendFunction(GrAlphaBlendFnc_t rgb_sf, GrAlphaBlendFnc_t rgb_df, GrAlphaBlendFnc_t alpha_sf, GrAlphaBlendFnc_t alpha_df)
387 +#define _grAlphaCombine20 6 // void grAlphaCombine(GrCombineFunction_t func, GrCombineFactor_t factor, GrCombineLocal_t local, GrCombineOther_t other, FxBool invert)
388 +#define _grAlphaControlsITRGBLighting4 7 // void grAlphaControlsITRGBLighting(FxBool enable)
389 +#define _grAlphaTestFunction4 8 // void grAlphaTestFunction(GrCmpFnc_t function)
390 +#define _grAlphaTestReferenceValue4 9 // void grAlphaTestReferenceValue(GrAlpha_t value)
391 +#define _grBufferClear12 10 // void grBufferClear(GrColor_t color, GrAlpha_t alpha, FxU16 depth)
392 +#define _grBufferNumPending0 11 // int grBufferNumPending(void)
393 +#define _grBufferSwap4 12 // void grBufferSwap(int swap_interval)
394 +#define _grCheckForRoom4 13 // void grCheckForRoom(FxI32 n)
395 +#define _grChromakeyMode4 14 // void grChromakeyMode(GrChromakeyMode_t mode)
396 +#define _grChromakeyValue4 15 // void grChromakeyValue(GrColor_t value)
397 +#define _grClipWindow16 16 // void grClipWindow(FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy)
398 +#define _grColorCombine20 17 // void grColorCombine(GrCombineFunction_t func, GrCombineFactor_t factor, GrCombineLocal_t local, GrCombineOther_t other, FxBool invert)
399 +#define _grColorMask8 18 // void grColorMask(FxBool rgb, FxBool alpha)
400 +#define _grConstantColorValue416 19 // void grConstantColorValue4(float a, float r, float g, float b)
401 +#define _grConstantColorValue4 20 // void grConstantColorValue(GrColor_t color)
402 +#define _grCullMode4 21 // void grCullMode(GrCullMode_t mode)
403 +#define _grDepthBiasLevel4 22 // void grDepthBiasLevel(FxI16 level)
404 +#define _grDepthBufferFunction4 23 // void grDepthBufferFunction(GrCmpFnc_t func)
405 +#define _grDepthBufferMode4 24 // void grDepthBufferMode(GrDepthBufferMode_t mode)
406 +#define _grDepthMask4 25 // void grDepthMask(FxBool enable)
407 +#define _grDisableAllEffects0 26 // void grDisableAllEffects(void)
408 +#define _grDitherMode4 27 // void grDitherMode(GrDitherMode_t mode)
409 +#define _grDrawLine8 28 // void grDrawLine(const GrVertex *a, const GrVertex *b)
410 +#define _grDrawPlanarPolygon12 29 // void grDrawPlanarPolygon(int nVerts, int ilist[], const GrVertex vlist[])
411 +#define _grDrawPlanarPolygonVertexList8 30 // void grDrawPlanarPolygonVertexList(int nVerts, const GrVertex vlist[])
412 +#define _grDrawPoint4 31 // void grDrawPoint(const GrVertex *a)
413 +#define _grDrawPolygon12 32 // void grDrawPolygon(int nVerts, int ilist[], const GrVertex vlist[])
414 +#define _grDrawPolygonVertexList8 33 // void grDrawPolygonVertexList(int nVerts, const GrVertex vlist[])
415 +#define _grDrawTriangle12 34 // void grDrawTriangle(const GrVertex *a, const GrVertex *b, const GrVertex *c)
416 +#define _grErrorSetCallback4 35 // void grErrorSetCallback(void (*function)(const char *string, FxBool fatal))
417 +#define _grFogColorValue4 36 // void grFogColorValue(GrColor_t value)
418 +#define _grFogMode4 37 // void grFogMode(GrFogMode_t mode)
419 +#define _grFogTable4 38 // void grFogTable(const GrFog_t table[GR_FOG_TABLE_SIZE])
420 +#define _grGammaCorrectionValue4 39 // void grGammaCorrectionValue(float value)
421 +#define _grGlideGetState4 40 // void grGlideGetState(GrState *state)
422 +#define _grGlideGetVersion4 41 // void grGlideGetVersion(char version[80])
423 +#define _grGlideInit0 42 // void grGlideInit(void)
424 +#define _grGlideSetState4 43 // void grGlideSetState(const GrState *state)
425 +#define _grGlideShamelessPlug4 44 // void grGlideShamelessPlug(const FxBool on)
426 +#define _grGlideShutdown0 45 // void grGlideShutdown(void)
427 +#define _grHints8 46 // void grHints(GrHint_t type, FxU32 hintMask)
428 +#define _grLfbConstantAlpha4 47 // void grLfbConstantAlpha(GrAlpha_t alpha)
429 +#define _grLfbConstantDepth4 48 // void grLfbConstantDepth(FxU16 depth)
430 +#define _grLfbLock24 49 // FxBool grLfbLock(GrLock_t type, GrBuffer_t buffer, GrLfbWriteMode_t writeMode, GrOriginLocation_t origin, FxBool pixelPipeline, GrLfbInfo_t *info)
431 +#define _grLfbReadRegion28 50 // FxBool grLfbReadRegion(GrBuffer_t src_buffer, FxU32 src_x, FxU32 src_y, FxU32 src_width, FxU32 src_height, FxU32 dst_stride, void *dst_data)
432 +#define _grLfbUnlock8 51 // FxBool grLfbUnlock(GrLock_t type, GrBuffer_t buffer)
433 +#define _grLfbWriteColorFormat4 52 // void grLfbWriteColorFormat(GrColorFormat_t colorFormat)
434 +#define _grLfbWriteColorSwizzle8 53 // void grLfbWriteColorSwizzle(FxBool swizzleBytes, FxBool swapWords)
435 +#define _grLfbWriteRegion32 54 // FxBool grLfbWriteRegion(GrBuffer_t dst_buffer, FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format, FxU32 src_width, FxU32 src_height, FxU32 src_stride, void *src_data)
436 +#define _grRenderBuffer4 55 // void grRenderBuffer(GrBuffer_t buffer)
437 +#define _grResetTriStats0 56 // void grResetTriStats()
438 +#define _grSplash20 57 // void grSplash(float x, float y, float width, float height, FxU32 frame)
439 +#define _grSstConfigPipeline12 58 //
440 +#define _grSstControl4 59 // FxBool grSstControl(FxU32 code)
441 +#define _grSstIdle0 60 // void grSstIdle(void)
442 +#define _grSstIsBusy0 61 // FxBool grSstIsBusy(void)
443 +#define _grSstOrigin4 62 // void grSstOrigin(GrOriginLocation_t origin)
444 +#define _grSstPerfStats4 63 // void grSstPerfStats(GrSstPerfStats_t *pStats)
445 +#define _grSstQueryBoards4 64 // FxBool grSstQueryBoards(GrHwConfiguration *hwConfig)
446 +#define _grSstQueryHardware4 65 // FxBool grSstQueryHardware(GrHwConfiguration *hwConfig)
447 +#define _grSstResetPerfStats0 66 // void grSstResetPerfStats(void)
448 +#define _grSstScreenHeight0 67 // FxU32 grSstScreenHeight(void)
449 +#define _grSstScreenWidth0 68 // FxU32 grSstScreenWidth(void)
450 +#define _grSstSelect4 69 // void grSstSelect(int which_sst)
451 +#define _grSstStatus0 70 // FxU32 grSstStatus(void)
452 +#define _grSstVRetraceOn0 71 // FxBool grSstVRetraceOn(void)
453 +#define _grSstVidMode8 72 //
454 +#define _grSstVideoLine0 73 // FxU32 grSstVideoLine(void)
455 +#define _grSstWinClose0 74 // void grSstWinClose(void)
456 +#define _grSstWinOpen28 75 // FxBool grSstWinOpen(FxU32 hwnd, GrScreenResolution_t res, GrScreenRefresh_t ref, GrColorFormat_t cformat, GrOriginLocation_t org_loc, int num_buffers, int num_aux_buffers)
457 +#define _grTexCalcMemRequired16 76 // FxU32 grTexCalcMemRequired(GrLOD_t smallLod, GrLOD_t largeLod, GrAspectRatio_t aspect, GrTextureFormat_t format)
458 +#define _grTexClampMode12 77 // void grTexClampMode(GrChipID_t tmu, GrTextureClampMode_t sClampMode, GrTextureClampMode_t tClampMode)
459 +#define _grTexCombine28 78 // void grTexCombine(GrChipID_t tmu, GrCombineFunction_t rgb_function, GrCombineFactor_t rgb_factor, GrCombineFunction_t alpha_function, GrCombineFactor_t alpha_factor, FxBool rgb_invert, FxBool alpha_invert)
460 +#define _grTexCombineFunction8 79 // void grTexCombineFunction(GrChipID_t tmu, GrTextureCombineFnc_t fnc)
461 +#define _grTexDetailControl16 80 // void grTexDetailControl(GrChipID_t tmu, int lodBias, FxU8 detailScale, float detailMax)
462 +#define _grTexDownloadMipMap16 81 // void grTexDownloadMipMap(GrChipID_t tmu, FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info)
463 +#define _grTexDownloadMipMapLevel32 82 // void grTexDownloadMipMapLevel(GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLod, GrLOD_t largeLod, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 evenOdd, void *data)
464 +#define _grTexDownloadMipMapLevelPartial40 83 // void grTexDownloadMipMapLevelPartial(GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLod, GrLOD_t largeLod, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 evenOdd, void *data, int start, int end)
465 +#define _grTexDownloadTable12 84 // void grTexDownloadTable(GrChipID_t tmu, GrTexTable_t type, void *data)
466 +#define _grTexDownloadTablePartial20 85 // void grTexDownloadTablePartial(GrChipID_t tmu, GrTexTable_t type, void *data, int start, int end)
467 +#define _grTexFilterMode12 86 // void grTexFilterMode(GrChipID_t tmu, GrTextureFilterMode_t minFilterMode, GrTextureFilterMode_t magFilterMode)
468 +#define _grTexLodBiasValue8 87 // void grTexLodBiasValue(GrChipID_t tmu, float bias)
469 +#define _grTexMaxAddress4 88 // FxU32 grTexMaxAddress(GrChipID_t tmu)
470 +#define _grTexMinAddress4 89 // FxU32 grTexMinAddress(GrChipID_t tmu)
471 +#define _grTexMipMapMode12 90 // void grTexMipMapMode(GrChipID_t tmu, GrMipMapMode_t mode, FxBool lodBlend)
472 +#define _grTexMultibase8 91 // void grTexMultibase(GrChipID_t tmu, FxBool enable)
473 +#define _grTexMultibaseAddress20 92 // void grTexMultibaseAddress(GrChipID_t tmu, GrTexBaseRange_t range, FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info)
474 +#define _grTexNCCTable8 93 // void grTexNCCTable(GrChipID_t tmu, GrNCCTable_t table)
475 +#define _grTexSource16 94 // void grTexSource(GrChipID_t tmu, FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info)
476 +#define _grTexTextureMemRequired8 95 // FxU32 grTexTextureMemRequired(FxU32 evenOdd, GrTexInfo *info)
477 +#define _grTriStats8 96 // void grTriStats(FxU32 *trisProcessed, FxU32 *trisDrawn)
478 +#define _gu3dfGetInfo8 97 // FxBool gu3dfGetInfo(const char *filename, Gu3dfInfo *info)
479 +#define _gu3dfLoad8 98 // FxBool gu3dfLoad(const char *filename, Gu3dfInfo *info)
480 +#define _guAADrawTriangleWithClip12 99 // void guAADrawTriangleWithClip(const GrVertex *va, const GrVertex *vb, const GrVertex *vc)
481 +#define _guAlphaSource4 100 // void guAlphaSource(GrAlphaSource_t mode)
482 +#define _guColorCombineFunction4 101 // void guColorCombineFunction(GrColorCombineFnc_t func)
483 +#define _guDrawPolygonVertexListWithClip8 102 // void guDrawPolygonVertexListWithClip(int nverts, const GrVertex vlist[])
484 +#define _guDrawTriangleWithClip12 103 // void guDrawTriangleWithClip(const GrVertex *va, const GrVertex *vb, const GrVertex *vc)
485 +#define _guEncodeRLE1616 104 //
486 +#define _guEndianSwapBytes4 105 //
487 +#define _guEndianSwapWords4 106 //
488 +#define _guFogGenerateExp28 107 // void guFogGenerateExp2(GrFog_t fogTable[GR_FOG_TABLE_SIZE], float density)
489 +#define _guFogGenerateExp8 108 // void guFogGenerateExp(GrFog_t fogTable[GR_FOG_TABLE_SIZE], float density)
490 +#define _guFogGenerateLinear12 109 // void guFogGenerateLinear(GrFog_t fogTable[GR_FOG_TABLE_SIZE], float nearW, float farW)
491 +#define _guFogTableIndexToW4 110 // float guFogTableIndexToW(int i)
492 +#define _guMPDrawTriangle12 111 //
493 +#define _guMPInit0 112 //
494 +#define _guMPTexCombineFunction4 113 //
495 +#define _guMPTexSource8 114 //
496 +#define _guMovieSetName4 115 //
497 +#define _guMovieStart0 116 //
498 +#define _guMovieStop0 117 //
499 +#define _guTexAllocateMemory60 118 // GrMipMapId_t guTexAllocateMemory(GrChipID_t tmu, FxU8 evenOddMask, int width, int height, GrTextureFormat_t format, GrMipMapMode_t mmMode, GrLOD_t smallLod, GrLOD_t largeLod, GrAspectRatio_t aspectRatio, GrTextureClampMode_t sClampMode, GrTextureClampMode_t tClampMode, GrTextureFilterMode_t minFilterMode, GrTextureFilterMode_t magFilterMode, float lodBias, FxBool lodBlend)
500 +#define _guTexChangeAttributes48 119 // FxBool guTexChangeAttributes(GrMipMapID_t mmid, int width, int height, GrTextureFormat_t format, GrMipMapMode_t mmMode, GrLOD_t smallLod, GrLOD_t largeLod, GrAspectRatio_t aspectRatio, GrTextureClampMode_t sClampMode, GrTextureClampMode_t tClampMode, GrTextureFilterMode_t minFilterMode, GrTextureFilterMode_t magFilterMode)
501 +#define _guTexCombineFunction8 120 // void guTexCombineFunction(GrChipID_t tmu, GrTextureCombineFnc_t func)
502 +#define _guTexCreateColorMipMap0 121 //
503 +#define _guTexDownloadMipMap12 122 // void guTexDownloadMipMap(GrMipMapId_t mmid, const void *src, const GuNccTable *nccTable)
504 +#define _guTexDownloadMipMapLevel12 123 // void guTexDownloadMipMapLevel(GrMipMapId_t mmid, GrLOD_t lod, const void **src)
505 +#define _guTexGetCurrentMipMap4 124 // GrMipMapId_t guTexGetCurrentMipMap (GrChipID_t tmu)
506 +#define _guTexGetMipMapInfo4 125 // GrMipMapInfo *guTexGetMipMapInfo(GrMipMapId_t mmid)
507 +#define _guTexMemQueryAvail4 126 // FxU32 guTexMemQueryAvail(GrChipID_t tmu)
508 +#define _guTexMemReset0 127 // void guTexMemReset(void)
509 +#define _guTexSource4 128 // void guTexSource(GrMipMapId_t mmid)
510 +#define _ConvertAndDownloadRle64 129 // void ConvertAndDownloadRle(GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLod, GrLOD_t largeLod, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 evenOdd, FxU8 *bm_data, long bm_h, FxU32 u0, FxU32 v0, FxU32 width, FxU32 height, FxU32 dest_width, FxU32 dest_height, FxU16 *tlut)
511 +#define GLIDE_MAX 129
513 +#endif // __3DFX_H__
515 +#endif // GLIDEDEF_H
516 diff -urN dosbox.orig/include/mem.h dosbox/include/mem.h
517 --- dosbox.orig/include/mem.h 2011-01-11 19:48:52.658165437 -0300
518 +++ dosbox/include/mem.h 2011-01-11 20:01:45.194832103 -0300
519 @@ -152,6 +152,8 @@
521 void MEM_BlockWrite(PhysPt pt,void const * const data,Bitu size);
522 void MEM_BlockRead(PhysPt pt,void * data,Bitu size);
523 +void MEM_BlockWrite32(PhysPt pt,void * data,Bitu size);
524 +void MEM_BlockRead32(PhysPt pt,void * data,Bitu size);
525 void MEM_BlockCopy(PhysPt dest,PhysPt src,Bitu size);
526 void MEM_StrCopy(PhysPt pt,char * data,Bitu size);
528 diff -urN dosbox.orig/src/dosbox.cpp dosbox/src/dosbox.cpp
529 --- dosbox.orig/src/dosbox.cpp 2011-01-11 19:48:52.678165437 -0300
530 +++ dosbox/src/dosbox.cpp 2011-01-11 20:01:45.198165437 -0300
531 @@ -77,6 +77,7 @@
533 void KEYBOARD_Init(Section*); //TODO This should setup INT 16 too but ok ;)
534 void JOYSTICK_Init(Section*);
535 +void GLIDE_Init(Section*);
536 void MOUSE_Init(Section*);
537 void SBLASTER_Init(Section*);
538 void GUS_Init(Section*);
539 @@ -649,6 +650,14 @@
540 Pmulti_remain->Set_help("see serial1");
543 + secprop=control->AddSection_prop("glide",&GLIDE_Init,true);
544 + Pbool = secprop->Add_bool("glide",Property::Changeable::WhenIdle,false);
545 + Pbool->Set_help("Enable glide emulation: true,false.");
546 + Phex = secprop->Add_hex("grport",Property::Changeable::WhenIdle,0x600);
547 + Phex->Set_help("I/O port to use for host communication.");
548 + Pstring = secprop->Add_string("lfb",Property::Changeable::WhenIdle,"full");
549 + Pstring->Set_help("LFB access: full,read,write,none.");
551 /* All the DOS Related stuff, which will eventually start up in the shell */
552 secprop=control->AddSection_prop("dos",&DOS_Init,false);//done
553 secprop->AddInitFunction(&XMS_Init,true);//done
554 diff -urN dosbox.orig/src/gui/sdlmain.cpp dosbox/src/gui/sdlmain.cpp
555 --- dosbox.orig/src/gui/sdlmain.cpp 2011-01-11 19:48:52.714832103 -0300
556 +++ dosbox/src/gui/sdlmain.cpp 2011-01-11 20:01:45.198165437 -0300
557 @@ -50,6 +50,7 @@
558 #include "cpu.h"
559 #include "cross.h"
560 #include "control.h"
561 +#include "glidedef.h"
563 #define MAPPERFILE "mapper-" VERSION ".map"
564 //#define DISABLE_JOYSTICK
565 @@ -347,6 +348,10 @@
568 void GFX_ResetScreen(void) {
569 + if(glide.enabled) {
570 + GLIDE_ResetScreen(true);
571 + return;
573 GFX_Stop();
574 if (sdl.draw.callback)
575 (sdl.draw.callback)( GFX_CallBackReset );
576 @@ -685,7 +690,10 @@
577 } else {
578 if (sdl.mouse.locked) GFX_CaptureMouse();
580 - GFX_ResetScreen();
581 + if (glide.enabled)
582 + GLIDE_ResetScreen();
583 + else
584 + GFX_ResetScreen();
587 static void SwitchFullScreen(bool pressed) {
588 @@ -1410,7 +1418,7 @@
589 throw(0);
590 break;
591 case SDL_VIDEOEXPOSE:
592 - if (sdl.draw.callback) sdl.draw.callback( GFX_CallBackRedraw );
593 + if ((sdl.draw.callback) && (!glide.enabled)) sdl.draw.callback( GFX_CallBackRedraw );
594 break;
595 #ifdef WIN32
596 case SDL_KEYDOWN:
597 @@ -1815,6 +1823,7 @@
598 if (strcmp(sdl_drv_name,"windib")==0) LOG_MSG("SDL_Init: Starting up with SDL windib video driver.\n Try to update your video card and directx drivers!");
600 #endif
601 + glide.fullscreen = &sdl.desktop.fullscreen;
602 sdl.num_joysticks=SDL_NumJoysticks();
604 /* Parse configuration files */
605 diff -urN dosbox.orig/src/hardware/Makefile.am dosbox/src/hardware/Makefile.am
606 --- dosbox.orig/src/hardware/Makefile.am 2011-01-11 19:48:52.694832103 -0300
607 +++ dosbox/src/hardware/Makefile.am 2011-01-11 20:01:45.201498771 -0300
608 @@ -10,6 +10,6 @@
609 memory.cpp mixer.cpp pcspeaker.cpp pic.cpp sblaster.cpp tandy_sound.cpp timer.cpp \
610 vga.cpp vga_attr.cpp vga_crtc.cpp vga_dac.cpp vga_draw.cpp vga_gfx.cpp vga_other.cpp \
611 vga_memory.cpp vga_misc.cpp vga_seq.cpp vga_xga.cpp vga_s3.cpp vga_tseng.cpp vga_paradise.cpp \
612 - cmos.cpp disney.cpp gus.cpp mpu401.cpp ipx.cpp ipxserver.cpp dbopl.cpp
613 + cmos.cpp disney.cpp gus.cpp mpu401.cpp ipx.cpp ipxserver.cpp dbopl.cpp glide.cpp
616 diff -urN dosbox.orig/src/hardware/glide.cpp dosbox/src/hardware/glide.cpp
617 --- dosbox.orig/src/hardware/glide.cpp 1969-12-31 21:00:00.000000000 -0300
618 +++ dosbox/src/hardware/glide.cpp 2011-01-11 20:01:45.201498771 -0300
619 @@ -0,0 +1,1792 @@
621 + * Copyright (C) 2002-2009 The DOSBox Team
623 + * This program is free software; you can redistribute it and/or modify
624 + * it under the terms of the GNU General Public License as published by
625 + * the Free Software Foundation; either version 2 of the License, or
626 + * (at your option) any later version.
628 + * This program is distributed in the hope that it will be useful,
629 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
630 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
631 + * GNU Library General Public License for more details.
633 + * You should have received a copy of the GNU General Public License
634 + * along with this program; if not, write to the Free Software
635 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
636 + */
638 +#include "dosbox.h"
639 +#include "inout.h"
640 +#include "mem.h"
641 +#include "paging.h"
642 +#include "glide.h"
643 +#include "setup.h"
644 +#include "vga.h"
645 +#include "dos_inc.h" /* for Drives[] */
646 +#include "../dos/drives.h"
648 +#include <iomanip>
649 +#include <sstream>
650 +using namespace std;
652 +#include "SDL.h"
654 +#if defined (WIN32)
655 +#include "SDL_syswm.h"
656 +#include <windows.h>
658 +#else // Linux
659 +#include <dlfcn.h>
661 +#endif
663 +extern void GFX_Stop(void);
664 +extern void GFX_ResetScreen(void);
665 +extern const char* RunningProgram;
667 +// Macro to properly pass floating point values
668 +#define F(a) *((float*)&a)
670 +#define SAFE_DELETE(p) { if(p) { delete p; p = NULL; } }
671 +#define ALIGN(x, a) (((x)+(a)-1)&~((a)-1))
673 +#define G_OK 1
674 +#define G_FAIL 0
676 +// Print debug messages
677 +#define LOG_GLIDE 0
679 +void VFILE_Remove(const char *name);
680 +static void process_msg(Bitu);
682 +/** Global Variables **/
683 +GLIDE_Block glide;
685 +// Pointers to loaded routines
686 +static FncPointers FP;
687 +static void ** fn_pt=NULL;
689 +// Shared memory address
690 +static Bit16u glsegment=0;
691 +static Bit32u param[20];
693 +// Pointer to return value
694 +static PhysPt ret;
695 +static Bit16u ret_value;
697 +// Temporary texture buffer
698 +static Bit32u texsize=0;
699 +static void* texmem=NULL;
701 +static HostPt hwnd=NULL;
702 +static char lfbacc=0;
704 +// Tomb Rider shadow hack
705 +static Bit8u tomb = 0;
706 +static FxI32 GrOriginLocation = 0;
708 +#if defined (WIN32)
709 +static HINSTANCE hdll=NULL; // Handle to glide2x lib file
710 +#else
711 +static void * hdll=NULL;
712 +#endif
714 +#if LOG_GLIDE
715 +static int GLIDE_count[GLIDE_MAX+2];
716 +#endif
718 +static Bitu read_gl(Bitu port,Bitu iolen)
720 + Bitu r=ret_value;
721 +#if LOG_GLIDE
722 + if(ret_value == G_OK)
723 + LOG_MSG("Glide:Port read. Return address: 0x%x, value: %d", ret, mem_readd(ret));
724 + else if(ret_value == G_FAIL)
725 + LOG_MSG("Glide:Port read. Return address: 0x%x, value: %d. Writing G_FAIL to port", ret, mem_readd(ret));
726 + else
727 + LOG_MSG("Glide:Port read. Returning %hu", ret_value);
728 +#endif
730 + ret_value = ret_value >> 8;
732 + return r;
735 +static void write_gl(Bitu port,Bitu val,Bitu iolen)
737 + ret = 0;
738 + ret_value = G_FAIL;
739 + FP.grFunction0 = NULL;
741 + // Allocate shared memory (80 bytes)
742 + if(val > GLIDE_MAX) {
743 + if(glsegment==0) {
744 + glsegment=DOS_GetMemory(5);
745 +#if LOG_GLIDE
746 + LOG_MSG("Glide:Memory allocated at 0x%x (segment: %hu)", glsegment<<4, glsegment);
747 +#endif
749 + ret_value=glsegment;
750 + LOG_MSG("Glide:Activated");
751 + return;
754 + // Process function parameters (80 bytes)
755 + MEM_BlockRead32(PhysMake(glsegment,0), param, 80);
756 + process_msg(val);
758 +// LOG_MSG("Glide:Function %s executed OK", grTable[val].name);
761 +class GLIDE_PageHandler : public PageHandler {
762 +private:
763 + PhysPt base_addr; // LFB physical address
764 + HostPt lfb_addr;
766 +public:
768 + FxU32 locked;
769 + GLIDE_PageHandler(HostPt addr, PhysPt phyaddr = GLIDE_LFB):base_addr(phyaddr),locked(0) {
771 + lfb_addr = addr-base_addr;
772 + if(addr == NULL) {
773 + LOG_MSG("Glide:NULL address passed!");
774 + lfb_addr = NULL;
776 + flags=PFLAG_READABLE|PFLAG_WRITEABLE|PFLAG_NOCODE;
777 + PAGING_UnlinkPages(base_addr>>12, GLIDE_PAGES);
778 + LOG_MSG("Glide:GLIDE_PageHandler installed at 0x%x (%d pages)", base_addr, GLIDE_PAGES);
781 + ~GLIDE_PageHandler() {
782 + LOG_MSG("Glide:Resetting page handler at 0x%x", base_addr);
783 + PAGING_UnlinkPages(base_addr>>12, GLIDE_PAGES);
786 + void SetLFBAddr(HostPt addr) {
787 + if(addr-base_addr != lfb_addr) {
788 + lfb_addr=addr-base_addr;
789 +#if LOG_GLIDE
790 + LOG_MSG("Glide:LFB addr set to 0x%x (0x%x), clear TLB", lfb_addr, addr);
791 +#endif
792 + PAGING_UnlinkPages(base_addr>>12, GLIDE_PAGES);
796 + PhysPt GetPhysPt(void) {
797 + return base_addr;
800 + Bitu readb(PhysPt addr) {
801 +// LOG_MSG("Glide:Read from 0x%p", lfb_addr+addr);
802 + return *(Bit8u *)(lfb_addr+addr);
805 + Bitu readw(PhysPt addr) {
806 +// LOG_MSG("Glide:Read from 0x%p", lfb_addr+addr);
807 + return *(Bit16u *)(lfb_addr+addr);
810 + Bitu readd(PhysPt addr) {
811 +// LOG_MSG("Glide:Read from 0x%p", lfb_addr+addr);
812 + return *(Bit32u *)(lfb_addr+addr);
815 + void writeb(PhysPt addr,Bitu val) {
816 +// LOG_MSG("Glide:Write to 0x%p", lfb_addr+addr);
817 + *(Bit8u *)(lfb_addr+addr)=(Bit8u)val;
820 + void writew(PhysPt addr,Bitu val) {
821 +// LOG_MSG("Glide:Write to 0x%p", lfb_addr+addr);
822 + *(Bit16u *)(lfb_addr+addr)=(Bit16u)val;
825 + void writed(PhysPt addr,Bitu val) {
826 +// LOG_MSG("Glide:Write to 0x%p", lfb_addr+addr);
827 + *(Bit32u *)(lfb_addr+addr)=(Bit32u)val;
830 + HostPt GetHostReadPt(Bitu phys_page) {
831 +// LOG_MSG("Glide:GetHostReadPt called with %d, returning 0x%x", phys_page, lfb_addr+(phys_page*MEM_PAGESIZE));
832 + return lfb_addr+(phys_page*MEM_PAGESIZE);
835 + HostPt GetHostWritePt(Bitu phys_page) {
836 +// LOG_MSG("Glide:GetHostWritePt called with %d, returning 0x%x", phys_page, lfb_addr+(phys_page*MEM_PAGESIZE));
837 + return lfb_addr+(phys_page*MEM_PAGESIZE);
842 +class GLIDE: public Module_base {
843 +private:
844 + AutoexecObject autoexecline;
845 + // Glide port
846 + Bitu glide_base;
847 + Bit8u *ovl_data;
848 +public:
849 + GLIDE(Section* configuration):Module_base(configuration),glide_base(0),ovl_data(NULL) {
850 + Section_prop * section=static_cast<Section_prop *>(configuration);
852 + if(!section->Get_bool("glide")) return;
853 + std::string str = section->Get_string("lfb");
854 + lowcase(str);
855 + if(str == "none") {
856 + LOG_MSG("Glide:Disabled LFB access");
857 + lfbacc=0;
858 + } else if(str == "read") {
859 + LOG_MSG("Glide:LFB access: read-only");
860 + lfbacc=1;
861 + } else if(str == "write") {
862 + LOG_MSG("Glide:LFB access: write-only");
863 + lfbacc=2;
864 + } else {
865 + LOG_MSG("Glide:LFB access: read-write");
866 + lfbacc=3;
869 + // load glide2x.ovl if possible
870 + FILE * ovl = fopen("glide2x.ovl", "rb");
871 + long ovl_size;
873 + if(ovl != NULL) {
874 + fseek(ovl, 0, SEEK_END);
875 + ovl_size=ftell(ovl);
876 + ovl_data=(Bit8u*)malloc(ovl_size);
877 + fseek(ovl, 0, SEEK_SET);
878 + fread(ovl_data, sizeof(char), ovl_size, ovl);
879 + fclose(ovl);
882 + // load glide2x.dll
883 +#if defined(WIN32)
884 + hdll = LoadLibrary("glide2x.dll");
885 +#elif defined(MACOSX)
886 + hdll = dlopen("libglide2x.dylib", RTLD_NOW);
887 +#else
888 + hdll = dlopen("libglide2x.so", RTLD_NOW);
889 +#endif
891 + if(!hdll) {
892 + LOG_MSG("Glide:Unable to load glide2x library, glide emulation disabled");
893 + return;
896 +#if LOG_GLIDE
897 + SDL_memset(GLIDE_count, 0, sizeof(GLIDE_count));
898 +#endif
900 + // Allocate some temporary space
901 + texmem = (void*)malloc(1024*768*2);
902 + if(texmem == NULL) {
903 + LOG_MSG("Glide:Unable to allocate texture memory, glide disabled");
904 + return;
907 + // Allocate memory for dll pointers
908 + fn_pt = (void**)malloc(sizeof(void*)*(GLIDE_MAX+1));
909 + if(fn_pt == NULL) {
910 + LOG_MSG("Glide:Unable to allocate memory, glide disabled");
911 + free(texmem); texmem = NULL;
912 + return;
914 + for(int i=0; i<(GLIDE_MAX+1); i++) {
915 +#if defined(WIN32)
916 + ostringstream temp;
917 + temp << "_" << grTable[i].name << "@" << (Bitu)grTable[i].parms;
918 + fn_pt[i] = (void*)(GetProcAddress(hdll, temp.str().c_str()));
919 +#else
920 + fn_pt[i] = (void*)(dlsym(hdll, grTable[i].name));
921 +#endif
922 +#if LOG_GLIDE
923 + if(fn_pt[i] == NULL) {
924 + LOG_MSG("Glide:Warning, unable to load %s from glide2x", grTable[i].name);
926 +#endif
929 + glide.lfb_pagehandler = new GLIDE_PageHandler((HostPt)texmem);
930 + glide_base=section->Get_hex("grport");
932 + IO_RegisterReadHandler(glide_base,read_gl,IO_MB);
933 + IO_RegisterWriteHandler(glide_base,write_gl,IO_MB);
935 + ostringstream temp;
936 + temp << "SET GLIDE=" << hex << glide_base << ends;
938 + autoexecline.Install(temp.str());
939 + glide.splash = true;
941 +#if defined (WIN32)
942 + // Get hwnd information
943 + SDL_SysWMinfo wmi;
944 + SDL_VERSION(&wmi.version);
945 + if(SDL_GetWMInfo(&wmi)) {
946 + hwnd = (HostPt)wmi.window;
947 + } else {
948 + LOG_MSG("SDL:Error retrieving window information");
950 +#endif
952 + if(ovl_data)
953 + VFILE_Register("GLIDE2X.OVL", ovl_data, ovl_size);
956 + ~GLIDE() {
957 + if(glide.enabled) {
958 + // void grGlideShutdown(void)
959 + FP.grFunction0 = (pfunc0)fn_pt[_grGlideShutdown0];
960 + if(FP.grFunction0) FP.grFunction0();
961 + glide.enabled = false;
964 + SAFE_DELETE(glide.lfb_pagehandler);
965 + if(fn_pt)
966 + free(fn_pt); fn_pt = NULL;
967 + if(texmem)
968 + free(texmem); texmem = NULL;
970 + if(glide_base) {
971 + IO_FreeReadHandler(glide_base,IO_MB);
972 + IO_FreeWriteHandler(glide_base,IO_MB);
975 + if(hdll) {
976 +#if defined (WIN32)
977 + FreeLibrary(hdll);
978 +#else
979 + dlclose(hdll);
980 +#endif
981 + hdll = NULL;
984 + VFILE_Remove("GLIDE2X.OVL");
985 + if(ovl_data) free(ovl_data);
989 +static GLIDE* test;
990 +void GLIDE_ShutDown(Section* sec) {
991 + delete test;
994 +void GLIDE_Init(Section* sec) {
995 + test = new GLIDE(sec);
996 + sec->AddDestroyFunction(&GLIDE_ShutDown,true);
999 +void GLIDE_ResetScreen(bool update)
1001 +#if LOG_GLIDE
1002 + LOG_MSG("Glide:ResetScreen");
1003 +#endif
1004 + VGA_KillDrawing();
1005 + GFX_Stop();
1007 + // OpenGlide will resize the window on it's own (using SDL)
1008 + if(
1009 +#ifdef WIN32
1010 + // dgVoodoo needs a little help :)
1011 + // Most other wrappers render fullscreen by default
1012 + (GetProcAddress(hdll, "DispatchDosNT") != NULL) ||
1013 +#endif
1014 + // and resize when mapper and/or GUI finish
1015 + update) {
1016 + SDL_SetVideoMode(glide.width,glide.height,0,
1017 + (glide.fullscreen[0]?SDL_FULLSCREEN:0)|SDL_ANYFORMAT|SDL_SWSURFACE);
1021 +static bool GetFileName(char * filename)
1023 + localDrive *ldp;
1024 + Bit8u drive;
1025 + char fullname[DOS_PATHLENGTH];
1027 + // Get full path
1028 + if(!DOS_MakeName(filename,fullname,&drive)) return false;
1030 +#if LOG_GLIDE
1031 + LOG_MSG("Glide:Fullname: %s", fullname);
1032 +#endif
1034 + // Get real system path
1035 + ldp = dynamic_cast<localDrive*>(Drives[drive]);
1036 + if(ldp == NULL) return false;
1038 + ldp->GetSystemFilename(filename,fullname);
1039 +#if LOG_GLIDE
1040 + LOG_MSG("Glide:System path: %s", filename);
1041 +#endif
1042 + return true;
1045 +typedef FxBool (FX_CALL *pfxSplashInit)(FxU32 hWnd, FxU32 screenWidth, FxU32 screenHeight,
1046 + FxU32 numColBuf, FxU32 numAuxBuf, GrColorFormat_t colorFormat);
1047 +typedef void (FX_CALL *pfxSplash)(float x, float y, float w, float h, FxU32 frameNumber);
1049 +static void grSplash(void)
1051 +#ifdef WIN32
1052 + HINSTANCE dll = LoadLibrary("3dfxSpl2.dll");
1053 + if(dll == NULL) {
1054 + return;
1057 + pfxSplashInit fxSplashInit = (pfxSplashInit)GetProcAddress(dll, "_fxSplashInit@24");
1058 + pfxSplash fxSplash = (pfxSplash)GetProcAddress(dll, "_fxSplash@20");
1060 + if((fxSplashInit == NULL) || (fxSplash == NULL)) {
1061 + FreeLibrary(dll);
1062 + return;
1065 + fxSplashInit(0, glide.width, glide.height, 2, 1, GR_COLORFORMAT_ABGR);
1066 + fxSplash(0, 0, glide.width, glide.height, 0);
1068 + // Openglide does not restore this state
1069 + FP.grFunction1i = (pfunc1i)fn_pt[_grSstOrigin4];
1070 + if(FP.grFunction1i) {
1071 + FP.grFunction1i(GrOriginLocation);
1074 + FreeLibrary(dll);
1075 +#endif
1078 +static void process_msg(Bitu value)
1080 + GrLfbInfo_t lfbinfo;
1081 + DBGrLfbInfo_t dblfbinfo;
1083 + GrTexInfo texinfo;
1084 + DBGrTexInfo dbtexinfo;
1086 + Gu3dfInfo guinfo;
1087 + DBGu3dfInfo dbguinfo;
1089 + GrVertex vertex[3];
1091 + GrMipMapInfo * mipmap;
1093 + // Temporary memory used in functions
1094 + FxI32 * ilist = (FxI32*)texmem;
1095 + FxU16 * ptr16 = (FxU16*)texmem;
1097 + // Filename translation
1098 + char filename[512];
1100 + // Return value address
1101 + ret = param[0];
1102 + Bitu i = value;
1103 + FxU32 j, k;
1105 + if((i > GLIDE_MAX) || (fn_pt[i] == NULL)) {
1106 + LOG_MSG("Glide:Invalid function pointer for call %s", (i > GLIDE_MAX) ? "(invalid)" : grTable[i].name);
1107 + return;
1110 +#if LOG_GLIDE
1111 + LOG_MSG("Glide:Processing call %s (%d), return address: 0x%x", grTable[i].name, value, ret);
1112 + GLIDE_count[i]++;
1113 +#endif
1115 + switch (value) {
1117 + case _grAADrawLine8:
1118 + // void grAADrawLine(GrVertex *va, GrVertex *vb)
1119 + FP.grFunction2p = (pfunc2p)fn_pt[i];
1120 + MEM_BlockRead32(param[1], &vertex[0], sizeof(GrVertex));
1121 + MEM_BlockRead32(param[2], &vertex[1], sizeof(GrVertex));
1122 + FP.grFunction2p(&vertex[0], &vertex[1]);
1123 + break;
1124 + case _grAADrawPoint4:
1125 + // void grAADrawPoint(GrVertex *p)
1126 + FP.grFunction1p = (pfunc1p)fn_pt[i];
1127 + MEM_BlockRead32(param[1], &vertex[0], sizeof(GrVertex));
1128 + FP.grFunction1p(&vertex[0]);
1129 + break;
1130 + case _grAADrawPolygon12:
1131 + // void grAADrawPolygon(int nVerts, const int ilist[], const GrVertex vlist[])
1132 + FP.grFunction1i2p = (pfunc1i2p)fn_pt[i];
1133 + i = sizeof(FxI32)*param[1];
1134 + MEM_BlockRead32(param[2], ilist, i);
1136 + // Find the number of vertices (?)
1137 + k = 0;
1138 + for(j = 0; j < param[1]; j++) {
1139 + if(ilist[j] > k)
1140 + k = ilist[j];
1143 + MEM_BlockRead32(param[3], ilist+i, sizeof(GrVertex)*k);
1144 + FP.grFunction1i2p(param[1], ilist, ilist+i);
1145 + break;
1146 + case _grAADrawPolygonVertexList8:
1147 + // void grAADrawPolygonVertexList(int nVerts, const GrVertex vlist[])
1148 + FP.grFunction1i1p = (pfunc1i1p)fn_pt[i];
1149 + MEM_BlockRead32(param[2], texmem, sizeof(GrVertex)*param[1]);
1150 + FP.grFunction1i1p(param[1], texmem);
1151 + break;
1152 + case _grAADrawTriangle24:
1153 + // void grAADrawTriangle(GrVertex *a, GrVertex *b, GrVertex *c,
1154 + // FxBool antialiasAB, FxBool antialiasBC, FxBool antialiasCA)
1155 + FP.grFunction3p3i = (pfunc3p3i)fn_pt[i];
1156 + MEM_BlockRead32(param[1], &vertex[0], sizeof(GrVertex));
1157 + MEM_BlockRead32(param[2], &vertex[1], sizeof(GrVertex));
1158 + MEM_BlockRead32(param[3], &vertex[2], sizeof(GrVertex));
1159 + FP.grFunction3p3i(&vertex[0], &vertex[1], &vertex[2], param[4], param[5], param[6]);
1160 + break;
1161 + case _grAlphaBlendFunction16:
1162 + // void grAlphaBlendFunction(GrAlphaBlendFnc_t rgb_sf, GrAlphaBlendFnc_t rgb_df,
1163 + // GrAlphaBlendFnc_t alpha_sf, GrAlphaBlendFnc_t alpha_df)
1164 + if(tomb == 1) {
1165 + if((FP.grFunction1i = (pfunc1i)fn_pt[_grConstantColorValue4]))
1166 + FP.grFunction1i(0x7f000000);
1167 + } else if(tomb == 2) {
1168 + param[5] = 0x42fe0000;
1169 + param[6] = 0;
1170 + if((FP.grFunction4f = (pfunc4f)fn_pt[_grConstantColorValue416]))
1171 + FP.grFunction4f(F(param[5]), F(param[6]), F(param[6]), F(param[6]));
1173 + FP.grFunction4i = (pfunc4i)fn_pt[i];
1174 + FP.grFunction4i(param[1], param[2], param[3], param[4]);
1175 + break;
1176 + case _grAlphaCombine20:
1177 + // void grAlphaCombine(GrCombineFunction_t func, GrCombineFactor_t factor,
1178 + // GrCombineLocal_t local, GrCombineOther_t other, FxBool invert)
1179 + FP.grFunction5i = (pfunc5i)fn_pt[i];
1180 + FP.grFunction5i(param[1], param[2], param[3], param[4], param[5]);
1181 + break;
1182 + case _grAlphaControlsITRGBLighting4:
1183 + // void grAlphaControlsITRGBLighting(FxBool enable)
1184 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1185 + FP.grFunction1i(param[1]);
1186 + break;
1187 + case _grAlphaTestFunction4:
1188 + // void grAlphaTestFunction(GrCmpFnc_t function)
1189 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1190 + FP.grFunction1i(param[1]);
1191 + break;
1192 + case _grAlphaTestReferenceValue4:
1193 + // void grAlphaTestReferenceValue(GrAlpha_t value)
1194 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1195 + FP.grFunction1i(param[1]);
1196 + break;
1197 + case _grBufferClear12:
1198 + // void grBufferClear(GrColor_t color, GrAlpha_t alpha, FxU16 depth)
1199 + FP.grFunction3i = (pfunc3i)fn_pt[i];
1200 + FP.grFunction3i(param[1], param[2], param[3]);
1201 + break;
1202 + case _grBufferNumPending0:
1203 + // int grBufferNumPending(void)
1204 + FP.grRFunction0 = (prfunc0)fn_pt[i];
1205 + if(ret == 0) {
1206 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
1207 + return;
1209 + mem_writed(ret, FP.grRFunction0());
1210 + ret_value = G_OK;
1211 + break;
1212 + case _grBufferSwap4:
1213 + // void grBufferSwap(int swap_interval)
1214 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1215 + FP.grFunction1i(param[1]);
1216 + break;
1217 + case _grCheckForRoom4:
1218 + // void grCheckForRoom(FxI32 n)
1219 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1220 + FP.grFunction1i(param[1]);
1221 + break;
1222 + case _grChromakeyMode4:
1223 + // void grChromakeyMode(GrChromakeyMode_t mode)
1224 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1225 + FP.grFunction1i(param[1]);
1226 + break;
1227 + case _grChromakeyValue4:
1228 + // void grChromakeyValue(GrColor_t value)
1229 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1230 + FP.grFunction1i(param[1]);
1231 + break;
1232 + case _grClipWindow16:
1233 + // void grClipWindow(FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy)
1234 + FP.grFunction4i = (pfunc4i)fn_pt[i];
1235 + FP.grFunction4i(param[1], param[2], param[3], param[4]);
1236 + break;
1237 + case _grColorCombine20:
1238 + // void grColorCombine(GrCombineFunction_t func, GrCombineFactor_t factor,
1239 + // GrCombineLocal_t local, GrCombineOther_t other, FxBool invert)
1240 + FP.grFunction5i = (pfunc5i)fn_pt[i];
1241 + FP.grFunction5i(param[1], param[2], param[3], param[4], param[5]);
1242 + break;
1243 + case _grColorMask8:
1244 + // void grColorMask(FxBool rgb, FxBool alpha)
1245 + FP.grFunction2i = (pfunc2i)fn_pt[i];
1246 + FP.grFunction2i(param[1], param[2]);
1247 + break;
1248 + case _grConstantColorValue416:
1249 + // void grConstantColorValue4(float a, float r, float g, float b)
1250 + FP.grFunction4f = (pfunc4f)fn_pt[i];
1251 + FP.grFunction4f(F(param[1]), F(param[2]), F(param[3]), F(param[4]));
1252 + break;
1253 + case _grConstantColorValue4:
1254 + // void grConstantColorValue(GrColor_t color)
1255 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1256 + FP.grFunction1i(param[1]);
1257 + break;
1258 + case _grCullMode4:
1259 + // void grCullMode(GrCullMode_t mode)
1260 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1261 + FP.grFunction1i(param[1]);
1262 + break;
1263 + case _grDepthBiasLevel4:
1264 + // void grDepthBiasLevel(FxI16 level)
1265 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1266 + FP.grFunction1i(param[1]);
1267 + break;
1268 + case _grDepthBufferFunction4:
1269 + // void grDepthBufferFunction(GrCmpFnc_t func)
1270 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1271 + FP.grFunction1i(param[1]);
1272 + break;
1273 + case _grDepthBufferMode4:
1274 + // void grDepthBufferMode(GrDepthBufferMode_t mode)
1275 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1276 + FP.grFunction1i(param[1]);
1277 + break;
1278 + case _grDepthMask4:
1279 + // void grDepthMask(FxBool enable)
1280 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1281 + FP.grFunction1i(param[1]);
1282 + break;
1283 + case _grDisableAllEffects0:
1284 + // void grDisableAllEffects(void)
1285 + FP.grFunction0 = (pfunc0)fn_pt[i];
1286 + FP.grFunction0();
1287 + break;
1288 + case _grDitherMode4:
1289 + // void grDitherMode(GrDitherMode_t mode)
1290 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1291 + FP.grFunction1i(param[1]);
1292 + break;
1293 + case _grDrawLine8:
1294 + // void grDrawLine(const GrVertex *a, const GrVertex *b)
1295 + FP.grFunction2p = (pfunc2p)fn_pt[i];
1296 + MEM_BlockRead32(param[1], &vertex[0], sizeof(GrVertex));
1297 + MEM_BlockRead32(param[2], &vertex[1], sizeof(GrVertex));
1298 + FP.grFunction2p(&vertex[0], &vertex[1]);
1299 + break;
1300 + case _grDrawPlanarPolygon12:
1301 + // void grDrawPlanarPolygon(int nVerts, int ilist[], const GrVertex vlist[])
1302 + FP.grFunction1i2p = (pfunc1i2p)fn_pt[i];
1303 + i = sizeof(FxI32)*param[1];
1304 + MEM_BlockRead32(param[2], ilist, i);
1306 + // Find the number of vertices (?)
1307 + k = 0;
1308 + for(j = 0; j < param[1]; j++) {
1309 + if(ilist[j] > k)
1310 + k = ilist[j];
1313 + MEM_BlockRead32(param[3], ilist+i, sizeof(GrVertex)*k);
1314 + FP.grFunction1i2p(param[1], ilist, ilist+i);
1315 + break;
1316 + case _grDrawPlanarPolygonVertexList8:
1317 + // void grDrawPlanarPolygonVertexList(int nVertices, const GrVertex vlist[])
1318 + FP.grFunction1i1p = (pfunc1i1p)fn_pt[i];
1319 + MEM_BlockRead32(param[2], texmem, sizeof(GrVertex)*param[1]);
1320 + FP.grFunction1i1p(param[1], texmem);
1321 + break;
1322 + case _grDrawPoint4:
1323 + // void grDrawPoint(const GrVertex *a)
1324 + FP.grFunction1p = (pfunc1p)fn_pt[i];
1325 + MEM_BlockRead32(param[1], &vertex[0], sizeof(GrVertex));
1326 + FP.grFunction1p(&vertex[0]);
1327 + break;
1328 + case _grDrawPolygon12:
1329 + // void grDrawPolygon(int nVerts, int ilist[], const GrVertex vlist[])
1330 + FP.grFunction1i2p = (pfunc1i2p)fn_pt[i];
1331 + i = sizeof(FxI32)*param[1];
1332 + MEM_BlockRead32(param[2], ilist, i);
1334 + // Find the number of vertices (?)
1335 + k = 0;
1336 + for(j = 0; j < param[1]; j++) {
1337 + if(ilist[j] > k)
1338 + k = ilist[j];
1341 + MEM_BlockRead32(param[3], ilist+i, sizeof(GrVertex)*k);
1342 + FP.grFunction1i2p(param[1], ilist, ilist+i);
1343 + break;
1344 + case _grDrawPolygonVertexList8:
1345 + // void grDrawPolygonVertexList(int nVerts, const GrVertex vlist[])
1346 + FP.grFunction1i1p = (pfunc1i1p)fn_pt[i];
1347 + MEM_BlockRead32(param[2], texmem, sizeof(GrVertex)*param[1]);
1348 + FP.grFunction1i1p(param[1], texmem);
1349 + break;
1350 + case _grDrawTriangle12:
1351 + // void grDrawTriangle(const GrVertex *a, const GrVertex *b, const GrVertex *c)
1352 + FP.grFunction3p = (pfunc3p)fn_pt[i];
1353 + MEM_BlockRead32(param[1], &vertex[0], sizeof(GrVertex));
1354 + MEM_BlockRead32(param[2], &vertex[1], sizeof(GrVertex));
1355 + MEM_BlockRead32(param[3], &vertex[2], sizeof(GrVertex));
1356 + FP.grFunction3p(&vertex[0], &vertex[1], &vertex[2]);
1357 + break;
1359 + case _grErrorSetCallback4:
1360 + // void grErrorSetCallback(void (*function)(const char *string, FxBool fatal))
1361 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1362 + FP.grFunction1i(*param[1]);
1363 + break;
1365 + case _grFogColorValue4:
1366 + // void grFogColorValue(GrColor_t value)
1367 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1368 + FP.grFunction1i(param[1]);
1369 + break;
1370 + case _grFogMode4:
1371 + // void grFogMode(GrFogMode_t mode)
1372 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1373 + FP.grFunction1i(param[1]);
1374 + break;
1375 + case _grFogTable4:
1376 + // void grFogTable(const GrFog_t grTable[GR_FOG_TABLE_SIZE])
1377 + FP.grFunction1p = (pfunc1p)fn_pt[i];
1378 + MEM_BlockRead32(param[1], texmem, sizeof(GrFog_t)*GR_FOG_TABLE_SIZE);
1379 + FP.grFunction1p(texmem);
1380 + break;
1381 + case _grGammaCorrectionValue4:
1382 + // void grGammaCorrectionValue(float value)
1383 + FP.grFunction1f = (pfunc1f)fn_pt[i];
1384 + FP.grFunction1f(F(param[1]));
1385 + break;
1386 + case _grGlideGetState4:
1387 + // void grGlideGetState(GrState *state)
1388 + FP.grFunction1p = (pfunc1p)fn_pt[i];
1389 + MEM_BlockRead32(param[1], texmem, sizeof(GrState));
1390 + FP.grFunction1p(texmem);
1391 + MEM_BlockWrite32(param[1], texmem, sizeof(GrState));
1392 + break;
1393 + case _grGlideGetVersion4:
1394 + // void grGlideGetVersion(char version[80])
1395 + FP.grFunction1p = (pfunc1p)fn_pt[i];
1396 + FP.grFunction1p(filename);
1397 + k = 0;
1398 + do {
1399 + mem_writeb(param[1]++, filename[k++]);
1400 + } while(filename[k] != '\0');
1401 + mem_writeb(param[1], '\0');
1402 + break;
1403 + case _grGlideInit0:
1404 + // void grGlideInit(void)
1405 + FP.grFunction0 = (pfunc0)fn_pt[i];
1406 + FP.grFunction0();
1407 + if(!strncasecmp(RunningProgram, "Tombub", 6)) tomb = 2;
1408 + else if(!strncasecmp(RunningProgram, "Tomb", 4)) tomb = 1;
1409 + else tomb = 0;
1411 + // Set LFB pointer
1412 + if(mem_readd(param[1]) == 0xFFFFFFFF) { // Find LFB magic
1413 + mem_writed(param[1], glide.lfb_pagehandler->GetPhysPt());
1414 + } else {
1415 + LOG_MSG("Glide:Detected incompatible guest ovl/dll!");
1417 + break;
1418 + case _grGlideSetState4:
1419 + // void grGlideSetState(const GrState *state)
1420 + FP.grFunction1p = (pfunc1p)fn_pt[i];
1421 + MEM_BlockRead32(param[1], texmem, sizeof(GrState));
1422 + FP.grFunction1p(texmem);
1423 + MEM_BlockWrite32(param[1], texmem, sizeof(GrState));
1424 + break;
1425 + case _grGlideShamelessPlug4:
1426 + // void grGlideShamelessPlug(const FxBool on)
1427 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1428 + FP.grFunction1i(param[1]);
1429 + break;
1430 + case _grGlideShutdown0:
1431 + // void grGlideShutdown(void)
1432 + if(glide.enabled) {
1433 + FP.grFunction0 = (pfunc0)fn_pt[_grSstWinClose0];
1434 + FP.grFunction0();
1435 + glide.enabled = false;
1436 + GFX_ResetScreen();
1438 + FP.grFunction0 = (pfunc0)fn_pt[i];
1439 + FP.grFunction0();
1440 + glide.splash = true;
1442 +#if LOG_GLIDE
1443 + for(j=0;j<(GLIDE_MAX+1);j++) {
1444 + if(GLIDE_count[j]) {
1445 + LOG_MSG("Glide:%6d calls function %s (%d)", GLIDE_count[j], grTable[j].name, j);
1448 + LOG_MSG("Glide: %d framebuffer locks (%d read, %d write)", GLIDE_count[_grLfbLock24],
1449 + GLIDE_count[GLIDE_MAX+1], GLIDE_count[_grLfbLock24] - GLIDE_count[GLIDE_MAX+1]);
1450 + SDL_memset(GLIDE_count, 0, sizeof(GLIDE_count));
1451 +#endif
1452 + break;
1453 + case _grHints8:
1454 + // void grHints(GrHints_t type, FxU32 hintMask)
1455 + FP.grFunction2i = (pfunc2i)fn_pt[i];
1456 + FP.grFunction2i(param[1], param[2]);
1457 + break;
1458 + case _grLfbConstantAlpha4:
1459 + // void grLfbConstantAlpha(GrAlpha_t alpha)
1460 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1461 + FP.grFunction1i(param[1]);
1462 + break;
1463 + case _grLfbConstantDepth4:
1464 + // void grLfbConstantDepth(FxU16 depth)
1465 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1466 + FP.grFunction1i(param[1]);
1467 + break;
1468 + case _grLfbLock24:
1469 + // FxBool grLfbLock(GrLock_t type, GrBuffer_t buffer, GrLfbWriteMode_t writeMode,
1470 + // GrOriginLocation_t origin, FxBool pixelPipeline, GrLfbInfo_t *info)
1471 + FP.grRFunction5i1p = (prfunc5i1p)fn_pt[i];
1472 + if(ret == 0) {
1473 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
1474 + return;
1477 + // Read parameters
1478 + MEM_BlockRead32(param[6], &dblfbinfo, sizeof(DBGrLfbInfo_t));
1479 + lfbinfo.size = sizeof(GrLfbInfo_t);
1480 + lfbinfo.origin = dblfbinfo.origin;
1481 + lfbinfo.lfbPtr = texmem;
1483 + k = FXTRUE;
1484 + j = param[1]&1; j++;
1486 + if(glide.lfb_pagehandler) {
1488 + if(j&lfbacc) {
1489 + // Lock the buffer
1490 + k = FP.grRFunction5i1p(param[1], param[2], param[3], param[4], param[5], &lfbinfo);
1491 + if(k == FXTRUE) {
1492 + glide.lfb_pagehandler->locked++;
1493 + dblfbinfo.writeMode = lfbinfo.writeMode;
1494 + dblfbinfo.strideInBytes = lfbinfo.strideInBytes;
1495 + dblfbinfo.lfbPtr = glide.lfb_pagehandler->GetPhysPt();
1496 + MEM_BlockWrite32(param[6], &dblfbinfo, sizeof(DBGrLfbInfo_t));
1497 + } else {
1498 + LOG_MSG("Glide:LFB Lock failed!");
1500 + } // else lock is faked (texmem used for read/write)
1502 + // Set LFB address for page handler
1503 + glide.lfb_pagehandler->SetLFBAddr((HostPt)lfbinfo.lfbPtr);
1505 + if(j == 1) {// Is a read-only lock
1506 +#if LOG_GLIDE
1507 + LOG_MSG("Glide:Read-only lock. Real LFB is at 0x%p.", lfbinfo.lfbPtr);
1508 + GLIDE_count[GLIDE_MAX+1]++;
1509 +#endif
1510 + } else { // Is a write-only lock
1511 +#if LOG_GLIDE
1512 + LOG_MSG("Glide:Write-only lock. Real LFB is at 0x%p.", lfbinfo.lfbPtr);
1513 +#endif
1515 + } else { // Fail
1516 + LOG_MSG("Glide:Failed to install page handler!");
1517 + k = FXFALSE;
1520 + mem_writed(ret, k);
1521 + ret_value = G_OK;
1522 + break;
1523 + case _grLfbReadRegion28:
1524 + // FxBool grLfbReadRegion(GrBuffer_t src_buffer, FxU32 src_x, FxU32 src_y, FxU32 src_width,
1525 + // FxU32 src_height, FxU32 dst_stride, void *dst_data)
1526 + FP.grRFunction6i1p = (prfunc6i1p)fn_pt[i];
1527 + if(ret == 0) {
1528 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
1529 + return;
1531 + mem_writed(ret, FP.grRFunction6i1p(param[1], param[2], param[3], param[4], param[5], param[6], ptr16));
1532 + for(k = 0; k < param[5]; k++) {
1533 + // 16-bit data always
1534 + MEM_BlockWrite(param[7]+((k*param[6])<<1), ptr16+(k*param[6]), param[4]<<1);
1536 + ret_value = G_OK;
1537 + break;
1538 + case _grLfbUnlock8:
1539 + // FxBool grLfbUnlock(GrLock_t type, GrBuffer_t buffer)
1540 + FP.grRFunction2i = (prfunc2i)fn_pt[i];
1541 + if(ret == 0) {
1542 + LOG_MSG("Glide:Invalid return value handle (%d)!", _grLfbUnlock8);
1543 + return;
1545 + k = FXTRUE;
1546 + if(glide.lfb_pagehandler && glide.lfb_pagehandler->locked) {
1547 + k = FP.grRFunction2i(param[1], param[2]);
1548 + glide.lfb_pagehandler->locked--;
1550 + mem_writed(ret, k);
1551 + ret_value = G_OK;
1552 + break;
1553 + case _grLfbWriteColorFormat4:
1554 + // void grLfbWriteColorFormat(GrColorFormat_t colorFormat)
1555 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1556 + FP.grFunction1i(param[1]);
1557 + break;
1558 + case _grLfbWriteColorSwizzle8:
1559 + // void grLfbWriteColorSwizzle(FxBool swizzleBytes, FxBool swapWords)
1560 + FP.grFunction2i = (pfunc2i)fn_pt[i];
1561 + FP.grFunction2i(param[1], param[2]);
1562 + break;
1563 + case _grLfbWriteRegion32:
1564 + // FxBool grLfbWriteRegion(GrBuffer_t dst_buffer, FxU32 dst_x, FxU32 dst_y,
1565 + // GrLfbSrcFmt_t src_format, FxU32 src_width, FxU32 src_height, FxU32 src_stride, void *src_data)
1566 + FP.grRFunction7i1p = (prfunc7i1p)fn_pt[i];
1567 + if(ret == 0) {
1568 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
1569 + return;
1572 + switch(param[4]) {
1573 + case GR_LFB_SRC_FMT_565:
1574 + case GR_LFB_SRC_FMT_555:
1575 + case GR_LFB_SRC_FMT_1555:
1576 + for(k = 0; k < param[6]; k++) {
1577 + MEM_BlockRead(param[8]+((k*param[7])<<1), ptr16+(k*param[7]), param[5]<<1);
1579 + break;
1580 + case GR_LFB_SRC_FMT_888:
1581 + case GR_LFB_SRC_FMT_8888:
1582 + case GR_LFB_SRC_FMT_565_DEPTH:
1583 + case GR_LFB_SRC_FMT_555_DEPTH:
1584 + case GR_LFB_SRC_FMT_1555_DEPTH:
1585 + case GR_LFB_SRC_FMT_ZA16:
1586 + case GR_LFB_SRC_FMT_RLE16:
1587 + for(k = 0; k < param[6]; k++) {
1588 + MEM_BlockRead(param[8]+((k*param[7])<<2), ptr16+((k*param[7])<<1), param[5]<<2);
1590 + break;
1591 + default:
1592 + LOG_MSG("Glide:Unknown color format passed to %s!", grTable[i].name);
1593 + return;
1594 + break;
1597 + mem_writed(ret, FP.grRFunction7i1p(param[1], param[2], param[3], param[4], param[5], param[6], param[7], ptr16));
1598 + ret_value = G_OK;
1599 + break;
1600 + case _grRenderBuffer4:
1601 + // void grRenderBuffer(GrBuffer_t buffer)
1602 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1603 + FP.grFunction1i(param[1]);
1604 + break;
1605 + case _grResetTriStats0:
1606 + // void grResetTriStats()
1607 + FP.grFunction0 = (pfunc0)fn_pt[i];
1608 + FP.grFunction0();
1609 + break;
1610 + case _grSplash20:
1611 + // void grSplash(float x, float y, float width, float height, FxU32 frame)
1612 + FP.grFunction4f1i = (pfunc4f1i)fn_pt[i];
1613 + FP.grFunction4f1i(F(param[1]), F(param[2]), F(param[3]), F(param[4]), param[5]);
1614 + break;
1616 + case _grSstConfigPipeline12:
1617 + //
1618 + FP.grFunction3i = (pfunc3i)fn_pt[i];
1619 + FP.grFunction3i();
1620 + break;
1622 + case _grSstControl4:
1623 + // FxBool grSstControl(FxU32 code)
1624 + FP.grRFunction1i = (prfunc1i)fn_pt[i];
1625 + if(ret == 0) {
1626 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
1627 + return;
1629 + mem_writed(ret, FP.grRFunction1i(param[1]));
1630 + ret_value = G_OK;
1631 + break;
1632 + case _grSstIdle0:
1633 + // void grSstIdle(void)
1634 + FP.grFunction0 = (pfunc0)fn_pt[i];
1635 + FP.grFunction0();
1636 + break;
1637 + case _grSstIsBusy0:
1638 + // FxBool grSstIsBusy(void)
1639 + FP.grRFunction0 = (prfunc0)fn_pt[i];
1640 + if(ret == 0) {
1641 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
1642 + return;
1644 + mem_writed(ret, FP.grRFunction0());
1645 + ret_value = G_OK;
1646 + break;
1647 + case _grSstOrigin4:
1648 + // void grSstOrigin(GrOriginLocation_t origin)
1649 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1650 + FP.grFunction1i(param[1]);
1651 + GrOriginLocation = param[1];
1652 + break;
1653 + case _grSstPerfStats4:
1654 + // void grSstPerfStats(GrSstPerfStats_t *pStats)
1655 + FP.grFunction1p = (pfunc1p)fn_pt[i];
1656 + MEM_BlockRead32(param[1], texmem, sizeof(GrSstPerfStats_t));
1657 + FP.grFunction1p(texmem);
1658 + break;
1659 + case _grSstQueryBoards4:
1660 + // FxBool grSstQueryBoards(GrHwConfiguration *hwConfig)
1661 + FP.grRFunction1p = (prfunc1p)fn_pt[i];
1662 + MEM_BlockRead32(param[1], texmem, sizeof(GrHwConfiguration));
1663 + if(ret == 0) {
1664 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
1665 + return;
1667 + mem_writed(ret, FP.grRFunction1p(texmem));
1668 + MEM_BlockWrite32(param[1], texmem, sizeof(GrHwConfiguration));
1669 + ret_value = G_OK;
1670 + break;
1671 + case _grSstQueryHardware4:
1672 + // FxBool grSstQueryHardware(GrHwConfiguration *hwConfig)
1673 + FP.grRFunction1p = (prfunc1p)fn_pt[i];
1674 + MEM_BlockRead32(param[1], texmem, sizeof(GrHwConfiguration));
1675 + if(ret == 0) {
1676 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
1677 + return;
1679 + mem_writed(ret, FP.grRFunction1p(texmem));
1680 + MEM_BlockWrite32(param[1], texmem, sizeof(GrHwConfiguration));
1681 + ret_value = G_OK;
1682 + break;
1683 + case _grSstResetPerfStats0:
1684 + // void grSstResetPerfStats(void)
1685 + FP.grFunction0 = (pfunc0)fn_pt[i];
1686 + FP.grFunction0();
1687 + break;
1688 + case _grSstScreenHeight0:
1689 + // FxU32 grSstScreenHeight(void)
1690 + FP.grRFunction0 = (prfunc0)fn_pt[i];
1691 + if(ret == 0) {
1692 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
1693 + return;
1695 + mem_writed(ret, FP.grRFunction0());
1696 + ret_value = G_OK;
1697 + break;
1698 + case _grSstScreenWidth0:
1699 + // FxU32 grSstScreenWidth(void)
1700 + FP.grRFunction0 = (prfunc0)fn_pt[i];
1701 + if(ret == 0) {
1702 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
1703 + return;
1705 + mem_writed(ret, FP.grRFunction0());
1706 + ret_value = G_OK;
1707 + break;
1708 + case _grSstSelect4:
1709 + // void grSstSelect(int which_sst)
1710 + FP.grFunction1i = (pfunc1i)fn_pt[i];
1711 + FP.grFunction1i(param[1]);
1712 + break;
1713 + case _grSstStatus0:
1714 + // FxU32 grSstStatus(void)
1715 + FP.grRFunction0 = (prfunc0)fn_pt[i];
1716 + if(ret == 0) {
1717 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
1718 + return;
1720 + mem_writed(ret, FP.grRFunction0());
1721 + ret_value = G_OK;
1722 + break;
1723 + case _grSstVRetraceOn0:
1724 + // FxBool grSstVRetraceOn(void)
1725 + FP.grRFunction0 = (prfunc0)fn_pt[i];
1726 + if(ret == 0) {
1727 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
1728 + return;
1730 + mem_writed(ret, FP.grRFunction0());
1731 + ret_value = G_OK;
1732 + break;
1734 + case _grSstVidMode8:
1735 + //
1736 + FP.grFunction2i = (pfunc2i)fn_pt[i];
1737 + FP.grFunction2i();
1738 + break;
1740 + case _grSstVideoLine0:
1741 + // FxU32 grSstVideoLine(void)
1742 + FP.grRFunction0 = (prfunc0)fn_pt[i];
1743 + if(ret == 0) {
1744 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
1745 + return;
1747 + mem_writed(ret, FP.grRFunction0());
1748 + ret_value = G_OK;
1749 + break;
1750 + case _grSstWinClose0:
1751 + // void grSstWinClose(void)
1752 + FP.grFunction0 = (pfunc0)fn_pt[i];
1753 + FP.grFunction0();
1754 + if(glide.enabled) {
1755 + glide.enabled = false;
1756 + GFX_ResetScreen();
1758 + break;
1759 + case _grSstWinOpen28:
1760 + // FxBool grSstWinOpen(FxU32 hwnd, GrScreenResolution_t res, GrScreenRefresh_t ref,
1761 + // GrColorFormat_t cformat, GrOriginLocation_t org_loc, int num_buffers, int num_aux_buffers)
1762 + FP.grRFunction1p6i = (prfunc1p6i)fn_pt[i];
1763 + if(ret == 0) {
1764 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
1765 + return;
1768 + if(glide.enabled) {
1769 + LOG_MSG("Glide:grSstWinOpen called when glide is active!");
1770 + mem_writed(ret, FXFALSE);
1771 + ret_value = G_OK;
1772 + break;
1775 + // Check for successful memory map
1776 + if(mem_readd(param[10]) == 0) {
1777 + LOG_MSG("Glide:LFB memory map failed, using default LFB address!");
1778 + // Write physical address instead, it can crash but it just might work
1779 + mem_writed(param[10], glide.lfb_pagehandler->GetPhysPt());
1782 + glide.enabled = true;
1783 + glide.width = param[8];
1784 + glide.height = param[9];
1785 + GrOriginLocation = param[5];
1787 + // Resize window and disable updates
1788 + GLIDE_ResetScreen();
1790 + k = FP.grRFunction1p6i(hwnd, param[2], param[3], param[4], param[5], param[6], param[7]);
1791 + if(k == FXFALSE) {
1792 + LOG_MSG("Glide:grSstWinOpen failed!");
1793 + glide.enabled = false;
1794 + GFX_ResetScreen();
1795 + mem_writed(ret, FXFALSE);
1796 + ret_value = G_OK;
1797 + break;
1800 + mem_writed(ret, k);
1801 + if(glide.splash) {
1802 + grSplash();
1803 + glide.splash = false;
1806 + LOG_MSG("Glide:Resolution set to:%dx%d, LFB at 0x%x (linear: 0x%x)", glide.width, glide.height, glide.lfb_pagehandler->GetPhysPt(), mem_readd(param[10]));
1807 + ret_value = G_OK;
1808 + break;
1809 + case _grTexCalcMemRequired16:
1810 + // FxU32 grTexCalcMemRequired(GrLOD_t smallLod, GrLOD_t largeLod, GrAspectRatio_t aspect,
1811 + // GrTextureFormat_t format)
1812 + FP.grRFunction4i = (prfunc4i)fn_pt[i];
1813 + if(ret == 0) {
1814 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
1815 + return;
1817 + mem_writed(ret, FP.grRFunction4i(param[1], param[2], param[3], param[4]));
1818 + ret_value = G_OK;
1819 + break;
1820 + case _grTexClampMode12:
1821 + // void grTexClampMode(GrChipID_t tmu, GrTextureClampMode_t sClampMode, GrTextureClampMode_t tClampMode)
1822 + FP.grFunction3i = (pfunc3i)fn_pt[i];
1823 + FP.grFunction3i(param[1], param[3], param[3]);
1824 + break;
1825 + case _grTexCombine28:
1826 + // void grTexCombine(GrChipID_t tmu, GrCombineFunction_t rgb_function, GrCombineFactor_t rgb_factor,
1827 + // GrCombineFunction_t alpha_function, GrCombineFactor_t alpha_factor, FxBool rgb_invert,
1828 + // FxBool alpha_invert)
1829 + FP.grFunction7i = (pfunc7i)fn_pt[i];
1830 + FP.grFunction7i(param[1], param[2], param[3], param[4], param[5], param[6], param[7]);
1831 + break;
1832 + case _grTexCombineFunction8:
1833 + // void grTexCombineFunction(GrChipID_t tmu, GrTextureCombineFnc_t fnc)
1834 + FP.grFunction2i = (pfunc2i)fn_pt[i];
1835 + FP.grFunction2i(param[1], param[2]);
1836 + break;
1837 + case _grTexDetailControl16:
1838 + // void grTexDetailControl(GrChipID_t tmu, int lodBias, FxU8 detailScale, float detailMax)
1839 + FP.grFunction3i1f = (pfunc3i1f)fn_pt[i];
1840 + FP.grFunction3i1f(param[1], param[2], param[3], F(param[4]));
1841 + break;
1842 + case _grTexDownloadMipMap16:
1843 + // void grTexDownloadMipMap(GrChipID_t tmu, FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info)
1844 + FP.grRFunction1i1p = (prfunc1i1p)fn_pt[_grTexTextureMemRequired8];
1845 + if(FP.grRFunction1i1p == NULL) {
1846 + LOG_MSG("Glide:Unable to get pointer to grTexTextureMemRequired");
1847 + return;
1850 + MEM_BlockRead32(param[4], &dbtexinfo, sizeof(DBGrTexInfo));
1852 + texinfo.smallLod = dbtexinfo.smallLod;
1853 + texinfo.largeLod = dbtexinfo.largeLod;
1854 + texinfo.aspectRatio = dbtexinfo.aspectRatio;
1855 + texinfo.format = dbtexinfo.format;
1856 + texinfo.data = NULL;
1858 + texsize = FP.grRFunction1i1p(param[3], &texinfo);
1859 + MEM_BlockRead(dbtexinfo.data, texmem, texsize);
1860 + texinfo.data = texmem;
1862 + FP.grFunction3i1p = (pfunc3i1p)fn_pt[i];
1863 + FP.grFunction3i1p(param[1], param[2], param[3], &texinfo);
1864 + break;
1865 + case _grTexDownloadMipMapLevel32:
1866 + // void grTexDownloadMipMapLevel(GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLod,
1867 + // GrLOD_t largeLod, GrAspectRatio_t aspectRatio, GrTextureFormat_t format,
1868 + // FxU32 evenOdd, void *data)
1869 + FP.grRFunction1i1p = (prfunc1i1p)fn_pt[_grTexTextureMemRequired8];
1870 + if(FP.grRFunction1i1p == NULL) {
1871 + LOG_MSG("Glide:Unable to get pointer to grTexTextureMemRequired");
1872 + return;
1875 + texinfo.smallLod = param[3];
1876 + texinfo.largeLod = param[4];
1877 + texinfo.aspectRatio = param[5];
1878 + texinfo.format = param[6];
1879 + texinfo.data = NULL;
1881 + texsize = FP.grRFunction1i1p(param[7], &texinfo);
1882 + MEM_BlockRead(param[8], texmem, texsize);
1884 + FP.grFunction7i1p = (pfunc7i1p)fn_pt[i];
1885 + FP.grFunction7i1p(param[1], param[2], param[3], param[4], param[5], param[6], param[7], texmem);
1886 + break;
1887 + case _grTexDownloadMipMapLevelPartial40:
1888 + // FX_ENTRY void FX_CALL grTexDownloadMipMapLevelPartial(GrChipID_t tmu, FxU32 startAddress,
1889 + // GrLOD_t thisLod, GrLOD_t largeLod, GrAspectRatio_t aspectRatio, GrTextureFormat_t format,
1890 + // FxU32 evenOdd, void *data, int start, int end);
1891 + FP.grRFunction1i1p = (prfunc1i1p)fn_pt[_grTexTextureMemRequired8];
1892 + if(FP.grRFunction1i1p == NULL) {
1893 + LOG_MSG("Glide:Unable to get pointer to grTexTextureMemRequired");
1894 + return;
1897 + texinfo.smallLod = param[3];
1898 + texinfo.largeLod = param[4];
1899 + texinfo.aspectRatio = param[5];
1900 + texinfo.format = param[6];
1901 + texinfo.data = NULL;
1903 + texsize = FP.grRFunction1i1p(param[7], &texinfo);
1904 + MEM_BlockRead(param[8], texmem, texsize);
1906 + FP.grFunction7i1p2i = (pfunc7i1p2i)fn_pt[i];
1907 + FP.grFunction7i1p2i(param[1], param[2], param[3], param[4], param[5], param[6], param[7], texmem,
1908 + param[9], param[10]);
1909 + break;
1910 + case _grTexDownloadTable12:
1911 + // void grTexDownloadTable(GrChipID_t tmu, GrTexTable_t type, void *data)
1912 + FP.grFunction2i1p = (pfunc2i1p)fn_pt[i];
1914 + if(param[2] == GR_TEXTABLE_PALETTE)
1915 + MEM_BlockRead32(param[3], texmem, sizeof(GuTexPalette));
1916 + else // GR_TEXTABLE_NCC0 or GR_TEXTABLE_NCC1
1917 + MEM_BlockRead32(param[3], texmem, sizeof(GuNccTable));
1919 + FP.grFunction2i1p(param[1], param[2], texmem);
1920 + break;
1921 + case _grTexDownloadTablePartial20:
1922 + // void grTexDownloadTablePartial(GrChipID_t tmu, GrTexTable_t type, void *data, int start, int end)
1923 + FP.grFunction2i1p2i = (pfunc2i1p2i)fn_pt[i];
1925 + if(param[2] == GR_TEXTABLE_PALETTE) {
1926 + MEM_BlockRead32(param[3], texmem, sizeof(FxU32)*(param[5]-param[4]+1));
1927 + FP.grFunction2i1p2i(param[1], param[2], texmem, param[4], param[5]);
1928 + } else { // GR_TEXTABLE_NCC0 or GR_TEXTABLE_NCC1
1929 + LOG_MSG("Glide:Downloading partial NCC tables is not supported!");
1932 + break;
1933 + case _grTexFilterMode12:
1934 + // void grTexFilterMode(GrChipID_t tmu, GrTextureFilterMode_t minFilterMode,
1935 + // GrTextureFilterMode_t magFilterMode)
1936 + FP.grFunction3i = (pfunc3i)fn_pt[i];
1937 + FP.grFunction3i(param[1], param[2], param[3]);
1938 + break;
1939 + case _grTexLodBiasValue8:
1940 + // void grTexLodBiasValue(GrChipID_t tmu, float bias)
1941 + FP.grFunction1i1f = (pfunc1i1f)fn_pt[i];
1942 + FP.grFunction1i1f(param[1], F(param[2]));
1943 + break;
1944 + case _grTexMaxAddress4:
1945 + // FxU32 grTexMaxAddress(GrChipID_t tmu)
1946 + FP.grRFunction1i = (prfunc1i)fn_pt[i];
1947 + if(ret == 0) {
1948 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
1949 + return;
1951 + mem_writed(ret, FP.grRFunction1i(param[1]));
1952 + ret_value = G_OK;
1953 + break;
1954 + case _grTexMinAddress4:
1955 + // FxU32 grTexMinAddress(GrChipID_t tmu)
1956 + FP.grRFunction1i = (prfunc1i)fn_pt[i];
1957 + if(ret == 0) {
1958 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
1959 + return;
1961 + mem_writed(ret, FP.grRFunction1i(param[1]));
1962 + ret_value = G_OK;
1963 + break;
1964 + case _grTexMipMapMode12:
1965 + // void grTexMipMapMode(GrChipID_t tmu, GrMipMapMode_t mode, FxBool lodBlend)
1966 + FP.grFunction3i = (pfunc3i)fn_pt[i];
1967 + FP.grFunction3i(param[1], param[2], param[3]);
1968 + break;
1969 + case _grTexMultibase8:
1970 + // void grTexMultibase(GrChipID_t tmu, FxBool enable)
1971 + FP.grFunction2i = (pfunc2i)fn_pt[i];
1972 + FP.grFunction2i(param[1], param[2]);
1973 + break;
1975 + case _grTexMultibaseAddress20:
1976 + // void grTexMultibaseAddress(GrChipID_t tmu, GrTexBaseRange_t range, FxU32 startAddress,
1977 + // FxU32 evenOdd, GrTexInfo *info)
1978 + FP.grFunction4i1p = (pfunc4i1p)fn_pt[i];
1980 + // This is a bit more complicated since *info contains a pointer to data
1981 + texinfo = (GrTexInfo*)param[5];
1982 + data = (PhysPt)texinfo->data; // Store for later reference
1983 + texinfo->data = VIRTOREAL(data);
1984 +#if LOG_GLIDE
1985 + if(log_func[value-_grAADrawLine8] == 1) {
1986 + LOG_MSG("Glide:Replacing pointer 0x%x with 0x%x in function %d", data, texinfo->data, _grTexMultibaseAddress20);
1987 + log_func[value-_grAADrawLine8] = 2;
1989 +#endif
1990 + FP.grFunction20(param[1], param[2], param[3], param[4], (int)texinfo);
1991 + texinfo->data = (void*)data; // Change the pointer back
1992 + break;
1994 + case _grTexNCCTable8:
1995 + // void grTexNCCTable(GrChipID_t tmu, GrNCCTable_t table)
1996 + FP.grFunction2i = (pfunc2i)fn_pt[i];
1997 + FP.grFunction2i(param[1], param[2]);
1998 + break;
1999 + case _grTexSource16:
2000 + // void grTexSource(GrChipID_t tmu, FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info)
2001 + FP.grFunction3i1p = (pfunc3i1p)fn_pt[i];
2003 + // Copy the data from DB struct
2004 + MEM_BlockRead32(param[4], &dbtexinfo, sizeof(DBGrTexInfo));
2006 + texinfo.smallLod = dbtexinfo.smallLod;
2007 + texinfo.largeLod = dbtexinfo.largeLod;
2008 + texinfo.aspectRatio = dbtexinfo.aspectRatio;
2009 + texinfo.format = dbtexinfo.format;
2011 + FP.grFunction3i1p(param[1], param[2], param[3], &texinfo);
2012 + break;
2013 + case _grTexTextureMemRequired8:
2014 + // FxU32 grTexTextureMemRequired(FxU32 evenOdd, GrTexInfo *info)
2015 + FP.grRFunction1i1p = (prfunc1i1p)fn_pt[i];
2016 + if(ret == 0) {
2017 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
2018 + return;
2021 + // Copy the data from DB struct
2022 + MEM_BlockRead32(param[2], &dbtexinfo, sizeof(DBGrTexInfo));
2024 + texinfo.smallLod = dbtexinfo.smallLod;
2025 + texinfo.largeLod = dbtexinfo.largeLod;
2026 + texinfo.aspectRatio = dbtexinfo.aspectRatio;
2027 + texinfo.format = dbtexinfo.format;
2029 + mem_writed(ret, FP.grRFunction1i1p(param[1], &texinfo));
2031 + ret_value = G_OK;
2032 + break;
2033 + case _grTriStats8:
2034 + // void grTriStats(FxU32 *trisProcessed, FxU32 *trisDrawn)
2035 + FP.grFunction2p = (pfunc2p)fn_pt[i];
2036 + MEM_BlockRead32(param[1], ilist, sizeof(FxU32));
2037 + MEM_BlockRead32(param[2], ilist + 1, sizeof(FxU32));
2038 + FP.grFunction2p(ilist, ilist + 1);
2039 + MEM_BlockWrite32(param[1], ilist, sizeof(FxU32));
2040 + MEM_BlockWrite32(param[2], ilist + 1, sizeof(FxU32));
2041 + break;
2042 + case _gu3dfGetInfo8:
2043 + // FxBool gu3dfGetInfo(const char *filename, Gu3dfInfo *info)
2044 + FP.grRFunction2p = (prfunc2p)fn_pt[i];
2045 + if(ret == 0) {
2046 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
2047 + return;
2049 + MEM_StrCopy(param[1], filename, 512);
2051 +#if LOG_GLIDE
2052 + LOG_MSG("Glide:Filename info found in gu3dfGetInfo: %s", filename);
2053 +#endif
2054 + if(!GetFileName(filename)) break;
2055 + mem_writed(ret, FP.grRFunction2p(filename, &guinfo));
2057 + // Copy the data back to DB struct if successful
2058 + if(mem_readd(ret)) {
2059 + MEM_BlockRead32(param[2], &dbguinfo, sizeof(DBGu3dfInfo));
2060 + dbguinfo.header.width = (Bit32u)guinfo.header.width;
2061 + dbguinfo.header.height = (Bit32u)guinfo.header.height;
2062 + dbguinfo.header.small_lod = (Bit32s)guinfo.header.small_lod;
2063 + dbguinfo.header.large_lod = (Bit32s)guinfo.header.large_lod;
2064 + dbguinfo.header.aspect_ratio = (Bit32s)guinfo.header.aspect_ratio;
2065 + dbguinfo.header.format = (Bit32s)guinfo.header.format;
2066 + dbguinfo.mem_required = (Bit32u)guinfo.mem_required;
2067 + MEM_BlockWrite32(param[2], &dbguinfo, sizeof(DBGu3dfInfo));
2070 + ret_value = G_OK;
2071 + break;
2072 + case _gu3dfLoad8:
2073 + // FxBool gu3dfLoad(const char *filename, Gu3dfInfo *info)
2074 + FP.grRFunction2p = (prfunc2p)fn_pt[i];
2075 + if(ret == 0) {
2076 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
2077 + return;
2080 + // Although glide ref specifies *info should be filled by gu3dfGetInfo before calling gu3dfLoad,
2081 + // OpenGlide will re-read the header in gu3dfLoad as well
2082 + MEM_BlockRead32(param[2], &dbguinfo, sizeof(DBGu3dfInfo));
2083 + MEM_StrCopy(param[1], filename, 512);
2085 +#if LOG_GLIDE
2086 + LOG_MSG("Glide:Filename info found in gu3dfLoad: %s", filename);
2087 +#endif
2088 + if(!GetFileName(filename)) break;
2090 + guinfo.data = texmem;
2091 + mem_writed(ret, FP.grRFunction2p(filename, &guinfo));
2093 + // Copy the data back to DB struct if successful
2094 + if(mem_readd(ret)) {
2095 + for(j=0;j<256;j++)
2096 + dbguinfo.table.palette.data[j] = (Bit32u)guinfo.table.palette.data[j];
2097 + MEM_BlockWrite(dbguinfo.data, guinfo.data, guinfo.mem_required);
2100 + MEM_BlockWrite32(param[2], &dbguinfo, sizeof(DBGu3dfInfo));
2101 + ret_value = G_OK;
2102 + break;
2103 + case _guAADrawTriangleWithClip12:
2104 + // void guAADrawTriangleWithClip(const GrVertex *va, const GrVertex *vb, const GrVertex *vc)
2105 + FP.grFunction3p = (pfunc3p)fn_pt[i];
2106 + MEM_BlockRead32(param[1], &vertex[0], sizeof(GrVertex));
2107 + MEM_BlockRead32(param[2], &vertex[1], sizeof(GrVertex));
2108 + MEM_BlockRead32(param[3], &vertex[2], sizeof(GrVertex));
2109 + FP.grFunction3p(&vertex[0], &vertex[1], &vertex[2]);
2110 + break;
2111 + case _guAlphaSource4:
2112 + // void guAlphaSource(GrAlphaSourceMode_t mode)
2113 + FP.grFunction1i = (pfunc1i)fn_pt[i];
2114 + FP.grFunction1i(param[1]);
2115 + break;
2116 + case _guColorCombineFunction4:
2117 + // void guColorCombineFunction(GrColorCombineFunction_t func)
2118 + FP.grFunction1i = (pfunc1i)fn_pt[i];
2119 + FP.grFunction1i(param[1]);
2120 + break;
2121 + case _guDrawPolygonVertexListWithClip8:
2122 + // void guDrawPolygonVertexListWithClip(int nverts, const GrVertex vlist[])
2123 + FP.grFunction1i1p = (pfunc1i1p)fn_pt[i];
2124 + MEM_BlockRead32(param[2], texmem, sizeof(GrVertex)*param[1]);
2125 + FP.grFunction1i1p(param[1], texmem);
2126 + break;
2127 + case _guDrawTriangleWithClip12:
2128 + // void guDrawTriangleWithClip(const GrVertex *va, const GrVertex *vb, const GrVertex *vc)
2129 + FP.grFunction3p = (pfunc3p)fn_pt[i];
2130 + MEM_BlockRead32(param[1], &vertex[0], sizeof(GrVertex));
2131 + MEM_BlockRead32(param[2], &vertex[1], sizeof(GrVertex));
2132 + MEM_BlockRead32(param[3], &vertex[2], sizeof(GrVertex));
2133 + FP.grFunction3p(&vertex[0], &vertex[1], &vertex[2]);
2134 + break;
2136 + case _guEncodeRLE1616:
2137 + //
2138 + FP.grFunction16 = (pfunc16)fn_pt[i];
2139 + FP.grFunction16();
2140 + break;
2141 + case _guEndianSwapBytes4:
2142 + //
2143 + FP.grFunction1i = (pfunc1i)fn_pt[i];
2144 + FP.grFunction1i();
2145 + break;
2146 + case _guEndianSwapWords4:
2147 + //
2148 + FP.grFunction1i = (pfunc1i)fn_pt[i];
2149 + FP.grFunction1i();
2150 + break;
2152 + case _guFogGenerateExp28:
2153 + // void guFogGenerateExp2(GrFog_t fogTable[GR_FOG_TABLE_SIZE], float density)
2154 + FP.grFunction1p1f = (pfunc1p1f)fn_pt[i];
2155 + FP.grFunction1p1f(texmem, F(param[2]));
2156 + MEM_BlockWrite32(param[1], texmem, GR_FOG_TABLE_SIZE*sizeof(GrFog_t));
2157 + break;
2158 + case _guFogGenerateExp8:
2159 + // void guFogGenerateExp(GrFog_t fogTable[GR_FOG_TABLE_SIZE], float density)
2160 + FP.grFunction1p1f = (pfunc1p1f)fn_pt[i];
2161 + FP.grFunction1p1f(texmem, F(param[2]));
2162 + MEM_BlockWrite32(param[1], texmem, GR_FOG_TABLE_SIZE*sizeof(GrFog_t));
2163 + break;
2164 + case _guFogGenerateLinear12:
2165 + // void guFogGenerateLinear(GrFog_t fogTable[GR_FOG_TABLE_SIZE], float nearW, float farW)
2166 + FP.grFunction1p2f = (pfunc1p2f)fn_pt[i];
2167 + FP.grFunction1p2f(texmem, F(param[2]), F(param[3]));
2168 + MEM_BlockWrite32(param[1], texmem, GR_FOG_TABLE_SIZE*sizeof(GrFog_t));
2169 + break;
2171 + case _guFogTableIndexToW4:
2172 + // float guFogTableIndexToW(int i)
2173 + FP.grFFunction1i = (pffunc1i)fn_pt[i];
2174 + if(ret == 0) {
2175 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
2176 + return;
2178 + mem_writed(ret, FP.grRFunction4(param[1]));
2179 + ret_value = G_OK;
2180 + break;
2181 + case _guMPDrawTriangle12:
2182 + //
2183 + FP.grFunction3i = (pfunc3i)fn_pt[i];
2184 + FP.grFunction3i();
2185 + break;
2186 + case _guMPInit0:
2187 + //
2188 + FP.grFunction0 = (pfunc0)fn_pt[i];
2189 + FP.grFunction0();
2190 + break;
2191 + case _guMPTexCombineFunction4:
2192 + //
2193 + FP.grFunction1i = (pfunc1i)fn_pt[i];
2194 + FP.grFunction1i();
2195 + break;
2196 + case _guMPTexSource8:
2197 + //
2198 + FP.grFunction2i = (pfunc2i)fn_pt[i];
2199 + FP.grFunction2i();
2200 + break;
2201 + case _guMovieSetName4:
2202 + //
2203 + FP.grFunction1i = (pfunc1i)fn_pt[i];
2204 + FP.grFunction1i();
2205 + break;
2206 + case _guMovieStart0:
2207 + //
2208 + FP.grFunction0 = (pfunc0)fn_pt[i];
2209 + FP.grFunction0();
2210 + break;
2211 + case _guMovieStop0:
2212 + //
2213 + FP.grFunction0 = (pfunc0)fn_pt[i];
2214 + FP.grFunction0();
2215 + break;
2217 + case _guTexAllocateMemory60:
2218 + // GrMipMapId_t guTexAllocateMemory(GrChipID_t tmu, FxU8 evenOddMask, int width, int height,
2219 + // GrTextureFormat_t format, GrMipMapMode_t mmMode, GrLOD_t smallLod, GrLOD_t largeLod,
2220 + // GrAspectRatio_t aspectRatio, GrTextureClampMode_t sClampMode,
2221 + // GrTextureClampMode_t tClampMode, GrTextureFilterMode_t minFilterMode,
2222 + // GrTextureFilterMode_t magFilterMode, float lodBias, FxBool lodBlend)
2223 + FP.grRFunction13i1f1i = (prfunc13i1f1i)fn_pt[i];
2224 + if(ret == 0) {
2225 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
2226 + return;
2228 + mem_writed(ret, FP.grRFunction13i1f1i(param[1], param[2], param[3], param[4], param[5], param[6], param[7],
2229 + param[8], param[9], param[10], param[11], param[12], param[13], F(param[14]), param[15]));
2230 + ret_value = G_OK;
2231 + break;
2232 + case _guTexChangeAttributes48:
2233 + // FxBool guTexChangeAttributes(GrMipMapID_t mmid, int width, int height, GrTextureFormat_t format,
2234 + // GrMipMapMode_t mmMode, GrLOD_t smallLod, GrLOD_t largeLod, GrAspectRatio_t aspectRatio,
2235 + // GrTextureClampMode_t sClampMode, GrTextureClampMode_t tClampMode,
2236 + // GrTextureFilterMode_t minFilterMode, GrTextureFilterMode_t magFilterMode)
2237 + FP.grRFunction12i = (prfunc12i)fn_pt[i];
2238 + if(ret == 0) {
2239 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
2240 + return;
2242 + mem_writed(ret, FP.grRFunction12i(param[1], param[2], param[3], param[4], param[5], param[6], param[7],
2243 + param[8], param[9], param[10], param[11], param[12]));
2244 + ret_value = G_OK;
2245 + break;
2246 + case _guTexCombineFunction8:
2247 + // void guTexCombineFunction(GrChipID_t tmu, GrTextureCombineFnc_t func)
2248 + FP.grFunction2i = (pfunc2i)fn_pt[i];
2249 + FP.grFunction2i(param[1], param[2]);
2250 + break;
2252 + case _guTexCreateColorMipMap0:
2253 + //
2254 + FP.grFunction0 = (pfunc0)fn_pt[i];
2255 + FP.grFunction0();
2256 + break;
2258 + case _guTexDownloadMipMap12:
2259 + // void guTexDownloadMipMap(GrMipMapId_t mmid, const void *src, const GuNccTable *nccTable)
2260 + FP.grRPTFunction1i = (prptfunc1i)fn_pt[_guTexGetMipMapInfo4];
2261 + mipmap = (GrMipMapInfo*)FP.grRPTFunction1i(param[1]);
2263 + if(mipmap) {
2264 + texinfo.aspectRatio = mipmap->aspect_ratio;
2265 + texinfo.format = mipmap->format;
2266 + texinfo.largeLod = mipmap->lod_max;
2267 + texinfo.smallLod = mipmap->lod_min;
2269 + FP.grRFunction1i1p = (prfunc1i1p)fn_pt[_grTexTextureMemRequired8];
2270 + if(FP.grRFunction1i1p == NULL) {
2271 + LOG_MSG("Glide:Unable to get pointer to grTexTextureMemRequired");
2272 + return;
2275 + texsize = FP.grRFunction1i1p(mipmap->odd_even_mask, &texinfo);
2277 + MEM_BlockRead(param[2], texmem, texsize);
2278 + MEM_BlockRead32(param[3], (Bit8u*)texmem+texsize, sizeof(GuNccTable));
2280 + FP.grFunction1i2p = (pfunc1i2p)fn_pt[i];
2281 + FP.grFunction1i2p(param[1], texmem, (Bit8u*)texmem+texsize);
2282 + } else {
2283 + LOG_MSG("Glide:Unable to get GrMipMapInfo pointer");
2285 + break;
2287 + case _guTexDownloadMipMapLevel12:
2288 + // void guTexDownloadMipMapLevel(GrMipMapId_t mmid, GrLOD_t lod, const void **src)
2289 + FP.grFunction2i1p = (pfunc2i1p)fn_pt[i];
2290 + FP.grFunction2i1p(param[1], param[2], *param[3]);
2291 + break;
2293 + case _guTexGetCurrentMipMap4:
2294 + // GrMipMapId_t guTexGetCurrentMipMap(GrChipID_t tmu)
2295 + FP.grRFunction1i = (prfunc1i)fn_pt[i];
2296 + if(ret == 0) {
2297 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
2298 + return;
2300 + mem_writed(ret, FP.grRFunction1i(param[1]));
2301 + ret_value = G_OK;
2302 + break;
2304 + case _guTexGetMipMapInfo4:
2305 + // GrMipMapInfo *guTexGetMipMapInfo(GrMipMapId_t mmid)
2306 + FP.grRFunction4 = (prfunc4)fn_pt[i];
2307 + if(ret == 0) {
2308 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
2309 + return;
2311 + mem_writed(ret, FP.grRFunction4(param[1]));
2312 + ret_value = G_OK;
2313 + break;
2315 + case _guTexMemQueryAvail4:
2316 + // FxU32 guTexMemQueryAvail(GrChipID_t tmu)
2317 + FP.grRFunction1i = (prfunc1i)fn_pt[i];
2318 + if(ret == 0) {
2319 + LOG_MSG("Glide:Invalid return value handle for %s!", grTable[i].name);
2320 + return;
2322 + mem_writed(ret, FP.grRFunction1i(param[1]));
2323 + ret_value = G_OK;
2324 + break;
2325 + case _guTexMemReset0:
2326 + // void guTexMemReset(void)
2327 + FP.grFunction0 = (pfunc0)fn_pt[i];
2328 + FP.grFunction0();
2329 + break;
2330 + case _guTexSource4:
2331 + // void guTexSource(GrMipMapId_t mmid)
2332 + FP.grFunction1i = (pfunc1i)fn_pt[i];
2333 + FP.grFunction1i(param[1]);
2334 + break;
2335 + case _ConvertAndDownloadRle64: {
2336 + // void ConvertAndDownloadRle(GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLod, GrLOD_t largeLod,
2337 + // GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 evenOdd,
2338 + // FxU8 *bm_data, long bm_h, FxU32 u0, FxU32 v0, FxU32 width, FxU32 height,
2339 + // FxU32 dest_width, FxU32 dest_height, FxU16 *tlut)
2341 +#if LOG_GLIDE
2342 + LOG_MSG("Glide: RLE width: %d, height: %d, bm_h: %d, u0: %d, v0: %d, dest %dx%d",
2343 + param[12], param[13], param[9], param[10], param[11], param[14], param[15]);
2344 +#endif
2346 + FxU8 c;
2347 + FxU32 scount = 0;
2348 + FxU32 dcount = 0;
2350 + FxU16 * src = ptr16 + param[14]*param[15];
2351 + FxU32 offset = 4 + param[9];
2353 + // Line offset (v0)
2354 + for(j = 0; j < param[11]; j++ ) {
2355 + offset += mem_readb(param[8]+4+j);
2358 + // Write height lines
2359 + for(k = 0; k < param[13]; k++) {
2361 + // Decode one RLE line
2362 + scount = offset;
2363 + while((c = mem_readb(param[8]+scount)) != 0xE0) {
2365 + if(c > 0xE0) {
2366 + for(int count = 0; count < (c&0x1f); count++) {
2368 + // tlut is FxU16*
2369 + src[dcount] = mem_readw(param[16]+(mem_readb(param[8]+scount+1)<<1));
2370 + dcount++;
2372 + scount += 2;
2374 + } else {
2375 + src[dcount] = mem_readw(param[16]+(c<<1));
2376 + dcount++; scount++;
2380 + // Copy Line into destination texture, offset u0
2381 + SDL_memcpy(ptr16 + (k*param[14]), src + param[10], sizeof(FxU16)*param[14]);
2382 + offset += mem_readb(param[8] + 4 + j++);
2383 + dcount = 0;
2386 + // One additional line
2387 + if(param[13] < param[15])
2388 + SDL_memcpy(ptr16 + (k*param[14]), src + param[10], sizeof(FxU16)*param[14]);
2390 + // Download decoded texture
2391 + texinfo.smallLod = param[3];
2392 + texinfo.largeLod = param[4];
2393 + texinfo.aspectRatio = param[5];
2394 + texinfo.format = param[6];
2395 + texinfo.data = ptr16;
2397 + // void grTexDownloadMipMap(GrChipID_t tmu, FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info)
2398 + FP.grFunction3i1p = (pfunc3i1p)fn_pt[_grTexDownloadMipMap16];
2399 + if(FP.grFunction3i1p == NULL) {
2400 + LOG_MSG("Glide:Unable to get pointer to grTexDownloadMipMap");
2401 + break;
2403 + FP.grFunction3i1p(param[1], param[2], param[7], &texinfo);
2404 + break;
2406 + default:
2407 + LOG_MSG("Glide:Unsupported glide call %s", grTable[i].name);
2408 + break;
2410 + } /* switch */
2411 +} /* process_msg() */
2412 diff -urN dosbox.orig/src/hardware/memory.cpp dosbox/src/hardware/memory.cpp
2413 --- dosbox.orig/src/hardware/memory.cpp 2011-01-11 19:48:52.694832103 -0300
2414 +++ dosbox/src/hardware/memory.cpp 2011-01-11 20:01:45.201498771 -0300
2415 @@ -24,6 +24,7 @@
2416 #include "setup.h"
2417 #include "paging.h"
2418 #include "regs.h"
2419 +#include "glidedef.h"
2421 #include <string.h>
2423 @@ -141,6 +142,8 @@
2424 } else if ((phys_page>=memory.lfb.start_page+0x01000000/4096) &&
2425 (phys_page<memory.lfb.start_page+0x01000000/4096+16)) {
2426 return memory.lfb.mmiohandler;
2427 + } else if ((phys_page>=(GLIDE_LFB>>12)) && (phys_page<(GLIDE_LFB>>12)+GLIDE_PAGES)) {
2428 + if(glide.enabled) return (PageHandler*)glide.lfb_pagehandler;
2430 return &illegal_page_handler;
2432 @@ -192,6 +195,24 @@
2436 +void MEM_BlockRead32(PhysPt pt,void * data,Bitu size) {
2437 + Bit32u * write=(Bit32u *) data;
2438 + size>>=2;
2439 + while (size--) {
2440 + *write++=mem_readd_inline(pt);
2441 + pt+=4;
2445 +void MEM_BlockWrite32(PhysPt pt,void * data,Bitu size) {
2446 + Bit32u * read=(Bit32u *) data;
2447 + size>>=2;
2448 + while (size--) {
2449 + mem_writed_inline(pt,*read++);
2450 + pt+=4;
2454 void MEM_BlockCopy(PhysPt dest,PhysPt src,Bitu size) {
2455 mem_memcpy(dest,src,size);
2457 diff -urN dosbox.orig/src/hardware/vga_draw.cpp dosbox/src/hardware/vga_draw.cpp
2458 --- dosbox.orig/src/hardware/vga_draw.cpp 2011-01-11 19:48:52.694832103 -0300
2459 +++ dosbox/src/hardware/vga_draw.cpp 2011-01-11 20:03:38.441498770 -0300
2460 @@ -30,6 +30,7 @@
2461 //#undef C_DEBUG
2462 //#define C_DEBUG 1
2463 //#define LOG(X,Y) LOG_MSG
2464 +#include "glidedef.h"
2466 #define VGA_PARTS 4
2468 @@ -791,9 +791,11 @@
2471 static void VGA_VerticalTimer(Bitu /*val*/) {
2472 - vga.draw.delay.framestart = PIC_FullIndex();
2473 - PIC_AddEvent( VGA_VerticalTimer, (float)vga.draw.delay.vtotal );
2475 + if(!glide.enabled) {
2476 + vga.draw.delay.framestart = PIC_FullIndex();
2477 + PIC_AddEvent( VGA_VerticalTimer, (float)vga.draw.delay.vtotal );
2480 switch(machine) {
2481 case MCH_PCJR:
2482 case MCH_TANDY:
2483 @@ -933,7 +935,9 @@
2484 PIC_RemoveEvents(VGA_DrawPart);
2485 RENDER_EndUpdate(true);
2487 - vga.draw.lines_done = 0;
2488 + if(!glide.enabled) {
2489 + vga.draw.lines_done = 0;
2491 vga.draw.parts_left = vga.draw.parts_total;
2492 PIC_AddEvent(VGA_DrawPart,(float)vga.draw.delay.parts + draw_skip,vga.draw.parts_lines);
2493 break;
2494 @@ -946,7 +950,9 @@
2495 else PIC_RemoveEvents(VGA_DrawSingleLine);
2496 RENDER_EndUpdate(true);
2498 - vga.draw.lines_done = 0;
2499 + if(!glide.enabled) {
2500 + vga.draw.lines_done = 0;
2502 if (vga.draw.mode==EGALINE)
2503 PIC_AddEvent(VGA_DrawEGASingleLine,(float)(vga.draw.delay.htotal/4.0 + draw_skip));
2504 else PIC_AddEvent(VGA_DrawSingleLine,(float)(vga.draw.delay.htotal/4.0 + draw_skip));
2505 @@ -1557,7 +1563,9 @@
2506 LOG(LOG_VGA,LOG_NORMAL)("%s width, %s height aspect %f",
2507 doublewidth ? "double":"normal",doubleheight ? "double":"normal",aspect_ratio);
2508 #endif
2509 - RENDER_SetSize(width,height,bpp,(float)fps,aspect_ratio,doublewidth,doubleheight);
2510 + if(!glide.enabled) {
2511 + RENDER_SetSize(width,height,bpp,(float)fps,aspect_ratio,doublewidth,doubleheight);