From 6c7076b9d2da58ff1e32e747f7512f572b24ed06 Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 20 Feb 2026 03:39:33 +0200 Subject: [PATCH] plugins: rm old/unmaintained standalone stuff only interferes with refactoring --- frontend/nopic.h | 60 - plugins/dfxvideo/Makefile | 9 - plugins/dfxvideo/gpu.c | 1143 --------------- plugins/gpu-gles/Makefile | 2 - plugins/gpu-gles/gpuPlugin.c | 2658 ---------------------------------- plugins/gpu-gles/gpuPlugin.h | 36 - plugins/gpu_unai/Makefile | 2 - plugins/gpu_unai/gpu.cpp | 830 ----------- plugins/gpu_unai/old/gpu.cpp | 916 ------------ plugins/gpu_unai/old/gpu.h | 87 -- plugins/gpu_unai/old/port.h | 36 - plugins/gpu_unai/port.h | 41 - plugins/gpulib/gpulib.mak | 12 - 13 files changed, 5832 deletions(-) delete mode 100644 frontend/nopic.h delete mode 100644 plugins/dfxvideo/gpu.c delete mode 100644 plugins/gpu-gles/gpuPlugin.c delete mode 100644 plugins/gpu_unai/gpu.cpp delete mode 100644 plugins/gpu_unai/old/gpu.cpp delete mode 100644 plugins/gpu_unai/old/gpu.h delete mode 100644 plugins/gpu_unai/old/port.h delete mode 100644 plugins/gpu_unai/port.h diff --git a/frontend/nopic.h b/frontend/nopic.h deleted file mode 100644 index 1815983f..00000000 --- a/frontend/nopic.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef __NOPIC_H__ -#define __NOPIC_H__ - -/* these are just deps, to be removed */ - -static const struct { - unsigned int width; - unsigned int height; - unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ - unsigned char pixel_data[128 * 96 * 3 + 1]; -} NoPic_Image = { - 128, 96, 3, "" -}; - -extern void PaintPicDot(unsigned char * p,unsigned char c); -extern unsigned char cFont[10][120]; - -void DrawNumBorPic(unsigned char *pMem, int lSelectedSlot) -{ - unsigned char *pf; - int x,y; - int c,v; - - pf=pMem+(103*3); // offset to number rect - - for(y=0;y<20;y++) // loop the number rect pixel - { - for(x=0;x<6;x++) - { - c=cFont[lSelectedSlot][x+y*6]; // get 4 char dot infos at once (number depends on selected slot) - v=(c&0xc0)>>6; - PaintPicDot(pf,(unsigned char)v);pf+=3; // paint the dots into the rect - v=(c&0x30)>>4; - PaintPicDot(pf,(unsigned char)v);pf+=3; - v=(c&0x0c)>>2; - PaintPicDot(pf,(unsigned char)v);pf+=3; - v=c&0x03; - PaintPicDot(pf,(unsigned char)v);pf+=3; - } - pf+=104*3; // next rect y line - } - - pf=pMem; // ptr to first pos in 128x96 pic - for(x=0;x<128;x++) // loop top/bottom line - { - *(pf+(95*128*3))=0x00;*pf++=0x00; - *(pf+(95*128*3))=0x00;*pf++=0x00; // paint it red - *(pf+(95*128*3))=0xff;*pf++=0xff; - } - pf=pMem; // ptr to first pos - for(y=0;y<96;y++) // loop left/right line - { - *(pf+(127*3))=0x00;*pf++=0x00; - *(pf+(127*3))=0x00;*pf++=0x00; // paint it red - *(pf+(127*3))=0xff;*pf++=0xff; - pf+=127*3; // offset to next line - } -} - -#endif /* __NOPIC_H__ */ diff --git a/plugins/dfxvideo/Makefile b/plugins/dfxvideo/Makefile index fb879f4d..f3b0da31 100644 --- a/plugins/dfxvideo/Makefile +++ b/plugins/dfxvideo/Makefile @@ -4,16 +4,7 @@ CFLAGS += -I../../include include ../../config.mak -SRC_STANDALONE += gpu.c SRC_GPULIB += gpulib_if.c -#ifeq "$(ARCH)" "arm" -SRC_STANDALONE += draw_pl.c -#else -#SRC_STANDALONE += draw.c -#LDLIBS_STANDALONE += -lX11 -lXv -lXext -#endif - -#BIN_STANDALONE = gpuPEOPS.so BIN_GPULIB = gpu_peops.so include ../gpulib/gpulib.mak diff --git a/plugins/dfxvideo/gpu.c b/plugins/dfxvideo/gpu.c deleted file mode 100644 index 1a3f25ac..00000000 --- a/plugins/dfxvideo/gpu.c +++ /dev/null @@ -1,1143 +0,0 @@ -/*************************************************************************** - gpu.c - description - ------------------- - begin : Sun Oct 28 2001 - copyright : (C) 2001 by Pete Bernert - email : BlackDove@addcom.de - ***************************************************************************/ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. See also the license.txt file for * - * additional informations. * - * * - ***************************************************************************/ - -#include "gpu.h" -#include "stdint.h" -#include "psemu_plugin_defs.h" - -//////////////////////////////////////////////////////////////////////// -// memory image of the PSX vram -//////////////////////////////////////////////////////////////////////// - -unsigned char *psxVub; -unsigned short *psxVuw; -unsigned short *psxVuw_eom; - -//////////////////////////////////////////////////////////////////////// -// GPU globals -//////////////////////////////////////////////////////////////////////// - -static long lGPUdataRet; -long lGPUstatusRet; -uint32_t ulStatusControl[256]; - -static uint32_t gpuDataM[256]; -static unsigned char gpuCommand = 0; -static long gpuDataC = 0; -static long gpuDataP = 0; - -VRAMLoad_t VRAMWrite; -VRAMLoad_t VRAMRead; -DATAREGISTERMODES DataWriteMode; -DATAREGISTERMODES DataReadMode; - -BOOL bSkipNextFrame = FALSE; -BOOL fskip_frameReady; -DWORD lace_count_since_flip; -DWORD dwLaceCnt=0; -short sDispWidths[8] = {256,320,512,640,368,384,512,640}; -PSXDisplay_t PSXDisplay; -PSXDisplay_t PreviousPSXDisplay; -long lSelectedSlot=0; -BOOL bDoLazyUpdate=FALSE; -uint32_t lGPUInfoVals[16]; -static int iFakePrimBusy=0; -static const int *skip_advice; - -//////////////////////////////////////////////////////////////////////// -// some misc external display funcs -//////////////////////////////////////////////////////////////////////// - -#include - -// FPS library -#include "fps.c" - - -//////////////////////////////////////////////////////////////////////// -// sets all kind of act fixes -//////////////////////////////////////////////////////////////////////// - -static void SetFixes(void) - { - if(dwActFixes&0x02) sDispWidths[4]=384; - else sDispWidths[4]=368; - } - -//////////////////////////////////////////////////////////////////////// -// INIT, will be called after lib load... well, just do some var init... -//////////////////////////////////////////////////////////////////////// - -// one extra MB for soft drawing funcs security -static unsigned char vram[1024*512*2 + 1024*1024] __attribute__((aligned(2048))); - -long CALLBACK GPUinit(void) // GPU INIT -{ - memset(ulStatusControl,0,256*sizeof(uint32_t)); // init save state scontrol field - - //!!! ATTENTION !!! - psxVub=vram + 512 * 1024; // security offset into double sized psx vram! - - psxVuw=(unsigned short *)psxVub; - psxVuw_eom=psxVuw+1024*512; // pre-calc of end of vram - - memset(vram,0x00,(512*2)*1024 + (1024*1024)); - memset(lGPUInfoVals,0x00,16*sizeof(uint32_t)); - - PSXDisplay.RGB24 = FALSE; // init some stuff - PSXDisplay.Interlaced = FALSE; - PSXDisplay.DrawOffset.x = 0; - PSXDisplay.DrawOffset.y = 0; - PSXDisplay.DisplayMode.x= 320; - PSXDisplay.DisplayMode.y= 240; - PreviousPSXDisplay.DisplayMode.x= 320; - PreviousPSXDisplay.DisplayMode.y= 240; - PSXDisplay.Disabled = FALSE; - PreviousPSXDisplay.Range.x0 =0; - PreviousPSXDisplay.Range.y0 =0; - PSXDisplay.Range.x0=0; - PSXDisplay.Range.x1=0; - PreviousPSXDisplay.DisplayModeNew.y=0; - PSXDisplay.Double = 1; - lGPUdataRet = 0x400; - - DataWriteMode = DR_NORMAL; - - // Reset transfer values, to prevent mis-transfer of data - memset(&VRAMWrite, 0, sizeof(VRAMLoad_t)); - memset(&VRAMRead, 0, sizeof(VRAMLoad_t)); - - // device initialised already ! - lGPUstatusRet = 0x14802000; - GPUIsIdle; - GPUIsReadyForCommands; - bDoVSyncUpdate = TRUE; - - return 0; -} - -//////////////////////////////////////////////////////////////////////// -// Here starts all... -//////////////////////////////////////////////////////////////////////// - - -long GPUopen(unsigned long * disp,char * CapText,char * CfgFile) -{ - unsigned long d; - - SetFixes(); - - InitFPS(); - - bDoVSyncUpdate = TRUE; - - d=ulInitDisplay(); // setup x - - if(disp) - *disp=d; // wanna x pointer? ok - - if(d) return 0; - return -1; -} - - -//////////////////////////////////////////////////////////////////////// -// time to leave... -//////////////////////////////////////////////////////////////////////// - -long CALLBACK GPUclose() // GPU CLOSE -{ - CloseDisplay(); // shutdown direct draw - - return 0; -} - -//////////////////////////////////////////////////////////////////////// -// I shot the sheriff -//////////////////////////////////////////////////////////////////////// - -long CALLBACK GPUshutdown(void) // GPU SHUTDOWN -{ - CloseDisplay(); // shutdown direct draw - return 0; // nothinh to do -} - -//////////////////////////////////////////////////////////////////////// -// Update display (swap buffers) -//////////////////////////////////////////////////////////////////////// - -static void updateDisplay(void) // UPDATE DISPLAY -{ - if(PSXDisplay.Disabled) // disable? - { - return; // -> and bye - } - - if(dwActFixes&32) // pc fps calculation fix - { - if(UseFrameLimit) PCFrameCap(); // -> brake - if(UseFrameSkip) PCcalcfps(); - } - - if(UseFrameSkip) // skip ? - { - if(fskip_frameReady) - { - DoBufferSwap(); // -> to skip or not to skip - fskip_frameReady=FALSE; - bDoVSyncUpdate=FALSE; // vsync done - } - } - else // no skip ? - { - bSkipNextFrame = FALSE; - DoBufferSwap(); // -> swap - bDoVSyncUpdate=FALSE; // vsync done - } -} - -static void decideSkip(void) -{ - if(!bDoVSyncUpdate) - return; - - lace_count_since_flip=0; - fskip_frameReady=!bSkipNextFrame; - - if(dwActFixes&0xa0) // -> pc fps calculation fix/old skipping fix - { - int skip = (skip_advice && *skip_advice) || UseFrameSkip == 1 || fps_skip < fFrameRateHz; - if(skip && !bSkipNextFrame) // -> skip max one in a row - {bSkipNextFrame = TRUE; fps_skip=fFrameRateHz;} - else bSkipNextFrame = FALSE; - } - else FrameSkip(); -} - -//////////////////////////////////////////////////////////////////////// -// roughly emulated screen centering bits... not complete !!! -//////////////////////////////////////////////////////////////////////// - -void ChangeDispOffsetsX(void) // X CENTER -{ - long lx,l; - - if(!PSXDisplay.Range.x1) return; - - l=PreviousPSXDisplay.DisplayMode.x; - - l*=(long)PSXDisplay.Range.x1; - l/=2560;lx=l;l&=0xfffffff8; - - if(l==PreviousPSXDisplay.Range.y1) return; // abusing range.y1 for - PreviousPSXDisplay.Range.y1=(short)l; // storing last x range and test - - if(lx>=PreviousPSXDisplay.DisplayMode.x) - { - PreviousPSXDisplay.Range.x1= - (short)PreviousPSXDisplay.DisplayMode.x; - PreviousPSXDisplay.Range.x0=0; - } - else - { - PreviousPSXDisplay.Range.x1=(short)l; - - PreviousPSXDisplay.Range.x0= - (PSXDisplay.Range.x0-500)/8; - - if(PreviousPSXDisplay.Range.x0<0) - PreviousPSXDisplay.Range.x0=0; - - if((PreviousPSXDisplay.Range.x0+lx)> - PreviousPSXDisplay.DisplayMode.x) - { - PreviousPSXDisplay.Range.x0= - (short)(PreviousPSXDisplay.DisplayMode.x-lx); - PreviousPSXDisplay.Range.x0+=2; //??? - - PreviousPSXDisplay.Range.x1+=(short)(lx-l); - - PreviousPSXDisplay.Range.x1-=2; // makes linux stretching easier - - } - - // some linux alignment security - PreviousPSXDisplay.Range.x0=PreviousPSXDisplay.Range.x0>>1; - PreviousPSXDisplay.Range.x0=PreviousPSXDisplay.Range.x0<<1; - PreviousPSXDisplay.Range.x1=PreviousPSXDisplay.Range.x1>>1; - PreviousPSXDisplay.Range.x1=PreviousPSXDisplay.Range.x1<<1; - - DoClearScreenBuffer(); - } - - bDoVSyncUpdate=TRUE; -} - -//////////////////////////////////////////////////////////////////////// - -void ChangeDispOffsetsY(void) // Y CENTER -{ - int iT,iO=PreviousPSXDisplay.Range.y0; - int iOldYOffset=PreviousPSXDisplay.DisplayModeNew.y; - -// new - - if((PreviousPSXDisplay.DisplayModeNew.x+PSXDisplay.DisplayModeNew.y)>512) - { - int dy1=512-PreviousPSXDisplay.DisplayModeNew.x; - int dy2=(PreviousPSXDisplay.DisplayModeNew.x+PSXDisplay.DisplayModeNew.y)-512; - - if(dy1>=dy2) - { - PreviousPSXDisplay.DisplayModeNew.y=-dy2; - } - else - { - PSXDisplay.DisplayPosition.y=0; - PreviousPSXDisplay.DisplayModeNew.y=-dy1; - } - } - else PreviousPSXDisplay.DisplayModeNew.y=0; - -// eon - - if(PreviousPSXDisplay.DisplayModeNew.y!=iOldYOffset) // if old offset!=new offset: recalc height - { - PSXDisplay.Height = PSXDisplay.Range.y1 - - PSXDisplay.Range.y0 + - PreviousPSXDisplay.DisplayModeNew.y; - PSXDisplay.DisplayModeNew.y=PSXDisplay.Height*PSXDisplay.Double; - } - -// - - if(PSXDisplay.PAL) iT=48; else iT=28; - - if(PSXDisplay.Range.y0>=iT) - { - PreviousPSXDisplay.Range.y0= - (short)((PSXDisplay.Range.y0-iT-4)*PSXDisplay.Double); - if(PreviousPSXDisplay.Range.y0<0) - PreviousPSXDisplay.Range.y0=0; - PSXDisplay.DisplayModeNew.y+= - PreviousPSXDisplay.Range.y0; - } - else - PreviousPSXDisplay.Range.y0=0; - - if(iO!=PreviousPSXDisplay.Range.y0) - { - DoClearScreenBuffer(); - } -} - -//////////////////////////////////////////////////////////////////////// -// check if update needed -//////////////////////////////////////////////////////////////////////// - -static void updateDisplayIfChanged(void) // UPDATE DISPLAY IF CHANGED -{ - if ((PSXDisplay.DisplayMode.y == PSXDisplay.DisplayModeNew.y) && - (PSXDisplay.DisplayMode.x == PSXDisplay.DisplayModeNew.x)) - { - if((PSXDisplay.RGB24 == PSXDisplay.RGB24New) && - (PSXDisplay.Interlaced == PSXDisplay.InterlacedNew)) return; - } - - PSXDisplay.RGB24 = PSXDisplay.RGB24New; // get new infos - - PSXDisplay.DisplayMode.y = PSXDisplay.DisplayModeNew.y; - PSXDisplay.DisplayMode.x = PSXDisplay.DisplayModeNew.x; - PreviousPSXDisplay.DisplayMode.x= // previous will hold - min(640,PSXDisplay.DisplayMode.x); // max 640x512... that's - PreviousPSXDisplay.DisplayMode.y= // the size of my - min(512,PSXDisplay.DisplayMode.y); // back buffer surface - PSXDisplay.Interlaced = PSXDisplay.InterlacedNew; - - PSXDisplay.DisplayEnd.x= // calc end of display - PSXDisplay.DisplayPosition.x+ PSXDisplay.DisplayMode.x; - PSXDisplay.DisplayEnd.y= - PSXDisplay.DisplayPosition.y+ PSXDisplay.DisplayMode.y+PreviousPSXDisplay.DisplayModeNew.y; - PreviousPSXDisplay.DisplayEnd.x= - PreviousPSXDisplay.DisplayPosition.x+ PSXDisplay.DisplayMode.x; - PreviousPSXDisplay.DisplayEnd.y= - PreviousPSXDisplay.DisplayPosition.y+ PSXDisplay.DisplayMode.y+PreviousPSXDisplay.DisplayModeNew.y; - - ChangeDispOffsetsX(); - - if(iFrameLimit==2) SetAutoFrameCap(); // -> set it - - if(UseFrameSkip) decideSkip(); // stupid stuff when frame skipping enabled -} - -//////////////////////////////////////////////////////////////////////// -// update lace is called evry VSync -//////////////////////////////////////////////////////////////////////// - -void CALLBACK GPUupdateLace(void) // VSYNC -{ - //if(!(dwActFixes&1)) - // lGPUstatusRet^=0x80000000; // odd/even bit - - //pcsx-rearmed: removed, this is handled by core - //if(!(dwActFixes&32)) // std fps limitation? - // CheckFrameRate(); - - if(PSXDisplay.Interlaced) // interlaced mode? - { - lGPUstatusRet^=0x80000000; // odd/even bit? - - if(bDoVSyncUpdate && PSXDisplay.DisplayMode.x>0 && PSXDisplay.DisplayMode.y>0) - { - updateDisplay(); - } - } - else // non-interlaced? - { - if(dwActFixes&64) // lazy screen update fix - { - if(bDoLazyUpdate) - updateDisplay(); - bDoLazyUpdate=FALSE; - } - else - { - if(bDoVSyncUpdate) // some primitives drawn? - updateDisplay(); // -> update display - } - } - - if(UseFrameSkip) { // frame over-skip guard - lace_count_since_flip++; - if(lace_count_since_flip > 8) { - bSkipNextFrame=FALSE; - fskip_frameReady=TRUE; - } - } -} - -//////////////////////////////////////////////////////////////////////// -// process read request from GPU status register -//////////////////////////////////////////////////////////////////////// - - -uint32_t CALLBACK GPUreadStatus(void) // READ STATUS -{ - if(dwActFixes&1) - { - static int iNumRead=0; // odd/even hack - if((iNumRead++)==2) - { - iNumRead=0; - lGPUstatusRet^=0x80000000; // interlaced bit toggle... we do it on every 3 read status... needed by some games (like ChronoCross) with old epsxe versions (1.5.2 and older) - } - } - - if(iFakePrimBusy) // 27.10.2007 - PETE : emulating some 'busy' while drawing... pfff - { - iFakePrimBusy--; - - if(iFakePrimBusy&1) // we do a busy-idle-busy-idle sequence after/while drawing prims - { - GPUIsBusy; - GPUIsNotReadyForCommands; - } - else - { - GPUIsIdle; - GPUIsReadyForCommands; - } - } - return lGPUstatusRet; -} - -//////////////////////////////////////////////////////////////////////// -// processes data send to GPU status register -// these are always single packet commands. -//////////////////////////////////////////////////////////////////////// - -void CALLBACK GPUwriteStatus(uint32_t gdata) // WRITE STATUS -{ - uint32_t lCommand=(gdata>>24)&0xff; - - ulStatusControl[lCommand]=gdata; // store command for freezing - - switch(lCommand) - { - //--------------------------------------------------// - // reset gpu - case 0x00: - memset(lGPUInfoVals,0x00,16*sizeof(uint32_t)); - lGPUstatusRet=0x14802000; - PSXDisplay.Disabled=1; - DataWriteMode=DataReadMode=DR_NORMAL; - PSXDisplay.DrawOffset.x=PSXDisplay.DrawOffset.y=0; - drawX=drawY=0;drawW=drawH=0; - sSetMask=0;lSetMask=0;bCheckMask=FALSE; - usMirror=0; - GlobalTextAddrX=0;GlobalTextAddrY=0; - GlobalTextTP=0;GlobalTextABR=0; - PSXDisplay.RGB24=FALSE; - PSXDisplay.Interlaced=FALSE; - bUsingTWin = FALSE; - return; - //--------------------------------------------------// - // dis/enable display - case 0x03: - - PreviousPSXDisplay.Disabled = PSXDisplay.Disabled; - PSXDisplay.Disabled = (gdata & 1); - - if(PSXDisplay.Disabled) - lGPUstatusRet|=GPUSTATUS_DISPLAYDISABLED; - else lGPUstatusRet&=~GPUSTATUS_DISPLAYDISABLED; - return; - - //--------------------------------------------------// - // setting transfer mode - case 0x04: - gdata &= 0x03; // Only want the lower two bits - - DataWriteMode=DataReadMode=DR_NORMAL; - if(gdata==0x02) DataWriteMode=DR_VRAMTRANSFER; - if(gdata==0x03) DataReadMode =DR_VRAMTRANSFER; - lGPUstatusRet&=~GPUSTATUS_DMABITS; // Clear the current settings of the DMA bits - lGPUstatusRet|=(gdata << 29); // Set the DMA bits according to the received data - - return; - //--------------------------------------------------// - // setting display position - case 0x05: - { - PreviousPSXDisplay.DisplayPosition.x = PSXDisplay.DisplayPosition.x; - PreviousPSXDisplay.DisplayPosition.y = PSXDisplay.DisplayPosition.y; - -// new - PSXDisplay.DisplayPosition.y = (short)((gdata>>10)&0x1ff); - - // store the same val in some helper var, we need it on later compares - PreviousPSXDisplay.DisplayModeNew.x=PSXDisplay.DisplayPosition.y; - - if((PSXDisplay.DisplayPosition.y+PSXDisplay.DisplayMode.y)>512) - { - int dy1=512-PSXDisplay.DisplayPosition.y; - int dy2=(PSXDisplay.DisplayPosition.y+PSXDisplay.DisplayMode.y)-512; - - if(dy1>=dy2) - { - PreviousPSXDisplay.DisplayModeNew.y=-dy2; - } - else - { - PSXDisplay.DisplayPosition.y=0; - PreviousPSXDisplay.DisplayModeNew.y=-dy1; - } - } - else PreviousPSXDisplay.DisplayModeNew.y=0; -// eon - - PSXDisplay.DisplayPosition.x = (short)(gdata & 0x3ff); - PSXDisplay.DisplayEnd.x= - PSXDisplay.DisplayPosition.x+ PSXDisplay.DisplayMode.x; - PSXDisplay.DisplayEnd.y= - PSXDisplay.DisplayPosition.y+ PSXDisplay.DisplayMode.y + PreviousPSXDisplay.DisplayModeNew.y; - PreviousPSXDisplay.DisplayEnd.x= - PreviousPSXDisplay.DisplayPosition.x+ PSXDisplay.DisplayMode.x; - PreviousPSXDisplay.DisplayEnd.y= - PreviousPSXDisplay.DisplayPosition.y+ PSXDisplay.DisplayMode.y + PreviousPSXDisplay.DisplayModeNew.y; - - bDoVSyncUpdate=TRUE; - - if (!(PSXDisplay.Interlaced)) // stupid frame skipping option - { - if(dwActFixes&64) bDoLazyUpdate=TRUE; - } - if(UseFrameSkip) decideSkip(); - }return; - //--------------------------------------------------// - // setting width - case 0x06: - - PSXDisplay.Range.x0=(short)(gdata & 0x7ff); - PSXDisplay.Range.x1=(short)((gdata>>12) & 0xfff); - - PSXDisplay.Range.x1-=PSXDisplay.Range.x0; - - ChangeDispOffsetsX(); - - return; - //--------------------------------------------------// - // setting height - case 0x07: - { - - PSXDisplay.Range.y0=(short)(gdata & 0x3ff); - PSXDisplay.Range.y1=(short)((gdata>>10) & 0x3ff); - - PreviousPSXDisplay.Height = PSXDisplay.Height; - - PSXDisplay.Height = PSXDisplay.Range.y1 - - PSXDisplay.Range.y0 + - PreviousPSXDisplay.DisplayModeNew.y; - - if(PreviousPSXDisplay.Height!=PSXDisplay.Height) - { - PSXDisplay.DisplayModeNew.y=PSXDisplay.Height*PSXDisplay.Double; - - ChangeDispOffsetsY(); - - updateDisplayIfChanged(); - } - return; - } - //--------------------------------------------------// - // setting display infos - case 0x08: - - PSXDisplay.DisplayModeNew.x = - sDispWidths[(gdata & 0x03) | ((gdata & 0x40) >> 4)]; - - if (gdata&0x04) PSXDisplay.Double=2; - else PSXDisplay.Double=1; - - PSXDisplay.DisplayModeNew.y = PSXDisplay.Height*PSXDisplay.Double; - - ChangeDispOffsetsY(); - - PSXDisplay.PAL = (gdata & 0x08)?TRUE:FALSE; // if 1 - PAL mode, else NTSC - PSXDisplay.RGB24New = (gdata & 0x10)?TRUE:FALSE; // if 1 - TrueColor - PSXDisplay.InterlacedNew = (gdata & 0x20)?TRUE:FALSE; // if 1 - Interlace - - lGPUstatusRet&=~GPUSTATUS_WIDTHBITS; // Clear the width bits - lGPUstatusRet|= - (((gdata & 0x03) << 17) | - ((gdata & 0x40) << 10)); // Set the width bits - - if(PSXDisplay.InterlacedNew) - { - if(!PSXDisplay.Interlaced) - { - PreviousPSXDisplay.DisplayPosition.x = PSXDisplay.DisplayPosition.x; - PreviousPSXDisplay.DisplayPosition.y = PSXDisplay.DisplayPosition.y; - } - lGPUstatusRet|=GPUSTATUS_INTERLACED; - } - else lGPUstatusRet&=~(GPUSTATUS_INTERLACED|0x80000000); - - if (PSXDisplay.PAL) - lGPUstatusRet|=GPUSTATUS_PAL; - else lGPUstatusRet&=~GPUSTATUS_PAL; - - if (PSXDisplay.Double==2) - lGPUstatusRet|=GPUSTATUS_DOUBLEHEIGHT; - else lGPUstatusRet&=~GPUSTATUS_DOUBLEHEIGHT; - - if (PSXDisplay.RGB24New) - lGPUstatusRet|=GPUSTATUS_RGB24; - else lGPUstatusRet&=~GPUSTATUS_RGB24; - - updateDisplayIfChanged(); - - return; - //--------------------------------------------------// - // ask about GPU version and other stuff - case 0x10: - - gdata&=0xff; - - switch(gdata) - { - case 0x02: - lGPUdataRet=lGPUInfoVals[INFO_TW]; // tw infos - return; - case 0x03: - lGPUdataRet=lGPUInfoVals[INFO_DRAWSTART]; // draw start - return; - case 0x04: - lGPUdataRet=lGPUInfoVals[INFO_DRAWEND]; // draw end - return; - case 0x05: - case 0x06: - lGPUdataRet=lGPUInfoVals[INFO_DRAWOFF]; // draw offset - return; - case 0x07: - lGPUdataRet=0x02; // gpu type - return; - case 0x08: - case 0x0F: // some bios addr? - lGPUdataRet=0xBFC03720; - return; - } - return; - //--------------------------------------------------// - } -} - -//////////////////////////////////////////////////////////////////////// -// vram read/write helpers, needed by LEWPY's optimized vram read/write :) -//////////////////////////////////////////////////////////////////////// - -static inline void FinishedVRAMWrite(void) -{ - // Set register to NORMAL operation - DataWriteMode = DR_NORMAL; - // Reset transfer values, to prevent mis-transfer of data - VRAMWrite.x = 0; - VRAMWrite.y = 0; - VRAMWrite.Width = 0; - VRAMWrite.Height = 0; - VRAMWrite.ColsRemaining = 0; - VRAMWrite.RowsRemaining = 0; -} - -static inline void FinishedVRAMRead(void) -{ - // Set register to NORMAL operation - DataReadMode = DR_NORMAL; - // Reset transfer values, to prevent mis-transfer of data - VRAMRead.x = 0; - VRAMRead.y = 0; - VRAMRead.Width = 0; - VRAMRead.Height = 0; - VRAMRead.ColsRemaining = 0; - VRAMRead.RowsRemaining = 0; - - // Indicate GPU is no longer ready for VRAM data in the STATUS REGISTER - lGPUstatusRet&=~GPUSTATUS_READYFORVRAM; -} - -//////////////////////////////////////////////////////////////////////// -// core read from vram -//////////////////////////////////////////////////////////////////////// - -void CALLBACK GPUreadDataMem(uint32_t * pMem, int iSize) -{ - int i; - - if(DataReadMode!=DR_VRAMTRANSFER) return; - - GPUIsBusy; - - // adjust read ptr, if necessary - while(VRAMRead.ImagePtr>=psxVuw_eom) - VRAMRead.ImagePtr-=512*1024; - while(VRAMRead.ImagePtr 0) && (VRAMRead.RowsRemaining > 0)) - { - // lower 16 bit - lGPUdataRet=(uint32_t)GETLE16(VRAMRead.ImagePtr); - - VRAMRead.ImagePtr++; - if(VRAMRead.ImagePtr>=psxVuw_eom) VRAMRead.ImagePtr-=512*1024; - VRAMRead.RowsRemaining --; - - if(VRAMRead.RowsRemaining<=0) - { - VRAMRead.RowsRemaining = VRAMRead.Width; - VRAMRead.ColsRemaining--; - VRAMRead.ImagePtr += 1024 - VRAMRead.Width; - if(VRAMRead.ImagePtr>=psxVuw_eom) VRAMRead.ImagePtr-=512*1024; - } - - // higher 16 bit (always, even if it's an odd width) - lGPUdataRet|=(uint32_t)GETLE16(VRAMRead.ImagePtr)<<16; - PUTLE32(pMem, lGPUdataRet); pMem++; - - if(VRAMRead.ColsRemaining <= 0) - {FinishedVRAMRead();goto ENDREAD;} - - VRAMRead.ImagePtr++; - if(VRAMRead.ImagePtr>=psxVuw_eom) VRAMRead.ImagePtr-=512*1024; - VRAMRead.RowsRemaining--; - if(VRAMRead.RowsRemaining<=0) - { - VRAMRead.RowsRemaining = VRAMRead.Width; - VRAMRead.ColsRemaining--; - VRAMRead.ImagePtr += 1024 - VRAMRead.Width; - if(VRAMRead.ImagePtr>=psxVuw_eom) VRAMRead.ImagePtr-=512*1024; - } - if(VRAMRead.ColsRemaining <= 0) - {FinishedVRAMRead();goto ENDREAD;} - } - else {FinishedVRAMRead();goto ENDREAD;} - } - -ENDREAD: - GPUIsIdle; -} - - -//////////////////////////////////////////////////////////////////////// - -uint32_t CALLBACK GPUreadData(void) -{ - uint32_t l; - GPUreadDataMem(&l,1); - return lGPUdataRet; -} - -// Software drawing function -#include "soft.c" - -// PSX drawing primitives -#include "prim.c" - -//////////////////////////////////////////////////////////////////////// -// processes data send to GPU data register -// extra table entries for fixing polyline troubles -//////////////////////////////////////////////////////////////////////// - -static const unsigned char primTableCX[256] = -{ - // 00 - 0,0,3,0,0,0,0,0, - // 08 - 0,0,0,0,0,0,0,0, - // 10 - 0,0,0,0,0,0,0,0, - // 18 - 0,0,0,0,0,0,0,0, - // 20 - 4,4,4,4,7,7,7,7, - // 28 - 5,5,5,5,9,9,9,9, - // 30 - 6,6,6,6,9,9,9,9, - // 38 - 8,8,8,8,12,12,12,12, - // 40 - 3,3,3,3,0,0,0,0, - // 48 -// 5,5,5,5,6,6,6,6, // FLINE - 254,254,254,254,254,254,254,254, - // 50 - 4,4,4,4,0,0,0,0, - // 58 -// 7,7,7,7,9,9,9,9, // GLINE - 255,255,255,255,255,255,255,255, - // 60 - 3,3,3,3,4,4,4,4, - // 68 - 2,2,2,2,3,3,3,3, // 3=SPRITE1??? - // 70 - 2,2,2,2,3,3,3,3, - // 78 - 2,2,2,2,3,3,3,3, - // 80 - 4,0,0,0,0,0,0,0, - // 88 - 0,0,0,0,0,0,0,0, - // 90 - 0,0,0,0,0,0,0,0, - // 98 - 0,0,0,0,0,0,0,0, - // a0 - 3,0,0,0,0,0,0,0, - // a8 - 0,0,0,0,0,0,0,0, - // b0 - 0,0,0,0,0,0,0,0, - // b8 - 0,0,0,0,0,0,0,0, - // c0 - 3,0,0,0,0,0,0,0, - // c8 - 0,0,0,0,0,0,0,0, - // d0 - 0,0,0,0,0,0,0,0, - // d8 - 0,0,0,0,0,0,0,0, - // e0 - 0,1,1,1,1,1,1,0, - // e8 - 0,0,0,0,0,0,0,0, - // f0 - 0,0,0,0,0,0,0,0, - // f8 - 0,0,0,0,0,0,0,0 -}; - -void CALLBACK GPUwriteDataMem(uint32_t * pMem, int iSize) -{ - unsigned char command; - uint32_t gdata=0; - int i=0; - GPUIsBusy; - GPUIsNotReadyForCommands; - -STARTVRAM: - - if(DataWriteMode==DR_VRAMTRANSFER) - { - BOOL bFinished=FALSE; - - // make sure we are in vram - while(VRAMWrite.ImagePtr>=psxVuw_eom) - VRAMWrite.ImagePtr-=512*1024; - while(VRAMWrite.ImagePtr0) - { - while(VRAMWrite.RowsRemaining>0) - { - if(i>=iSize) {goto ENDVRAM;} - i++; - - gdata=GETLE32(pMem); pMem++; - - PUTLE16(VRAMWrite.ImagePtr, (unsigned short)gdata); VRAMWrite.ImagePtr++; - if(VRAMWrite.ImagePtr>=psxVuw_eom) VRAMWrite.ImagePtr-=512*1024; - VRAMWrite.RowsRemaining --; - - if(VRAMWrite.RowsRemaining <= 0) - { - VRAMWrite.ColsRemaining--; - if (VRAMWrite.ColsRemaining <= 0) // last pixel is odd width - { - gdata=(gdata&0xFFFF)|(((uint32_t)GETLE16(VRAMWrite.ImagePtr))<<16); - FinishedVRAMWrite(); - bDoVSyncUpdate=TRUE; - goto ENDVRAM; - } - VRAMWrite.RowsRemaining = VRAMWrite.Width; - VRAMWrite.ImagePtr += 1024 - VRAMWrite.Width; - } - - PUTLE16(VRAMWrite.ImagePtr, (unsigned short)(gdata>>16)); VRAMWrite.ImagePtr++; - if(VRAMWrite.ImagePtr>=psxVuw_eom) VRAMWrite.ImagePtr-=512*1024; - VRAMWrite.RowsRemaining --; - } - - VRAMWrite.RowsRemaining = VRAMWrite.Width; - VRAMWrite.ColsRemaining--; - VRAMWrite.ImagePtr += 1024 - VRAMWrite.Width; - bFinished=TRUE; - } - - FinishedVRAMWrite(); - if(bFinished) bDoVSyncUpdate=TRUE; - } - -ENDVRAM: - - if(DataWriteMode==DR_NORMAL) - { - void (* *primFunc)(unsigned char *); - if(bSkipNextFrame) primFunc=primTableSkip; - else primFunc=primTableJ; - - for(;i>24) & 0xff); - -//if(command>=0xb0 && command<0xc0) auxprintf("b0 %x!!!!!!!!!\n",command); - - if(primTableCX[command]) - { - gpuDataC = primTableCX[command]; - gpuCommand = command; - PUTLE32_(&gpuDataM[0], gdata); - gpuDataP = 1; - } - else continue; - } - else - { - PUTLE32_(&gpuDataM[gpuDataP], gdata); - if(gpuDataC>128) - { - if((gpuDataC==254 && gpuDataP>=3) || - (gpuDataC==255 && gpuDataP>=4 && !(gpuDataP&1))) - { - if((gpuDataM[gpuDataP] & HOST2LE32(0xF000F000)) == HOST2LE32(0x50005000)) - gpuDataP=gpuDataC-1; - } - } - gpuDataP++; - } - - if(gpuDataP == gpuDataC) - { - gpuDataC=gpuDataP=0; - primFunc[gpuCommand]((unsigned char *)gpuDataM); - if(dwActFixes&0x0400) // hack for emulating "gpu busy" in some games - iFakePrimBusy=4; - } - } - } - - lGPUdataRet=gdata; - - GPUIsReadyForCommands; - GPUIsIdle; -} - -//////////////////////////////////////////////////////////////////////// - -void CALLBACK GPUwriteData(uint32_t gdata) -{ - PUTLE32_(&gdata, gdata); - GPUwriteDataMem(&gdata,1); -} - -//////////////////////////////////////////////////////////////////////// -// process gpu commands -//////////////////////////////////////////////////////////////////////// - -unsigned long lUsedAddr[3]; - -static inline BOOL CheckForEndlessLoop(unsigned long laddr) -{ - if(laddr==lUsedAddr[1]) return TRUE; - if(laddr==lUsedAddr[2]) return TRUE; - - if(laddr 2000000) break; - if(CheckForEndlessLoop(addr)) break; - - count = baseAddrB[addr+3]; - dmaWords += 1 + count; - - dmaMem=addr+4; - - if(count>0) GPUwriteDataMem(&baseAddrL[dmaMem>>2],count); - - addr = GETLE32(&baseAddrL[addr>>2])&0xffffff; - } while (!(addr & 0x800000)); // contrary to some documentation, the end-of-linked-list marker is not actually 0xFF'FFFF - // any pointer with bit 23 set will do. - - GPUIsIdle; - - return dmaWords; -} - -//////////////////////////////////////////////////////////////////////// -// Freeze -//////////////////////////////////////////////////////////////////////// - -typedef struct GPUFREEZETAG -{ - uint32_t ulFreezeVersion; // should be always 1 for now (set by main emu) - uint32_t ulStatus; // current gpu status - uint32_t ulControl[256]; // latest control register values - unsigned char psxVRam[1024*1024*2]; // current VRam image (full 2 MB for ZN) -} GPUFreeze_t; - -//////////////////////////////////////////////////////////////////////// - -long CALLBACK GPUfreeze(uint32_t ulGetFreezeData,GPUFreeze_t * pF) -{ - //----------------------------------------------------// - if(ulGetFreezeData==2) // 2: info, which save slot is selected? (just for display) - { - long lSlotNum=*((long *)pF); - if(lSlotNum<0) return 0; - if(lSlotNum>8) return 0; - lSelectedSlot=lSlotNum+1; - return 1; - } - //----------------------------------------------------// - if(!pF) return 0; // some checks - if(pF->ulFreezeVersion!=1) return 0; - - if(ulGetFreezeData==1) // 1: get data - { - pF->ulStatus=lGPUstatusRet; - memcpy(pF->ulControl,ulStatusControl,256*sizeof(uint32_t)); - memcpy(pF->psxVRam, psxVub, 1024*512*2); - - return 1; - } - - if(ulGetFreezeData!=0) return 0; // 0: set data - - lGPUstatusRet=pF->ulStatus; - memcpy(ulStatusControl,pF->ulControl,256*sizeof(uint32_t)); - memcpy(psxVub, pF->psxVRam, 1024*512*2); - -// RESET TEXTURE STORE HERE, IF YOU USE SOMETHING LIKE THAT - - PreviousPSXDisplay.Height = 0; - GPUwriteStatus(ulStatusControl[0]); - GPUwriteStatus(ulStatusControl[1]); - GPUwriteStatus(ulStatusControl[2]); - GPUwriteStatus(ulStatusControl[3]); - GPUwriteStatus(ulStatusControl[8]); // try to repair things - GPUwriteStatus(ulStatusControl[6]); - GPUwriteStatus(ulStatusControl[7]); - GPUwriteStatus(ulStatusControl[5]); - GPUwriteStatus(ulStatusControl[4]); - - return 1; -} - -// rearmed thing -#include "../../frontend/plugin_lib.h" - -const struct rearmed_cbs *rcbs; - -void GPUrearmedCallbacks(const struct rearmed_cbs *cbs) -{ - // sync config - UseFrameSkip = cbs->frameskip; - iUseDither = cbs->gpu_peops.iUseDither; - dwActFixes = cbs->gpu_peops.dwActFixes; - fFrameRateHz = cbs->gpu_peops.fFrameRateHz; - dwFrameRateTicks = cbs->gpu_peops.dwFrameRateTicks; - if (cbs->pl_vout_set_raw_vram) - cbs->pl_vout_set_raw_vram(psxVub); - if (cbs->pl_set_gpu_caps) - cbs->pl_set_gpu_caps(0); - - skip_advice = &cbs->fskip_advice; - fps_skip = 100.0f; - rcbs = cbs; -} diff --git a/plugins/gpu-gles/Makefile b/plugins/gpu-gles/Makefile index 6e10e189..9e046872 100644 --- a/plugins/gpu-gles/Makefile +++ b/plugins/gpu-gles/Makefile @@ -2,7 +2,6 @@ CFLAGS += -ggdb -O2 # -Wall include ../../config.mak -SRC_STANDALONE += gpuDraw.c gpuFps.c gpuPlugin.c gpuPrim.c gpuTexture.c SRC_GPULIB += gpulib_if.c CFLAGS += -I$(PREFIX)include @@ -16,6 +15,5 @@ CFLAGS += $(CFLAGS_GLES) LDLIBS += $(LDLIBS_GLES) endif -#BIN_STANDALONE = gpuGLES.so BIN_GPULIB = gpu_gles.so include ../gpulib/gpulib.mak diff --git a/plugins/gpu-gles/gpuPlugin.c b/plugins/gpu-gles/gpuPlugin.c deleted file mode 100644 index 906d01ee..00000000 --- a/plugins/gpu-gles/gpuPlugin.c +++ /dev/null @@ -1,2658 +0,0 @@ -/*************************************************************************** - gpu.c - description - ------------------- - begin : Sun Mar 08 2009 - copyright : (C) 1999-2009 by Pete Bernert - email : BlackDove@addcom.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. See also the license.txt file for * - * additional informations. * - * * - ***************************************************************************/ - -//*************************************************************************// -// History of changes: -// -// 2009/03/08 - Pete -// - generic cleanup for the Peops release -// -//*************************************************************************// - -//#include "gpuStdafx.h" - -//#include -#define _IN_GPU - -#include -#include -#include -#include -#include "gpuExternals.h" -#include "gpuPlugin.h" -#include "gpuDraw.h" -#include "gpuTexture.h" -#include "gpuFps.h" -#include "gpuPrim.h" - -//#include "NoPic.h" - -#include "gpuStdafx.h" - -short g_m1=255,g_m2=255,g_m3=255; -short DrawSemiTrans=FALSE; -short Ymin; -short Ymax; - -short ly0,lx0,ly1,lx1,ly2,lx2,ly3,lx3; // global psx vertex coords -long GlobalTextAddrX,GlobalTextAddrY,GlobalTextTP; -long GlobalTextREST,GlobalTextABR,GlobalTextPAGE; - -unsigned long dwGPUVersion=0; -int iGPUHeight=512; -int iGPUHeightMask=511; -int GlobalTextIL=0; -int iTileCheat=0; - -//////////////////////////////////////////////////////////////////////// -// memory image of the PSX vram -//////////////////////////////////////////////////////////////////////// - -unsigned char *psxVSecure; -unsigned char *psxVub; -signed char *psxVsb; -unsigned short *psxVuw; -unsigned short *psxVuw_eom; -signed short *psxVsw; -unsigned long *psxVul; -signed long *psxVsl; - -// macro for easy access to packet information -#define GPUCOMMAND(x) ((x>>24) & 0xff) - -GLfloat gl_z=0.0f; -BOOL bNeedInterlaceUpdate=FALSE; -BOOL bNeedRGB24Update=FALSE; -BOOL bChangeWinMode=FALSE; - -unsigned long ulStatusControl[256]; - -//////////////////////////////////////////////////////////////////////// -// global GPU vars -//////////////////////////////////////////////////////////////////////// - -static long GPUdataRet; -long lGPUstatusRet; -char szDispBuf[64]; - -static unsigned long gpuDataM[256]; -static unsigned char gpuCommand = 0; -static long gpuDataC = 0; -static long gpuDataP = 0; - -VRAMLoad_t VRAMWrite; -VRAMLoad_t VRAMRead; -int iDataWriteMode; -int iDataReadMode; - -long lClearOnSwap; -long lClearOnSwapColor; -BOOL bSkipNextFrame = FALSE; -int iColDepth; -BOOL bChangeRes; -BOOL bWindowMode; -int iWinSize; - -// possible psx display widths -short dispWidths[8] = {256,320,512,640,368,384,512,640}; - -PSXDisplay_t PSXDisplay; -PSXDisplay_t PreviousPSXDisplay; -TWin_t TWin; -short imageX0,imageX1; -short imageY0,imageY1; -BOOL bDisplayNotSet = TRUE; -GLuint uiScanLine=0; -int iUseScanLines=0; -long lSelectedSlot=0; -unsigned char * pGfxCardScreen=0; -int iBlurBuffer=0; -int iScanBlend=0; -int iRenderFVR=0; -int iNoScreenSaver=0; -unsigned long ulGPUInfoVals[16]; -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 -//////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////// -// snapshot funcs (saves screen to bitmap / text infos into file) -//////////////////////////////////////////////////////////////////////// - -void ResizeWindow() -{ - rRatioRect.left = rRatioRect.top=0; - rRatioRect.right = iResX; - rRatioRect.bottom = iResY; - glViewport(rRatioRect.left, // init viewport by ratio rect - iResY-(rRatioRect.top+rRatioRect.bottom), - rRatioRect.right, - rRatioRect.bottom); glError(); - - 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" - glLoadIdentity(); - glScalef(1.0f/255.99f,1.0f/255.99f,1.0f); // geforce precision hack -#endif - - glMatrixMode(GL_PROJECTION); glError(); // init projection with psx resolution - glLoadIdentity(); glError(); - glOrtho(0,PSXDisplay.DisplayMode.x, - PSXDisplay.DisplayMode.y, 0, -1, 1); glError(); - if (bKeepRatio) - SetAspectRatio(); -} - -char * GetConfigInfos(int hW) -{ - char szO[2][4]={"off","on "}; - char szTxt[256]; - char * pB=(char *)malloc(32767); -/* - if(!pB) return NULL; - *pB=0; - //----------------------------------------------------// - strcat(pB,szTxt); - strcat(pB,szTxt); -#ifdef _WINDOWS - if(hW) - { - hdc = GetDC(hW); - bSetupPixelFormat(hdc); - hglrc = wglCreateContext(hdc); - wglMakeCurrent(hdc, hglrc); - } -#endif - sprintf(szTxt,"Card vendor: %s\r\n",(char *)glGetString(GL_VENDOR)); - strcat(pB,szTxt); - sprintf(szTxt,"GFX card: %s\r\n",(char *)glGetString(GL_RENDERER)); - strcat(pB,szTxt); - sprintf(szTxt,"OGL version: %s\r\n\r\n",(char *)glGetString(GL_VERSION)); - strcat(pB,szTxt); - //strcat(pB,(char *)glGetString(GL_EXTENSIONS)); - //strcat(pB,"\r\n\r\n"); - -#ifdef _WINDOWS - if(hW) - { - wglMakeCurrent(NULL, NULL); - wglDeleteContext(hglrc); - ReleaseDC(hW,hdc); - } - //----------------------------------------------------// -#endif - if(hW && bWindowMode) - sprintf(szTxt,"Resolution/Color:\r\n- %dx%d ",LOWORD(iWinSize),HIWORD(iWinSize)); - else - sprintf(szTxt,"Resolution/Color:\r\n- %dx%d ",iResX,iResY); - strcat(pB,szTxt); - if(bWindowMode) sprintf(szTxt,"Window mode\r\n"); - else - { - sprintf(szTxt,"Fullscreen "); - strcat(pB,szTxt); - if(bChangeRes) sprintf(szTxt,"- Desktop changing [%d Bit]\r\n",iColDepth); - else sprintf(szTxt,"- NO desktop changing\r\n"); - } - strcat(pB,szTxt); - -// if(iForceVSync>=0) sprintf(szTxt,"- V-Sync: %s\r\n",szO[iForceVSync]); -// else strcpy(szTxt,"- V-Sync: Driver\r\n"); - strcat(pB,szTxt); - sprintf(szTxt,"- Keep psx aspect ratio: %s\r\n\r\n",szO[bKeepRatio]); - strcat(pB,szTxt); - //----------------------------------------------------// - strcpy(szTxt,"Textures:\r\n- "); -/*! if(iTexQuality==0) strcat(szTxt,"Default"); - else if(iTexQuality==1) strcat(szTxt,"R4G4B4A4"); - else if(iTexQuality==2) strcat(szTxt,"R5G5B5A1"); - else if(iTexQuality==3) strcat(szTxt,"R8G8A8A8"); - else if(iTexQuality==4) strcat(szTxt,"B8G8R8A8"); - if(!hW && bGLExt) strcat(szTxt," (packed pixels)\r\n"); - else strcat(szTxt,"\r\n"); - strcat(pB,szTxt); - if(!hW) - { - sprintf(szTxt,"- Filtering: %d - edge clamping ",iFilterType); - if(iClampType==GL_TO_EDGE_CLAMP) strcat(szTxt,"supported\r\n"); - else strcat(szTxt,"NOT supported\r\n"); - } - else sprintf(szTxt,"- iFiltering: %d\r\n",iFilterType); - strcat(pB,szTxt); - sprintf(szTxt,"- Hi-Res textures: %d\r\n",iHiResTextures); - strcat(pB,szTxt); - if(!hW) - { - sprintf(szTxt,"- Palettized tex windows: %s\r\n",szO[iUsePalTextures]); - strcat(pB,szTxt); - } - !*/ - /*sprintf(szTxt,"- VRam size: %d MBytes",iVRamSize); - if(!hW) - sprintf(szTxt+strlen(szTxt)," - %d textures usable\r\n\r\n",iSortTexCnt); - else strcat(szTxt,"\r\n\r\n"); - strcat(pB,szTxt); - //----------------------------------------------------// - sprintf(szTxt,"Framerate:\r\n- FPS limitation: %s\r\n",szO[bUseFrameLimit]); - strcat(pB,szTxt); - sprintf(szTxt,"- Frame skipping: %s\r\n",szO[bUseFrameSkip]); - strcat(pB,szTxt); - if(iFrameLimit==2) - strcpy(szTxt,"- FPS limit: Auto\r\n\r\n"); - else sprintf(szTxt,"- FPS limit: %.1f\r\n\r\n",fFrameRate); - strcat(pB,szTxt); - //----------------------------------------------------// - sprintf(szTxt,"Compatibility:\r\n- Offscreen drawing: %d\r\n",iOffscreenDrawing); - strcat(pB,szTxt); - sprintf(szTxt,"- Framebuffer texture: %d",iFrameTexType); - if(!hW && iFrameTexType==2) - { - if(gTexFrameName) strcat(szTxt," - texture created\r\n"); - else strcat(szTxt," - not used yet\r\n"); - } - else strcat(szTxt,"\r\n"); - strcat(pB,szTxt); - sprintf(szTxt,"- Framebuffer access: %d\r\n",iFrameReadType); - strcat(pB,szTxt); -// sprintf(szTxt,"- Alpha multipass: %s\r\n",szO[bOpaquePass]); - strcat(pB,szTxt); - sprintf(szTxt,"- Mask bit: %s\r\n",szO[iUseMask]); - strcat(pB,szTxt); - //sprintf(szTxt,"- Advanced blending: %s",szO[bAdvancedBlend]); - //if(!hW && bAdvancedBlend) -// { -// if(bGLBlend) strcat(szTxt," (hardware)\r\n"); -// else strcat(szTxt," (software)\r\n"); -// } - strcat(szTxt,"\r\n"); - strcat(pB,szTxt); - - if(!hW) - { - strcpy(szTxt,"- Subtractive blending: "); -// if(glBlendEquationEXTEx) -// { -// if(bUseMultiPass) strcat(szTxt,"supported, but not used!"); -// else strcat(szTxt,"activated"); -// } - strcat(szTxt," NOT supported!"); - strcat(szTxt,"\r\n\r\n"); - } - else strcpy(szTxt,"\r\n"); - - strcat(pB,szTxt); - //----------------------------------------------------// - sprintf(szTxt,"Misc:\r\n- Scanlines: %s",szO[iUseScanLines]); - strcat(pB,szTxt); - if(iUseScanLines) sprintf(szTxt," [%d]\r\n",iScanBlend); - else strcpy(szTxt,"\r\n"); - strcat(pB,szTxt); -// sprintf(szTxt,"- Line mode: %s\r\n",szO[bUseLines]); - strcat(pB,szTxt); -// sprintf(szTxt,"- Line AA: %s\r\n",szO[bUseAntiAlias]); -// fwrite(szTxt,lstrlen(szTxt),1,txtfile); - sprintf(szTxt,"- Unfiltered FB: %s\r\n",szO[bUseFastMdec]); - strcat(pB,szTxt); - sprintf(szTxt,"- 15 bit FB: %s\r\n",szO[bUse15bitMdec]); - strcat(pB,szTxt); - sprintf(szTxt,"- Dithering: %s\r\n",szO[bDrawDither]); - strcat(pB,szTxt); - sprintf(szTxt,"- Screen smoothing: %s",szO[iBlurBuffer]); - strcat(pB,szTxt); - if(!hW && iBlurBuffer) - { - if(gTexBlurName) strcat(pB," - supported\r\n"); - else strcat(pB," - not supported\r\n"); - } - else strcat(pB,"\r\n"); - sprintf(szTxt,"- Game fixes: %s [%08lx]\r\n",szO[bUseFixes],dwCfgFixes); - strcat(pB,szTxt); - //----------------------------------------------------// -*/ return pB; -} - -//////////////////////////////////////////////////////////////////////// -// save text infos to file -//////////////////////////////////////////////////////////////////////// - -void DoTextSnapShot(int iNum) -{ -} - -//////////////////////////////////////////////////////////////////////// -// saves screen bitmap to file -//////////////////////////////////////////////////////////////////////// - -void DoSnapShot(void) -{ -} - -void CALLBACK GPUmakeSnapshot(void) -{ - //bSnapShot = TRUE; -} - -//////////////////////////////////////////////////////////////////////// -// GPU INIT... here starts it all (first func called by emu) -//////////////////////////////////////////////////////////////////////// - -long CALLBACK GPUinit() -{ -memset(ulStatusControl,0,256*sizeof(unsigned long)); - -bChangeRes=FALSE; -bWindowMode=FALSE; - -bKeepRatio = TRUE; -// different ways of accessing PSX VRAM - -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! -psxVsb=(signed char *)psxVub; -psxVsw=(signed short *)psxVub; -psxVsl=(signed long *)psxVub; -psxVuw=(unsigned short *)psxVub; -psxVul=(unsigned long *)psxVub; - -psxVuw_eom=psxVuw+1024*iGPUHeight; // pre-calc of end of vram - -memset(psxVSecure,0x00,(iGPUHeight*2)*1024 + (1024*1024)); -memset(ulGPUInfoVals,0x00,16*sizeof(unsigned long)); - -InitFrameCap(); // init frame rate stuff - -PSXDisplay.RGB24 = 0; // init vars -PreviousPSXDisplay.RGB24= 0; -PSXDisplay.Interlaced = 0; -PSXDisplay.InterlacedTest=0; -PSXDisplay.DrawOffset.x = 0; -PSXDisplay.DrawOffset.y = 0; -PSXDisplay.DrawArea.x0 = 0; -PSXDisplay.DrawArea.y0 = 0; -PSXDisplay.DrawArea.x1 = 320; -PSXDisplay.DrawArea.y1 = 240; -PSXDisplay.DisplayMode.x= 320; -PSXDisplay.DisplayMode.y= 240; -PSXDisplay.Disabled = FALSE; -PreviousPSXDisplay.Range.x0 =0; -PreviousPSXDisplay.Range.x1 =0; -PreviousPSXDisplay.Range.y0 =0; -PreviousPSXDisplay.Range.y1 =0; -PSXDisplay.Range.x0=0; -PSXDisplay.Range.x1=0; -PSXDisplay.Range.y0=0; -PSXDisplay.Range.y1=0; -PreviousPSXDisplay.DisplayPosition.x = 1; -PreviousPSXDisplay.DisplayPosition.y = 1; -PSXDisplay.DisplayPosition.x = 1; -PSXDisplay.DisplayPosition.y = 1; -PreviousPSXDisplay.DisplayModeNew.y=0; -PSXDisplay.Double=1; -GPUdataRet=0x400; - -PSXDisplay.DisplayModeNew.x=0; -PSXDisplay.DisplayModeNew.y=0; - -//PreviousPSXDisplay.Height = PSXDisplay.Height = 239; - -iDataWriteMode = DR_NORMAL; - -// Reset transfer values, to prevent mis-transfer of data -memset(&VRAMWrite,0,sizeof(VRAMLoad_t)); -memset(&VRAMRead,0,sizeof(VRAMLoad_t)); - -// device initialised already ! -//lGPUstatusRet = 0x74000000; - -STATUSREG = 0x14802000; -GPUIsIdle; -GPUIsReadyForCommands; - -return 0; -} - - -//////////////////////////////////////////////////////////////////////// -// OPEN interface func: attention! -// some emus are calling this func in their main Window thread, -// but all other interface funcs (to draw stuff) in a different thread! -// that's a problem, since OGL is thread safe! Therefore we cannot -// initialize the OGL stuff right here, we simply set a "bIsFirstFrame = TRUE" -// flag, to initialize OGL on the first real draw call. -// btw, we also call this open func ourselfes, each time when the user -// is changing between fullscreen/window mode (ENTER key) -// btw part 2: in windows the plugin gets the window handle from the -// main emu, and doesn't create it's own window (if it would do it, -// some PAD or SPU plugins would not work anymore) -//////////////////////////////////////////////////////////////////////// - -long CALLBACK GPUopen(unsigned long *disp, char *cap, char *cfg) -{ - iResX=800;iResY=480; - iColDepth=8; - bChangeRes=FALSE; - bWindowMode=FALSE; - bFullVRam=FALSE; - iFilterType=0; - // bAdvancedBlend=FALSE; - bDrawDither=FALSE; - // bUseLines=FALSE; - bUseFrameLimit=FALSE; - bUseFrameSkip=FALSE; - iFrameLimit=0; - fFrameRate=50.0f; - iOffscreenDrawing=0; - //bOpaquePass=FALSE; - //bUseAntiAlias=FALSE; - //iTexQuality=0; - iUseMask=0; - iZBufferDepth=0; - bUseFastMdec=FALSE; - bUse15bitMdec=FALSE; - dwCfgFixes=0; - bUseFixes=FALSE; - // iUseScanLines=0; - iFrameTexType=0; - iFrameReadType=0; - //iShowFPS=0; - bKeepRatio=TRUE; - iScanBlend=0; - iVRamSize=0; - iTexGarbageCollection=0; - iBlurBuffer=0; - //iHiResTextures=0; - iNoScreenSaver=0; - //iForceVSync=0; - - - - bIsFirstFrame = TRUE; // flag: we have to init OGL later in windows! - - rRatioRect.left = rRatioRect.top=0; - rRatioRect.right = iResX; - rRatioRect.bottom = iResY; - - bDisplayNotSet = TRUE; - bSetClip=TRUE; - - SetFixes(); // setup game fixes - - 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(NULL, NULL); - - return 0; -} - -//////////////////////////////////////////////////////////////////////// -// close -//////////////////////////////////////////////////////////////////////// - - -long GPUclose() // LINUX CLOSE -{ - GLcleanup(); // close OGL - - if(pGfxCardScreen) free(pGfxCardScreen); // free helper memory - pGfxCardScreen=0; - -// osd_close_display(); // destroy display - - return 0; -} - -//////////////////////////////////////////////////////////////////////// -// I shot the sheriff... last function called from emu -//////////////////////////////////////////////////////////////////////// - -long CALLBACK GPUshutdown() -{ - if(psxVSecure) free(psxVSecure); // kill emulated vram memory - psxVSecure=0; - - return 0; -} - -//////////////////////////////////////////////////////////////////////// -// paint it black: simple func to clean up optical border garbage -//////////////////////////////////////////////////////////////////////// - -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(); - - glEnable(GL_ALPHA_TEST); glError(); - glEnable(GL_SCISSOR_TEST); glError(); - -} - -//////////////////////////////////////////////////////////////////////// -// helper to draw scanlines -//////////////////////////////////////////////////////////////////////// - -__inline void XPRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2, - OGLVertex* vertex3, OGLVertex* vertex4) -{ - -} - -//////////////////////////////////////////////////////////////////////// -// scanlines -//////////////////////////////////////////////////////////////////////// - -void SetScanLines(void) -{ -} - -//////////////////////////////////////////////////////////////////////// -// blur, babe, blur (heavy performance hit for a so-so fullscreen effect) -//////////////////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////////////////// -// Update display (swap buffers)... called in interlaced mode on -// every emulated vsync, otherwise whenever the displayed screen region -// has been changed -//////////////////////////////////////////////////////////////////////// - -int iLastRGB24=0; // special vars for checking when to skip two display updates -int iSkipTwo=0; -void GPUvSinc(void){ -updateDisplay(); -} -void updateDisplay(void) // UPDATE DISPLAY -{ -BOOL bBlur=FALSE; - - -bFakeFrontBuffer=FALSE; -bRenderFrontBuffer=FALSE; - -if(iRenderFVR) // frame buffer read fix mode still active? - { - iRenderFVR--; // -> if some frames in a row without read access: turn off mode - if(!iRenderFVR) bFullVRam=FALSE; - } - -if(iLastRGB24 && iLastRGB24!=PSXDisplay.RGB24+1) // (mdec) garbage check - { - iSkipTwo=2; // -> skip two frames to avoid garbage if color mode changes - } -iLastRGB24=0; - -if(PSXDisplay.RGB24)// && !bNeedUploadAfter) // (mdec) upload wanted? - { - PrepareFullScreenUpload(-1); - UploadScreen(PSXDisplay.Interlaced); // -> upload whole screen from psx vram - bNeedUploadTest=FALSE; - bNeedInterlaceUpdate=FALSE; - bNeedUploadAfter=FALSE; - bNeedRGB24Update=FALSE; - } -else -if(bNeedInterlaceUpdate) // smaller upload? - { - bNeedInterlaceUpdate=FALSE; - xrUploadArea=xrUploadAreaIL; // -> upload this rect - UploadScreen(TRUE); - } - -if(dwActFixes&512) bCheckFF9G4(NULL); // special game fix for FF9 - -if(PreviousPSXDisplay.Range.x0|| // paint black borders around display area, if needed - PreviousPSXDisplay.Range.y0) - PaintBlackBorders(); - -if(PSXDisplay.Disabled) // display disabled? - { - //LOGE("PSXDisplay.Disabled"); - - // moved here - 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; - } - -if(iSkipTwo) // we are in skipping mood? - { - iSkipTwo--; - iDrawnSomething=0; // -> simply lie about something drawn - } - -//if(iBlurBuffer && !bSkipNextFrame) // "blur display" activated? -// {BlurBackBuffer();bBlur=TRUE;} // -> blur it - -// if(iUseScanLines) SetScanLines(); // "scan lines" activated? do it - -// if(usCursorActive) ShowGunCursor(); // "gun cursor" wanted? show 'em - -if(dwActFixes&128) // special FPS limitation mode? - { - if(bUseFrameLimit) PCFrameCap(); // -> ok, do it -// if(bUseFrameSkip || ulKeybits&KEY_SHOWFPS) - PCcalcfps(); - } - -// if(gTexPicName) DisplayPic(); // some gpu info picture active? display it - -// if(bSnapShot) DoSnapShot(); // snapshot key pressed? cheeeese :) - -// if(ulKeybits&KEY_SHOWFPS) // wanna see FPS? - { -// sprintf(szDispBuf,"%06.1f",fps_cur); -// DisplayText(); // -> show it - } - -//----------------------------------------------------// -// main buffer swapping (well, or skip it) - -if(bUseFrameSkip) // frame skipping active ? - { - if(!bSkipNextFrame) - { - if(iDrawnSomething) flipEGL(); - } - if((fps_skip < fFrameRateHz) && !(bSkipNextFrame)) - {bSkipNextFrame = TRUE; fps_skip=fFrameRateHz;} - else bSkipNextFrame = FALSE; - - } -else // no skip ? - { - if(iDrawnSomething) flipEGL(); - } - -iDrawnSomething=0; - -//----------------------------------------------------// - -if(lClearOnSwap) // clear buffer after swap? - { - GLclampf g,b,r; - - if(bDisplayNotSet) // -> set new vals - SetOGLDisplaySettings(1); - - g=((GLclampf)GREEN(lClearOnSwapColor))/255.0f; // -> get col - b=((GLclampf)BLUE(lClearOnSwapColor))/255.0f; - r=((GLclampf)RED(lClearOnSwapColor))/255.0f; - glDisable(GL_SCISSOR_TEST); glError(); - glClearColor(r,g,b,128); glError(); // -> clear - glClear(uiBufferBits); glError(); - glEnable(GL_SCISSOR_TEST); glError(); - lClearOnSwap=0; // -> done - } -else - { -// if(bBlur) UnBlurBackBuffer(); // unblur buff, if blurred before - - if(iZBufferDepth) // clear zbuffer as well (if activated) - { - glDisable(GL_SCISSOR_TEST); glError(); - glClear(GL_DEPTH_BUFFER_BIT); glError(); - glEnable(GL_SCISSOR_TEST); glError(); - } - } - -gl_z=0.0f; - -//----------------------------------------------------// -// additional uploads immediatly after swapping - -if(bNeedUploadAfter) // upload wanted? - { - bNeedUploadAfter=FALSE; - bNeedUploadTest=FALSE; - UploadScreen(-1); // -> upload - } - -if(bNeedUploadTest) - { - bNeedUploadTest=FALSE; - if(PSXDisplay.InterlacedTest && - //iOffscreenDrawing>2 && - PreviousPSXDisplay.DisplayPosition.x==PSXDisplay.DisplayPosition.x && - PreviousPSXDisplay.DisplayEnd.x==PSXDisplay.DisplayEnd.x && - PreviousPSXDisplay.DisplayPosition.y==PSXDisplay.DisplayPosition.y && - PreviousPSXDisplay.DisplayEnd.y==PSXDisplay.DisplayEnd.y) - { - PrepareFullScreenUpload(TRUE); - UploadScreen(TRUE); - } - } - -//----------------------------------------------------// -// rumbling (main emu pad effect) - -if(iRumbleTime) // shake screen by modifying view port - { - int i1=0,i2=0,i3=0,i4=0; - - iRumbleTime--; - if(iRumbleTime) - { - i1=((rand()*iRumbleVal)/RAND_MAX)-(iRumbleVal/2); - i2=((rand()*iRumbleVal)/RAND_MAX)-(iRumbleVal/2); - i3=((rand()*iRumbleVal)/RAND_MAX)-(iRumbleVal/2); - i4=((rand()*iRumbleVal)/RAND_MAX)-(iRumbleVal/2); - } - - glViewport(rRatioRect.left+i1, - iResY-(rRatioRect.top+rRatioRect.bottom)+i2, - rRatioRect.right+i3, - rRatioRect.bottom+i4); glError(); - } - -//----------------------------------------------------// - - - -// if(ulKeybits&KEY_RESETTEXSTORE) ResetStuff(); // reset on gpu mode changes? do it before next frame is filled -} - -//////////////////////////////////////////////////////////////////////// -// update front display: smaller update func, if something has changed -// in the frontbuffer... dirty, but hey... real men know no pain -//////////////////////////////////////////////////////////////////////// - -void updateFrontDisplay(void) -{ -if(PreviousPSXDisplay.Range.x0|| - PreviousPSXDisplay.Range.y0) - PaintBlackBorders(); - -//if(iBlurBuffer) BlurBackBuffer(); - -//if(iUseScanLines) SetScanLines(); - -// if(usCursorActive) ShowGunCursor(); - -bFakeFrontBuffer=FALSE; -bRenderFrontBuffer=FALSE; - -// if(gTexPicName) DisplayPic(); -// if(ulKeybits&KEY_SHOWFPS) DisplayText(); - -if(iDrawnSomething) // linux: - flipEGL(); - - -//if(iBlurBuffer) UnBlurBackBuffer(); -} - -//////////////////////////////////////////////////////////////////////// -// check if update needed -//////////////////////////////////////////////////////////////////////// -void ChangeDispOffsetsX(void) // CENTER X -{ -long lx,l;short sO; - -if(!PSXDisplay.Range.x1) return; // some range given? - -l=PSXDisplay.DisplayMode.x; - -l*=(long)PSXDisplay.Range.x1; // some funky calculation -l/=2560;lx=l;l&=0xfffffff8; - -if(l==PreviousPSXDisplay.Range.x1) return; // some change? - -sO=PreviousPSXDisplay.Range.x0; // store old - -if(lx>=PSXDisplay.DisplayMode.x) // range bigger? - { - PreviousPSXDisplay.Range.x1= // -> take display width - PSXDisplay.DisplayMode.x; - PreviousPSXDisplay.Range.x0=0; // -> start pos is 0 - } -else // range smaller? center it - { - PreviousPSXDisplay.Range.x1=l; // -> store width (8 pixel aligned) - PreviousPSXDisplay.Range.x0= // -> calc start pos - (PSXDisplay.Range.x0-500)/8; - if(PreviousPSXDisplay.Range.x0<0) // -> we don't support neg. values yet - PreviousPSXDisplay.Range.x0=0; - - if((PreviousPSXDisplay.Range.x0+lx)> // -> uhuu... that's too much - PSXDisplay.DisplayMode.x) - { - PreviousPSXDisplay.Range.x0= // -> adjust start - PSXDisplay.DisplayMode.x-lx; - PreviousPSXDisplay.Range.x1+=lx-l; // -> adjust width - } - } - -if(sO!=PreviousPSXDisplay.Range.x0) // something changed? - { - bDisplayNotSet=TRUE; // -> recalc display stuff - } -} - -//////////////////////////////////////////////////////////////////////// - -void ChangeDispOffsetsY(void) // CENTER Y -{ -int iT;short sO; // store previous y size - -if(PSXDisplay.PAL) iT=48; else iT=28; // different offsets on PAL/NTSC - -if(PSXDisplay.Range.y0>=iT) // crossed the security line? :) - { - PreviousPSXDisplay.Range.y1= // -> store width - PSXDisplay.DisplayModeNew.y; - - sO=(PSXDisplay.Range.y0-iT-4)*PSXDisplay.Double; // -> calc offset - if(sO<0) sO=0; - - PSXDisplay.DisplayModeNew.y+=sO; // -> add offset to y size, too - } -else sO=0; // else no offset - -if(sO!=PreviousPSXDisplay.Range.y0) // something changed? - { - PreviousPSXDisplay.Range.y0=sO; - bDisplayNotSet=TRUE; // -> recalc display stuff - } -} - -//////////////////////////////////////////////////////////////////////// -// Aspect ratio of ogl screen: simply adjusting ogl view port -//////////////////////////////////////////////////////////////////////// - -void SetAspectRatio(void) -{ -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; - -s=min(xs,ys); -r.right =(int)((float)PSXDisplay.DisplayModeNew.x*s); -r.bottom=(int)((float)PSXDisplay.DisplayModeNew.y*s); -if(r.right > iResX) r.right = iResX; -if(r.bottom > iResY) r.bottom = iResY; -if(r.right < 1) r.right = 1; -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); glError(); - if(bKeepRatio) SetAspectRatio(); - } - -bDisplayNotSet = TRUE; // re-calc offsets/display area - -bUp=FALSE; -if(PSXDisplay.RGB24!=PSXDisplay.RGB24New) // clean up textures, if rgb mode change (usually mdec on/off) - { - PreviousPSXDisplay.RGB24=0; // no full 24 frame uploaded yet - ResetTextureArea(FALSE); - bUp=TRUE; - } - -PSXDisplay.RGB24 = PSXDisplay.RGB24New; // get new infos -PSXDisplay.DisplayMode.y = PSXDisplay.DisplayModeNew.y; -PSXDisplay.DisplayMode.x = PSXDisplay.DisplayModeNew.x; -PSXDisplay.Interlaced = PSXDisplay.InterlacedNew; - -PSXDisplay.DisplayEnd.x= // calc new ends - PSXDisplay.DisplayPosition.x+ PSXDisplay.DisplayMode.x; -PSXDisplay.DisplayEnd.y= - PSXDisplay.DisplayPosition.y+ PSXDisplay.DisplayMode.y+PreviousPSXDisplay.DisplayModeNew.y; -PreviousPSXDisplay.DisplayEnd.x= - PreviousPSXDisplay.DisplayPosition.x+ PSXDisplay.DisplayMode.x; -PreviousPSXDisplay.DisplayEnd.y= - PreviousPSXDisplay.DisplayPosition.y+ PSXDisplay.DisplayMode.y+PreviousPSXDisplay.DisplayModeNew.y; - -ChangeDispOffsetsX(); - -if(iFrameLimit==2) SetAutoFrameCap(); // set new fps limit vals (depends on interlace) - -if(bUp) updateDisplay(); // yeah, real update (swap buffer) -} - -//////////////////////////////////////////////////////////////////////// -// window mode <-> fullscreen mode (windows) -//////////////////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////////////////// -// swap update check (called by psx vsync function) -//////////////////////////////////////////////////////////////////////// - -BOOL bSwapCheck(void) -{ -static int iPosCheck=0; -static PSXPoint_t pO; -static PSXPoint_t pD; -static int iDoAgain=0; - -if(PSXDisplay.DisplayPosition.x==pO.x && - PSXDisplay.DisplayPosition.y==pO.y && - PSXDisplay.DisplayEnd.x==pD.x && - PSXDisplay.DisplayEnd.y==pD.y) - iPosCheck++; -else iPosCheck=0; - -pO=PSXDisplay.DisplayPosition; -pD=PSXDisplay.DisplayEnd; - -if(iPosCheck<=4) return FALSE; - -iPosCheck=4; - -if(PSXDisplay.Interlaced) return FALSE; - -if (bNeedInterlaceUpdate|| - bNeedRGB24Update || - bNeedUploadAfter|| - bNeedUploadTest || - iDoAgain - ) - { - iDoAgain=0; - if(bNeedUploadAfter) - iDoAgain=1; - if(bNeedUploadTest && PSXDisplay.InterlacedTest) - iDoAgain=1; - - bDisplayNotSet = TRUE; - updateDisplay(); - - PreviousPSXDisplay.DisplayPosition.x=PSXDisplay.DisplayPosition.x; - PreviousPSXDisplay.DisplayPosition.y=PSXDisplay.DisplayPosition.y; - PreviousPSXDisplay.DisplayEnd.x=PSXDisplay.DisplayEnd.x; - PreviousPSXDisplay.DisplayEnd.y=PSXDisplay.DisplayEnd.y; - pO=PSXDisplay.DisplayPosition; - pD=PSXDisplay.DisplayEnd; - - return TRUE; - } - -return FALSE; -} -//////////////////////////////////////////////////////////////////////// -// gun cursor func: player=0-7, x=0-511, y=0-255 -//////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////// -// update lace is called every VSync. Basically we limit frame rate -// here, and in interlaced mode we swap ogl display buffers. -//////////////////////////////////////////////////////////////////////// - -static unsigned short usFirstPos=2; - -void CALLBACK GPUupdateLace(void) -{ -if(!(dwActFixes&0x1000)) - STATUSREG^=0x80000000; // interlaced bit toggle, if the CC game fix is not active (see gpuReadStatus) - -if(!(dwActFixes&128)) // normal frame limit func - CheckFrameRate(); - -if(iOffscreenDrawing==4) // special check if high offscreen drawing is on - { - if(bSwapCheck()) return; - } - -if(PSXDisplay.Interlaced) // interlaced mode? - { - if(PSXDisplay.DisplayMode.x>0 && PSXDisplay.DisplayMode.y>0) - { - updateDisplay(); // -> swap buffers (new frame) - } - } -else if(bRenderFrontBuffer) // no interlace mode? and some stuff in front has changed? - { - updateFrontDisplay(); // -> update front buffer - } -else if(usFirstPos==1) // initial updates (after startup) - { - updateDisplay(); - } - -} - -//////////////////////////////////////////////////////////////////////// -// process read request from GPU status register -//////////////////////////////////////////////////////////////////////// - -unsigned long CALLBACK GPUreadStatus(void) -{ -if(dwActFixes&0x1000) // CC game fix - { - static int iNumRead=0; - if((iNumRead++)==2) - { - iNumRead=0; - STATUSREG^=0x80000000; // interlaced bit toggle... we do it on every second read status... needed by some games (like ChronoCross) - } - } - -if(iFakePrimBusy) // 27.10.2007 - emulating some 'busy' while drawing... pfff... not perfect, but since our emulated dma is not done in an extra thread... - { - iFakePrimBusy--; - - if(iFakePrimBusy&1) // we do a busy-idle-busy-idle sequence after/while drawing prims - { - GPUIsBusy; - GPUIsNotReadyForCommands; - } - else - { - GPUIsIdle; - GPUIsReadyForCommands; - } - } - -return STATUSREG; -} - -//////////////////////////////////////////////////////////////////////// -// processes data send to GPU status register -// these are always single packet commands. -//////////////////////////////////////////////////////////////////////// - -void CALLBACK GPUwriteStatus(unsigned long gdata) -{ -unsigned long lCommand=(gdata>>24)&0xff; - -if(bIsFirstFrame) GLinitialize(NULL, NULL); // real ogl startup (needed by some emus) - -ulStatusControl[lCommand]=gdata; - -switch(lCommand) - { - //--------------------------------------------------// - // reset gpu - case 0x00: - memset(ulGPUInfoVals,0x00,16*sizeof(unsigned long)); - lGPUstatusRet=0x14802000; - PSXDisplay.Disabled=1; - iDataWriteMode=iDataReadMode=DR_NORMAL; - PSXDisplay.DrawOffset.x=PSXDisplay.DrawOffset.y=0; - drawX=drawY=0;drawW=drawH=0; - sSetMask=0;lSetMask=0;bCheckMask=FALSE;iSetMask=0; - usMirror=0; - GlobalTextAddrX=0;GlobalTextAddrY=0; - GlobalTextTP=0;GlobalTextABR=0; - PSXDisplay.RGB24=FALSE; - PSXDisplay.Interlaced=FALSE; - bUsingTWin = FALSE; - return; - - // dis/enable display - case 0x03: - PreviousPSXDisplay.Disabled = PSXDisplay.Disabled; - PSXDisplay.Disabled = (gdata & 1); - - if(PSXDisplay.Disabled) - STATUSREG|=GPUSTATUS_DISPLAYDISABLED; - else STATUSREG&=~GPUSTATUS_DISPLAYDISABLED; - - if (iOffscreenDrawing==4 && - PreviousPSXDisplay.Disabled && - !(PSXDisplay.Disabled)) - { - - if(!PSXDisplay.RGB24) - { - PrepareFullScreenUpload(TRUE); - UploadScreen(TRUE); - updateDisplay(); - } - } - - return; - - // setting transfer mode - case 0x04: - gdata &= 0x03; // only want the lower two bits - - iDataWriteMode=iDataReadMode=DR_NORMAL; - if(gdata==0x02) iDataWriteMode=DR_VRAMTRANSFER; - if(gdata==0x03) iDataReadMode =DR_VRAMTRANSFER; - - STATUSREG&=~GPUSTATUS_DMABITS; // clear the current settings of the DMA bits - STATUSREG|=(gdata << 29); // set the DMA bits according to the received data - - return; - - // setting display position - case 0x05: - { - short sx=(short)(gdata & 0x3ff); - short sy; - - if(iGPUHeight==1024) - { - if(dwGPUVersion==2) - sy = (short)((gdata>>12)&0x3ff); - else sy = (short)((gdata>>10)&0x3ff); - } - else sy = (short)((gdata>>10)&0x3ff); // really: 0x1ff, but we adjust it later - - if (sy & 0x200) - { - sy|=0xfc00; - PreviousPSXDisplay.DisplayModeNew.y=sy/PSXDisplay.Double; - sy=0; - } - else PreviousPSXDisplay.DisplayModeNew.y=0; - - if(sx>1000) sx=0; - - if(usFirstPos) - { - usFirstPos--; - if(usFirstPos) - { - PreviousPSXDisplay.DisplayPosition.x = sx; - PreviousPSXDisplay.DisplayPosition.y = sy; - PSXDisplay.DisplayPosition.x = sx; - PSXDisplay.DisplayPosition.y = sy; - } - } - - if(dwActFixes&8) - { - if((!PSXDisplay.Interlaced) && - PreviousPSXDisplay.DisplayPosition.x == sx && - PreviousPSXDisplay.DisplayPosition.y == sy) - return; - - PSXDisplay.DisplayPosition.x = PreviousPSXDisplay.DisplayPosition.x; - PSXDisplay.DisplayPosition.y = PreviousPSXDisplay.DisplayPosition.y; - PreviousPSXDisplay.DisplayPosition.x = sx; - PreviousPSXDisplay.DisplayPosition.y = sy; - } - else - { - if((!PSXDisplay.Interlaced) && - PSXDisplay.DisplayPosition.x == sx && - PSXDisplay.DisplayPosition.y == sy) - return; - PreviousPSXDisplay.DisplayPosition.x = PSXDisplay.DisplayPosition.x; - PreviousPSXDisplay.DisplayPosition.y = PSXDisplay.DisplayPosition.y; - PSXDisplay.DisplayPosition.x = sx; - PSXDisplay.DisplayPosition.y = sy; - } - - PSXDisplay.DisplayEnd.x= - PSXDisplay.DisplayPosition.x+ PSXDisplay.DisplayMode.x; - PSXDisplay.DisplayEnd.y= - PSXDisplay.DisplayPosition.y+ PSXDisplay.DisplayMode.y+PreviousPSXDisplay.DisplayModeNew.y; - - PreviousPSXDisplay.DisplayEnd.x= - PreviousPSXDisplay.DisplayPosition.x+ PSXDisplay.DisplayMode.x; - PreviousPSXDisplay.DisplayEnd.y= - PreviousPSXDisplay.DisplayPosition.y+ PSXDisplay.DisplayMode.y+PreviousPSXDisplay.DisplayModeNew.y; - - bDisplayNotSet = TRUE; - - if (!(PSXDisplay.Interlaced)) - { - updateDisplay(); - } - else - if(PSXDisplay.InterlacedTest && - ((PreviousPSXDisplay.DisplayPosition.x != PSXDisplay.DisplayPosition.x)|| - (PreviousPSXDisplay.DisplayPosition.y != PSXDisplay.DisplayPosition.y))) - PSXDisplay.InterlacedTest--; - - return; - } - - // setting width - case 0x06: - - PSXDisplay.Range.x0=gdata & 0x7ff; //0x3ff; - PSXDisplay.Range.x1=(gdata>>12) & 0xfff;//0x7ff; - - PSXDisplay.Range.x1-=PSXDisplay.Range.x0; - - ChangeDispOffsetsX(); - - return; - - // setting height - case 0x07: - - PreviousPSXDisplay.Height = PSXDisplay.Height; - - PSXDisplay.Range.y0=gdata & 0x3ff; - PSXDisplay.Range.y1=(gdata>>10) & 0x3ff; - - PSXDisplay.Height = PSXDisplay.Range.y1 - - PSXDisplay.Range.y0 + - PreviousPSXDisplay.DisplayModeNew.y; - - if (PreviousPSXDisplay.Height != PSXDisplay.Height) - { - PSXDisplay.DisplayModeNew.y=PSXDisplay.Height*PSXDisplay.Double; - ChangeDispOffsetsY(); - updateDisplayIfChanged(); - } - return; - - // setting display infos - case 0x08: - - PSXDisplay.DisplayModeNew.x = dispWidths[(gdata & 0x03) | ((gdata & 0x40) >> 4)]; - - if (gdata&0x04) PSXDisplay.Double=2; - else PSXDisplay.Double=1; - PSXDisplay.DisplayModeNew.y = PSXDisplay.Height*PSXDisplay.Double; - - ChangeDispOffsetsY(); - - PSXDisplay.PAL = (gdata & 0x08)?TRUE:FALSE; // if 1 - PAL mode, else NTSC - PSXDisplay.RGB24New = (gdata & 0x10)?TRUE:FALSE; // if 1 - TrueColor - PSXDisplay.InterlacedNew = (gdata & 0x20)?TRUE:FALSE; // if 1 - Interlace - - STATUSREG&=~GPUSTATUS_WIDTHBITS; // clear the width bits - - STATUSREG|= - (((gdata & 0x03) << 17) | - ((gdata & 0x40) << 10)); // set the width bits - - PreviousPSXDisplay.InterlacedNew=FALSE; - if (PSXDisplay.InterlacedNew) - { - if(!PSXDisplay.Interlaced) - { - PSXDisplay.InterlacedTest=2; - PreviousPSXDisplay.DisplayPosition.x = PSXDisplay.DisplayPosition.x; - PreviousPSXDisplay.DisplayPosition.y = PSXDisplay.DisplayPosition.y; - PreviousPSXDisplay.InterlacedNew=TRUE; - } - - STATUSREG|=GPUSTATUS_INTERLACED; - } - else - { - PSXDisplay.InterlacedTest=0; - STATUSREG&=~GPUSTATUS_INTERLACED; - } - - if (PSXDisplay.PAL) - STATUSREG|=GPUSTATUS_PAL; - else STATUSREG&=~GPUSTATUS_PAL; - - if (PSXDisplay.Double==2) - STATUSREG|=GPUSTATUS_DOUBLEHEIGHT; - else STATUSREG&=~GPUSTATUS_DOUBLEHEIGHT; - - if (PSXDisplay.RGB24New) - STATUSREG|=GPUSTATUS_RGB24; - else STATUSREG&=~GPUSTATUS_RGB24; - - updateDisplayIfChanged(); - - return; - - //--------------------------------------------------// - // ask about GPU version and other stuff - case 0x10: - - gdata&=0xff; - - switch(gdata) - { - case 0x02: - GPUdataRet=ulGPUInfoVals[INFO_TW]; // tw infos - return; - case 0x03: - GPUdataRet=ulGPUInfoVals[INFO_DRAWSTART]; // draw start - return; - case 0x04: - GPUdataRet=ulGPUInfoVals[INFO_DRAWEND]; // draw end - return; - case 0x05: - case 0x06: - GPUdataRet=ulGPUInfoVals[INFO_DRAWOFF]; // draw offset - return; - case 0x07: - if(dwGPUVersion==2) - GPUdataRet=0x01; - else GPUdataRet=0x02; // gpu type - return; - case 0x08: - case 0x0F: // some bios addr? - GPUdataRet=0xBFC03720; - return; - } - return; - //--------------------------------------------------// - } -} - -//////////////////////////////////////////////////////////////////////// -// vram read/write helpers -//////////////////////////////////////////////////////////////////////// - -BOOL bNeedWriteUpload=FALSE; - -__inline void FinishedVRAMWrite(void) -{ - if(bNeedWriteUpload) - { - bNeedWriteUpload=FALSE; - CheckWriteUpdate(); - } - - // set register to NORMAL operation - iDataWriteMode = DR_NORMAL; - - // reset transfer values, to prevent mis-transfer of data - VRAMWrite.ColsRemaining = 0; - VRAMWrite.RowsRemaining = 0; -} - -__inline void FinishedVRAMRead(void) -{ - // set register to NORMAL operation - iDataReadMode = DR_NORMAL; - // reset transfer values, to prevent mis-transfer of data - VRAMRead.x = 0; - VRAMRead.y = 0; - VRAMRead.Width = 0; - VRAMRead.Height = 0; - VRAMRead.ColsRemaining = 0; - VRAMRead.RowsRemaining = 0; - - // indicate GPU is no longer ready for VRAM data in the STATUS REGISTER - STATUSREG&=~GPUSTATUS_READYFORVRAM; -} - -//////////////////////////////////////////////////////////////////////// -// vram read check ex (reading from card's back/frontbuffer if needed... -// slow!) -//////////////////////////////////////////////////////////////////////// - -void CheckVRamReadEx(int x, int y, int dx, int dy) -{ - unsigned short sArea; - int ux,uy,udx,udy,wx,wy; - unsigned short * p1, *p2; - float XS,YS; - unsigned char * ps; - unsigned char * px; - unsigned short s,sx; - - if(STATUSREG&GPUSTATUS_RGB24) return; - - if(((dx > PSXDisplay.DisplayPosition.x) && - (x < PSXDisplay.DisplayEnd.x) && - (dy > PSXDisplay.DisplayPosition.y) && - (y < PSXDisplay.DisplayEnd.y))) - sArea=0; - else - if((!(PSXDisplay.InterlacedTest) && - (dx > PreviousPSXDisplay.DisplayPosition.x) && - (x < PreviousPSXDisplay.DisplayEnd.x) && - (dy > PreviousPSXDisplay.DisplayPosition.y) && - (y < PreviousPSXDisplay.DisplayEnd.y))) - sArea=1; - else - { - return; - } - - ////////////// - - if(iRenderFVR) - { - bFullVRam=TRUE;iRenderFVR=2;return; - } - bFullVRam=TRUE;iRenderFVR=2; - - ////////////// - - p2=0; - - if(sArea==0) - { - ux=PSXDisplay.DisplayPosition.x; - uy=PSXDisplay.DisplayPosition.y; - udx=PSXDisplay.DisplayEnd.x-ux; - udy=PSXDisplay.DisplayEnd.y-uy; - if((PreviousPSXDisplay.DisplayEnd.x- - PreviousPSXDisplay.DisplayPosition.x)==udx && - (PreviousPSXDisplay.DisplayEnd.y- - PreviousPSXDisplay.DisplayPosition.y)==udy) - p2=(psxVuw + (1024*PreviousPSXDisplay.DisplayPosition.y) + - PreviousPSXDisplay.DisplayPosition.x); - } - else - { - ux=PreviousPSXDisplay.DisplayPosition.x; - uy=PreviousPSXDisplay.DisplayPosition.y; - udx=PreviousPSXDisplay.DisplayEnd.x-ux; - udy=PreviousPSXDisplay.DisplayEnd.y-uy; - if((PSXDisplay.DisplayEnd.x- - PSXDisplay.DisplayPosition.x)==udx && - (PSXDisplay.DisplayEnd.y- - PSXDisplay.DisplayPosition.y)==udy) - p2=(psxVuw + (1024*PSXDisplay.DisplayPosition.y) + - PSXDisplay.DisplayPosition.x); - } - - p1=(psxVuw + (1024*uy) + ux); - if(p1==p2) p2=0; - - x=0;y=0; - wx=dx=udx;wy=dy=udy; - - if(udx<=0) return; - if(udy<=0) return; - if(dx<=0) return; - if(dy<=0) return; - if(wx<=0) return; - if(wy<=0) return; - - XS=(float)rRatioRect.right/(float)wx; - YS=(float)rRatioRect.bottom/(float)wy; - - dx=(int)((float)(dx)*XS); - dy=(int)((float)(dy)*YS); - - if(dx>iResX) dx=iResX; - if(dy>iResY) dy=iResY; - - if(dx<=0) return; - if(dy<=0) return; - - // ogl y adjust - y=iResY-y-dy; - - x+=rRatioRect.left; - y-=rRatioRect.top; - - if(y<0) y=0; if((y+dy)>iResY) dy=iResY-y; - - if(!pGfxCardScreen) - { - 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); glError(); - //if(!sArea) glReadBuffer(GL_BACK); - - s=0; - - XS=(float)dx/(float)(udx); - YS=(float)dy/(float)(udy+1); - - for(y=udy;y>0;y--) - { - for(x=0;x=psxVuw && p1>3;px++; - s=sx; - sx=(*px)>>3;px++; - s|=sx<<5; - sx=(*px)>>3; - s|=sx<<10; - s&=~0x8000; - *p1=s; - } - if(p2>=psxVuw && p2 PSXDisplay.DisplayPosition.x) && - (x < PSXDisplay.DisplayEnd.x) && - (dy > PSXDisplay.DisplayPosition.y) && - (y < PSXDisplay.DisplayEnd.y))) - sArea=0; - else - if((!(PSXDisplay.InterlacedTest) && - (dx > PreviousPSXDisplay.DisplayPosition.x) && - (x < PreviousPSXDisplay.DisplayEnd.x) && - (dy > PreviousPSXDisplay.DisplayPosition.y) && - (y < PreviousPSXDisplay.DisplayEnd.y))) - sArea=1; - else - { - return; - } - - if(dwActFixes&0x40) - { - if(iRenderFVR) - { - bFullVRam=TRUE;iRenderFVR=2;return; - } - bFullVRam=TRUE;iRenderFVR=2; - } - - ux=x;uy=y;udx=dx;udy=dy; - - if(sArea==0) - { - x -=PSXDisplay.DisplayPosition.x; - dx-=PSXDisplay.DisplayPosition.x; - y -=PSXDisplay.DisplayPosition.y; - dy-=PSXDisplay.DisplayPosition.y; - wx=PSXDisplay.DisplayEnd.x-PSXDisplay.DisplayPosition.x; - wy=PSXDisplay.DisplayEnd.y-PSXDisplay.DisplayPosition.y; - } - else - { - x -=PreviousPSXDisplay.DisplayPosition.x; - dx-=PreviousPSXDisplay.DisplayPosition.x; - y -=PreviousPSXDisplay.DisplayPosition.y; - dy-=PreviousPSXDisplay.DisplayPosition.y; - wx=PreviousPSXDisplay.DisplayEnd.x-PreviousPSXDisplay.DisplayPosition.x; - wy=PreviousPSXDisplay.DisplayEnd.y-PreviousPSXDisplay.DisplayPosition.y; - } - if(x<0) {ux-=x;x=0;} - if(y<0) {uy-=y;y=0;} - if(dx>wx) {udx-=(dx-wx);dx=wx;} - if(dy>wy) {udy-=(dy-wy);dy=wy;} - udx-=ux; - udy-=uy; - - p=(psxVuw + (1024*uy) + ux); - - if(udx<=0) return; - if(udy<=0) return; - if(dx<=0) return; - if(dy<=0) return; - if(wx<=0) return; - if(wy<=0) return; - - XS=(float)rRatioRect.right/(float)wx; - YS=(float)rRatioRect.bottom/(float)wy; - - dx=(int)((float)(dx)*XS); - dy=(int)((float)(dy)*YS); - x=(int)((float)x*XS); - y=(int)((float)y*YS); - - dx-=x; - dy-=y; - - if(dx>iResX) dx=iResX; - if(dy>iResY) dy=iResY; - - if(dx<=0) return; - if(dy<=0) return; - - // ogl y adjust - y=iResY-y-dy; - - x+=rRatioRect.left; - y-=rRatioRect.top; - - if(y<0) y=0; if((y+dy)>iResY) dy=iResY-y; - - if(!pGfxCardScreen) - { - 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); glError(); glError(); -// if(bFront) glReadBuffer(GL_BACK); - - XS=(float)dx/(float)(udx); - YS=(float)dy/(float)(udy+1); - - for(y=udy;y>0;y--) - { - for(x=0;x=psxVuw && p>3;px++; - s=sx; - sx=(*px)>>3;px++; - s|=sx<<5; - sx=(*px)>>3; - s|=sx<<10; - s&=~0x8000; - *p=s; - } - p++; - } - p += 1024 - udx; - } -} - -//////////////////////////////////////////////////////////////////////// -// core read from vram -//////////////////////////////////////////////////////////////////////// - -void CALLBACK GPUreadDataMem(unsigned long * pMem, int iSize) -{ -int i; - -if(iDataReadMode!=DR_VRAMTRANSFER) return; - -GPUIsBusy; - -// adjust read ptr, if necessary -while(VRAMRead.ImagePtr>=psxVuw_eom) - VRAMRead.ImagePtr-=iGPUHeight*1024; -while(VRAMRead.ImagePtr1) && - !(iDrawnSomething==2 && - VRAMRead.x == VRAMWrite.x && - VRAMRead.y == VRAMWrite.y && - VRAMRead.Width == VRAMWrite.Width && - VRAMRead.Height == VRAMWrite.Height)) - CheckVRamRead(VRAMRead.x,VRAMRead.y, - VRAMRead.x+VRAMRead.RowsRemaining, - VRAMRead.y+VRAMRead.ColsRemaining, - TRUE); - -for(i=0;i 0) && (VRAMRead.RowsRemaining > 0)) - { - // lower 16 bit - GPUdataRet=(unsigned long)*VRAMRead.ImagePtr; - - VRAMRead.ImagePtr++; - if(VRAMRead.ImagePtr>=psxVuw_eom) VRAMRead.ImagePtr-=iGPUHeight*1024; - VRAMRead.RowsRemaining --; - - if(VRAMRead.RowsRemaining<=0) - { - VRAMRead.RowsRemaining = VRAMRead.Width; - VRAMRead.ColsRemaining--; - VRAMRead.ImagePtr += 1024 - VRAMRead.Width; - if(VRAMRead.ImagePtr>=psxVuw_eom) VRAMRead.ImagePtr-=iGPUHeight*1024; - } - - // higher 16 bit (always, even if it's an odd width) - GPUdataRet|=(unsigned long)(*VRAMRead.ImagePtr)<<16; - *pMem++=GPUdataRet; - - if(VRAMRead.ColsRemaining <= 0) - {FinishedVRAMRead();goto ENDREAD;} - - VRAMRead.ImagePtr++; - if(VRAMRead.ImagePtr>=psxVuw_eom) VRAMRead.ImagePtr-=iGPUHeight*1024; - VRAMRead.RowsRemaining--; - if(VRAMRead.RowsRemaining<=0) - { - VRAMRead.RowsRemaining = VRAMRead.Width; - VRAMRead.ColsRemaining--; - VRAMRead.ImagePtr += 1024 - VRAMRead.Width; - if(VRAMRead.ImagePtr>=psxVuw_eom) VRAMRead.ImagePtr-=iGPUHeight*1024; - } - if(VRAMRead.ColsRemaining <= 0) - {FinishedVRAMRead();goto ENDREAD;} - } - else {FinishedVRAMRead();goto ENDREAD;} - } - -ENDREAD: -GPUIsIdle; -} - -unsigned long CALLBACK GPUreadData(void) -{ - unsigned long l; - GPUreadDataMem(&l,1); - return GPUdataRet; -} - -//////////////////////////////////////////////////////////////////////// -// helper table to know how much data is used by drawing commands -//////////////////////////////////////////////////////////////////////// - -const unsigned char primTableCX[256] = -{ - // 00 - 0,0,3,0,0,0,0,0, - // 08 - 0,0,0,0,0,0,0,0, - // 10 - 0,0,0,0,0,0,0,0, - // 18 - 0,0,0,0,0,0,0,0, - // 20 - 4,4,4,4,7,7,7,7, - // 28 - 5,5,5,5,9,9,9,9, - // 30 - 6,6,6,6,9,9,9,9, - // 38 - 8,8,8,8,12,12,12,12, - // 40 - 3,3,3,3,0,0,0,0, - // 48 -// 5,5,5,5,6,6,6,6, //FLINE - 254,254,254,254,254,254,254,254, - // 50 - 4,4,4,4,0,0,0,0, - // 58 -// 7,7,7,7,9,9,9,9, // LINEG3 LINEG4 - 255,255,255,255,255,255,255,255, - // 60 - 3,3,3,3,4,4,4,4, // TILE SPRT - // 68 - 2,2,2,2,3,3,3,3, // TILE1 - // 70 - 2,2,2,2,3,3,3,3, - // 78 - 2,2,2,2,3,3,3,3, - // 80 - 4,0,0,0,0,0,0,0, - // 88 - 0,0,0,0,0,0,0,0, - // 90 - 0,0,0,0,0,0,0,0, - // 98 - 0,0,0,0,0,0,0,0, - // a0 - 3,0,0,0,0,0,0,0, - // a8 - 0,0,0,0,0,0,0,0, - // b0 - 0,0,0,0,0,0,0,0, - // b8 - 0,0,0,0,0,0,0,0, - // c0 - 3,0,0,0,0,0,0,0, - // c8 - 0,0,0,0,0,0,0,0, - // d0 - 0,0,0,0,0,0,0,0, - // d8 - 0,0,0,0,0,0,0,0, - // e0 - 0,1,1,1,1,1,1,0, - // e8 - 0,0,0,0,0,0,0,0, - // f0 - 0,0,0,0,0,0,0,0, - // f8 - 0,0,0,0,0,0,0,0 -}; - -//////////////////////////////////////////////////////////////////////// -// processes data send to GPU data register -//////////////////////////////////////////////////////////////////////// - -void CALLBACK GPUwriteDataMem(unsigned long * pMem, int iSize) -{ -unsigned char command; -unsigned long gdata=0; -int i=0; -GPUIsBusy; -GPUIsNotReadyForCommands; - -STARTVRAM: - -if(iDataWriteMode==DR_VRAMTRANSFER) - { - // make sure we are in vram - while(VRAMWrite.ImagePtr>=psxVuw_eom) - VRAMWrite.ImagePtr-=iGPUHeight*1024; - while(VRAMWrite.ImagePtr0) - { - while(VRAMWrite.RowsRemaining>0) - { - if(i>=iSize) {goto ENDVRAM;} - i++; - - gdata=*pMem++; - - *VRAMWrite.ImagePtr++ = (unsigned short)gdata; - if(VRAMWrite.ImagePtr>=psxVuw_eom) VRAMWrite.ImagePtr-=iGPUHeight*1024; - VRAMWrite.RowsRemaining --; - - if(VRAMWrite.RowsRemaining <= 0) - { - VRAMWrite.ColsRemaining--; - if (VRAMWrite.ColsRemaining <= 0) // last pixel is odd width - { - gdata=(gdata&0xFFFF)|(((unsigned long)(*VRAMWrite.ImagePtr))<<16); - FinishedVRAMWrite(); - goto ENDVRAM; - } - VRAMWrite.RowsRemaining = VRAMWrite.Width; - VRAMWrite.ImagePtr += 1024 - VRAMWrite.Width; - } - - *VRAMWrite.ImagePtr++ = (unsigned short)(gdata>>16); - if(VRAMWrite.ImagePtr>=psxVuw_eom) VRAMWrite.ImagePtr-=iGPUHeight*1024; - VRAMWrite.RowsRemaining --; - } - - VRAMWrite.RowsRemaining = VRAMWrite.Width; - VRAMWrite.ColsRemaining--; - VRAMWrite.ImagePtr += 1024 - VRAMWrite.Width; - } - - FinishedVRAMWrite(); - } - -ENDVRAM: - -if(iDataWriteMode==DR_NORMAL) - { - void (* *primFunc)(unsigned char *); - if(bSkipNextFrame) primFunc=primTableSkip; - else primFunc=primTableJ; - - for(;i>24) & 0xff); - - if(primTableCX[command]) - { - gpuDataC = primTableCX[command]; - gpuCommand = command; - gpuDataM[0] = gdata; - gpuDataP = 1; - } - else continue; - } - else - { - gpuDataM[gpuDataP] = gdata; - if(gpuDataC>128) - { - if((gpuDataC==254 && gpuDataP>=3) || - (gpuDataC==255 && gpuDataP>=4 && !(gpuDataP&1))) - { - if((gpuDataM[gpuDataP] & 0xF000F000) == 0x50005000) - gpuDataP=gpuDataC-1; - } - } - gpuDataP++; - } - - if(gpuDataP == gpuDataC) - { - gpuDataC=gpuDataP=0; - primFunc[gpuCommand]((unsigned char *)gpuDataM); - - if(dwEmuFixes&0x0001 || dwActFixes&0x20000) // hack for emulating "gpu busy" in some games - iFakePrimBusy=4; - } - } - } - -GPUdataRet=gdata; - -GPUIsReadyForCommands; -GPUIsIdle; -} - -//////////////////////////////////////////////////////////////////////// - -void CALLBACK GPUwriteData(unsigned long gdata) -{ - GPUwriteDataMem(&gdata,1); -} - -//////////////////////////////////////////////////////////////////////// -// this function will be removed soon (or 'soonish') (or never) -//////////////////////////////////////////////////////////////////////// - -void CALLBACK GPUsetMode(unsigned int gdata) -{ - // ignore old psemu setmode: - - // imageTransfer = gdata; - // iDataWriteMode=(gdata&1)?DR_VRAMTRANSFER:DR_NORMAL; - // iDataReadMode =(gdata&2)?DR_VRAMTRANSFER:DR_NORMAL; -} - -// and this function will be removed soon as well, hehehe... -long CALLBACK GPUgetMode(void) -{ - // ignore old psemu setmode - // return imageTransfer; - -long iT=0; - -if(iDataWriteMode==DR_VRAMTRANSFER) iT|=0x1; -if(iDataReadMode ==DR_VRAMTRANSFER) iT|=0x2; - -return iT; -} - -//////////////////////////////////////////////////////////////////////// -// call config dlg (Windows + Linux) -//////////////////////////////////////////////////////////////////////// - -#ifndef _WINDOWS - -/*#include - -void StartCfgTool(char * pCmdLine) // linux: start external cfg tool -{ - FILE * cf;char filename[255],t[255]; - - strcpy(filename,"cfg/cfgPeopsMesaGL"); // look in cfg sub folder first - cf=fopen(filename,"rb"); - if(cf!=NULL) - { - fclose(cf); - getcwd(t,255); - chdir("cfg"); - sprintf(filename,"./cfgPeopsMesaGL %s",pCmdLine); - system(filename); - chdir(t); - } - else - { - strcpy(filename,"cfgPeopsMesaGL"); // look in current folder - cf=fopen(filename,"rb"); - if(cf!=NULL) - { - fclose(cf); - sprintf(filename,"./cfgPeopsMesaGL %s",pCmdLine); - system(filename); - } - else - { - sprintf(filename,"%s/cfgPeopsMesaGL",getenv("HOME")); // look in home folder - cf=fopen(filename,"rb"); - if(cf!=NULL) - { - fclose(cf); - getcwd(t,255); - chdir(getenv("HOME")); - sprintf(filename,"./cfgPeopsMesaGL %s",pCmdLine); - system(filename); - chdir(t); - } - else printf("cfgPeopsMesaGL not found!\n"); - } - } -} -*/ -#endif - - -long CALLBACK GPUconfigure(void) -{ - - - return 0; -} - -//////////////////////////////////////////////////////////////////////// -// sets all kind of act fixes -//////////////////////////////////////////////////////////////////////// - -void SetFixes(void) -{ - ReInitFrameCap(); - - if(dwActFixes & 0x2000) - dispWidths[4]=384; - else dispWidths[4]=368; -} - -//////////////////////////////////////////////////////////////////////// -// Pete Special: make an 'intelligent' dma chain check (<-Tekken3) -//////////////////////////////////////////////////////////////////////// - -unsigned long lUsedAddr[3]; - -__inline BOOL CheckForEndlessLoop(unsigned long laddr) -{ -if(laddr==lUsedAddr[1]) return TRUE; -if(laddr==lUsedAddr[2]) return TRUE; - -if(laddr 2000000) break; - if(CheckForEndlessLoop(addr)) break; - - count = baseAddrB[addr+3]; - - dmaMem=addr+4; - - if(count>0) GPUwriteDataMem(&baseAddrL[dmaMem>>2],count); - - addr = baseAddrL[addr>>2]&0xffffff; - } while (!(addr & 0x800000)); // contrary to some documentation, the end-of-linked-list marker is not actually 0xFF'FFFF - // any pointer with bit 23 set will do. -GPUIsIdle; - -return 0; -} - -//////////////////////////////////////////////////////////////////////// -// show about dlg -//////////////////////////////////////////////////////////////////////// - -void CALLBACK GPUabout(void) -{ - -} - -//////////////////////////////////////////////////////////////////////// -// We are ever fine ;) -//////////////////////////////////////////////////////////////////////// - -long CALLBACK GPUtest(void) -{ - // 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) - - return 0; -} - -//////////////////////////////////////////////////////////////////////// -// save state funcs -//////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////// - -long CALLBACK GPUfreeze(unsigned long ulGetFreezeData,GPUFreeze_t * pF) -{ -if(ulGetFreezeData==2) - { - long lSlotNum=*((long *)pF); - if(lSlotNum<0) return 0; - if(lSlotNum>8) return 0; - lSelectedSlot=lSlotNum+1; - return 1; - } - -if(!pF) return 0; -if(pF->ulFreezeVersion!=1) return 0; - -if(ulGetFreezeData==1) - { - pF->ulStatus=STATUSREG; - memcpy(pF->ulControl,ulStatusControl,256*sizeof(unsigned long)); - memcpy(pF->psxVRam, psxVub, 1024*iGPUHeight*2); - - return 1; - } - -if(ulGetFreezeData!=0) return 0; - -STATUSREG=pF->ulStatus; -memcpy(ulStatusControl,pF->ulControl,256*sizeof(unsigned long)); -memcpy(psxVub, pF->psxVRam, 1024*iGPUHeight*2); - -ResetTextureArea(TRUE); - - 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]); - return 1; -} - -//////////////////////////////////////////////////////////////////////// -// special "emu infos" / "emu effects" functions -//////////////////////////////////////////////////////////////////////// - -//00 = black -//01 = white -//10 = red -//11 = transparent - -unsigned char cFont[10][120]= -{ -// 0 -{0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x05,0x54,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x05,0x54,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa -}, -// 1 -{0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x50,0x00,0x00, - 0x80,0x00,0x05,0x50,0x00,0x00, - 0x80,0x00,0x00,0x50,0x00,0x00, - 0x80,0x00,0x00,0x50,0x00,0x00, - 0x80,0x00,0x00,0x50,0x00,0x00, - 0x80,0x00,0x00,0x50,0x00,0x00, - 0x80,0x00,0x00,0x50,0x00,0x00, - 0x80,0x00,0x00,0x50,0x00,0x00, - 0x80,0x00,0x00,0x50,0x00,0x00, - 0x80,0x00,0x05,0x55,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa -}, -// 2 -{0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x05,0x54,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x00,0x05,0x00,0x00, - 0x80,0x00,0x00,0x05,0x00,0x00, - 0x80,0x00,0x00,0x14,0x00,0x00, - 0x80,0x00,0x00,0x50,0x00,0x00, - 0x80,0x00,0x01,0x40,0x00,0x00, - 0x80,0x00,0x05,0x00,0x00,0x00, - 0x80,0x00,0x14,0x00,0x00,0x00, - 0x80,0x00,0x15,0x55,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa -}, -// 3 -{0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x05,0x54,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x00,0x05,0x00,0x00, - 0x80,0x00,0x00,0x05,0x00,0x00, - 0x80,0x00,0x01,0x54,0x00,0x00, - 0x80,0x00,0x00,0x05,0x00,0x00, - 0x80,0x00,0x00,0x05,0x00,0x00, - 0x80,0x00,0x00,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x05,0x54,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa -}, -// 4 -{0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x14,0x00,0x00, - 0x80,0x00,0x00,0x54,0x00,0x00, - 0x80,0x00,0x01,0x54,0x00,0x00, - 0x80,0x00,0x01,0x54,0x00,0x00, - 0x80,0x00,0x05,0x14,0x00,0x00, - 0x80,0x00,0x14,0x14,0x00,0x00, - 0x80,0x00,0x15,0x55,0x00,0x00, - 0x80,0x00,0x00,0x14,0x00,0x00, - 0x80,0x00,0x00,0x14,0x00,0x00, - 0x80,0x00,0x00,0x55,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa -}, -// 5 -{0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x15,0x55,0x00,0x00, - 0x80,0x00,0x14,0x00,0x00,0x00, - 0x80,0x00,0x14,0x00,0x00,0x00, - 0x80,0x00,0x14,0x00,0x00,0x00, - 0x80,0x00,0x15,0x54,0x00,0x00, - 0x80,0x00,0x00,0x05,0x00,0x00, - 0x80,0x00,0x00,0x05,0x00,0x00, - 0x80,0x00,0x00,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x05,0x54,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa -}, -// 6 -{0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x01,0x54,0x00,0x00, - 0x80,0x00,0x05,0x00,0x00,0x00, - 0x80,0x00,0x14,0x00,0x00,0x00, - 0x80,0x00,0x14,0x00,0x00,0x00, - 0x80,0x00,0x15,0x54,0x00,0x00, - 0x80,0x00,0x15,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x05,0x54,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa -}, -// 7 -{0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x15,0x55,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x00,0x14,0x00,0x00, - 0x80,0x00,0x00,0x14,0x00,0x00, - 0x80,0x00,0x00,0x50,0x00,0x00, - 0x80,0x00,0x00,0x50,0x00,0x00, - 0x80,0x00,0x01,0x40,0x00,0x00, - 0x80,0x00,0x01,0x40,0x00,0x00, - 0x80,0x00,0x05,0x00,0x00,0x00, - 0x80,0x00,0x05,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa -}, -// 8 -{0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x05,0x54,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x05,0x54,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x05,0x54,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa -}, -// 9 -{0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x05,0x54,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x14,0x05,0x00,0x00, - 0x80,0x00,0x14,0x15,0x00,0x00, - 0x80,0x00,0x05,0x55,0x00,0x00, - 0x80,0x00,0x00,0x05,0x00,0x00, - 0x80,0x00,0x00,0x05,0x00,0x00, - 0x80,0x00,0x00,0x14,0x00,0x00, - 0x80,0x00,0x05,0x50,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0x80,0x00,0x00,0x00,0x00,0x00, - 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa -} -}; - -//////////////////////////////////////////////////////////////////////// - -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;} - if(c==2) {*p++=0x00;*p++=0x00;*p=0xff;return;} -} - -//////////////////////////////////////////////////////////////////////// - -long CALLBACK GPUgetScreenPic(unsigned char * pMem) -{ - float XS,YS;int x,y,v; - unsigned char * ps, * px, * pf; - unsigned char c; - - if(!pGfxCardScreen) - { - 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); glError(); - -// glReadBuffer(GL_BACK); - - XS=(float)iResX/128; - YS=(float)iResY/96; - pf=pMem; - - for(y=96;y>0;y--) - { - for(x=0;x<128;x++) - { - px=ps+(3*((int)((float)x * XS))+ - (3*iResX)*((int)((float)y*YS))); - *(pf+0)=*(px+2); - *(pf+1)=*(px+1); - *(pf+2)=*(px+0); - pf+=3; - } - } - - ///////////////////////////////////////////////////////////////////// - // generic number/border painter - - pf=pMem+(103*3); - - for(y=0;y<20;y++) - { - for(x=0;x<6;x++) - { - c=cFont[lSelectedSlot][x+y*6]; - v=(c&0xc0)>>6; - PaintPicDot(pf,(unsigned char)v);pf+=3; // paint the dots into the rect - v=(c&0x30)>>4; - PaintPicDot(pf,(unsigned char)v);pf+=3; - v=(c&0x0c)>>2; - PaintPicDot(pf,(unsigned char)v);pf+=3; - v=c&0x03; - PaintPicDot(pf,(unsigned char)v);pf+=3; - } - pf+=104*3; - } - - pf=pMem; - for(x=0;x<128;x++) - { - *(pf+(95*128*3))=0x00;*pf++=0x00; - *(pf+(95*128*3))=0x00;*pf++=0x00; - *(pf+(95*128*3))=0xff;*pf++=0xff; - } - pf=pMem; - for(y=0;y<96;y++) - { - *(pf+(127*3))=0x00;*pf++=0x00; - *(pf+(127*3))=0x00;*pf++=0x00; - *(pf+(127*3))=0xff;*pf++=0xff; - pf+=127*3; - } - -} - -//////////////////////////////////////////////////////////////////////// - -long CALLBACK GPUshowScreenPic(unsigned char * pMem) -{ -// DestroyPic(); -// if(pMem==0) return; -// CreatePic(pMem); -} - -//////////////////////////////////////////////////////////////////////// - -void CALLBACK GPUsetfix(unsigned long dwFixBits) -{ - dwEmuFixes=dwFixBits; -} - -//////////////////////////////////////////////////////////////////////// - -void CALLBACK GPUvisualVibration(unsigned long iSmall, unsigned long iBig) -{ - int iVibVal; - - if(PSXDisplay.DisplayModeNew.x) // calc min "shake pixel" from screen width - iVibVal=max(1,iResX/PSXDisplay.DisplayModeNew.x); - else iVibVal=1; - // big rumble: 4...15 sp ; small rumble 1...3 sp - if(iBig) iRumbleVal=max(4*iVibVal,min(15*iVibVal,((int)iBig *iVibVal)/10)); - else iRumbleVal=max(1*iVibVal,min( 3*iVibVal,((int)iSmall*iVibVal)/10)); - - srand(timeGetTime()); // init rand (will be used in BufferSwap) - - iRumbleTime=15; // let the rumble last 16 buffer swaps -} - -//////////////////////////////////////////////////////////////////////// -// main emu can set display infos (A/M/G/D) -//////////////////////////////////////////////////////////////////////// - -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); -} diff --git a/plugins/gpu-gles/gpuPlugin.h b/plugins/gpu-gles/gpuPlugin.h index fd803d0f..1ac821bf 100644 --- a/plugins/gpu-gles/gpuPlugin.h +++ b/plugins/gpu-gles/gpuPlugin.h @@ -55,40 +55,6 @@ extern "C" { #define bool unsigned short -#if 0 -typedef struct { - unsigned int ulFreezeVersion; - unsigned int ulStatus; - unsigned int ulControl[256]; - unsigned char psxVRam[1024*1024*2]; -} GPUFreeze_t; - -long CALLBACK GPUinit(); -long CALLBACK GPUshutdown(); -long CALLBACK GPUopen(unsigned long *disp, char *cap, char *cfg); -long CALLBACK GPUclose(); -unsigned long CALLBACK GPUreadData(void); -void CALLBACK GPUreadDataMem(unsigned long * pMem, int iSize); -unsigned long CALLBACK GPUreadStatus(void); -void CALLBACK GPUwriteData(unsigned long gdata); -void CALLBACK GPUwriteDataMem(unsigned long * pMem, int iSize); -void CALLBACK GPUwriteStatus(unsigned long gdata); -long CALLBACK GPUdmaChain(unsigned long * baseAddrL, unsigned long addr); -void CALLBACK GPUupdateLace(void); -void CALLBACK GPUmakeSnapshot(void); -long CALLBACK GPUfreeze(unsigned long ulGetFreezeData,GPUFreeze_t * pF); -long CALLBACK GPUgetScreenPic(unsigned char * pMem); -long CALLBACK GPUshowScreenPic(unsigned char * pMem); -//void CALLBACK GPUkeypressed(int keycode); -//void CALLBACK GPUdisplayText(s8 * pText); -//void CALLBACK GPUclearDynarec(void (CALLBACK *callback)(void)); -long CALLBACK GPUconfigure(void); -long CALLBACK GPUtest(void); -void CALLBACK GPUabout(void); -#endif - -void DoSnapShot(void); -void GPUvSinc(void); void updateDisplay(void); void updateFrontDisplay(void); void SetAutoFrameCap(void); @@ -97,8 +63,6 @@ void CheckVRamRead(int x, int y, int dx, int dy, bool bFront); void CheckVRamReadEx(int x, int y, int dx, int dy); void SetFixes(void); -void PaintPicDot(unsigned char * p,unsigned char c); -//void DrawNumBorPic(unsigned char *pMem, int lSelectedSlot); void ResizeWindow(); //////////////////////////////////////////////////////////////////////////// diff --git a/plugins/gpu_unai/Makefile b/plugins/gpu_unai/Makefile index 8fe90cb5..12bb26ed 100644 --- a/plugins/gpu_unai/Makefile +++ b/plugins/gpu_unai/Makefile @@ -7,13 +7,11 @@ CFLAGS += -DUSE_GPULIB=1 include ../../config.mak -SRC_STANDALONE += gpu.cpp SRC_GPULIB += gpulib_if.cpp old/if.cpp ifeq "$(ARCH)" "arm" SRC += gpu_arm.S endif -#BIN_STANDALONE = gpuPCSX4ALL.so BIN_GPULIB = gpu_unai.so include ../gpulib/gpulib.mak diff --git a/plugins/gpu_unai/gpu.cpp b/plugins/gpu_unai/gpu.cpp deleted file mode 100644 index c3f70954..00000000 --- a/plugins/gpu_unai/gpu.cpp +++ /dev/null @@ -1,830 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2010 PCSX4ALL Team * -* Copyright (C) 2010 Unai * -* Copyright (C) 2016 Senquack (dansilsby gmail com) * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * -***************************************************************************/ - -#include -#include "plugins.h" -#include "psxcommon.h" -//#include "port.h" -#include "gpu_unai.h" - -#define VIDEO_WIDTH 320 - -#ifdef TIME_IN_MSEC -#define TPS 1000 -#else -#define TPS 1000000 -#endif - -#define IS_PAL (gpu_unai.GPU_GP1&(0x08<<17)) - -//senquack - Original 512KB of guard space seems not to be enough, as Xenogears -// accesses outside this range and crashes in town intro fight sequence. -// Increased to 2MB total (double PSX VRAM) and Xenogears no longer -// crashes, but some textures are still messed up. Also note that alignment min -// is 16 bytes, needed for pixel-skipping rendering/blitting in high horiz res. -// Extra 4KB is for guard room at beginning. -// TODO: Determine cause of out-of-bounds write/reads. <-- Note: this is largely -// solved by adoption of PCSX Rearmed's 'gpulib' in gpulib_if.cpp, which -// replaces this file (gpu.cpp) -//u16 GPU_FrameBuffer[(FRAME_BUFFER_SIZE+512*1024)/2] __attribute__((aligned(32))); -static u16 GPU_FrameBuffer[(FRAME_BUFFER_SIZE*2 + 4096)/2] __attribute__((aligned(32))); - -/////////////////////////////////////////////////////////////////////////////// -// GPU fixed point math -#include "gpu_fixedpoint.h" - -/////////////////////////////////////////////////////////////////////////////// -// Inner loop driver instantiation file -#include "gpu_inner.h" - -/////////////////////////////////////////////////////////////////////////////// -// GPU internal image drawing functions -#include "gpu_raster_image.h" - -/////////////////////////////////////////////////////////////////////////////// -// GPU internal line drawing functions -#include "gpu_raster_line.h" - -/////////////////////////////////////////////////////////////////////////////// -// GPU internal polygon drawing functions -#include "gpu_raster_polygon.h" - -/////////////////////////////////////////////////////////////////////////////// -// GPU internal sprite drawing functions -#include "gpu_raster_sprite.h" - -/////////////////////////////////////////////////////////////////////////////// -// GPU command buffer execution/store -#include "gpu_command.h" - -/////////////////////////////////////////////////////////////////////////////// -static void gpuReset(void) -{ - memset((void*)&gpu_unai, 0, sizeof(gpu_unai)); - gpu_unai.vram = (u16*)GPU_FrameBuffer + (4096/2); //4kb guard room in front - gpu_unai.GPU_GP1 = 0x14802000; - gpu_unai.DrawingArea[2] = 256; - gpu_unai.DrawingArea[3] = 240; - gpu_unai.DisplayArea[2] = 256; - gpu_unai.DisplayArea[3] = 240; - gpu_unai.DisplayArea[5] = 240; - gpu_unai.TextureWindow[0] = 0; - gpu_unai.TextureWindow[1] = 0; - gpu_unai.TextureWindow[2] = 255; - gpu_unai.TextureWindow[3] = 255; - //senquack - new vars must be updated whenever texture window is changed: - // (used for polygon-drawing in gpu_inner.h, gpu_raster_polygon.h) - const u32 fb = FIXED_BITS; // # of fractional fixed-pt bits of u4/v4 - gpu_unai.u_msk = (((u32)gpu_unai.TextureWindow[2]) << fb) | ((1 << fb) - 1); - gpu_unai.v_msk = (((u32)gpu_unai.TextureWindow[3]) << fb) | ((1 << fb) - 1); - - // Configuration options - gpu_unai.config = gpu_unai_config_ext; - gpu_unai.ilace_mask = gpu_unai.config.ilace_force; - gpu_unai.frameskip.skipCount = gpu_unai.config.frameskip_count; - - SetupLightLUT(); - SetupDitheringConstants(); -} - -/////////////////////////////////////////////////////////////////////////////// -long GPU_init(void) -{ - gpuReset(); - -#ifdef GPU_UNAI_USE_INT_DIV_MULTINV - // s_invTable - for(unsigned int i=1;i<=(1<ulFreezeVersion != 1) return (0); - - if (bWrite) - { - p2->ulStatus = gpu_unai.GPU_GP1; - memset(p2->ulControl, 0, sizeof(p2->ulControl)); - // save resolution and registers for P.E.Op.S. compatibility - p2->ulControl[3] = (3 << 24) | ((gpu_unai.GPU_GP1 >> 23) & 1); - p2->ulControl[4] = (4 << 24) | ((gpu_unai.GPU_GP1 >> 29) & 3); - p2->ulControl[5] = (5 << 24) | (gpu_unai.DisplayArea[0] | (gpu_unai.DisplayArea[1] << 10)); - p2->ulControl[6] = (6 << 24) | (2560 << 12); - p2->ulControl[7] = (7 << 24) | (gpu_unai.DisplayArea[4] | (gpu_unai.DisplayArea[5] << 10)); - p2->ulControl[8] = (8 << 24) | ((gpu_unai.GPU_GP1 >> 17) & 0x3f) | ((gpu_unai.GPU_GP1 >> 10) & 0x40); - memcpy((void*)p2->psxVRam, (void*)gpu_unai.vram, FRAME_BUFFER_SIZE); - return (1); - } - else - { - extern void GPU_writeStatus(u32 data); - gpu_unai.GPU_GP1 = p2->ulStatus; - memcpy((void*)gpu_unai.vram, (void*)p2->psxVRam, FRAME_BUFFER_SIZE); - GPU_writeStatus((5 << 24) | p2->ulControl[5]); - GPU_writeStatus((7 << 24) | p2->ulControl[7]); - GPU_writeStatus((8 << 24) | p2->ulControl[8]); - gpuSetTexture(gpu_unai.GPU_GP1); - return (1); - } - return (0); -} - -/////////////////////////////////////////////////////////////////////////////// -// GPU DMA comunication - -/////////////////////////////////////////////////////////////////////////////// -u8 PacketSize[256] = -{ - 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0-15 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31 - 3, 3, 3, 3, 6, 6, 6, 6, 4, 4, 4, 4, 8, 8, 8, 8, // 32-47 - 5, 5, 5, 5, 8, 8, 8, 8, 7, 7, 7, 7, 11, 11, 11, 11, // 48-63 - 2, 2, 2, 2, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, // 64-79 - 3, 3, 3, 3, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, // 80-95 - 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, // 96-111 - 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, // 112-127 - 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 128- - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 144 - 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 160 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // - 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // -}; - -/////////////////////////////////////////////////////////////////////////////// -INLINE void gpuSendPacket() -{ - gpuSendPacketFunction(gpu_unai.PacketBuffer.U4[0]>>24); -} - -/////////////////////////////////////////////////////////////////////////////// -INLINE void gpuCheckPacket(u32 uData) -{ - if (gpu_unai.PacketCount) - { - gpu_unai.PacketBuffer.U4[gpu_unai.PacketIndex++] = uData; - --gpu_unai.PacketCount; - } - else - { - gpu_unai.PacketBuffer.U4[0] = uData; - gpu_unai.PacketCount = PacketSize[uData >> 24]; - gpu_unai.PacketIndex = 1; - } - if (!gpu_unai.PacketCount) gpuSendPacket(); -} - -/////////////////////////////////////////////////////////////////////////////// -void GPU_writeDataMem(u32* dmaAddress, int dmaCount) -{ - #ifdef ENABLE_GPU_LOG_SUPPORT - fprintf(stdout,"GPU_writeDataMem(%d)\n",dmaCount); - #endif - u32 data; - const u16 *VIDEO_END = (u16*)gpu_unai.vram+(FRAME_BUFFER_SIZE/2)-1; - gpu_unai.GPU_GP1 &= ~0x14000000; - - while (dmaCount) - { - if (gpu_unai.dma.FrameToWrite) - { - while (dmaCount) - { - dmaCount--; - data = *dmaAddress++; - if ((&gpu_unai.dma.pvram[gpu_unai.dma.px])>(VIDEO_END)) gpu_unai.dma.pvram-=512*1024; - gpu_unai.dma.pvram[gpu_unai.dma.px] = data; - if (++gpu_unai.dma.px >= gpu_unai.dma.x_end) - { - gpu_unai.dma.px = 0; - gpu_unai.dma.pvram += 1024; - if (++gpu_unai.dma.py >= gpu_unai.dma.y_end) - { - gpu_unai.dma.FrameToWrite = false; - gpu_unai.GPU_GP1 &= ~0x08000000; - gpu_unai.fb_dirty = true; - break; - } - } - if ((&gpu_unai.dma.pvram[gpu_unai.dma.px])>(VIDEO_END)) gpu_unai.dma.pvram-=512*1024; - gpu_unai.dma.pvram[gpu_unai.dma.px] = data>>16; - if (++gpu_unai.dma.px >= gpu_unai.dma.x_end) - { - gpu_unai.dma.px = 0; - gpu_unai.dma.pvram += 1024; - if (++gpu_unai.dma.py >= gpu_unai.dma.y_end) - { - gpu_unai.dma.FrameToWrite = false; - gpu_unai.GPU_GP1 &= ~0x08000000; - gpu_unai.fb_dirty = true; - break; - } - } - } - } - else - { - data = *dmaAddress++; - dmaCount--; - gpuCheckPacket(data); - } - } - - gpu_unai.GPU_GP1 = (gpu_unai.GPU_GP1 | 0x14000000) & ~0x60000000; -} - -long GPU_dmaChain(u32 *rambase, u32 start_addr) -{ - #ifdef ENABLE_GPU_LOG_SUPPORT - fprintf(stdout,"GPU_dmaChain(0x%x)\n",start_addr); - #endif - - u32 addr, *list; - u32 len, count; - long dma_words = 0; - - if (gpu_unai.dma.last_dma) *gpu_unai.dma.last_dma |= 0x800000; - - gpu_unai.GPU_GP1 &= ~0x14000000; - - addr = start_addr & 0xffffff; - for (count = 0; addr != 0xffffff; count++) - { - list = rambase + (addr & 0x1fffff) / 4; - len = list[0] >> 24; - addr = list[0] & 0xffffff; - - dma_words += 1 + len; - - // add loop detection marker - list[0] |= 0x800000; - - if (len) GPU_writeDataMem(list + 1, len); - - if (addr & 0x800000) - { - #ifdef ENABLE_GPU_LOG_SUPPORT - fprintf(stdout,"GPU_dmaChain(LOOP)\n"); - #endif - break; - } - } - - // remove loop detection markers - addr = start_addr & 0x1fffff; - while (count-- > 0) - { - list = rambase + addr / 4; - addr = list[0] & 0x1fffff; - list[0] &= ~0x800000; - } - - if (gpu_unai.dma.last_dma) *gpu_unai.dma.last_dma &= ~0x800000; - gpu_unai.dma.last_dma = rambase + (start_addr & 0x1fffff) / 4; - - gpu_unai.GPU_GP1 = (gpu_unai.GPU_GP1 | 0x14000000) & ~0x60000000; - - return dma_words; -} - -/////////////////////////////////////////////////////////////////////////////// -void GPU_writeData(u32 data) -{ - const u16 *VIDEO_END = (u16*)gpu_unai.vram+(FRAME_BUFFER_SIZE/2)-1; - #ifdef ENABLE_GPU_LOG_SUPPORT - fprintf(stdout,"GPU_writeData()\n"); - #endif - gpu_unai.GPU_GP1 &= ~0x14000000; - - if (gpu_unai.dma.FrameToWrite) - { - if ((&gpu_unai.dma.pvram[gpu_unai.dma.px])>(VIDEO_END)) gpu_unai.dma.pvram-=512*1024; - gpu_unai.dma.pvram[gpu_unai.dma.px]=(u16)data; - if (++gpu_unai.dma.px >= gpu_unai.dma.x_end) - { - gpu_unai.dma.px = 0; - gpu_unai.dma.pvram += 1024; - if (++gpu_unai.dma.py >= gpu_unai.dma.y_end) - { - gpu_unai.dma.FrameToWrite = false; - gpu_unai.GPU_GP1 &= ~0x08000000; - gpu_unai.fb_dirty = true; - } - } - if (gpu_unai.dma.FrameToWrite) - { - if ((&gpu_unai.dma.pvram[gpu_unai.dma.px])>(VIDEO_END)) gpu_unai.dma.pvram-=512*1024; - gpu_unai.dma.pvram[gpu_unai.dma.px]=data>>16; - if (++gpu_unai.dma.px >= gpu_unai.dma.x_end) - { - gpu_unai.dma.px = 0; - gpu_unai.dma.pvram += 1024; - if (++gpu_unai.dma.py >= gpu_unai.dma.y_end) - { - gpu_unai.dma.FrameToWrite = false; - gpu_unai.GPU_GP1 &= ~0x08000000; - gpu_unai.fb_dirty = true; - } - } - } - } - else - { - gpuCheckPacket(data); - } - gpu_unai.GPU_GP1 |= 0x14000000; -} - - -/////////////////////////////////////////////////////////////////////////////// -void GPU_readDataMem(u32* dmaAddress, int dmaCount) -{ - const u16 *VIDEO_END = (u16*)gpu_unai.vram+(FRAME_BUFFER_SIZE/2)-1; - #ifdef ENABLE_GPU_LOG_SUPPORT - fprintf(stdout,"GPU_readDataMem(%d)\n",dmaCount); - #endif - if(!gpu_unai.dma.FrameToRead) return; - - gpu_unai.GPU_GP1 &= ~0x14000000; - do - { - if ((&gpu_unai.dma.pvram[gpu_unai.dma.px])>(VIDEO_END)) gpu_unai.dma.pvram-=512*1024; - // lower 16 bit - //senquack - 64-bit fix (from notaz) - //u32 data = (unsigned long)gpu_unai.dma.pvram[gpu_unai.dma.px]; - u32 data = (u32)gpu_unai.dma.pvram[gpu_unai.dma.px]; - - if (++gpu_unai.dma.px >= gpu_unai.dma.x_end) - { - gpu_unai.dma.px = 0; - gpu_unai.dma.pvram += 1024; - } - - if ((&gpu_unai.dma.pvram[gpu_unai.dma.px])>(VIDEO_END)) gpu_unai.dma.pvram-=512*1024; - // higher 16 bit (always, even if it's an odd width) - //senquack - 64-bit fix (from notaz) - //data |= (unsigned long)(gpu_unai.dma.pvram[gpu_unai.dma.px])<<16; - data |= (u32)(gpu_unai.dma.pvram[gpu_unai.dma.px])<<16; - - *dmaAddress++ = data; - - if (++gpu_unai.dma.px >= gpu_unai.dma.x_end) - { - gpu_unai.dma.px = 0; - gpu_unai.dma.pvram += 1024; - if (++gpu_unai.dma.py >= gpu_unai.dma.y_end) - { - gpu_unai.dma.FrameToRead = false; - gpu_unai.GPU_GP1 &= ~0x08000000; - break; - } - } - } while (--dmaCount); - - gpu_unai.GPU_GP1 = (gpu_unai.GPU_GP1 | 0x14000000) & ~0x60000000; -} - - - -/////////////////////////////////////////////////////////////////////////////// -u32 GPU_readData(void) -{ - const u16 *VIDEO_END = (u16*)gpu_unai.vram+(FRAME_BUFFER_SIZE/2)-1; - #ifdef ENABLE_GPU_LOG_SUPPORT - fprintf(stdout,"GPU_readData()\n"); - #endif - gpu_unai.GPU_GP1 &= ~0x14000000; - if (gpu_unai.dma.FrameToRead) - { - if ((&gpu_unai.dma.pvram[gpu_unai.dma.px])>(VIDEO_END)) gpu_unai.dma.pvram-=512*1024; - gpu_unai.GPU_GP0 = gpu_unai.dma.pvram[gpu_unai.dma.px]; - if (++gpu_unai.dma.px >= gpu_unai.dma.x_end) - { - gpu_unai.dma.px = 0; - gpu_unai.dma.pvram += 1024; - if (++gpu_unai.dma.py >= gpu_unai.dma.y_end) - { - gpu_unai.dma.FrameToRead = false; - gpu_unai.GPU_GP1 &= ~0x08000000; - } - } - if ((&gpu_unai.dma.pvram[gpu_unai.dma.px])>(VIDEO_END)) gpu_unai.dma.pvram-=512*1024; - gpu_unai.GPU_GP0 |= gpu_unai.dma.pvram[gpu_unai.dma.px]<<16; - if (++gpu_unai.dma.px >= gpu_unai.dma.x_end) - { - gpu_unai.dma.px = 0; - gpu_unai.dma.pvram += 1024; - if (++gpu_unai.dma.py >= gpu_unai.dma.y_end) - { - gpu_unai.dma.FrameToRead = false; - gpu_unai.GPU_GP1 &= ~0x08000000; - } - } - - } - gpu_unai.GPU_GP1 |= 0x14000000; - - return (gpu_unai.GPU_GP0); -} - -/////////////////////////////////////////////////////////////////////////////// -u32 GPU_readStatus(void) -{ - return gpu_unai.GPU_GP1; -} - -INLINE void GPU_NoSkip(void) -{ - #ifdef ENABLE_GPU_LOG_SUPPORT - fprintf(stdout,"GPU_NoSkip()\n"); - #endif - gpu_unai.frameskip.wasSkip = gpu_unai.frameskip.isSkip; - if (gpu_unai.frameskip.isSkip) - { - gpu_unai.frameskip.isSkip = false; - gpu_unai.frameskip.skipGPU = false; - } - else - { - gpu_unai.frameskip.isSkip = gpu_unai.frameskip.skipFrame; - gpu_unai.frameskip.skipGPU = gpu_unai.frameskip.skipFrame; - } -} - -/////////////////////////////////////////////////////////////////////////////// -void GPU_writeStatus(u32 data) -{ - #ifdef ENABLE_GPU_LOG_SUPPORT - fprintf(stdout,"GPU_writeStatus(%d,%d)\n",data>>24,data & 0xff); - #endif - switch (data >> 24) { - case 0x00: - gpuReset(); - break; - case 0x01: - gpu_unai.GPU_GP1 &= ~0x08000000; - gpu_unai.PacketCount = 0; - gpu_unai.dma.FrameToRead = gpu_unai.dma.FrameToWrite = false; - break; - case 0x02: - gpu_unai.GPU_GP1 &= ~0x08000000; - gpu_unai.PacketCount = 0; - gpu_unai.dma.FrameToRead = gpu_unai.dma.FrameToWrite = false; - break; - case 0x03: - gpu_unai.GPU_GP1 = (gpu_unai.GPU_GP1 & ~0x00800000) | ((data & 1) << 23); - break; - case 0x04: - if (data == 0x04000000) gpu_unai.PacketCount = 0; - gpu_unai.GPU_GP1 = (gpu_unai.GPU_GP1 & ~0x60000000) | ((data & 3) << 29); - break; - case 0x05: - // Start of Display Area in VRAM - gpu_unai.DisplayArea[0] = data & 0x3ff; // X (0..1023) - gpu_unai.DisplayArea[1] = (data >> 10) & 0x1ff; // Y (0..511) - GPU_NoSkip(); - break; - case 0x06: - // GP1(06h) - Horizontal Display range (on Screen) - // 0-11 X1 (260h+0) ;12bit ;\counted in 53.222400MHz units, - // 12-23 X2 (260h+320*8) ;12bit ;/relative to HSYNC - - // senquack - gpu_unai completely ignores GP1(0x06) command and - // lacks even a place in DisplayArea[] array to store the values. - // It seems to have been concerned only with vertical display range - // and centering top/bottom. I will not add support here, and - // focus instead on the gpulib version (gpulib_if.cpp) which uses - // gpulib for its PS1->host framebuffer blitting. - break; - case 0x07: - // GP1(07h) - Vertical Display range (on Screen) - // 0-9 Y1 (NTSC=88h-(224/2), (PAL=A3h-(264/2)) ;\scanline numbers on screen, - // 10-19 Y2 (NTSC=88h+(224/2), (PAL=A3h+(264/2)) ;/relative to VSYNC - // 20-23 Not used (zero) - { - u32 v1=data & 0x000003FF; //(short)(data & 0x3ff); - u32 v2=(data & 0x000FFC00) >> 10; //(short)((data>>10) & 0x3ff); - if ((gpu_unai.DisplayArea[4]!=v1)||(gpu_unai.DisplayArea[5]!=v2)) - { - gpu_unai.DisplayArea[4] = v1; - gpu_unai.DisplayArea[5] = v2; - #ifdef ENABLE_GPU_LOG_SUPPORT - fprintf(stdout,"video_clear(CHANGE_Y)\n"); - #endif - video_clear(); - } - } - break; - case 0x08: - { - static const u32 HorizontalResolution[8] = { 256, 368, 320, 384, 512, 512, 640, 640 }; - static const u32 VerticalResolution[4] = { 240, 480, 256, 480 }; - gpu_unai.GPU_GP1 = (gpu_unai.GPU_GP1 & ~0x007F0000) | ((data & 0x3F) << 17) | ((data & 0x40) << 10); - #ifdef ENABLE_GPU_LOG_SUPPORT - fprintf(stdout,"GPU_writeStatus(RES=%dx%d,BITS=%d,PAL=%d)\n",HorizontalResolution[(gpu_unai.GPU_GP1 >> 16) & 7], - VerticalResolution[(gpu_unai.GPU_GP1 >> 19) & 3],(gpu_unai.GPU_GP1&0x00200000?24:15),(IS_PAL?1:0)); - #endif - // Video mode change - u32 new_width = HorizontalResolution[(gpu_unai.GPU_GP1 >> 16) & 7]; - u32 new_height = VerticalResolution[(gpu_unai.GPU_GP1 >> 19) & 3]; - - if (gpu_unai.DisplayArea[2] != new_width || gpu_unai.DisplayArea[3] != new_height) - { - // Update width - gpu_unai.DisplayArea[2] = new_width; - - if (PixelSkipEnabled()) { - // Set blit_mask for high horizontal resolutions. This allows skipping - // rendering pixels that would never get displayed on low-resolution - // platforms that use simple pixel-dropping scaler. - switch (gpu_unai.DisplayArea[2]) - { - case 512: gpu_unai.blit_mask = 0xa4; break; // GPU_BlitWWSWWSWS - case 640: gpu_unai.blit_mask = 0xaa; break; // GPU_BlitWS - default: gpu_unai.blit_mask = 0; break; - } - } else { - gpu_unai.blit_mask = 0; - } - - // Update height - gpu_unai.DisplayArea[3] = new_height; - - if (LineSkipEnabled()) { - // Set rendering line-skip (only render every other line in high-res - // 480 vertical mode, or, optionally, force it for all video modes) - - if (gpu_unai.DisplayArea[3] == 480) { - if (gpu_unai.config.ilace_force) { - gpu_unai.ilace_mask = 3; // Only need 1/4 of lines - } else { - gpu_unai.ilace_mask = 1; // Only need 1/2 of lines - } - } else { - // Vert resolution changed from 480 to lower one - gpu_unai.ilace_mask = gpu_unai.config.ilace_force; - } - } else { - gpu_unai.ilace_mask = 0; - } - - #ifdef ENABLE_GPU_LOG_SUPPORT - fprintf(stdout,"video_clear(CHANGE_RES)\n"); - #endif - video_clear(); - } - - } - break; - case 0x10: - switch (data & 0xff) { - case 2: gpu_unai.GPU_GP0 = gpu_unai.tex_window; break; - case 3: gpu_unai.GPU_GP0 = (gpu_unai.DrawingArea[1] << 10) | gpu_unai.DrawingArea[0]; break; - case 4: gpu_unai.GPU_GP0 = ((gpu_unai.DrawingArea[3]-1) << 10) | (gpu_unai.DrawingArea[2]-1); break; - case 5: case 6: gpu_unai.GPU_GP0 = (((u32)gpu_unai.DrawingOffset[1] & 0x7ff) << 11) | ((u32)gpu_unai.DrawingOffset[0] & 0x7ff); break; - case 7: gpu_unai.GPU_GP0 = 2; break; - case 8: case 15: gpu_unai.GPU_GP0 = 0xBFC03720; break; - } - break; - } -} - -// Blitting functions -#include "gpu_blit.h" - -static void gpuVideoOutput(void) -{ - int h0, x0, y0, w0, h1; - - x0 = gpu_unai.DisplayArea[0]; - y0 = gpu_unai.DisplayArea[1]; - - w0 = gpu_unai.DisplayArea[2]; - h0 = gpu_unai.DisplayArea[3]; // video mode - - h1 = gpu_unai.DisplayArea[5] - gpu_unai.DisplayArea[4]; // display needed - if (h0 == 480) h1 = Min2(h1*2,480); - - bool isRGB24 = (gpu_unai.GPU_GP1 & 0x00200000 ? true : false); - u16* dst16 = SCREEN; - u16* src16 = (u16*)gpu_unai.vram; - - // PS1 fb read wraps around (fixes black screen in 'Tobal no. 1') - unsigned int src16_offs_msk = 1024*512-1; - unsigned int src16_offs = (x0 + y0*1024) & src16_offs_msk; - - // Height centering - int sizeShift = 1; - if (h0 == 256) { - h0 = 240; - } else if (h0 == 480) { - sizeShift = 2; - } - if (h1 > h0) { - src16_offs = (src16_offs + (((h1-h0) / 2) * 1024)) & src16_offs_msk; - h1 = h0; - } else if (h1> sizeShift) * VIDEO_WIDTH; - } - - - /* Main blitter */ - int incY = (h0==480) ? 2 : 1; - h0=(h0==480 ? 2048 : 1024); - - { - const int li=gpu_unai.ilace_mask; - bool pi = ProgressiveInterlaceEnabled(); - bool pif = gpu_unai.prog_ilace_flag; - switch ( w0 ) - { - case 256: - for(int y1=y0+h1; y0>3 (8 times per second) -#define GPU_FRAMESKIP_UPDATE 3 - -static void GPU_frameskip (bool show) -{ - u32 now=get_ticks(); // current frame - - // Update frameskip - if (gpu_unai.frameskip.skipCount==0) gpu_unai.frameskip.skipFrame=false; // frameskip off - else if (gpu_unai.frameskip.skipCount==7) { if (show) gpu_unai.frameskip.skipFrame=!gpu_unai.frameskip.skipFrame; } // frameskip medium - else if (gpu_unai.frameskip.skipCount==8) gpu_unai.frameskip.skipFrame=true; // frameskip maximum - else - { - static u32 spd=100; // speed % - static u32 frames=0; // frames counter - static u32 prev=now; // previous fps calculation - frames++; - if ((now-prev)>=(TPS>>GPU_FRAMESKIP_UPDATE)) - { - if (IS_PAL) spd=(frames<<1); - else spd=((frames*1001)/600); - spd<<=GPU_FRAMESKIP_UPDATE; - frames=0; - prev=now; - } - switch(gpu_unai.frameskip.skipCount) - { - case 1: if (spd<50) gpu_unai.frameskip.skipFrame=true; else gpu_unai.frameskip.skipFrame=false; break; // frameskip on (spd<50%) - case 2: if (spd<60) gpu_unai.frameskip.skipFrame=true; else gpu_unai.frameskip.skipFrame=false; break; // frameskip on (spd<60%) - case 3: if (spd<70) gpu_unai.frameskip.skipFrame=true; else gpu_unai.frameskip.skipFrame=false; break; // frameskip on (spd<70%) - case 4: if (spd<80) gpu_unai.frameskip.skipFrame=true; else gpu_unai.frameskip.skipFrame=false; break; // frameskip on (spd<80%) - case 5: if (spd<90) gpu_unai.frameskip.skipFrame=true; else gpu_unai.frameskip.skipFrame=false; break; // frameskip on (spd<90%) - } - } -} - -/////////////////////////////////////////////////////////////////////////////// -void GPU_updateLace(void) -{ - // Interlace bit toggle - gpu_unai.GPU_GP1 ^= 0x80000000; - - // Update display? - if ((gpu_unai.fb_dirty) && (!gpu_unai.frameskip.wasSkip) && (!(gpu_unai.GPU_GP1&0x00800000))) - { - // Display updated - gpuVideoOutput(); - GPU_frameskip(true); - #ifdef ENABLE_GPU_LOG_SUPPORT - fprintf(stdout,"GPU_updateLace(UPDATE)\n"); - #endif - } else { - GPU_frameskip(false); - #ifdef ENABLE_GPU_LOG_SUPPORT - fprintf(stdout,"GPU_updateLace(SKIP)\n"); - #endif - } - - if ((!gpu_unai.frameskip.skipCount) && (gpu_unai.DisplayArea[3] == 480)) gpu_unai.frameskip.skipGPU=true; // Tekken 3 hack - - gpu_unai.fb_dirty=false; - gpu_unai.dma.last_dma = NULL; -} - -// Allows frontend to signal plugin to redraw screen after returning to emu -void GPU_requestScreenRedraw() -{ - gpu_unai.fb_dirty = true; -} - -void GPU_getScreenInfo(GPUScreenInfo_t *sinfo) -{ - bool depth24 = (gpu_unai.GPU_GP1 & 0x00200000 ? true : false); - int16_t hres = (uint16_t)gpu_unai.DisplayArea[2]; - int16_t vres = (uint16_t)gpu_unai.DisplayArea[3]; - int16_t w = hres; // Original gpu_unai doesn't support width < 100% - int16_t h = gpu_unai.DisplayArea[5] - gpu_unai.DisplayArea[4]; - if (vres == 480) - h *= 2; - if (h <= 0 || h > vres) - h = vres; - - sinfo->vram = (uint8_t*)gpu_unai.vram; - sinfo->x = (uint16_t)gpu_unai.DisplayArea[0]; - sinfo->y = (uint16_t)gpu_unai.DisplayArea[1]; - sinfo->w = w; - sinfo->h = h; - sinfo->hres = hres; - sinfo->vres = vres; - sinfo->depth24 = depth24; - sinfo->pal = IS_PAL; -} diff --git a/plugins/gpu_unai/old/gpu.cpp b/plugins/gpu_unai/old/gpu.cpp deleted file mode 100644 index 439a6c25..00000000 --- a/plugins/gpu_unai/old/gpu.cpp +++ /dev/null @@ -1,916 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2010 PCSX4ALL Team * -* Copyright (C) 2010 Unai * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * -***************************************************************************/ - -#include "port.h" -#include "gpu.h" -#include "profiler.h" -#include "debug.h" - -int skipCount = 2; /* frame skip (0,1,2,3...) */ -int skCount = 0; /* internal frame skip */ -int linesInterlace = 0; /* internal lines interlace */ -int linesInterlace_user = 0; /* Lines interlace */ - -bool isSkip = false; /* skip frame (info coming from GPU) */ -bool wasSkip = false; -bool skipFrame = false; /* skip frame (according to frame skip) */ -bool alt_fps = false; /* Alternative FPS algorithm */ -bool show_fps = false; /* Show FPS statistics */ - -bool isPAL = false; /* PAL video timing */ -bool progressInterlace_flag = false; /* Progressive interlace flag */ -bool progressInterlace = false; /* Progressive interlace option*/ -bool frameLimit = false; /* frames to wait */ - -bool light = true; /* lighting */ -bool blend = true; /* blending */ -bool FrameToRead = false; /* load image in progress */ -bool FrameToWrite = false; /* store image in progress */ -bool fb_dirty = false; - -bool enableAbbeyHack = false; /* Abe's Odyssey hack */ - -u8 BLEND_MODE; -u8 TEXT_MODE; -u8 Masking; - -u16 PixelMSB; -u16 PixelData; - -/////////////////////////////////////////////////////////////////////////////// -// GPU Global data -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// Dma Transfers info -s32 px,py; -s32 x_end,y_end; -u16* pvram; - -u32 GP0; -s32 PacketCount; -s32 PacketIndex; - -/////////////////////////////////////////////////////////////////////////////// -// Display status -u32 DisplayArea [6]; - -/////////////////////////////////////////////////////////////////////////////// -// Rasterizer status -u32 TextureWindow [4]; -u32 DrawingArea [4]; -u32 DrawingOffset [2]; - -/////////////////////////////////////////////////////////////////////////////// -// Rasterizer status - -u16* TBA; -u16* CBA; - -/////////////////////////////////////////////////////////////////////////////// -// Inner Loops -s32 u4, du4; -s32 v4, dv4; -s32 r4, dr4; -s32 g4, dg4; -s32 b4, db4; -u32 lInc; -u32 tInc, tMsk; - -GPUPacket PacketBuffer; -// FRAME_BUFFER_SIZE is defined in bytes; 512K is guard memory for out of range reads -u16 GPU_FrameBuffer[(FRAME_BUFFER_SIZE+512*1024)/2] __attribute__((aligned(2048))); -u32 GPU_GP1; - -/////////////////////////////////////////////////////////////////////////////// -// Inner loop driver instanciation file -#include "gpu_inner.h" - -/////////////////////////////////////////////////////////////////////////////// -// GPU Raster Macros -#define GPU_RGB16(rgb) ((((rgb)&0xF80000)>>9)|(((rgb)&0xF800)>>6)|(((rgb)&0xF8)>>3)) - -#define GPU_EXPANDSIGN(x) (((s32)(x)<<21)>>21) - -#define CHKMAX_X 1024 -#define CHKMAX_Y 512 - -#define GPU_SWAP(a,b,t) {(t)=(a);(a)=(b);(b)=(t);} - -/////////////////////////////////////////////////////////////////////////////// -// GPU internal image drawing functions -#include "gpu_raster_image.h" - -/////////////////////////////////////////////////////////////////////////////// -// GPU internal line drawing functions -#include "gpu_raster_line.h" - -/////////////////////////////////////////////////////////////////////////////// -// GPU internal polygon drawing functions -#include "gpu_raster_polygon.h" - -/////////////////////////////////////////////////////////////////////////////// -// GPU internal sprite drawing functions -#include "gpu_raster_sprite.h" - -/////////////////////////////////////////////////////////////////////////////// -// GPU command buffer execution/store -#include "gpu_command.h" - -/////////////////////////////////////////////////////////////////////////////// -INLINE void gpuReset(void) -{ - GPU_GP1 = 0x14802000; - TextureWindow[0] = 0; - TextureWindow[1] = 0; - TextureWindow[2] = 255; - TextureWindow[3] = 255; - DrawingArea[2] = 256; - DrawingArea[3] = 240; - DisplayArea[2] = 256; - DisplayArea[3] = 240; - DisplayArea[5] = 240; -} - -/////////////////////////////////////////////////////////////////////////////// -bool GPU_init(void) -{ - gpuReset(); - - // s_invTable - for(int i=1;i<=(1<>1); - #else - v *= double(0x80000000); - #endif - s_invTable[i-1]=s32(v); - } - return (0); -} - -/////////////////////////////////////////////////////////////////////////////// -void GPU_shutdown(void) -{ -} - -/////////////////////////////////////////////////////////////////////////////// -long GPU_freeze(unsigned int bWrite, GPUFreeze_t* p2) -{ - if (!p2) return (0); - if (p2->Version != 1) return (0); - - if (bWrite) - { - p2->GPU_gp1 = GPU_GP1; - memset(p2->Control, 0, sizeof(p2->Control)); - // save resolution and registers for P.E.Op.S. compatibility - p2->Control[3] = (3 << 24) | ((GPU_GP1 >> 23) & 1); - p2->Control[4] = (4 << 24) | ((GPU_GP1 >> 29) & 3); - p2->Control[5] = (5 << 24) | (DisplayArea[0] | (DisplayArea[1] << 10)); - p2->Control[6] = (6 << 24) | (2560 << 12); - p2->Control[7] = (7 << 24) | (DisplayArea[4] | (DisplayArea[5] << 10)); - p2->Control[8] = (8 << 24) | ((GPU_GP1 >> 17) & 0x3f) | ((GPU_GP1 >> 10) & 0x40); - memcpy(p2->FrameBuffer, (u16*)GPU_FrameBuffer, FRAME_BUFFER_SIZE); - return (1); - } - else - { - GPU_GP1 = p2->GPU_gp1; - memcpy((u16*)GPU_FrameBuffer, p2->FrameBuffer, FRAME_BUFFER_SIZE); - GPU_writeStatus((5 << 24) | p2->Control[5]); - GPU_writeStatus((7 << 24) | p2->Control[7]); - GPU_writeStatus((8 << 24) | p2->Control[8]); - gpuSetTexture(GPU_GP1); - return (1); - } - return (0); -} - -/////////////////////////////////////////////////////////////////////////////// -// GPU DMA comunication - -/////////////////////////////////////////////////////////////////////////////// -u8 PacketSize[256] = -{ - 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0-15 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31 - 3, 3, 3, 3, 6, 6, 6, 6, 4, 4, 4, 4, 8, 8, 8, 8, // 32-47 - 5, 5, 5, 5, 8, 8, 8, 8, 7, 7, 7, 7, 11, 11, 11, 11, // 48-63 - 2, 2, 2, 2, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, // 64-79 - 3, 3, 3, 3, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, // 80-95 - 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, // 96-111 - 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, // 112-127 - 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 128- - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 144 - 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 160 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // - 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // -}; - -/////////////////////////////////////////////////////////////////////////////// -INLINE void gpuSendPacket() -{ -#ifdef DEBUG_ANALYSIS - dbg_anacnt_GPU_sendPacket++; -#endif - gpuSendPacketFunction(PacketBuffer.U4[0]>>24); -} - -/////////////////////////////////////////////////////////////////////////////// -INLINE void gpuCheckPacket(u32 uData) -{ - if (PacketCount) - { - PacketBuffer.U4[PacketIndex++] = uData; - --PacketCount; - } - else - { - PacketBuffer.U4[0] = uData; - PacketCount = PacketSize[uData >> 24]; - PacketIndex = 1; - } - if (!PacketCount) gpuSendPacket(); -} - -/////////////////////////////////////////////////////////////////////////////// -void GPU_writeDataMem(u32* dmaAddress, s32 dmaCount) -{ -#ifdef DEBUG_ANALYSIS - dbg_anacnt_GPU_writeDataMem++; -#endif - pcsx4all_prof_pause(PCSX4ALL_PROF_CPU); - pcsx4all_prof_start_with_pause(PCSX4ALL_PROF_GPU,PCSX4ALL_PROF_HW_WRITE); - u32 data; - const u16 *VIDEO_END=(GPU_FrameBuffer+(FRAME_BUFFER_SIZE/2)-1); - GPU_GP1 &= ~0x14000000; - - while (dmaCount) - { - if (FrameToWrite) - { - while (dmaCount) - { - dmaCount--; - data = *dmaAddress++; - if ((&pvram[px])>(VIDEO_END)) pvram-=512*1024; - pvram[px] = data; - if (++px>=x_end) - { - px = 0; - pvram += 1024; - if (++py>=y_end) - { - FrameToWrite = false; - GPU_GP1 &= ~0x08000000; - break; - } - } - if ((&pvram[px])>(VIDEO_END)) pvram-=512*1024; - pvram[px] = data>>16; - if (++px>=x_end) - { - px = 0; - pvram += 1024; - if (++py>=y_end) - { - FrameToWrite = false; - GPU_GP1 &= ~0x08000000; - break; - } - } - } - } - else - { - data = *dmaAddress++; - dmaCount--; - gpuCheckPacket(data); - } - } - - GPU_GP1 = (GPU_GP1 | 0x14000000) & ~0x60000000; - fb_dirty = true; - pcsx4all_prof_end_with_resume(PCSX4ALL_PROF_GPU,PCSX4ALL_PROF_HW_WRITE); - pcsx4all_prof_resume(PCSX4ALL_PROF_CPU); -} - -u32 *lUsedAddr[3]; -INLINE int CheckForEndlessLoop(u32 *laddr) -{ - if(laddr==lUsedAddr[1]) return 1; - if(laddr==lUsedAddr[2]) return 1; - - if(laddr> 2)); - if(DMACommandCounter++ > 2000000) break; - if(CheckForEndlessLoop(address)) break; - data = *address++; - count = (data >> 24); - offset = data & 0x001FFFFF; - if (dmaVAddr != offset) dmaVAddr = offset; - else dmaVAddr = 0x1FFFFF; - - if(count>0) GPU_writeDataMem(address,count); - dma_words += 1 + count; - } - GPU_GP1 = (GPU_GP1 | 0x14000000) & ~0x60000000; - pcsx4all_prof_end_with_resume(PCSX4ALL_PROF_GPU,PCSX4ALL_PROF_HW_WRITE); - - return dma_words; -} - -/////////////////////////////////////////////////////////////////////////////// -void GPU_writeData(u32 data) -{ - const u16 *VIDEO_END=(GPU_FrameBuffer+(FRAME_BUFFER_SIZE/2)-1); -#ifdef DEBUG_ANALYSIS - dbg_anacnt_GPU_writeData++; -#endif - pcsx4all_prof_pause(PCSX4ALL_PROF_CPU); - pcsx4all_prof_start_with_pause(PCSX4ALL_PROF_GPU,PCSX4ALL_PROF_HW_WRITE); - GPU_GP1 &= ~0x14000000; - - if (FrameToWrite) - { - if ((&pvram[px])>(VIDEO_END)) pvram-=512*1024; - pvram[px]=(u16)data; - if (++px>=x_end) - { - px = 0; - pvram += 1024; - if (++py>=y_end) - { - FrameToWrite = false; - GPU_GP1 &= ~0x08000000; - } - } - if (FrameToWrite) - { - if ((&pvram[px])>(VIDEO_END)) pvram-=512*1024; - pvram[px]=data>>16; - if (++px>=x_end) - { - px = 0; - pvram += 1024; - if (++py>=y_end) - { - FrameToWrite = false; - GPU_GP1 &= ~0x08000000; - } - } - } - } - else - { - gpuCheckPacket(data); - } - GPU_GP1 |= 0x14000000; - fb_dirty = true; - pcsx4all_prof_end_with_resume(PCSX4ALL_PROF_GPU,PCSX4ALL_PROF_HW_WRITE); - pcsx4all_prof_resume(PCSX4ALL_PROF_CPU); - -} - - -/////////////////////////////////////////////////////////////////////////////// -void GPU_readDataMem(u32* dmaAddress, s32 dmaCount) -{ - const u16 *VIDEO_END=(GPU_FrameBuffer+(FRAME_BUFFER_SIZE/2)-1); -#ifdef DEBUG_ANALYSIS - dbg_anacnt_GPU_readDataMem++; -#endif - if(!FrameToRead) return; - - pcsx4all_prof_start_with_pause(PCSX4ALL_PROF_GPU,PCSX4ALL_PROF_HW_WRITE); - GPU_GP1 &= ~0x14000000; - do - { - if ((&pvram[px])>(VIDEO_END)) pvram-=512*1024; - // lower 16 bit - u32 data = pvram[px]; - - if (++px>=x_end) - { - px = 0; - pvram += 1024; - } - - if ((&pvram[px])>(VIDEO_END)) pvram-=512*1024; - // higher 16 bit (always, even if it's an odd width) - data |= (u32)(pvram[px])<<16; - - *dmaAddress++ = data; - - if (++px>=x_end) - { - px = 0; - pvram += 1024; - if (++py>=y_end) - { - FrameToRead = false; - GPU_GP1 &= ~0x08000000; - break; - } - } - } while (--dmaCount); - - GPU_GP1 = (GPU_GP1 | 0x14000000) & ~0x60000000; - pcsx4all_prof_end_with_resume(PCSX4ALL_PROF_GPU,PCSX4ALL_PROF_HW_WRITE); -} - - - -/////////////////////////////////////////////////////////////////////////////// -u32 GPU_readData(void) -{ - const u16 *VIDEO_END=(GPU_FrameBuffer+(FRAME_BUFFER_SIZE/2)-1); -#ifdef DEBUG_ANALYSIS - dbg_anacnt_GPU_readData++; -#endif - pcsx4all_prof_pause(PCSX4ALL_PROF_CPU); - pcsx4all_prof_start_with_pause(PCSX4ALL_PROF_GPU,PCSX4ALL_PROF_HW_READ); - GPU_GP1 &= ~0x14000000; - if (FrameToRead) - { - if ((&pvram[px])>(VIDEO_END)) pvram-=512*1024; - GP0 = pvram[px]; - if (++px>=x_end) - { - px = 0; - pvram += 1024; - if (++py>=y_end) - { - FrameToRead = false; - GPU_GP1 &= ~0x08000000; - } - } - if ((&pvram[px])>(VIDEO_END)) pvram-=512*1024; - GP0 |= pvram[px]<<16; - if (++px>=x_end) - { - px = 0; - pvram +=1024; - if (++py>=y_end) - { - FrameToRead = false; - GPU_GP1 &= ~0x08000000; - } - } - - } - GPU_GP1 |= 0x14000000; - - pcsx4all_prof_end_with_resume(PCSX4ALL_PROF_GPU,PCSX4ALL_PROF_HW_READ); - pcsx4all_prof_resume(PCSX4ALL_PROF_CPU); - return (GP0); -} - -/////////////////////////////////////////////////////////////////////////////// -u32 GPU_readStatus(void) -{ -#ifdef DEBUG_ANALYSIS - dbg_anacnt_GPU_readStatus++; -#endif - return GPU_GP1; -} - -/////////////////////////////////////////////////////////////////////////////// -void GPU_writeStatus(u32 data) -{ -#ifdef DEBUG_ANALYSIS - dbg_anacnt_GPU_writeStatus++; -#endif - pcsx4all_prof_pause(PCSX4ALL_PROF_CPU); - pcsx4all_prof_start_with_pause(PCSX4ALL_PROF_GPU,PCSX4ALL_PROF_HW_WRITE); - switch (data >> 24) { - case 0x00: - gpuReset(); - break; - case 0x01: - GPU_GP1 &= ~0x08000000; - PacketCount = 0; FrameToRead = FrameToWrite = false; - break; - case 0x02: - GPU_GP1 &= ~0x08000000; - PacketCount = 0; FrameToRead = FrameToWrite = false; - break; - case 0x03: - GPU_GP1 = (GPU_GP1 & ~0x00800000) | ((data & 1) << 23); - break; - case 0x04: - if (data == 0x04000000) - PacketCount = 0; - GPU_GP1 = (GPU_GP1 & ~0x60000000) | ((data & 3) << 29); - break; - case 0x05: - DisplayArea[0] = (data & 0x000003FF); //(short)(data & 0x3ff); - DisplayArea[1] = ((data & 0x0007FC00)>>10); //(data & 0x000FFC00) >> 10; //(short)((data>>10)&0x1ff); - fb_dirty = true; - wasSkip = isSkip; - if (isSkip) - isSkip = false; - else - isSkip = skipFrame; - break; - case 0x07: - DisplayArea[4] = data & 0x000003FF; //(short)(data & 0x3ff); - DisplayArea[5] = (data & 0x000FFC00) >> 10; //(short)((data>>10) & 0x3ff); - fb_dirty = true; - break; - case 0x08: - { - GPU_GP1 = (GPU_GP1 & ~0x007F0000) | ((data & 0x3F) << 17) | ((data & 0x40) << 10); - static u32 HorizontalResolution[8] = { 256, 368, 320, 384, 512, 512, 640, 640 }; - DisplayArea[2] = HorizontalResolution[(GPU_GP1 >> 16) & 7]; - static u32 VerticalResolution[4] = { 240, 480, 256, 480 }; - DisplayArea[3] = VerticalResolution[(GPU_GP1 >> 19) & 3]; - isPAL = (data & 0x08) ? true : false; // if 1 - PAL mode, else NTSC - } - fb_dirty = true; - break; - case 0x10: - switch (data & 0xffff) { - case 0: - case 1: - case 3: - GP0 = (DrawingArea[1] << 10) | DrawingArea[0]; - break; - case 4: - GP0 = ((DrawingArea[3]-1) << 10) | (DrawingArea[2]-1); - break; - case 6: - case 5: - GP0 = (DrawingOffset[1] << 11) | DrawingOffset[0]; - break; - case 7: - GP0 = 2; - break; - default: - GP0 = 0; - } - break; - } - pcsx4all_prof_end_with_resume(PCSX4ALL_PROF_GPU,PCSX4ALL_PROF_HW_WRITE); - pcsx4all_prof_resume(PCSX4ALL_PROF_CPU); -} - -#ifndef REARMED - -// Blitting functions -#include "gpu_blit.h" - -INLINE void gpuVideoOutput(void) -{ - static s16 old_res_horz, old_res_vert, old_rgb24; - s16 h0, x0, y0, w0, h1; - - x0 = DisplayArea[0]; - y0 = DisplayArea[1]; - - w0 = DisplayArea[2]; - h0 = DisplayArea[3]; // video mode - - h1 = DisplayArea[5] - DisplayArea[4]; // display needed - if (h0 == 480) h1 = Min2(h1*2,480); - - u16* dest_screen16 = SCREEN; - u16* src_screen16 = &((u16*)GPU_FrameBuffer)[FRAME_OFFSET(x0,y0)]; - u32 isRGB24 = (GPU_GP1 & 0x00200000 ? 32 : 0); - - /* Clear the screen if resolution changed to prevent interlacing and clipping to clash */ - if( (w0 != old_res_horz || h1 != old_res_vert || (s16)isRGB24 != old_rgb24) ) - { - // Update old resolution - old_res_horz = w0; - old_res_vert = h1; - old_rgb24 = (s16)isRGB24; - // Finally, clear the screen for this special case - video_clear(); - } - - // Height centering - int sizeShift = 1; - if(h0==256) h0 = 240; else if(h0==480) sizeShift = 2; - if(h1>h0) { src_screen16 += ((h1-h0)>>sizeShift)*1024; h1 = h0; } - else if(h1>sizeShift)*VIDEO_WIDTH; - - /* Main blitter */ - int incY = (h0==480) ? 2 : 1; - h0=(h0==480 ? 2048 : 1024); - - { - const int li=linesInterlace; - bool pi=progressInterlace; - bool pif=progressInterlace_flag; - switch ( w0 ) - { - case 256: - for(int y1=y0+h1; y0=1000000) - { - u32 expected_fps=(isPAL?50:60); - sprintf(msg,"FPS=%3d/%2d SPD=%3d%%",((real_fps*(12-skipCount))/12),((expected_fps*(12-skipCount))/12),((real_fps*100)/expected_fps)); - prev=now; - real_fps=0; - } - port_printf(5,5,msg); - } - - // Update frame-skip - if (!alt_fps) - { - // Video frame-skip - skipFrame=skipTable[skipCount][skCount]; - skCount--; if (skCount<0) skCount=11; - isSkip=skipFrame; - } - else - { - // Game frame-skip - if (!isSkip) - { - skipFrame=skipTable[skipCount][skCount]; - skCount--; if (skCount<0) skCount=11; - isSkip=true; - } - } - fb_dirty=false; - - pcsx4all_prof_end_with_resume(PCSX4ALL_PROF_GPU,PCSX4ALL_PROF_COUNTERS); -} - -#else - -#include "../../frontend/plugin_lib.h" - -extern "C" { - -static const struct rearmed_cbs *cbs; -static s16 old_res_horz, old_res_vert, old_rgb24; - -static void blit(void) -{ - u16 *base = (u16 *)GPU_FrameBuffer; - s16 isRGB24 = (GPU_GP1 & 0x00200000) ? 1 : 0; - s16 h0, x0, y0, w0, h1; - - x0 = DisplayArea[0] & ~1; // alignment needed by blitter - y0 = DisplayArea[1]; - base += FRAME_OFFSET(x0, y0); - - w0 = DisplayArea[2]; - h0 = DisplayArea[3]; // video mode - - h1 = DisplayArea[5] - DisplayArea[4]; // display needed - if (h0 == 480) h1 = Min2(h1*2,480); - - if (h1 <= 0) - return; - - if (w0 != old_res_horz || h1 != old_res_vert || isRGB24 != old_rgb24) - { - old_res_horz = w0; - old_res_vert = h1; - old_rgb24 = (s16)isRGB24; - cbs->pl_vout_set_mode(w0, h1, w0, h1, isRGB24 ? 24 : 16); - } - -#error out of date - cbs->pl_vout_flip(base, 1024, isRGB24, w0, h1); -} - -void GPU_updateLace(void) -{ - // Interlace bit toggle - GPU_GP1 ^= 0x80000000; - - if (!fb_dirty || (GPU_GP1&0x08800000)) - return; - - if (!wasSkip) { - blit(); - fb_dirty = false; - skCount = 0; - } - else { - skCount++; - if (skCount >= 8) - wasSkip = isSkip = 0; - } - - skipFrame = cbs->fskip_advice || cbs->frameskip == 1; -} - -long GPUopen(unsigned long *, char *, char *) -{ - cbs->pl_vout_open(); - return 0; -} - -long GPUclose(void) -{ - cbs->pl_vout_close(); - return 0; -} - -long GPUfreeze(unsigned int ulGetFreezeData, GPUFreeze_t* p2) -{ - if (ulGetFreezeData > 1) - return 0; - - return GPU_freeze(ulGetFreezeData, p2); -} - -void GPUrearmedCallbacks(const struct rearmed_cbs *cbs_) -{ - enableAbbeyHack = cbs_->gpu_unai.abe_hack; - light = !cbs_->gpu_unai.no_light; - blend = !cbs_->gpu_unai.no_blend; - if (cbs_->pl_vout_set_raw_vram) - cbs_->pl_vout_set_raw_vram((void *)GPU_FrameBuffer); - - cbs = cbs_; - if (cbs->pl_set_gpu_caps) - cbs->pl_set_gpu_caps(0); -} - -} /* extern "C" */ - -#endif diff --git a/plugins/gpu_unai/old/gpu.h b/plugins/gpu_unai/old/gpu.h deleted file mode 100644 index 18116303..00000000 --- a/plugins/gpu_unai/old/gpu.h +++ /dev/null @@ -1,87 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2010 PCSX4ALL Team * -* Copyright (C) 2010 Unai * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * -***************************************************************************/ - -#ifndef NEW_GPU_H -#define NEW_GPU_H - -/////////////////////////////////////////////////////////////////////////////// -// GPU global definitions -#define FRAME_BUFFER_SIZE (1024*512*2) -#define FRAME_WIDTH 1024 -#define FRAME_HEIGHT 512 -#define FRAME_OFFSET(x,y) (((y)<<10)+(x)) - -#define VIDEO_WIDTH 320 - -typedef char s8; -typedef signed short s16; -typedef signed int s32; -typedef signed long long s64; - -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned int u32; -typedef unsigned long long u64; - -#include "gpu_fixedpoint.h" - -/////////////////////////////////////////////////////////////////////////////// -// Tweaks and Hacks -extern int skipCount; -extern bool enableAbbeyHack; -extern bool show_fps; -extern bool alt_fps; - -/////////////////////////////////////////////////////////////////////////////// -// interlaced rendering -extern int linesInterlace_user; -extern bool progressInterlace; - -extern bool light; -extern bool blend; - -typedef struct { - u32 Version; - u32 GPU_gp1; - u32 Control[256]; - unsigned char FrameBuffer[1024*512*2]; -} GPUFreeze_t; - -struct GPUPacket -{ - union - { - u32 U4[16]; - s32 S4[16]; - u16 U2[32]; - s16 S2[32]; - u8 U1[64]; - s8 S1[64]; - }; -}; - -/////////////////////////////////////////////////////////////////////////////// -// Compile Options - -//#define ENABLE_GPU_NULL_SUPPORT // Enables NullGPU support -//#define ENABLE_GPU_LOG_SUPPORT // Enables gpu logger, very slow only for windows debugging - -/////////////////////////////////////////////////////////////////////////////// -#endif // NEW_GPU_H diff --git a/plugins/gpu_unai/old/port.h b/plugins/gpu_unai/old/port.h deleted file mode 100644 index 238b98bc..00000000 --- a/plugins/gpu_unai/old/port.h +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include - -#define INLINE static inline - -#define GPU_init GPUinit -#define GPU_shutdown GPUshutdown -//#define GPU_freeze GPUfreeze -#define GPU_writeDataMem GPUwriteDataMem -#define GPU_dmaChain GPUdmaChain -#define GPU_writeData GPUwriteData -#define GPU_readDataMem GPUreadDataMem -#define GPU_readData GPUreadData -#define GPU_readStatus GPUreadStatus -#define GPU_writeStatus GPUwriteStatus -#define GPU_updateLace GPUupdateLace - -extern "C" { - -#define u32 unsigned int -#define s32 signed int - -bool GPUinit(void); -void GPUshutdown(void); -void GPUwriteDataMem(u32* dmaAddress, s32 dmaCount); -long GPUdmaChain(u32* baseAddr, u32 dmaVAddr); -void GPUwriteData(u32 data); -void GPUreadDataMem(u32* dmaAddress, s32 dmaCount); -u32 GPUreadData(void); -u32 GPUreadStatus(void); -void GPUwriteStatus(u32 data); - -#undef u32 -#undef s32 - -} diff --git a/plugins/gpu_unai/port.h b/plugins/gpu_unai/port.h deleted file mode 100644 index 0a731f8e..00000000 --- a/plugins/gpu_unai/port.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef __GPU_UNAI_GPU_PORT_H__ -#define __GPU_UNAI_GPU_PORT_H__ - -#include -#include - -#define INLINE static inline - -#define GPU_init GPUinit -#define GPU_shutdown GPUshutdown -//#define GPU_freeze GPUfreeze -#define GPU_writeDataMem GPUwriteDataMem -#define GPU_dmaChain GPUdmaChain -#define GPU_writeData GPUwriteData -#define GPU_readDataMem GPUreadDataMem -#define GPU_readData GPUreadData -#define GPU_readStatus GPUreadStatus -#define GPU_writeStatus GPUwriteStatus -#define GPU_updateLace GPUupdateLace - -extern "C" { - -#define u32 unsigned int -#define s32 signed int - -bool GPUinit(void); -void GPUshutdown(void); -void GPUwriteDataMem(u32* dmaAddress, s32 dmaCount); -long GPUdmaChain(u32* baseAddr, u32 dmaVAddr); -void GPUwriteData(u32 data); -void GPUreadDataMem(u32* dmaAddress, s32 dmaCount); -u32 GPUreadData(void); -u32 GPUreadStatus(void); -void GPUwriteStatus(u32 data); - -#undef u32 -#undef s32 - -} - -#endif /* __GPU_UNAI_GPU_PORT_H__ */ diff --git a/plugins/gpulib/gpulib.mak b/plugins/gpulib/gpulib.mak index fef76c03..c86541c2 100644 --- a/plugins/gpulib/gpulib.mak +++ b/plugins/gpulib/gpulib.mak @@ -16,9 +16,6 @@ endif GPULIB_A = ../gpulib/gpulib.$(ARCH).a -ifdef BIN_STANDALONE -TARGETS += $(BIN_STANDALONE) -endif ifdef BIN_GPULIB TARGETS += $(BIN_GPULIB) endif @@ -30,15 +27,6 @@ PLUGINDIR = $(shell basename $(WD)) all: ../../config.mak $(TARGETS) -ifdef BIN_STANDALONE -ifneq ($(findstring .cpp,$(SRC_STANDALONE)),) -CC_STANDLALONE = $(CXX) -endif -$(BIN_STANDALONE): $(SRC) $(SRC_STANDALONE) $(GPULIB_A) - $(CC_STANDLALONE) -o $@ $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) $(LDLIBS_STANDALONE) - ln -fs $(PLUGINDIR)/$@ ../ -endif - ifdef BIN_GPULIB ifneq ($(findstring .cpp,$(SRC_GPULIB)),) CC_GPULIB = $(CXX) -- 2.47.3