ce879073 |
1 | /***************************************************************************\r |
2 | external.h - description\r |
3 | -------------------\r |
4 | begin : Sun Mar 08 2009\r |
5 | copyright : (C) 1999-2009 by Pete Bernert\r |
6 | web : www.pbernert.com \r |
7 | ***************************************************************************/\r |
8 | \r |
9 | /***************************************************************************\r |
10 | * *\r |
11 | * This program is free software; you can redistribute it and/or modify *\r |
12 | * it under the terms of the GNU General Public License as published by *\r |
13 | * the Free Software Foundation; either version 2 of the License, or *\r |
14 | * (at your option) any later version. See also the license.txt file for *\r |
15 | * additional informations. *\r |
16 | * *\r |
17 | ***************************************************************************/\r |
18 | \r |
19 | //*************************************************************************// \r |
20 | // History of changes:\r |
21 | //\r |
22 | // 2009/03/08 - Pete \r |
23 | // - generic cleanup for the Peops release\r |
24 | //\r |
25 | //*************************************************************************// \r |
26 | \r |
27 | /////////////////////////////////////////////////////////////////////////////\r |
28 | \r |
29 | #ifndef __GPU_EX__\r |
30 | #define __GPU_EX__\r |
31 | \r |
32 | #ifdef __cplusplus\r |
33 | extern "C" {\r |
34 | #endif\r |
7eadbf88 |
35 | \r |
ce879073 |
36 | #ifdef __NANOGL__\r |
37 | #include <gl/gl.h>\r |
38 | #include <gl/egl.h>\r |
39 | #else\r |
07f75e28 |
40 | #include <GLES/gl.h>\r |
41 | #include <GLES/glext.h>\r |
ce879073 |
42 | #endif\r |
43 | \r |
ce879073 |
44 | #ifdef __NANOGL__\r |
45 | #define glTexParameteri(x,y,z) glTexParameterf(x,y,z) \r |
46 | #define glAlphaFuncx(x,y) glAlphaFunc(x,y) \r |
47 | #ifndef APIENTRY\r |
48 | #define APIENTRY\r |
49 | #endif\r |
50 | extern void ( APIENTRY * glPixelStorei )(GLenum pname, GLint param);\r |
51 | #endif\r |
52 | \r |
53 | \r |
54 | #define MIRROR_TEST 1\r |
55 | \r |
56 | /////////////////////////////////////////////////////////////////////////////\r |
57 | \r |
58 | #define SCISSOR_TEST 1\r |
59 | \r |
60 | /////////////////////////////////////////////////////////////////////////////\r |
61 | \r |
62 | // for own sow/tow scaling\r |
63 | #define OWNSCALE 1\r |
64 | \r |
65 | /////////////////////////////////////////////////////////////////////////////\r |
66 | \r |
67 | #define CLUTUSED 0x80000000\r |
68 | //glColor4ubv(x.c.col)\r |
69 | #define SETCOL(x) if(x.c.lcol!=ulOLDCOL) {ulOLDCOL=x.c.lcol;glColor4ub(x.c.col[0],x.c.col[1],x.c.col[2],x.c.col[3]);} \r |
70 | //#define SETPCOL(x) if(x->c.lcol!=ulOLDCOL) {ulOLDCOL=x->c.lcol;glColor4ub(x->c.col[0],x->c.col[1],x->c.col[2],x->c.col[3]);}\r |
71 | \r |
72 | #define INFO_TW 0\r |
73 | #define INFO_DRAWSTART 1\r |
74 | #define INFO_DRAWEND 2\r |
75 | #define INFO_DRAWOFF 3\r |
76 | \r |
77 | #define SIGNSHIFT 21\r |
78 | #define CHKMAX_X 1024\r |
79 | #define CHKMAX_Y 512\r |
80 | \r |
81 | /////////////////////////////////////////////////////////////////////////////\r |
82 | \r |
83 | // GPU STATUS REGISTER bit values (c) Lewpy\r |
84 | \r |
85 | #define DR_NORMAL 0\r |
86 | #define DR_VRAMTRANSFER 1\r |
87 | \r |
88 | #define GPUSTATUS_ODDLINES 0x80000000\r |
89 | #define GPUSTATUS_DMABITS 0x60000000 // Two bits\r |
90 | #define GPUSTATUS_READYFORCOMMANDS 0x10000000\r |
91 | #define GPUSTATUS_READYFORVRAM 0x08000000\r |
92 | #define GPUSTATUS_IDLE 0x04000000\r |
93 | #define GPUSTATUS_DISPLAYDISABLED 0x00800000\r |
94 | #define GPUSTATUS_INTERLACED 0x00400000\r |
95 | #define GPUSTATUS_RGB24 0x00200000\r |
96 | #define GPUSTATUS_PAL 0x00100000\r |
97 | #define GPUSTATUS_DOUBLEHEIGHT 0x00080000\r |
98 | #define GPUSTATUS_WIDTHBITS 0x00070000 // Three bits\r |
99 | #define GPUSTATUS_MASKENABLED 0x00001000\r |
100 | #define GPUSTATUS_MASKDRAWN 0x00000800\r |
101 | #define GPUSTATUS_DRAWINGALLOWED 0x00000400\r |
102 | #define GPUSTATUS_DITHER 0x00000200\r |
103 | \r |
104 | #define STATUSREG lGPUstatusRet\r |
105 | \r |
106 | #define GPUIsBusy (STATUSREG &= ~GPUSTATUS_IDLE)\r |
107 | #define GPUIsIdle (STATUSREG |= GPUSTATUS_IDLE)\r |
108 | \r |
109 | #define GPUIsNotReadyForCommands (STATUSREG &= ~GPUSTATUS_READYFORCOMMANDS)\r |
110 | #define GPUIsReadyForCommands (STATUSREG |= GPUSTATUS_READYFORCOMMANDS)\r |
111 | \r |
112 | /////////////////////////////////////////////////////////////////////////////\r |
113 | \r |
114 | #define KEY_RESETTEXSTORE 1\r |
115 | #define KEY_SHOWFPS 2\r |
116 | #define KEY_RESETOPAQUE 4\r |
117 | #define KEY_RESETDITHER 8\r |
118 | #define KEY_RESETFILTER 16\r |
119 | #define KEY_RESETADVBLEND 32\r |
120 | #define KEY_BLACKWHITE 64\r |
121 | #define KEY_TOGGLEFBTEXTURE 128\r |
122 | #define KEY_STEPDOWN 256\r |
123 | #define KEY_TOGGLEFBREAD 512\r |
124 | \r |
125 | /////////////////////////////////////////////////////////////////////////////\r |
126 | // Linux is missing some stuff, eh? ;)\r |
127 | \r |
128 | #ifndef _WINDOWS\r |
129 | #ifndef FALSE\r |
130 | #define FALSE 0\r |
131 | #endif\r |
132 | #ifndef TRUE\r |
133 | #define TRUE 1\r |
134 | #endif\r |
135 | #ifndef BOOL\r |
136 | #define BOOL unsigned short\r |
137 | #endif\r |
138 | #ifndef bool\r |
139 | #define bool unsigned short\r |
140 | #endif\r |
141 | #define LOWORD(l) ((unsigned short)(l))\r |
142 | #define HIWORD(l) ((unsigned short)(((unsigned long)(l) >> 16) & 0xFFFF))\r |
143 | #define max(a,b) (((a) > (b)) ? (a) : (b))\r |
144 | #define min(a,b) (((a) < (b)) ? (a) : (b))\r |
145 | #define DWORD unsigned long\r |
146 | \r |
147 | typedef struct RECTTAG\r |
148 | {\r |
149 | int left;\r |
150 | int top;\r |
151 | int right;\r |
152 | int bottom;\r |
153 | }RECT;\r |
154 | \r |
155 | #endif\r |
156 | \r |
157 | /////////////////////////////////////////////////////////////////////////////\r |
158 | \r |
159 | typedef struct VRAMLOADTAG\r |
160 | {\r |
161 | short x;\r |
162 | short y;\r |
163 | short Width;\r |
164 | short Height;\r |
165 | short RowsRemaining;\r |
166 | short ColsRemaining;\r |
167 | unsigned short *ImagePtr;\r |
168 | } VRAMLoad_t;\r |
169 | \r |
170 | typedef struct PSXPOINTTAG\r |
171 | {\r |
172 | long x;\r |
173 | long y;\r |
174 | } PSXPoint_t;\r |
175 | \r |
176 | typedef struct PSXSPOINTTAG\r |
177 | {\r |
178 | short x;\r |
179 | short y;\r |
180 | } PSXSPoint_t;\r |
181 | \r |
182 | typedef struct PSXRECTTAG\r |
183 | {\r |
184 | short x0;\r |
185 | short x1;\r |
186 | short y0;\r |
187 | short y1;\r |
188 | } PSXRect_t;\r |
189 | \r |
190 | /////////////////////////////////////////////////////////////////////////////\r |
191 | \r |
192 | typedef struct TWINTAG\r |
193 | {\r |
194 | PSXRect_t Position;\r |
195 | PSXRect_t OPosition;\r |
196 | PSXPoint_t TextureSize;\r |
197 | float UScaleFactor;\r |
198 | float VScaleFactor;\r |
199 | } TWin_t;\r |
200 | \r |
201 | /////////////////////////////////////////////////////////////////////////////\r |
202 | \r |
203 | typedef struct PSXDISPLAYTAG\r |
204 | {\r |
205 | PSXPoint_t DisplayModeNew;\r |
206 | PSXPoint_t DisplayMode;\r |
207 | PSXPoint_t DisplayPosition;\r |
208 | PSXPoint_t DisplayEnd;\r |
209 | \r |
210 | long Double;\r |
211 | long Height;\r |
212 | long PAL;\r |
213 | long InterlacedNew;\r |
214 | long Interlaced;\r |
215 | long InterlacedTest;\r |
216 | long RGB24New;\r |
217 | long RGB24;\r |
218 | PSXSPoint_t DrawOffset;\r |
219 | PSXRect_t DrawArea;\r |
220 | PSXPoint_t GDrawOffset;\r |
221 | PSXPoint_t CumulOffset;\r |
222 | long Disabled;\r |
223 | PSXRect_t Range;\r |
224 | } PSXDisplay_t;\r |
225 | \r |
226 | /////////////////////////////////////////////////////////////////////////////\r |
227 | \r |
228 | typedef struct OGLVertexTag \r |
229 | {\r |
230 | GLfloat x;\r |
231 | GLfloat y;\r |
232 | GLfloat z;\r |
233 | \r |
234 | GLfloat sow;\r |
235 | GLfloat tow;\r |
236 | \r |
237 | union\r |
238 | COLTAG\r |
239 | {\r |
677ea103 |
240 | unsigned char col[4];\r |
ce879073 |
241 | unsigned long lcol;\r |
242 | } c;\r |
243 | \r |
244 | } OGLVertex;\r |
245 | \r |
246 | typedef union EXShortTag\r |
247 | {\r |
677ea103 |
248 | unsigned char c[2];\r |
ce879073 |
249 | unsigned short s;\r |
250 | } EXShort;\r |
251 | \r |
252 | typedef union EXLongTag\r |
253 | {\r |
677ea103 |
254 | unsigned char c[4];\r |
ce879073 |
255 | unsigned long l;\r |
256 | EXShort s[2];\r |
257 | } EXLong;\r |
258 | \r |
259 | \r |
260 | /////////////////////////////////////////////////////////////////////////////\r |
261 | \r |
262 | #ifdef _WINDOWS\r |
263 | \r |
264 | extern HINSTANCE hInst;\r |
265 | \r |
266 | #endif\r |
267 | \r |
268 | //-----------------------------------------------------//\r |
269 | \r |
270 | #ifndef _IN_DRAW\r |
271 | \r |
272 | extern int iResX;\r |
273 | extern int iResY;\r |
274 | extern BOOL bKeepRatio;\r |
275 | extern RECT rRatioRect;\r |
276 | extern BOOL bOpaquePass;\r |
277 | extern BOOL bAdvancedBlend;\r |
278 | \r |
279 | //extern PFNGLBLENDEQU glBlendEquationEXTEx;\r |
280 | //extern PFNGLCOLORTABLEEXT glColorTableEXTEx;\r |
281 | \r |
677ea103 |
282 | extern unsigned char gl_ux[8];\r |
283 | extern unsigned char gl_vy[8];\r |
ce879073 |
284 | extern OGLVertex vertex[4];\r |
285 | extern short sprtY,sprtX,sprtH,sprtW;\r |
286 | #ifdef _WINDOWS\r |
287 | extern HWND hWWindow;\r |
288 | #endif\r |
289 | extern BOOL bIsFirstFrame;\r |
290 | extern int iWinSize;\r |
291 | extern int iZBufferDepth;\r |
292 | extern GLbitfield uiBufferBits;\r |
293 | extern int iUseMask;\r |
294 | extern int iSetMask;\r |
295 | extern int iDepthFunc;\r |
296 | extern BOOL bCheckMask;\r |
297 | extern unsigned short sSetMask;\r |
298 | extern unsigned long lSetMask;\r |
299 | extern BOOL bSetClip;\r |
300 | extern GLuint gTexScanName;\r |
301 | \r |
302 | #endif\r |
303 | \r |
304 | //-----------------------------------------------------//\r |
305 | \r |
306 | #ifndef _IN_SOFT\r |
307 | \r |
308 | extern long GlobalTextAddrX,GlobalTextAddrY,GlobalTextTP;\r |
309 | extern long GlobalTextREST,GlobalTextABR,GlobalTextPAGE;\r |
310 | extern short ly0,lx0,ly1,lx1,ly2,lx2,ly3,lx3;\r |
311 | extern short g_m1;\r |
312 | extern short g_m2;\r |
313 | extern short g_m3;\r |
314 | extern short DrawSemiTrans;\r |
315 | \r |
316 | #endif\r |
317 | \r |
318 | //-----------------------------------------------------//\r |
319 | \r |
320 | #ifndef _IN_PRIMDRAW\r |
321 | \r |
322 | extern BOOL bNeedUploadTest;\r |
323 | extern BOOL bNeedUploadAfter;\r |
324 | extern BOOL bTexEnabled;\r |
325 | extern BOOL bBlendEnable;\r |
326 | extern BOOL bDrawDither;\r |
327 | extern int iFilterType; \r |
328 | extern BOOL bFullVRam;\r |
329 | extern BOOL bUseMultiPass;\r |
330 | extern int iOffscreenDrawing;\r |
331 | extern BOOL bOldSmoothShaded;\r |
332 | extern BOOL bUsingTWin;\r |
333 | extern BOOL bUsingMovie;\r |
334 | extern PSXRect_t xrMovieArea;\r |
335 | extern PSXRect_t xrUploadArea;\r |
336 | extern PSXRect_t xrUploadAreaIL;\r |
337 | extern PSXRect_t xrUploadAreaRGB24;\r |
338 | extern GLuint gTexName;\r |
339 | extern BOOL bDrawNonShaded;\r |
340 | extern BOOL bDrawMultiPass;\r |
341 | extern GLubyte ubGloColAlpha;\r |
342 | extern GLubyte ubGloAlpha;\r |
343 | extern short sSprite_ux2;\r |
344 | extern short sSprite_vy2;\r |
345 | extern BOOL bRenderFrontBuffer;\r |
346 | extern unsigned long ulOLDCOL;\r |
347 | extern unsigned long ulClutID;\r |
677ea103 |
348 | extern void (*primTableJ[256])(unsigned char *);\r |
349 | extern void (*primTableSkip[256])(unsigned char *);\r |
ce879073 |
350 | extern unsigned short usMirror;\r |
351 | extern unsigned long dwCfgFixes;\r |
352 | extern unsigned long dwActFixes;\r |
353 | extern unsigned long dwEmuFixes;\r |
354 | extern BOOL bUseFixes;\r |
355 | extern int iSpriteTex;\r |
356 | extern int iDrawnSomething;\r |
357 | \r |
358 | extern long drawX;\r |
359 | extern long drawY;\r |
360 | extern long drawW;\r |
361 | extern long drawH;\r |
362 | extern short sxmin;\r |
363 | extern short sxmax;\r |
364 | extern short symin;\r |
365 | extern short symax;\r |
366 | \r |
2ea6b470 |
367 | extern unsigned int CSVERTEX;\r |
368 | extern unsigned int CSCOLOR;\r |
369 | extern unsigned int CSTEXTURE;\r |
370 | \r |
ce879073 |
371 | #endif\r |
372 | \r |
373 | //-----------------------------------------------------//\r |
374 | \r |
375 | #ifndef _IN_TEXTURE\r |
376 | \r |
677ea103 |
377 | extern unsigned char ubOpaqueDraw;\r |
ce879073 |
378 | extern GLint giWantedRGBA;\r |
379 | extern GLint giWantedFMT;\r |
380 | extern GLint giWantedTYPE;\r |
381 | extern void (*LoadSubTexFn) (int,int,short,short);\r |
382 | extern long GlobalTexturePage;\r |
383 | extern unsigned long (*TCF[]) (unsigned long);\r |
384 | extern unsigned short (*PTCF[]) (unsigned short);\r |
385 | extern unsigned long (*PalTexturedColourFn) (unsigned long);\r |
386 | extern BOOL bUseFastMdec;\r |
387 | extern BOOL bUse15bitMdec;\r |
388 | extern int iFrameTexType;\r |
389 | extern int iFrameReadType;\r |
390 | extern int iClampType;\r |
391 | extern int iSortTexCnt;\r |
392 | extern BOOL bFakeFrontBuffer; \r |
393 | extern GLuint gTexFrameName;\r |
394 | extern GLuint gTexBlurName;\r |
395 | extern int iVRamSize;\r |
396 | extern int iTexGarbageCollection;\r |
397 | extern int iFTexA;\r |
398 | extern int iFTexB;\r |
399 | extern BOOL bIgnoreNextTile;\r |
400 | \r |
401 | \r |
402 | #endif\r |
403 | \r |
404 | //-----------------------------------------------------//\r |
405 | \r |
406 | #ifndef _IN_GPU\r |
407 | \r |
408 | extern VRAMLoad_t VRAMWrite;\r |
409 | extern VRAMLoad_t VRAMRead;\r |
410 | extern int iDataWriteMode;\r |
411 | extern int iDataReadMode;\r |
412 | extern int iColDepth;\r |
413 | extern BOOL bChangeRes;\r |
414 | extern BOOL bWindowMode;\r |
677ea103 |
415 | extern char szDispBuf[];\r |
416 | extern char szGPUKeys[];\r |
ce879073 |
417 | extern PSXDisplay_t PSXDisplay;\r |
418 | extern PSXDisplay_t PreviousPSXDisplay;\r |
419 | //extern unsigned long ulKeybits;\r |
420 | extern TWin_t TWin;\r |
421 | extern BOOL bDisplayNotSet;\r |
422 | extern long lGPUstatusRet;\r |
423 | extern short imageX0,imageX1;\r |
424 | extern short imageY0,imageY1;\r |
425 | extern long lClearOnSwap,lClearOnSwapColor;\r |
677ea103 |
426 | extern unsigned char * psxVub;\r |
427 | extern char * psxVsb;\r |
ce879073 |
428 | extern unsigned short * psxVuw;\r |
429 | extern signed short * psxVsw;\r |
430 | extern unsigned long * psxVul;\r |
431 | extern signed long * psxVsl;\r |
432 | extern GLfloat gl_z;\r |
433 | extern BOOL bNeedRGB24Update;\r |
434 | extern BOOL bChangeWinMode;\r |
435 | extern GLuint uiScanLine;\r |
436 | extern int iUseScanLines;\r |
437 | extern long lSelectedSlot;\r |
438 | extern int iScanBlend;\r |
439 | extern BOOL bInitCap;\r |
440 | extern int iBlurBuffer;\r |
441 | extern int iLastRGB24;\r |
442 | extern int iRenderFVR;\r |
443 | extern int iNoScreenSaver;\r |
444 | extern unsigned long ulGPUInfoVals[];\r |
445 | extern BOOL bNeedInterlaceUpdate;\r |
446 | extern BOOL bNeedWriteUpload;\r |
447 | extern BOOL bSkipNextFrame;\r |
448 | \r |
449 | \r |
450 | #ifndef _WINDOWS\r |
451 | extern int bFullScreen;\r |
452 | #endif\r |
453 | \r |
454 | #endif\r |
455 | \r |
456 | //-----------------------------------------------------//\r |
457 | \r |
458 | #ifndef _IN_MENU\r |
459 | \r |
460 | //extern unsigned long dwCoreFlags;\r |
461 | extern GLuint gTexPicName;\r |
462 | //extern PSXPoint_t ptCursorPoint[];\r |
463 | //extern unsigned short usCursorActive;\r |
464 | \r |
465 | #endif\r |
466 | \r |
467 | //-----------------------------------------------------//\r |
468 | \r |
469 | #ifndef _IN_CFG\r |
470 | \r |
471 | #ifndef _WINDOWS\r |
677ea103 |
472 | extern char * pConfigFile;\r |
ce879073 |
473 | #endif\r |
474 | \r |
475 | #endif\r |
476 | \r |
477 | //-----------------------------------------------------//\r |
478 | \r |
479 | #ifndef _IN_FPS\r |
480 | \r |
481 | extern BOOL bUseFrameLimit;\r |
482 | extern BOOL bUseFrameSkip;\r |
483 | extern float fFrameRate;\r |
484 | extern float fFrameRateHz;\r |
485 | extern int iFrameLimit;\r |
486 | extern float fps_skip;\r |
487 | extern float fps_cur;\r |
488 | \r |
489 | #endif\r |
490 | \r |
491 | //-----------------------------------------------------//\r |
492 | \r |
493 | typedef struct {\r |
677ea103 |
494 | unsigned char r;\r |
495 | unsigned char g;\r |
496 | unsigned char b;\r |
497 | unsigned char a;\r |
ce879073 |
498 | } Vec4f;\r |
499 | \r |
500 | /**/\r |
501 | typedef struct {\r |
502 | float x;\r |
503 | float y;\r |
504 | float z;\r |
505 | } Vec3f;\r |
506 | \r |
507 | typedef struct {\r |
508 | float x;\r |
509 | float y;\r |
510 | } Vec2f;\r |
511 | \r |
512 | /*\r |
513 | typedef struct {\r |
514 | int x;\r |
515 | int y;\r |
516 | int z;\r |
517 | } Vec3f;\r |
518 | \r |
519 | typedef struct {\r |
520 | int x;\r |
521 | int y;\r |
522 | } Vec2f;\r |
7eadbf88 |
523 | */\r |
ce879073 |
524 | \r |
525 | typedef struct {\r |
526 | Vec3f xyz;\r |
527 | Vec2f st;\r |
528 | } Vertex;\r |
529 | \r |
530 | typedef struct {\r |
531 | Vec3f xyz;\r |
532 | Vec2f st;\r |
533 | Vec4f rgba;\r |
534 | } Vertex2;\r |
535 | \r |
536 | #ifndef _IN_KEY\r |
537 | \r |
538 | //extern unsigned long ulKeybits;\r |
539 | \r |
540 | #endif\r |
541 | \r |
542 | //-----------------------------------------------------//\r |
543 | \r |
544 | #ifndef _IN_ZN\r |
545 | \r |
546 | extern unsigned long dwGPUVersion;\r |
547 | extern int iGPUHeight;\r |
548 | extern int iGPUHeightMask;\r |
549 | extern int GlobalTextIL;\r |
550 | extern int iTileCheat;\r |
551 | \r |
552 | #endif\r |
553 | \r |
554 | #ifdef __cplusplus\r |
555 | }\r |
556 | #endif\r |
557 | \r |
558 | \r |
559 | #endif\r |
560 | \r |
561 | //-----------------------------------------------------//\r |