X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fgpu-gles%2FgpuPlugin.c;h=9d749a5d924e488022d532df3fb03a19e38cd2fd;hp=d6e6fbb24c6c28a6745d9a70123833967ea01b68;hb=b243416b907e6ce366b051e77ed8a434f7668d5d;hpb=7eadbf885fc9ebd271fa0d7bce3f27394488b059 diff --git a/plugins/gpu-gles/gpuPlugin.c b/plugins/gpu-gles/gpuPlugin.c index d6e6fbb2..9d749a5d 100644 --- a/plugins/gpu-gles/gpuPlugin.c +++ b/plugins/gpu-gles/gpuPlugin.c @@ -27,25 +27,8 @@ //#include "gpuStdafx.h" //#include - #define _IN_GPU -#ifdef _WINDOWS -#include "stdafx.h" -#include -#include -#include -#include -#include - -#include "externals.h" -#include "gpu.h" -#include "draw.h" -#include "prim.h" -#include "texture.h" -#include "fps.h" -#include "resource.h" -#else #include #include #include @@ -60,10 +43,7 @@ //#include "NoPic.h" #include "gpuStdafx.h" -#endif -extern void ProcessEvents(); - short g_m1=255,g_m2=255,g_m3=255; short DrawSemiTrans=FALSE; short Ymin; @@ -83,8 +63,8 @@ int iTileCheat=0; // memory image of the PSX vram //////////////////////////////////////////////////////////////////////// -u8 *psxVSecure; -u8 *psxVub; +unsigned char *psxVSecure; +unsigned char *psxVub; signed char *psxVsb; unsigned short *psxVuw; unsigned short *psxVuw_eom; @@ -100,10 +80,6 @@ BOOL bNeedInterlaceUpdate=FALSE; BOOL bNeedRGB24Update=FALSE; BOOL bChangeWinMode=FALSE; -#ifdef _WINDOWS -extern HGLRC GLCONTEXT; -#endif - unsigned long ulStatusControl[256]; //////////////////////////////////////////////////////////////////////// @@ -112,10 +88,10 @@ unsigned long ulStatusControl[256]; static long GPUdataRet; long lGPUstatusRet; -s8 szDispBuf[64]; +char szDispBuf[64]; static unsigned long gpuDataM[256]; -static u8 gpuCommand = 0; +static unsigned char gpuCommand = 0; static long gpuDataC = 0; static long gpuDataP = 0; @@ -144,7 +120,7 @@ BOOL bDisplayNotSet = TRUE; GLuint uiScanLine=0; int iUseScanLines=0; long lSelectedSlot=0; -u8 * pGfxCardScreen=0; +unsigned char * pGfxCardScreen=0; int iBlurBuffer=0; int iScanBlend=0; int iRenderFVR=0; @@ -154,27 +130,13 @@ int iFakePrimBusy = 0; int iRumbleVal = 0; int iRumbleTime = 0; +static void (*rearmed_get_layer_pos)(int *x, int *y, int *w, int *h); +static void flipEGL(void); + //////////////////////////////////////////////////////////////////////// // stuff to make this a true PDK module //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS -s8 * CALLBACK PSEgetLibName(void) -{ - return "name"; -} - -unsigned long CALLBACK PSEgetLibType(void) -{ - return 1; -} - -unsigned long CALLBACK PSEgetLibVersion(void) -{ - return 1<<16|1<<8|1; -} -#endif - //////////////////////////////////////////////////////////////////////// // snapshot funcs (saves screen to bitmap / text infos into file) //////////////////////////////////////////////////////////////////////// @@ -187,10 +149,10 @@ void ResizeWindow() glViewport(rRatioRect.left, // init viewport by ratio rect iResY-(rRatioRect.top+rRatioRect.bottom), rRatioRect.right, - rRatioRect.bottom); + rRatioRect.bottom); glError(); - glScissor(0, 0, iResX, iResY); // init clipping (fullscreen) - glEnable(GL_SCISSOR_TEST); + glScissor(0, 0, iResX, iResY); glError(); // init clipping (fullscreen) + glEnable(GL_SCISSOR_TEST); glError(); #ifndef OWNSCALE glMatrixMode(GL_TEXTURE); // init psx tex sow and tow if not "ownscale" @@ -198,22 +160,19 @@ void ResizeWindow() glScalef(1.0f/255.99f,1.0f/255.99f,1.0f); // geforce precision hack #endif - glMatrixMode(GL_PROJECTION); // init projection with psx resolution - glLoadIdentity(); + glMatrixMode(GL_PROJECTION); glError(); // init projection with psx resolution + glLoadIdentity(); glError(); glOrtho(0,PSXDisplay.DisplayMode.x, - PSXDisplay.DisplayMode.y, 0, -1, 1); + PSXDisplay.DisplayMode.y, 0, -1, 1); glError(); if (bKeepRatio) SetAspectRatio(); } -s8 * GetConfigInfos(int hW) +char * GetConfigInfos(int hW) { -#ifdef _WINDOWS - HDC hdc;HGLRC hglrc; -#endif - s8 szO[2][4]={"off","on "}; - s8 szTxt[256]; - s8 * pB=(s8 *)malloc(32767); + char szO[2][4]={"off","on "}; + char szTxt[256]; + char * pB=(char *)malloc(32767); /* if(!pB) return NULL; *pB=0; @@ -235,7 +194,7 @@ s8 * GetConfigInfos(int hW) strcat(pB,szTxt); sprintf(szTxt,"OGL version: %s\r\n\r\n",(char *)glGetString(GL_VERSION)); strcat(pB,szTxt); - //strcat(pB,(s8 *)glGetString(GL_EXTENSIONS)); + //strcat(pB,(char *)glGetString(GL_EXTENSIONS)); //strcat(pB,"\r\n\r\n"); #ifdef _WINDOWS @@ -393,11 +352,7 @@ void DoSnapShot(void) { } -#ifdef _WINDOWS void CALLBACK GPUmakeSnapshot(void) -#else -void CALLBACK GPUmakeSnapshot(void) -#endif { //bSnapShot = TRUE; } @@ -406,31 +361,17 @@ void CALLBACK GPUmakeSnapshot(void) // GPU INIT... here starts it all (first func called by emu) //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS long CALLBACK GPUinit() -#else -long CALLBACK GPUinit() -#endif { memset(ulStatusControl,0,256*sizeof(unsigned long)); -#ifdef _WINDOWS -iResX=240;iResY=320; -#endif bChangeRes=FALSE; -#ifdef _WINDOWS -bWindowMode=TRUE; -#else bWindowMode=FALSE; -#endif -#ifdef _WINDOWS -iWinSize=MAKELONG(iResX,iResY); -#endif bKeepRatio = TRUE; // different ways of accessing PSX VRAM -psxVSecure=(u8 *)malloc((iGPUHeight*2)*1024 + (1024*1024)); // always alloc one extra MB for soft drawing funcs security +psxVSecure=(unsigned char *)malloc((iGPUHeight*2)*1024 + (1024*1024)); // always alloc one extra MB for soft drawing funcs security if(!psxVSecure) return -1; psxVub=psxVSecure+512*1024; // security offset into double sized psx vram! @@ -498,33 +439,6 @@ return 0; } -//////////////////////////////////////////////////////////////////////// -// GPU OPEN: funcs to open up the gpu display (Windows) -//////////////////////////////////////////////////////////////////////// - -#ifdef _WINDOWS - -void ChangeDesktop() // change destop resolution -{ - DEVMODE dv;long lRes,iTry=0; - - while(iTry<10) // keep on hammering... - { - memset(&dv,0,sizeof(DEVMODE)); - dv.dmSize=sizeof(DEVMODE); - dv.dmBitsPerPel=iColDepth; - dv.dmPelsWidth=iResX; - dv.dmPelsHeight=iResY; - - dv.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; - - lRes=ChangeDisplaySettings(&dv,0); // ...hammering the anvil - - if(lRes==DISP_CHANGE_SUCCESSFUL) return; - iTry++;Sleep(10); - } -} - //////////////////////////////////////////////////////////////////////// // OPEN interface func: attention! // some emus are calling this func in their main Window thread, @@ -539,35 +453,12 @@ void ChangeDesktop() // change destop resoluti // some PAD or SPU plugins would not work anymore) //////////////////////////////////////////////////////////////////////// -HMENU hPSEMenu=NULL; - -long CALLBACK GPUopen(HWND hwndGPU) -#else long CALLBACK GPUopen(int hwndGPU) -#endif { - #ifdef _WINDOWS - HDC hdc;RECT r;DEVMODE dv; - - hWWindow = hwndGPU; // store hwnd globally - #endif - // InitKeyHandler(); // init key handler (subclass window) - - - - #ifdef _WINDOWS - iResX=240;iResY=320; - #endif -#ifdef MAEMO_CHANGES - iResX=640;iResY=480; -#endif + iResX=800;iResY=480; iColDepth=8; bChangeRes=FALSE; - #ifdef _WINDOWS - bWindowMode=TRUE; - #else bWindowMode=FALSE; - #endif bFullVRam=FALSE; iFilterType=0; // bAdvancedBlend=FALSE; @@ -581,9 +472,6 @@ long CALLBACK GPUopen(int hwndGPU) //bOpaquePass=FALSE; //bUseAntiAlias=FALSE; //iTexQuality=0; - #ifdef _WINDOWS - iWinSize=MAKELONG(iResX,iResY); - #endif iUseMask=0; iZBufferDepth=0; bUseFastMdec=FALSE; @@ -605,65 +493,12 @@ long CALLBACK GPUopen(int hwndGPU) -#ifdef _WINDOWS - memset(&dv,0,sizeof(DEVMODE)); - dv.dmSize=sizeof(DEVMODE); - EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&dv); -#endif bIsFirstFrame = TRUE; // flag: we have to init OGL later in windows! -#ifdef _WINDOWS - if(bWindowMode) // win mode? - { - DWORD dw=GetWindowLong(hWWindow, GWL_STYLE); // -> adjust wnd style (owndc needed by some stupid ogl drivers) - dw&=~WS_THICKFRAME; - dw|=WS_BORDER|WS_CAPTION|CS_OWNDC; - SetWindowLong(hWWindow, GWL_STYLE, dw); - - hPSEMenu=GetMenu(hWWindow); // -> hide emu menu (if any) - if(hPSEMenu!=NULL) SetMenu(hWWindow,NULL); - - iResX=LOWORD(iWinSize);iResY=HIWORD(iWinSize); - ShowWindow(hWWindow,SW_SHOWNORMAL); - - MoveWindow(hWWindow, // -> center wnd - GetSystemMetrics(SM_CXFULLSCREEN)/2-iResX/2, - GetSystemMetrics(SM_CYFULLSCREEN)/2-iResY/2, - iResX+GetSystemMetrics(SM_CXFIXEDFRAME)+3, - iResY+GetSystemMetrics(SM_CYFIXEDFRAME)+GetSystemMetrics(SM_CYCAPTION)+3, - TRUE); - UpdateWindow(hWWindow); // -> let windows do some update - - if(dv.dmBitsPerPel==16 || dv.dmBitsPerPel==32) // -> overwrite user color info with desktop color info - iColDepth=dv.dmBitsPerPel; - } - else // fullscreen mode: - { - if(dv.dmBitsPerPel!=(unsigned int)iColDepth || // -> check, if we have to change resolution - dv.dmPelsWidth !=(unsigned int)iResX || - dv.dmPelsHeight!=(unsigned int)iResY) - bChangeRes=TRUE; else bChangeRes=FALSE; - - if(bChangeRes) ChangeDesktop(); // -> change the res (had to do an own func because of some MS 'optimizations') - - SetWindowLong(hWWindow, GWL_STYLE, CS_OWNDC); // -> adjust wnd style as well (to be sure) - - hPSEMenu=GetMenu(hWWindow); // -> hide menu - if(hPSEMenu!=NULL) SetMenu(hWWindow,NULL); - ShowWindow(hWWindow,SW_SHOWMAXIMIZED); // -> max mode - } -#endif rRatioRect.left = rRatioRect.top=0; rRatioRect.right = iResX; rRatioRect.bottom = iResY; -#ifdef _WINDOWS - r.left=r.top=0;r.right=iResX;r.bottom=iResY; // hack for getting a clean black window until OGL gets initialized - hdc = GetDC(hWWindow); - FillRect(hdc,&r,(HBRUSH)GetStockObject(BLACK_BRUSH)); - bSetupPixelFormat(hdc); - ReleaseDC(hWWindow,hdc); -#endif bDisplayNotSet = TRUE; bSetClip=TRUE; @@ -671,10 +506,12 @@ long CALLBACK GPUopen(int hwndGPU) InitializeTextureStore(); // init texture mem + CSTEXTURE = CSVERTEX = CSCOLOR = 0; + // lGPUstatusRet = 0x74000000; // with some emus, we could do the OGL init right here... oh my -// if(bIsFirstFrame) GLinitialize(); + if(bIsFirstFrame) GLinitialize(); return 0; } @@ -683,28 +520,6 @@ long CALLBACK GPUopen(int hwndGPU) // close //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS -long CALLBACK GPUclose() // WINDOWS CLOSE -{ -// ExitKeyHandler(); - - GLcleanup(); // close OGL - - if(bChangeRes) // change res back - ChangeDisplaySettings(NULL,0); - - if(hPSEMenu) // set menu again - SetMenu(hWWindow,hPSEMenu); - - if(pGfxCardScreen) free(pGfxCardScreen); // free helper memory - pGfxCardScreen=0; - -// if(iNoScreenSaver) EnableScreenSaver(TRUE); // enable screen saver again - - return 0; -} - -#else long GPUclose() // LINUX CLOSE { @@ -717,17 +532,12 @@ long GPUclose() // LINUX CLOSE return 0; } -#endif //////////////////////////////////////////////////////////////////////// // I shot the sheriff... last function called from emu //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS long CALLBACK GPUshutdown() -#else -long CALLBACK GPUshutdown() -#endif { if(psxVSecure) free(psxVSecure); // kill emulated vram memory psxVSecure=0; @@ -742,15 +552,15 @@ long CALLBACK GPUshutdown() void PaintBlackBorders(void) { short s; + glDisable(GL_SCISSOR_TEST); glError(); + if(bTexEnabled) {glDisable(GL_TEXTURE_2D);bTexEnabled=FALSE;} glError(); + if(bOldSmoothShaded) {glShadeModel(GL_FLAT);bOldSmoothShaded=FALSE;} glError(); + if(bBlendEnable) {glDisable(GL_BLEND);bBlendEnable=FALSE;} glError(); + glDisable(GL_ALPHA_TEST); glError(); - glDisable(GL_SCISSOR_TEST); - if(bTexEnabled) {glDisable(GL_TEXTURE_2D);bTexEnabled=FALSE;} - if(bOldSmoothShaded) {glShadeModel(GL_FLAT);bOldSmoothShaded=FALSE;} - if(bBlendEnable) {glDisable(GL_BLEND);bBlendEnable=FALSE;} - glDisable(GL_ALPHA_TEST); + glEnable(GL_ALPHA_TEST); glError(); + glEnable(GL_SCISSOR_TEST); glError(); - glEnable(GL_ALPHA_TEST); - glEnable(GL_SCISSOR_TEST); } //////////////////////////////////////////////////////////////////////// @@ -791,10 +601,6 @@ void updateDisplay(void) // UPDATE DISPLAY { BOOL bBlur=FALSE; -#ifdef _WINDOWS -HDC hdc=GetDC(hWWindow); // windows: -wglMakeCurrent(hdc,GLCONTEXT); // -> make context current again -#endif bFakeFrontBuffer=FALSE; bRenderFrontBuffer=FALSE; @@ -836,11 +642,13 @@ if(PreviousPSXDisplay.Range.x0|| // paint black borders aro if(PSXDisplay.Disabled) // display disabled? { + //LOGE("PSXDisplay.Disabled"); + // moved here - glDisable(GL_SCISSOR_TEST); - glClearColor(0,0,0,128); // -> clear whole backbuffer - glClear(uiBufferBits); - glEnable(GL_SCISSOR_TEST); + glDisable(GL_SCISSOR_TEST); glError(); + glClearColor(0,0,0,128); glError(); // -> clear whole backbuffer + glClear(uiBufferBits); glError(); + glEnable(GL_SCISSOR_TEST); glError(); gl_z=0.0f; bDisplayNotSet = TRUE; } @@ -882,29 +690,16 @@ if(bUseFrameSkip) // frame skipping active ? { if(!bSkipNextFrame) { - if(iDrawnSomething) -#ifdef _WINDOWS - SwapBuffers(wglGetCurrentDC()); // -> to skip or not to skip -#else - eglSwapBuffers(display,surface); -#endif + if(iDrawnSomething) flipEGL(); } - if(dwActFixes&0x180) // -> special old frame skipping: skip max one in a row - { if((fps_skip < fFrameRateHz) && !(bSkipNextFrame)) {bSkipNextFrame = TRUE; fps_skip=fFrameRateHz;} else bSkipNextFrame = FALSE; - } - else FrameSkip(); + } else // no skip ? { - if(iDrawnSomething) -#ifdef _WINDOWS - SwapBuffers(wglGetCurrentDC()); // -> swap -#else - eglSwapBuffers(display,surface); -#endif + if(iDrawnSomething) flipEGL(); } iDrawnSomething=0; @@ -921,11 +716,10 @@ if(lClearOnSwap) // clear buffer after swap g=((GLclampf)GREEN(lClearOnSwapColor))/255.0f; // -> get col b=((GLclampf)BLUE(lClearOnSwapColor))/255.0f; r=((GLclampf)RED(lClearOnSwapColor))/255.0f; - - glDisable(GL_SCISSOR_TEST); - glClearColor(r,g,b,128); // -> clear - glClear(uiBufferBits); - glEnable(GL_SCISSOR_TEST); + glDisable(GL_SCISSOR_TEST); glError(); + glClearColor(r,g,b,128); glError(); // -> clear + glClear(uiBufferBits); glError(); + glEnable(GL_SCISSOR_TEST); glError(); lClearOnSwap=0; // -> done } else @@ -934,11 +728,12 @@ else if(iZBufferDepth) // clear zbuffer as well (if activated) { - glDisable(GL_SCISSOR_TEST); - glClear(GL_DEPTH_BUFFER_BIT); - glEnable(GL_SCISSOR_TEST); + glDisable(GL_SCISSOR_TEST); glError(); + glClear(GL_DEPTH_BUFFER_BIT); glError(); + glEnable(GL_SCISSOR_TEST); glError(); } } + gl_z=0.0f; //----------------------------------------------------// @@ -985,7 +780,7 @@ if(iRumbleTime) // shake screen by modifyi glViewport(rRatioRect.left+i1, iResY-(rRatioRect.top+rRatioRect.bottom)+i2, rRatioRect.right+i3, - rRatioRect.bottom+i4); + rRatioRect.bottom+i4); glError(); } //----------------------------------------------------// @@ -1018,18 +813,9 @@ bRenderFrontBuffer=FALSE; // if(gTexPicName) DisplayPic(); // if(ulKeybits&KEY_SHOWFPS) DisplayText(); -#ifdef _WINDOWS - { // windows: - HDC hdc=GetDC(hWWindow); - wglMakeCurrent(hdc,GLCONTEXT); // -> make current again - if(iDrawnSomething) - SwapBuffers(wglGetCurrentDC()); // -> swap - ReleaseDC(hWWindow,hdc); // -> ! important ! - } -#else if(iDrawnSomething) // linux: - eglSwapBuffers(display,surface); -#endif + flipEGL(); + //if(iBlurBuffer) UnBlurBackBuffer(); } @@ -1119,6 +905,7 @@ float xs,ys,s;RECT r; if(!PSXDisplay.DisplayModeNew.x) return; if(!PSXDisplay.DisplayModeNew.y) return; +#if 0 xs=(float)iResX/(float)PSXDisplay.DisplayModeNew.x; ys=(float)iResY/(float)PSXDisplay.DisplayModeNew.y; @@ -1132,12 +919,11 @@ if(r.bottom < 1) r.bottom = 1; r.left = (iResX-r.right)/2; r.top = (iResY-r.bottom)/2; - if(r.bottom new psx resolution - PSXDisplay.DisplayModeNew.y, 0, -1, 1); + PSXDisplay.DisplayModeNew.y, 0, -1, 1); glError(); if(bKeepRatio) SetAspectRatio(); } @@ -1236,15 +1028,6 @@ if(bUp) updateDisplay(); // yeah, real update (swap // window mode <-> fullscreen mode (windows) //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS -void ChangeWindowMode(void) -{ - GPUclose(); - bWindowMode=!bWindowMode; - GPUopen(hWWindow); - bChangeWinMode=FALSE; -} -#endif //////////////////////////////////////////////////////////////////////// // swap update check (called by psx vsync function) @@ -1312,11 +1095,7 @@ return FALSE; static unsigned short usFirstPos=2; -#ifdef _WINDOWS -void CALLBACK GPUupdateLace(void) -#else void CALLBACK GPUupdateLace(void) -#endif { if(!(dwActFixes&0x1000)) STATUSREG^=0x80000000; // interlaced bit toggle, if the CC game fix is not active (see gpuReadStatus) @@ -1345,20 +1124,13 @@ else if(usFirstPos==1) // initial updates (after updateDisplay(); } -#ifdef _WINDOWS -if(bChangeWinMode) ChangeWindowMode(); -#endif } //////////////////////////////////////////////////////////////////////// // process read request from GPU status register //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS -unsigned long CALLBACK GPUreadStatus(void) -#else unsigned long CALLBACK GPUreadStatus(void) -#endif { if(dwActFixes&0x1000) // CC game fix { @@ -1394,17 +1166,11 @@ return STATUSREG; // these are always single packet commands. //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS -void CALLBACK GPUwriteStatus(unsigned long gdata) -#else void CALLBACK GPUwriteStatus(unsigned long gdata) -#endif { unsigned long lCommand=(gdata>>24)&0xff; -#ifdef _WINDOWS if(bIsFirstFrame) GLinitialize(); // real ogl startup (needed by some emus) -#endif ulStatusControl[lCommand]=gdata; @@ -1723,8 +1489,8 @@ void CheckVRamReadEx(int x, int y, int dx, int dy) int ux,uy,udx,udy,wx,wy; unsigned short * p1, *p2; float XS,YS; - u8 * ps; - u8 * px; + unsigned char * ps; + unsigned char * px; unsigned short s,sx; if(STATUSREG&GPUSTATUS_RGB24) return; @@ -1820,16 +1586,15 @@ void CheckVRamReadEx(int x, int y, int dx, int dy) if(!pGfxCardScreen) { - glPixelStorei(GL_PACK_ALIGNMENT,1); - pGfxCardScreen=(u8 *)malloc(iResX*iResY*4); + glPixelStorei(GL_PACK_ALIGNMENT,1); glError(); + pGfxCardScreen=(unsigned char *)malloc(iResX*iResY*4); } ps=pGfxCardScreen; //if(!sArea) glReadBuffer(GL_FRONT); - glReadPixels(x,y,dx,dy,GL_RGB,GL_UNSIGNED_BYTE,ps); - + glReadPixels(x,y,dx,dy,GL_RGB,GL_UNSIGNED_BYTE,ps); glError(); //if(!sArea) glReadBuffer(GL_BACK); s=0; @@ -1874,7 +1639,7 @@ void CheckVRamRead(int x, int y, int dx, int dy, bool bFront) { unsigned short sArea;unsigned short * p; int ux,uy,udx,udy,wx,wy;float XS,YS; - u8 * ps, * px; + unsigned char * ps, * px; unsigned short s=0,sx; if(STATUSREG&GPUSTATUS_RGB24) return; @@ -1968,16 +1733,15 @@ void CheckVRamRead(int x, int y, int dx, int dy, bool bFront) if(!pGfxCardScreen) { - glPixelStorei(GL_PACK_ALIGNMENT,1); - pGfxCardScreen=(u8 *)malloc(iResX*iResY*4); + glPixelStorei(GL_PACK_ALIGNMENT,1); glError(); + pGfxCardScreen=(unsigned char *)malloc(iResX*iResY*4); } ps=pGfxCardScreen; // if(bFront) glReadBuffer(GL_FRONT); - glReadPixels(x,y,dx,dy,GL_RGB,GL_UNSIGNED_BYTE,ps); - + glReadPixels(x,y,dx,dy,GL_RGB,GL_UNSIGNED_BYTE,ps); glError(); glError(); // if(bFront) glReadBuffer(GL_BACK); XS=(float)dx/(float)(udx); @@ -2010,11 +1774,7 @@ void CheckVRamRead(int x, int y, int dx, int dy, bool bFront) // core read from vram //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS -void CALLBACK GPUreadDataMem(unsigned int * pMem, int iSize) -#else void CALLBACK GPUreadDataMem(unsigned long * pMem, int iSize) -#endif { int i; @@ -2086,18 +1846,10 @@ ENDREAD: GPUIsIdle; } -#ifdef _WINDOWS -unsigned long CALLBACK GPUreadData(void) -#else unsigned long CALLBACK GPUreadData(void) -#endif { unsigned long l; -#ifdef _WINDOWS GPUreadDataMem(&l,1); -#else - GPUreadDataMem(&l,1); -#endif return GPUdataRet; } @@ -2105,7 +1857,7 @@ unsigned long CALLBACK GPUreadData(void) // helper table to know how much data is used by drawing commands //////////////////////////////////////////////////////////////////////// -const u8 primTableCX[256] = +const unsigned char primTableCX[256] = { // 00 0,0,3,0,0,0,0,0, @@ -2179,13 +1931,9 @@ const u8 primTableCX[256] = // processes data send to GPU data register //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS void CALLBACK GPUwriteDataMem(unsigned long * pMem, int iSize) -#else -void CALLBACK GPUwriteDataMem(unsigned long * pMem, int iSize) -#endif { -u8 command; +unsigned char command; unsigned long gdata=0; int i=0; GPUIsBusy; @@ -2245,7 +1993,7 @@ ENDVRAM: if(iDataWriteMode==DR_NORMAL) { - void (* *primFunc)(u8 *); + void (* *primFunc)(unsigned char *); if(bSkipNextFrame) primFunc=primTableSkip; else primFunc=primTableJ; @@ -2257,7 +2005,7 @@ if(iDataWriteMode==DR_NORMAL) if(gpuDataC == 0) { - command = (u8)((gdata>>24) & 0xff); + command = (unsigned char)((gdata>>24) & 0xff); if(primTableCX[command]) { @@ -2286,7 +2034,7 @@ if(iDataWriteMode==DR_NORMAL) if(gpuDataP == gpuDataC) { gpuDataC=gpuDataP=0; - primFunc[gpuCommand]((u8 *)gpuDataM); + primFunc[gpuCommand]((unsigned char *)gpuDataM); if(dwEmuFixes&0x0001 || dwActFixes&0x20000) // hack for emulating "gpu busy" in some games iFakePrimBusy=4; @@ -2302,17 +2050,9 @@ GPUIsIdle; //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS void CALLBACK GPUwriteData(unsigned long gdata) -#else -void CALLBACK GPUwriteData(unsigned long gdata) -#endif { -#ifdef _WINDOWS - GPUwriteDataMem(&gdata,1); -#else GPUwriteDataMem(&gdata,1); -#endif } //////////////////////////////////////////////////////////////////////// @@ -2350,9 +2090,9 @@ return iT; /*#include -void StartCfgTool(s8 * pCmdLine) // linux: start external cfg tool +void StartCfgTool(char * pCmdLine) // linux: start external cfg tool { - FILE * cf;s8 filename[255],t[255]; + FILE * cf;char filename[255],t[255]; strcpy(filename,"cfg/cfgPeopsMesaGL"); // look in cfg sub folder first cf=fopen(filename,"rb"); @@ -2396,22 +2136,9 @@ void StartCfgTool(s8 * pCmdLine) // linux: start external cf #endif -#ifdef _WINDOWS -long CALLBACK GPUconfigure(void) -#else long CALLBACK GPUconfigure(void) -#endif { -#ifdef _WINDOWS -// HWND hWP=GetActiveWindow(); -// DialogBox(hInst,MAKEINTRESOURCE(IDD_CFGDLG), -// hWP,(DLGPROC)CfgDlgProc); -#else - -// StartCfgTool("CFG"); - -#endif return 0; } @@ -2450,14 +2177,10 @@ return FALSE; // core gives a dma chain to gpu: same as the gpuwrite interface funcs //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS long CALLBACK GPUdmaChain(unsigned long * baseAddrL, unsigned long addr) -#else -long CALLBACK GPUdmaChain(unsigned long * baseAddrL, unsigned long addr) -#endif { unsigned long dmaMem; -u8 * baseAddrB; +unsigned char * baseAddrB; short count;unsigned int DMACommandCounter = 0; if(bIsFirstFrame) GLinitialize(); @@ -2466,7 +2189,7 @@ GPUIsBusy; lUsedAddr[0]=lUsedAddr[1]=lUsedAddr[2]=0xffffff; -baseAddrB = (u8*) baseAddrL; +baseAddrB = (unsigned char*) baseAddrL; do { @@ -2479,11 +2202,7 @@ do dmaMem=addr+4; -#ifdef _WINDOWS - if(count>0) GPUwriteDataMem(&baseAddrL[dmaMem>>2],count); -#else if(count>0) GPUwriteDataMem(&baseAddrL[dmaMem>>2],count); -#endif addr = baseAddrL[addr>>2]&0xffffff; } @@ -2498,11 +2217,7 @@ return 0; // show about dlg //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS -void CALLBACK GPUabout(void) -#else void CALLBACK GPUabout(void) -#endif { } @@ -2511,11 +2226,7 @@ void CALLBACK GPUabout(void) // We are ever fine ;) //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS -long CALLBACK GPUtest(void) -#else long CALLBACK GPUtest(void) -#endif { // if test fails this function should return negative value for error (unable to continue) // and positive value for warning (can continue but output might be crappy) @@ -2529,11 +2240,7 @@ long CALLBACK GPUtest(void) //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS long CALLBACK GPUfreeze(unsigned long ulGetFreezeData,GPUFreeze_t * pF) -#else -long CALLBACK GPUfreeze(unsigned long ulGetFreezeData,GPUFreeze_t * pF) -#endif { if(ulGetFreezeData==2) { @@ -2564,17 +2271,6 @@ memcpy(psxVub, pF->psxVRam, 1024*iGPUHeight*2); ResetTextureArea(TRUE); -#ifdef _WINDOWS - GPUwriteStatus(ulStatusControl[0]); - GPUwriteStatus(ulStatusControl[1]); - GPUwriteStatus(ulStatusControl[2]); - GPUwriteStatus(ulStatusControl[3]); - GPUwriteStatus(ulStatusControl[8]); - GPUwriteStatus(ulStatusControl[6]); - GPUwriteStatus(ulStatusControl[7]); - GPUwriteStatus(ulStatusControl[5]); - GPUwriteStatus(ulStatusControl[4]); -#else GPUwriteStatus(ulStatusControl[0]); GPUwriteStatus(ulStatusControl[1]); GPUwriteStatus(ulStatusControl[2]); @@ -2584,7 +2280,6 @@ ResetTextureArea(TRUE); GPUwriteStatus(ulStatusControl[7]); GPUwriteStatus(ulStatusControl[5]); GPUwriteStatus(ulStatusControl[4]); -#endif return 1; } @@ -2597,7 +2292,7 @@ ResetTextureArea(TRUE); //10 = red //11 = transparent -u8 cFont[10][120]= +unsigned char cFont[10][120]= { // 0 {0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, @@ -2823,7 +2518,7 @@ u8 cFont[10][120]= //////////////////////////////////////////////////////////////////////// -void PaintPicDot(u8 * p,u8 c) +void PaintPicDot(unsigned char * p,unsigned char c) { if(c==0) {*p++=0x00;*p++=0x00;*p=0x00;return;} if(c==1) {*p++=0xff;*p++=0xff;*p=0xff;return;} @@ -2832,27 +2527,23 @@ void PaintPicDot(u8 * p,u8 c) //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS -void CALLBACK GPUgetScreenPic(u8 * pMem) -#else -long CALLBACK GPUgetScreenPic(u8 * pMem) -#endif +long CALLBACK GPUgetScreenPic(unsigned char * pMem) { float XS,YS;int x,y,v; - u8 * ps, * px, * pf; - u8 c; + unsigned char * ps, * px, * pf; + unsigned char c; if(!pGfxCardScreen) { - glPixelStorei(GL_PACK_ALIGNMENT,1); - pGfxCardScreen=(u8 *)malloc(iResX*iResY*4); + glPixelStorei(GL_PACK_ALIGNMENT,1); glError(); + pGfxCardScreen=(unsigned char *)malloc(iResX*iResY*4); } ps=pGfxCardScreen; // glReadBuffer(GL_FRONT); - glReadPixels(0,0,iResX,iResY,GL_RGB,GL_UNSIGNED_BYTE,ps); + glReadPixels(0,0,iResX,iResY,GL_RGB,GL_UNSIGNED_BYTE,ps); glError(); // glReadBuffer(GL_BACK); @@ -2884,13 +2575,13 @@ long CALLBACK GPUgetScreenPic(u8 * pMem) { c=cFont[lSelectedSlot][x+y*6]; v=(c&0xc0)>>6; - PaintPicDot(pf,(u8)v);pf+=3; // paint the dots into the rect + PaintPicDot(pf,(unsigned char)v);pf+=3; // paint the dots into the rect v=(c&0x30)>>4; - PaintPicDot(pf,(u8)v);pf+=3; + PaintPicDot(pf,(unsigned char)v);pf+=3; v=(c&0x0c)>>2; - PaintPicDot(pf,(u8)v);pf+=3; + PaintPicDot(pf,(unsigned char)v);pf+=3; v=c&0x03; - PaintPicDot(pf,(u8)v);pf+=3; + PaintPicDot(pf,(unsigned char)v);pf+=3; } pf+=104*3; } @@ -2915,11 +2606,7 @@ long CALLBACK GPUgetScreenPic(u8 * pMem) //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS -void CALLBACK GPUshowScreenPic(u8 * pMem) -#else -long CALLBACK GPUshowScreenPic(u8 * pMem) -#endif +long CALLBACK GPUshowScreenPic(unsigned char * pMem) { // DestroyPic(); // if(pMem==0) return; @@ -2959,3 +2646,14 @@ void CALLBACK GPUdisplayFlags(unsigned long dwFlags) { // dwCoreFlags=dwFlags; } + +// pcsx-rearmed callbacks +void CALLBACK GPUrearmedCallbacks(const void **cbs) +{ + rearmed_get_layer_pos = cbs[0]; +} + +static void flipEGL(void) +{ + eglSwapBuffers(display, surface); +}