X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfxvideo%2Fgpu.c;h=9fa08fe3f9642b61609a47526576c5f78b61bf1d;hp=b3845263d0d435eb17fd4f637aae54658ddb8a82;hb=59d15d23d97d4347d8046057013f8979db0914f0;hpb=4215cb1fa3c1f545b2bac62c5fc4c478469a6a46 diff --git a/plugins/dfxvideo/gpu.c b/plugins/dfxvideo/gpu.c index b3845263..9fa08fe3 100644 --- a/plugins/dfxvideo/gpu.c +++ b/plugins/dfxvideo/gpu.c @@ -23,7 +23,6 @@ // memory image of the PSX vram //////////////////////////////////////////////////////////////////////// -unsigned char *psxVSecure; unsigned char *psxVub; signed char *psxVsb; unsigned short *psxVuw; @@ -61,7 +60,7 @@ long lSelectedSlot=0; BOOL bDoLazyUpdate=FALSE; uint32_t lGPUInfoVals[16]; static int iFakePrimBusy=0; -static uint32_t vBlank=0; +static const int *skip_advice; //////////////////////////////////////////////////////////////////////// // some misc external display funcs @@ -87,16 +86,15 @@ static void SetFixes(void) // 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 - psxVSecure = (unsigned char *)malloc((512*2)*1024 + (1024*1024)); // always alloc one extra MB for soft drawing funcs security - if (!psxVSecure) - return -1; - //!!! ATTENTION !!! - psxVub=psxVSecure + 512 * 1024; // security offset into double sized psx vram! + psxVub=vram + 512 * 1024; // security offset into double sized psx vram! psxVsb=(signed char *)psxVub; // different ways of accessing PSX VRAM psxVsw=(signed short *)psxVub; @@ -106,7 +104,7 @@ long CALLBACK GPUinit(void) // GPU INIT psxVuw_eom=psxVuw+1024*512; // pre-calc of end of vram - memset(psxVSecure,0x00,(512*2)*1024 + (1024*1024)); + memset(vram,0x00,(512*2)*1024 + (1024*1024)); memset(lGPUInfoVals,0x00,16*sizeof(uint32_t)); PSXDisplay.RGB24 = FALSE; // init some stuff @@ -184,7 +182,6 @@ long CALLBACK GPUclose() // GPU CLOSE long CALLBACK GPUshutdown(void) // GPU SHUTDOWN { CloseDisplay(); // shutdown direct draw - free(psxVSecure); return 0; // nothinh to do } @@ -232,7 +229,8 @@ static void decideSkip(void) if(dwActFixes&0xa0) // -> pc fps calculation fix/old skipping fix { - if((fps_skip < fFrameRateHz) && !bSkipNextFrame) // -> skip max one in a row + 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; } @@ -473,7 +471,7 @@ uint32_t CALLBACK GPUreadStatus(void) // READ STATUS GPUIsReadyForCommands; } } - return lGPUstatusRet | vBlank; + return lGPUstatusRet; } //////////////////////////////////////////////////////////////////////// @@ -647,7 +645,7 @@ void CALLBACK GPUwriteStatus(uint32_t gdata) // WRITE STATUS } lGPUstatusRet|=GPUSTATUS_INTERLACED; } - else lGPUstatusRet&=~GPUSTATUS_INTERLACED; + else lGPUstatusRet&=~(GPUSTATUS_INTERLACED|0x80000000); if (PSXDisplay.PAL) lGPUstatusRet|=GPUSTATUS_PAL; @@ -1040,6 +1038,7 @@ long CALLBACK GPUdmaChain(uint32_t * baseAddrL, uint32_t addr) uint32_t dmaMem; unsigned char * baseAddrB; short count;unsigned int DMACommandCounter = 0; + long dmaWords = 0; GPUIsBusy; @@ -1054,6 +1053,7 @@ long CALLBACK GPUdmaChain(uint32_t * baseAddrL, uint32_t addr) if(CheckForEndlessLoop(addr)) break; count = baseAddrB[addr+3]; + dmaWords += 1 + count; dmaMem=addr+4; @@ -1065,7 +1065,7 @@ long CALLBACK GPUdmaChain(uint32_t * baseAddrL, uint32_t addr) GPUIsIdle; - return 0; + return dmaWords; } //////////////////////////////////////////////////////////////////////// @@ -1114,6 +1114,7 @@ long CALLBACK GPUfreeze(uint32_t ulGetFreezeData,GPUFreeze_t * pF) // RESET TEXTURE STORE HERE, IF YOU USE SOMETHING LIKE THAT + PreviousPSXDisplay.Height = 0; GPUwriteStatus(ulStatusControl[0]); GPUwriteStatus(ulStatusControl[1]); GPUwriteStatus(ulStatusControl[2]); @@ -1127,8 +1128,23 @@ long CALLBACK GPUfreeze(uint32_t ulGetFreezeData,GPUFreeze_t * pF) return 1; } -void CALLBACK GPUvBlank(int val) +// rearmed thing +#include "../../frontend/plugin_lib.h" + +const struct rearmed_cbs *rcbs; + +void GPUrearmedCallbacks(const struct rearmed_cbs *cbs) { - vBlank=val?0x80000000:0; + // 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); + + skip_advice = &cbs->fskip_advice; + fps_skip = 100.0f; + rcbs = cbs; } -