libretro: handle regions
[pcsx_rearmed.git] / plugins / gpu-gles / gpuExternals.h
CommitLineData
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
33extern "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
50extern 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
147typedef 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
159typedef 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
170typedef struct PSXPOINTTAG\r
171{\r
172 long x;\r
173 long y;\r
174} PSXPoint_t;\r
175\r
176typedef struct PSXSPOINTTAG\r
177{\r
178 short x;\r
179 short y;\r
180} PSXSPoint_t;\r
181\r
182typedef 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
192typedef 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
203typedef 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
228typedef 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
238COLTAG\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
246typedef union EXShortTag\r
247{\r
677ea103 248 unsigned char c[2];\r
ce879073 249 unsigned short s;\r
250} EXShort;\r
251\r
252typedef 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
264extern HINSTANCE hInst;\r
265\r
266#endif\r
267 \r
268//-----------------------------------------------------//\r
269\r
270#ifndef _IN_DRAW\r
271\r
272extern int iResX;\r
273extern int iResY;\r
274extern BOOL bKeepRatio;\r
275extern RECT rRatioRect;\r
276extern BOOL bOpaquePass;\r
277extern BOOL bAdvancedBlend;\r
278\r
279//extern PFNGLBLENDEQU glBlendEquationEXTEx;\r
280//extern PFNGLCOLORTABLEEXT glColorTableEXTEx;\r
281\r
677ea103 282extern unsigned char gl_ux[8];\r
283extern unsigned char gl_vy[8];\r
ce879073 284extern OGLVertex vertex[4];\r
285extern short sprtY,sprtX,sprtH,sprtW;\r
286#ifdef _WINDOWS\r
287extern HWND hWWindow;\r
288#endif\r
289extern BOOL bIsFirstFrame;\r
290extern int iWinSize;\r
291extern int iZBufferDepth;\r
292extern GLbitfield uiBufferBits;\r
293extern int iUseMask;\r
294extern int iSetMask;\r
295extern int iDepthFunc;\r
296extern BOOL bCheckMask;\r
297extern unsigned short sSetMask;\r
298extern unsigned long lSetMask;\r
299extern BOOL bSetClip;\r
300extern GLuint gTexScanName;\r
301\r
302#endif\r
303\r
304//-----------------------------------------------------//\r
305\r
306#ifndef _IN_SOFT\r
307\r
308extern long GlobalTextAddrX,GlobalTextAddrY,GlobalTextTP;\r
309extern long GlobalTextREST,GlobalTextABR,GlobalTextPAGE;\r
310extern short ly0,lx0,ly1,lx1,ly2,lx2,ly3,lx3;\r
311extern short g_m1;\r
312extern short g_m2;\r
313extern short g_m3;\r
314extern short DrawSemiTrans;\r
315\r
316#endif\r
317\r
318//-----------------------------------------------------//\r
319\r
320#ifndef _IN_PRIMDRAW\r
321\r
322extern BOOL bNeedUploadTest;\r
323extern BOOL bNeedUploadAfter;\r
324extern BOOL bTexEnabled;\r
325extern BOOL bBlendEnable;\r
326extern BOOL bDrawDither;\r
327extern int iFilterType; \r
328extern BOOL bFullVRam;\r
329extern BOOL bUseMultiPass;\r
330extern int iOffscreenDrawing;\r
331extern BOOL bOldSmoothShaded;\r
332extern BOOL bUsingTWin;\r
333extern BOOL bUsingMovie;\r
334extern PSXRect_t xrMovieArea;\r
335extern PSXRect_t xrUploadArea;\r
336extern PSXRect_t xrUploadAreaIL;\r
337extern PSXRect_t xrUploadAreaRGB24;\r
338extern GLuint gTexName;\r
339extern BOOL bDrawNonShaded;\r
340extern BOOL bDrawMultiPass;\r
341extern GLubyte ubGloColAlpha;\r
342extern GLubyte ubGloAlpha;\r
343extern short sSprite_ux2;\r
344extern short sSprite_vy2;\r
345extern BOOL bRenderFrontBuffer;\r
346extern unsigned long ulOLDCOL;\r
347extern unsigned long ulClutID;\r
677ea103 348extern void (*primTableJ[256])(unsigned char *);\r
349extern void (*primTableSkip[256])(unsigned char *);\r
ce879073 350extern unsigned short usMirror;\r
351extern unsigned long dwCfgFixes;\r
352extern unsigned long dwActFixes;\r
353extern unsigned long dwEmuFixes;\r
354extern BOOL bUseFixes;\r
355extern int iSpriteTex;\r
356extern int iDrawnSomething;\r
357\r
358extern long drawX;\r
359extern long drawY;\r
360extern long drawW;\r
361extern long drawH;\r
362extern short sxmin;\r
363extern short sxmax;\r
364extern short symin;\r
365extern short symax;\r
366\r
2ea6b470 367extern unsigned int CSVERTEX;\r
368extern unsigned int CSCOLOR;\r
369extern unsigned int CSTEXTURE;\r
370\r
ce879073 371#endif\r
372\r
373//-----------------------------------------------------//\r
374\r
375#ifndef _IN_TEXTURE\r
376\r
677ea103 377extern unsigned char ubOpaqueDraw;\r
ce879073 378extern GLint giWantedRGBA;\r
379extern GLint giWantedFMT;\r
380extern GLint giWantedTYPE;\r
381extern void (*LoadSubTexFn) (int,int,short,short);\r
382extern long GlobalTexturePage;\r
383extern unsigned long (*TCF[]) (unsigned long);\r
384extern unsigned short (*PTCF[]) (unsigned short);\r
385extern unsigned long (*PalTexturedColourFn) (unsigned long);\r
386extern BOOL bUseFastMdec;\r
387extern BOOL bUse15bitMdec;\r
388extern int iFrameTexType;\r
389extern int iFrameReadType;\r
390extern int iClampType;\r
391extern int iSortTexCnt;\r
392extern BOOL bFakeFrontBuffer; \r
393extern GLuint gTexFrameName;\r
394extern GLuint gTexBlurName;\r
395extern int iVRamSize;\r
396extern int iTexGarbageCollection;\r
397extern int iFTexA;\r
398extern int iFTexB;\r
399extern BOOL bIgnoreNextTile;\r
400\r
401\r
402#endif\r
403\r
404//-----------------------------------------------------//\r
405\r
406#ifndef _IN_GPU\r
407\r
408extern VRAMLoad_t VRAMWrite;\r
409extern VRAMLoad_t VRAMRead;\r
410extern int iDataWriteMode;\r
411extern int iDataReadMode;\r
412extern int iColDepth;\r
413extern BOOL bChangeRes;\r
414extern BOOL bWindowMode;\r
677ea103 415extern char szDispBuf[];\r
416extern char szGPUKeys[];\r
ce879073 417extern PSXDisplay_t PSXDisplay;\r
418extern PSXDisplay_t PreviousPSXDisplay;\r
419//extern unsigned long ulKeybits;\r
420extern TWin_t TWin;\r
421extern BOOL bDisplayNotSet;\r
422extern long lGPUstatusRet;\r
423extern short imageX0,imageX1;\r
424extern short imageY0,imageY1;\r
425extern long lClearOnSwap,lClearOnSwapColor;\r
677ea103 426extern unsigned char * psxVub;\r
427extern char * psxVsb;\r
ce879073 428extern unsigned short * psxVuw;\r
429extern signed short * psxVsw;\r
430extern unsigned long * psxVul;\r
431extern signed long * psxVsl;\r
432extern GLfloat gl_z;\r
433extern BOOL bNeedRGB24Update;\r
434extern BOOL bChangeWinMode;\r
435extern GLuint uiScanLine;\r
436extern int iUseScanLines;\r
437extern long lSelectedSlot;\r
438extern int iScanBlend;\r
439extern BOOL bInitCap;\r
440extern int iBlurBuffer;\r
441extern int iLastRGB24;\r
442extern int iRenderFVR;\r
443extern int iNoScreenSaver;\r
444extern unsigned long ulGPUInfoVals[];\r
445extern BOOL bNeedInterlaceUpdate;\r
446extern BOOL bNeedWriteUpload;\r
447extern BOOL bSkipNextFrame;\r
448\r
449\r
450#ifndef _WINDOWS\r
451extern 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
461extern 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 472extern 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
481extern BOOL bUseFrameLimit;\r
482extern BOOL bUseFrameSkip;\r
483extern float fFrameRate;\r
484extern float fFrameRateHz;\r
485extern int iFrameLimit;\r
486extern float fps_skip;\r
487extern float fps_cur;\r
488\r
489#endif\r
490\r
491//-----------------------------------------------------//\r
492\r
493typedef struct {\r
677ea103 494unsigned char r;\r
495unsigned char g;\r
496unsigned char b;\r
497unsigned char a;\r
ce879073 498} Vec4f;\r
499\r
500/**/\r
501typedef struct {\r
502float x;\r
503float y;\r
504float z;\r
505} Vec3f;\r
506\r
507typedef struct {\r
508float x;\r
509float y;\r
510} Vec2f;\r
511\r
512/*\r
513typedef struct {\r
514int x;\r
515int y;\r
516int z;\r
517} Vec3f;\r
518\r
519typedef struct {\r
520int x;\r
521int y;\r
522} Vec2f;\r
7eadbf88 523*/\r
ce879073 524\r
525typedef struct {\r
526 Vec3f xyz;\r
527 Vec2f st;\r
528} Vertex;\r
529\r
530typedef 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
546extern unsigned long dwGPUVersion;\r
547extern int iGPUHeight;\r
548extern int iGPUHeightMask;\r
549extern int GlobalTextIL;\r
550extern 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