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