1 /***************************************************************************
\r
2 external.h - description
\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
9 /***************************************************************************
\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
17 ***************************************************************************/
\r
19 //*************************************************************************//
\r
20 // History of changes:
\r
22 // 2009/03/08 - Pete
\r
23 // - generic cleanup for the Peops release
\r
25 //*************************************************************************//
\r
27 /////////////////////////////////////////////////////////////////////////////
\r
40 #include <GLES/gl.h>
\r
41 #include <GLES/glext.h>
\r
45 #define GL_BGRA_EXT GL_RGBA // ??
\r
49 #define glTexParameteri(x,y,z) glTexParameterf(x,y,z)
\r
50 #define glAlphaFuncx(x,y) glAlphaFunc(x,y)
\r
54 extern void ( APIENTRY * glPixelStorei )(GLenum pname, GLint param);
\r
58 #define MIRROR_TEST 1
\r
60 /////////////////////////////////////////////////////////////////////////////
\r
62 #define SCISSOR_TEST 1
\r
64 /////////////////////////////////////////////////////////////////////////////
\r
66 // for own sow/tow scaling
\r
69 /////////////////////////////////////////////////////////////////////////////
\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
77 #define INFO_DRAWSTART 1
\r
78 #define INFO_DRAWEND 2
\r
79 #define INFO_DRAWOFF 3
\r
81 #define SIGNSHIFT 21
\r
82 #define CHKMAX_X 1024
\r
83 #define CHKMAX_Y 512
\r
85 /////////////////////////////////////////////////////////////////////////////
\r
87 // GPU STATUS REGISTER bit values (c) Lewpy
\r
90 #define DR_VRAMTRANSFER 1
\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
108 #define STATUSREG lGPUstatusRet
\r
110 #define GPUIsBusy (STATUSREG &= ~GPUSTATUS_IDLE)
\r
111 #define GPUIsIdle (STATUSREG |= GPUSTATUS_IDLE)
\r
113 #define GPUIsNotReadyForCommands (STATUSREG &= ~GPUSTATUS_READYFORCOMMANDS)
\r
114 #define GPUIsReadyForCommands (STATUSREG |= GPUSTATUS_READYFORCOMMANDS)
\r
116 /////////////////////////////////////////////////////////////////////////////
\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
129 /////////////////////////////////////////////////////////////////////////////
\r
130 // Linux is missing some stuff, eh? ;)
\r
140 #define BOOL unsigned short
\r
143 #define bool unsigned short
\r
145 #define LOWORD(l) ((unsigned short)(l))
\r
146 #define HIWORD(l) ((unsigned short)(((unsigned int)(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 int
\r
151 typedef struct RECTTAG
\r
161 /////////////////////////////////////////////////////////////////////////////
\r
163 typedef struct VRAMLOADTAG
\r
169 short RowsRemaining;
\r
170 short ColsRemaining;
\r
171 unsigned short *ImagePtr;
\r
174 typedef struct PSXPOINTTAG
\r
180 typedef struct PSXSPOINTTAG
\r
186 typedef struct PSXRECTTAG
\r
194 /////////////////////////////////////////////////////////////////////////////
\r
196 typedef struct TWINTAG
\r
198 PSXRect_t Position;
\r
199 PSXRect_t OPosition;
\r
200 PSXPoint_t TextureSize;
\r
201 float UScaleFactor;
\r
202 float VScaleFactor;
\r
205 /////////////////////////////////////////////////////////////////////////////
\r
207 typedef struct PSXDISPLAYTAG
\r
209 PSXPoint_t DisplayModeNew;
\r
210 PSXPoint_t DisplayMode;
\r
211 PSXPoint_t DisplayPosition;
\r
212 PSXPoint_t DisplayEnd;
\r
219 int InterlacedTest;
\r
222 PSXSPoint_t DrawOffset;
\r
223 PSXRect_t DrawArea;
\r
224 PSXPoint_t GDrawOffset;
\r
225 PSXPoint_t CumulOffset;
\r
230 /////////////////////////////////////////////////////////////////////////////
\r
232 typedef struct OGLVertexTag
\r
244 unsigned char col[4];
\r
250 typedef union EXShortTag
\r
252 unsigned char c[2];
\r
256 typedef union EXLongTag
\r
258 unsigned char c[4];
\r
264 /////////////////////////////////////////////////////////////////////////////
\r
268 extern HINSTANCE hInst;
\r
272 //-----------------------------------------------------//
\r
278 extern BOOL bKeepRatio;
\r
279 extern RECT rRatioRect;
\r
280 extern BOOL bOpaquePass;
\r
281 extern BOOL bAdvancedBlend;
\r
283 //extern PFNGLBLENDEQU glBlendEquationEXTEx;
\r
284 //extern PFNGLCOLORTABLEEXT glColorTableEXTEx;
\r
286 extern unsigned char gl_ux[8];
\r
287 extern unsigned char gl_vy[8];
\r
288 extern OGLVertex vertex[4];
\r
289 extern short sprtY,sprtX,sprtH,sprtW;
\r
291 //extern HWND hWWindow;
\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 int lSetMask;
\r
303 extern BOOL bSetClip;
\r
304 extern GLuint gTexScanName;
\r
308 //-----------------------------------------------------//
\r
312 extern int GlobalTextAddrX,GlobalTextAddrY,GlobalTextTP;
\r
313 extern int GlobalTextREST,GlobalTextABR,GlobalTextPAGE;
\r
314 extern short ly0,lx0,ly1,lx1,ly2,lx2,ly3,lx3;
\r
318 extern short DrawSemiTrans;
\r
322 //-----------------------------------------------------//
\r
324 #ifndef _IN_PRIMDRAW
\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 int ulOLDCOL;
\r
351 extern unsigned int ulClutID;
\r
352 extern void (*primTableJ[256])(unsigned char *);
\r
353 extern void (*primTableSkip[256])(unsigned char *);
\r
354 extern unsigned short usMirror;
\r
355 extern unsigned int dwCfgFixes;
\r
356 extern unsigned int dwActFixes;
\r
357 extern unsigned int dwEmuFixes;
\r
358 extern BOOL bUseFixes;
\r
359 extern int iSpriteTex;
\r
360 extern int iDrawnSomething;
\r
366 extern short sxmin;
\r
367 extern short sxmax;
\r
368 extern short symin;
\r
369 extern short symax;
\r
371 extern unsigned int CSVERTEX;
\r
372 extern unsigned int CSCOLOR;
\r
373 extern unsigned int CSTEXTURE;
\r
377 //-----------------------------------------------------//
\r
379 #ifndef _IN_TEXTURE
\r
381 extern unsigned char ubOpaqueDraw;
\r
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 int GlobalTexturePage;
\r
387 extern unsigned int (*TCF[]) (unsigned int );
\r
388 extern unsigned short (*PTCF[]) (unsigned short);
\r
389 extern unsigned int (*PalTexturedColourFn) (unsigned int);
\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
403 extern BOOL bIgnoreNextTile;
\r
408 //-----------------------------------------------------//
\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
419 extern char szDispBuf[];
\r
420 extern char szGPUKeys[];
\r
421 extern PSXDisplay_t PSXDisplay;
\r
422 extern PSXDisplay_t PreviousPSXDisplay;
\r
423 //extern unsigned int ulKeybits;
\r
424 extern TWin_t TWin;
\r
425 extern BOOL bDisplayNotSet;
\r
426 extern int lGPUstatusRet;
\r
427 extern short imageX0,imageX1;
\r
428 extern short imageY0,imageY1;
\r
429 extern int lClearOnSwap,lClearOnSwapColor;
\r
430 extern unsigned char * psxVub;
\r
431 extern char * psxVsb;
\r
432 extern unsigned short * psxVuw;
\r
433 extern signed short * psxVsw;
\r
434 extern unsigned int * psxVul;
\r
435 extern signed int * 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 int 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 int ulGPUInfoVals[];
\r
449 extern BOOL bNeedInterlaceUpdate;
\r
450 extern BOOL bNeedWriteUpload;
\r
451 extern BOOL bSkipNextFrame;
\r
455 extern int bFullScreen;
\r
460 //-----------------------------------------------------//
\r
464 //extern unsigned int dwCoreFlags;
\r
465 extern GLuint gTexPicName;
\r
466 //extern PSXPoint_t ptCursorPoint[];
\r
467 //extern unsigned short usCursorActive;
\r
471 //-----------------------------------------------------//
\r
476 extern char * pConfigFile;
\r
481 //-----------------------------------------------------//
\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
495 //-----------------------------------------------------//
\r
542 //extern unsigned int ulKeybits;
\r
546 //-----------------------------------------------------//
\r
550 extern unsigned int dwGPUVersion;
\r
551 extern int iGPUHeight;
\r
552 extern int iGPUHeightMask;
\r
553 extern int GlobalTextIL;
\r
554 extern int iTileCheat;
\r
565 //-----------------------------------------------------//
\r