gpu-gles: schtruck/fpse merge: remove windows code
[pcsx_rearmed.git] / plugins / gpu-gles / gpuPrim.c
index 9b718a5..37db052 100644 (file)
 \r
 #define _IN_PRIMDRAW\r
 \r
-#ifdef _WINDOWS\r
-#include "stdafx.h"\r
-#include "externals.h"\r
-#include "gpu.h"\r
-#include "draw.h"\r
-#include "texture.h"\r
-#else\r
 #include "gpuStdafx.h"\r
 #include "gpuExternals.h"\r
 #include "gpuPlugin.h"\r
@@ -40,8 +33,6 @@
 #include "gpuTexture.h"\r
 #include "gpuPrim.h"\r
 \r
-#endif\r
-\r
 ////////////////////////////////////////////////////////////////////////                                          \r
 // defines\r
 ////////////////////////////////////////////////////////////////////////\r
 // globals\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-#ifndef _WINDOWS\r
 EGLSurface surface;\r
 EGLDisplay display;\r
-#endif\r
+\r
 \r
 BOOL           bDrawTextured;                          // current active drawing states\r
 BOOL           bDrawSmoothShaded;\r
@@ -146,66 +136,6 @@ void UpdateGlobalTP(unsigned short gdata)
 // Some ASM color convertion... Lewpy's special...\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-#ifdef _WINDOWS\r
-#pragma warning  (disable : 4035)\r
-\r
-unsigned long DoubleBGR2RGB (unsigned long BGR)\r
-{\r
-\r
-    __asm\r
-    {\r
-        mov eax, BGR                /* this can hold the G value */\r
-        mov ebx, eax                /* this can hold the R value */\r
-        mov edx, eax                /* this can hold the B value */\r
-        and ebx, 000000ffh          /* mask the R value */\r
-        shl ebx, 1\r
-        test ebx, 00000100h\r
-        jz    RSKIP\r
-        mov ebx, 000000ffh\r
-\r
-RSKIP: \r
-        and eax, 0000ff00h          /* mask the G value */\r
-        shl eax, 1\r
-        test eax, 00010000h\r
-        jz    GSKIP\r
-        mov eax, 0000ff00h\r
-\r
-GSKIP: \r
-        and edx, 00ff0000h          /* mask the B value */\r
-        shl edx, 1\r
-        test edx, 01000000h\r
-        jz    BSKIP\r
-        mov edx, 00ff0000h\r
-        \r
-BSKIP: \r
-        or  eax, ebx                /* add R to G value */\r
-        or  eax, edx                /* add B to RG value */\r
-    }\r
-    /* Result returned in EAX */\r
-}\r
-\r
-unsigned short BGR24to16 (unsigned long BGR)\r
-{\r
-    __asm\r
-    {\r
-        mov eax, BGR                /* this can hold the G value */\r
-        mov ebx, eax                /* this can hold the R value */\r
-        mov edx, eax                /* this can hold the B value */\r
-        shr ebx, 3                  /* move the R value */\r
-        and edx, 00f80000h          /* mask the B value */\r
-        shr edx, 9                  /* move the B value */\r
-        and eax, 00f800h            /* mask the G value */\r
-        shr eax, 6                  /* move the G value */\r
-        and ebx, 0000001fh          /* mask the R value */\r
-        or  eax, ebx                /* add R to G value */\r
-        or  eax, edx                /* add B to RG value */\r
-    }\r
-    /* Result returned in AX */\r
-}\r
-\r
-#pragma warning  (default : 4035)\r
-\r
-#else\r
 \r
 unsigned long DoubleBGR2RGB (unsigned long BGR)\r
 {\r
@@ -228,13 +158,12 @@ unsigned short BGR24to16 (unsigned long BGR)
  return ((BGR>>3)&0x1f)|((BGR&0xf80000)>>9)|((BGR&0xf800)>>6);\r
 }\r
 \r
-#endif\r
 \r
 ////////////////////////////////////////////////////////////////////////\r
 // OpenGL primitive drawing commands\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-__inline void PRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2, \r
+void PRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2,\r
                                    OGLVertex* vertex3, OGLVertex* vertex4) \r
 {\r
 \r
@@ -1514,7 +1443,7 @@ void PrepareFullScreenUpload (long Position)
 ////////////////////////////////////////////////////////////////////////\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-u8 * LoadDirectMovieFast(void);\r
+unsigned char * LoadDirectMovieFast(void);\r
 \r
 void UploadScreenEx(long Position)\r
 {\r
@@ -1745,7 +1674,7 @@ BOOL IsInsideNextScreen(short x, short y, short xoff, short yoff)
 //Mask1    Set mask bit while drawing. 1 = on\r
 //Mask2    Do not draw to mask areas. 1= on\r
 \r
-void cmdSTP(u8 * baseAddr)\r
+void cmdSTP(unsigned char * baseAddr)\r
 {\r
  unsigned long gdata = ((unsigned long*)baseAddr)[0];\r
 \r
@@ -1778,7 +1707,7 @@ void cmdSTP(u8 * baseAddr)
 // cmd: Set texture page infos\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void cmdTexturePage(u8 * baseAddr)\r
+void cmdTexturePage(unsigned char * baseAddr)\r
 {\r
  unsigned long gdata = ((unsigned long*)baseAddr)[0];\r
  UpdateGlobalTP((unsigned short)gdata);\r
@@ -1789,7 +1718,7 @@ void cmdTexturePage(u8 * baseAddr)
 // cmd: turn on/off texture window\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void cmdTextureWindow(u8 *baseAddr)\r
+void cmdTextureWindow(unsigned char *baseAddr)\r
 {\r
  unsigned long gdata = ((unsigned long*)baseAddr)[0];\r
 \r
@@ -1998,7 +1927,7 @@ void ClampToPSXScreenOffset(short *x0, short *y0, short *x1, short *y1)
 // cmd: start of drawing area... primitives will be clipped inside\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void cmdDrawAreaStart(u8 * baseAddr)\r
+void cmdDrawAreaStart(unsigned char * baseAddr)\r
 {\r
  unsigned long gdata = ((unsigned long*)baseAddr)[0];\r
 \r
@@ -2029,7 +1958,7 @@ void cmdDrawAreaStart(u8 * baseAddr)
 // cmd: end of drawing area... primitives will be clipped inside\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void cmdDrawAreaEnd(u8 * baseAddr)\r
+void cmdDrawAreaEnd(unsigned char * baseAddr)\r
 {\r
  unsigned long gdata = ((unsigned long*)baseAddr)[0];\r
 \r
@@ -2064,7 +1993,7 @@ void cmdDrawAreaEnd(u8 * baseAddr)
 // cmd: draw offset... will be added to prim coords\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void cmdDrawOffset(u8 * baseAddr)\r
+void cmdDrawOffset(unsigned char * baseAddr)\r
 {\r
  unsigned long gdata = ((unsigned long*)baseAddr)[0];\r
 \r
@@ -2095,7 +2024,7 @@ void cmdDrawOffset(u8 * baseAddr)
 // cmd: load image to vram\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primLoadImage(u8 * baseAddr)\r
+void primLoadImage(unsigned char * baseAddr)\r
 {\r
  unsigned short *sgpuData = ((unsigned short *) baseAddr);\r
 \r
@@ -2252,7 +2181,7 @@ void CheckWriteUpdate()
 // cmd: vram -> psx mem\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primStoreImage(u8 * baseAddr)\r
+void primStoreImage(unsigned char * baseAddr)\r
 {\r
  unsigned short *sgpuData = ((unsigned short *) baseAddr);\r
 \r
@@ -2274,7 +2203,7 @@ void primStoreImage(u8 * baseAddr)
 // cmd: blkfill - NO primitive! Doesn't care about draw areas...\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primBlkFill(u8 * baseAddr)\r
+void primBlkFill(unsigned char * baseAddr)\r
 {\r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -2471,7 +2400,7 @@ void MoveImageWrapped(short imageX0,short imageY0,
 \r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primMoveImage(u8 * baseAddr)\r
+void primMoveImage(unsigned char * baseAddr)\r
 {\r
  short *sgpuData = ((short *) baseAddr);\r
  short imageY0,imageX0,imageY1,imageX1,imageSX,imageSY,i,j;\r
@@ -2630,7 +2559,7 @@ void primMoveImage(u8 * baseAddr)
 // cmd: draw free-size Tile \r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primTileS(u8 * baseAddr)\r
+void primTileS(unsigned char * baseAddr)\r
 {\r
  unsigned long *gpuData = ((unsigned long*)baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -2695,7 +2624,7 @@ void primTileS(u8 * baseAddr)
 // cmd: draw 1 dot Tile (point)\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primTile1(u8 * baseAddr)\r
+void primTile1(unsigned char * baseAddr)\r
 {\r
  unsigned long *gpuData = ((unsigned long*)baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -2742,7 +2671,7 @@ void primTile1(u8 * baseAddr)
 // cmd: draw 8 dot Tile (small rect)\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primTile8(u8 * baseAddr)\r
+void primTile8(unsigned char * baseAddr)\r
 {\r
  unsigned long *gpuData = ((unsigned long*)baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -2789,7 +2718,7 @@ void primTile8(u8 * baseAddr)
 // cmd: draw 16 dot Tile (medium rect)\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primTile16(u8 * baseAddr)\r
+void primTile16(unsigned char * baseAddr)\r
 {\r
  unsigned long *gpuData = ((unsigned long*)baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -2900,7 +2829,7 @@ void DrawMultiFilterSprite(void)
 // cmd: small sprite (textured rect)\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primSprt8(u8 * baseAddr)\r
+void primSprt8(unsigned char * baseAddr)\r
 {\r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -3021,7 +2950,7 @@ void primSprt8(u8 * baseAddr)
 // cmd: medium sprite (textured rect)\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primSprt16(u8 * baseAddr)\r
+void primSprt16(unsigned char * baseAddr)\r
 {\r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -3141,7 +3070,7 @@ void primSprt16(u8 * baseAddr)
 // cmd: free-size sprite (textured rect)\r
 ////////////////////////////////////////////////////////////////////////\r
  \r
-void primSprtSRest(u8 * baseAddr,unsigned short type)\r
+void primSprtSRest(unsigned char * baseAddr,unsigned short type)\r
 {\r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -3312,7 +3241,7 @@ void primSprtSRest(u8 * baseAddr,unsigned short type)
   }\r
 }\r
 \r
-void primSprtS(u8 * baseAddr)\r
+void primSprtS(unsigned char * baseAddr)\r
 {\r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -3451,7 +3380,7 @@ void primSprtS(u8 * baseAddr)
 // cmd: flat shaded Poly4\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primPolyF4(u8 *baseAddr)\r
+void primPolyF4(unsigned char *baseAddr)\r
 {\r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -3496,7 +3425,7 @@ void primPolyF4(u8 *baseAddr)
 // cmd: smooth shaded Poly4\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primPolyG4(u8 * baseAddr);\r
+void primPolyG4(unsigned char * baseAddr);\r
 \r
 BOOL bDrawOffscreenFrontFF9G4(void)\r
 {\r
@@ -3519,9 +3448,9 @@ BOOL bDrawOffscreenFrontFF9G4(void)
  return TRUE;\r
 }\r
 \r
-BOOL bCheckFF9G4(u8 * baseAddr)\r
+BOOL bCheckFF9G4(unsigned char * baseAddr)\r
 {\r
- static u8 pFF9G4Cache[32];\r
+ static unsigned char pFF9G4Cache[32];\r
  static int iFF9Fix=0;\r
 \r
  if(baseAddr)\r
@@ -3560,7 +3489,7 @@ BOOL bCheckFF9G4(u8 * baseAddr)
 \r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primPolyG4(u8 * baseAddr)\r
+void primPolyG4(unsigned char * baseAddr)\r
 {\r
  unsigned long *gpuData = (unsigned long *)baseAddr;\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -3778,7 +3707,7 @@ BOOL DoLineCheck(unsigned long * gpuData)
 \r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primPolyFT3(u8 * baseAddr)\r
+void primPolyFT3(unsigned char * baseAddr)\r
 {\r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -4214,7 +4143,7 @@ void RectTexAlign(void)
 \r
 }\r
 \r
-void primPolyFT4(u8 * baseAddr)\r
+void primPolyFT4(unsigned char * baseAddr)\r
 {\r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -4302,7 +4231,7 @@ void primPolyFT4(u8 * baseAddr)
 // cmd: smooth shaded Texture3\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primPolyGT3(u8 *baseAddr)\r
+void primPolyGT3(unsigned char *baseAddr)\r
 {    \r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -4411,7 +4340,7 @@ void primPolyGT3(u8 *baseAddr)
 // cmd: smooth shaded Poly3\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primPolyG3(u8 *baseAddr)\r
+void primPolyG3(unsigned char *baseAddr)\r
 {    \r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -4456,7 +4385,7 @@ void primPolyG3(u8 *baseAddr)
 // cmd: smooth shaded Texture4\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primPolyGT4(u8 *baseAddr)\r
+void primPolyGT4(unsigned char *baseAddr)\r
 { \r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -4576,7 +4505,7 @@ void primPolyGT4(u8 *baseAddr)
 // cmd: smooth shaded Poly3\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primPolyF3(u8 *baseAddr)\r
+void primPolyF3(unsigned char *baseAddr)\r
 {    \r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -4620,7 +4549,7 @@ void primPolyF3(u8 *baseAddr)
 // cmd: skipping shaded polylines\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primLineGSkip(u8 *baseAddr)\r
+void primLineGSkip(unsigned char *baseAddr)\r
 {    \r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -4645,7 +4574,7 @@ void primLineGSkip(u8 *baseAddr)
 // cmd: shaded polylines\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primLineGEx(u8 *baseAddr)\r
+void primLineGEx(unsigned char *baseAddr)\r
 {    \r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  int iMax=255;\r
@@ -4709,7 +4638,7 @@ void primLineGEx(u8 *baseAddr)
 // cmd: shaded polyline2\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primLineG2(u8 *baseAddr)\r
+void primLineG2(unsigned char *baseAddr)\r
 {    \r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -4754,7 +4683,7 @@ void primLineG2(u8 *baseAddr)
 // cmd: skipping flat polylines\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primLineFSkip(u8 *baseAddr)\r
+void primLineFSkip(unsigned char *baseAddr)\r
 {\r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  int i=2,iMax=255;\r
@@ -4774,7 +4703,7 @@ void primLineFSkip(u8 *baseAddr)
 // cmd: drawing flat polylines\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primLineFEx(u8 *baseAddr)\r
+void primLineFEx(unsigned char *baseAddr)\r
 {\r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  int iMax;\r
@@ -4832,7 +4761,7 @@ void primLineFEx(u8 *baseAddr)
 // cmd: drawing flat polyline2\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primLineF2(u8 *baseAddr)\r
+void primLineF2(unsigned char *baseAddr)\r
 {\r
  unsigned long *gpuData = ((unsigned long *) baseAddr);\r
  short *sgpuData = ((short *) baseAddr);\r
@@ -4873,7 +4802,7 @@ void primLineF2(u8 *baseAddr)
 // cmd: well, easiest command... not implemented\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void primNI(u8 *bA)\r
+void primNI(unsigned char *bA)\r
 {\r
 }\r
 \r
@@ -4881,7 +4810,7 @@ void primNI(u8 *bA)
 // cmd func ptr table\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void (*primTableJ[256])(u8 *) = \r
+void (*primTableJ[256])(unsigned char *) = \r
 {\r
     // 00\r
     primNI,primNI,primBlkFill,primNI,primNI,primNI,primNI,primNI,\r
@@ -4953,7 +4882,7 @@ void (*primTableJ[256])(u8 *) =
 // cmd func ptr table for skipping\r
 ////////////////////////////////////////////////////////////////////////\r
 \r
-void (*primTableSkip[256])(u8 *) = \r
+void (*primTableSkip[256])(unsigned char *) = \r
 {\r
     // 00\r
     primNI,primNI,primBlkFill,primNI,primNI,primNI,primNI,primNI,\r