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