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