X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libpcsxcore%2Fpsxcounters.c;h=5198646d95d38085c6320f34dc75be05f5f7ad2d;hb=086adfff4fe6352e401d00c052071a6b91245b40;hp=6b9e2b7a2f21cf4c8da86dc51b45284e72fb4361;hpb=3cf51e0893f3646f4f6217b9701c0ab199d8a6ac;p=pcsx_rearmed.git diff --git a/libpcsxcore/psxcounters.c b/libpcsxcore/psxcounters.c index 6b9e2b7a..5198646d 100644 --- a/libpcsxcore/psxcounters.c +++ b/libpcsxcore/psxcounters.c @@ -23,7 +23,8 @@ #include "psxcounters.h" #include "gpu.h" -#include "debug.h" +//#include "debug.h" +#define DebugVSync() /******************************************************************************/ @@ -60,15 +61,15 @@ static const u32 CountToOverflow = 0; static const u32 CountToTarget = 1; static const u32 FrameRate[] = { 60, 50 }; -static const u32 HSyncTotal[] = { 263, 313 }; +static const u32 HSyncTotal[] = { 263, 314 }; // actually one more on odd lines for PAL #define VBlankStart 240 #define VERBOSE_LEVEL 0 /******************************************************************************/ - +#ifdef DRC_DISABLE Rcnt rcnts[ CounterQuantity ]; - +#endif u32 hSyncCount = 0; u32 frame_counter = 0; static u32 hsync_steps = 0; @@ -299,19 +300,19 @@ void psxRcntUpdate() cycle = psxRegs.cycle; // rcnt 0. - if( cycle - rcnts[0].cycleStart >= rcnts[0].cycle ) + while( cycle - rcnts[0].cycleStart >= rcnts[0].cycle ) { psxRcntReset( 0 ); } // rcnt 1. - if( cycle - rcnts[1].cycleStart >= rcnts[1].cycle ) + while( cycle - rcnts[1].cycleStart >= rcnts[1].cycle ) { psxRcntReset( 1 ); } // rcnt 2. - if( cycle - rcnts[2].cycleStart >= rcnts[2].cycle ) + while( cycle - rcnts[2].cycleStart >= rcnts[2].cycle ) { psxRcntReset( 2 ); } @@ -327,7 +328,7 @@ void psxRcntUpdate() // VSync irq. if( hSyncCount == VBlankStart ) { - HW_GPU_STATUS &= ~PSXGPU_LCF; + HW_GPU_STATUS &= SWAP32(~PSXGPU_LCF); GPU_vBlank( 1, 0 ); setIrq( 0x01 ); @@ -347,9 +348,9 @@ void psxRcntUpdate() frame_counter++; gpuSyncPluginSR(); - if( (HW_GPU_STATUS & PSXGPU_ILACE_BITS) == PSXGPU_ILACE_BITS ) - HW_GPU_STATUS |= frame_counter << 31; - GPU_vBlank( 0, HW_GPU_STATUS >> 31 ); + if ((HW_GPU_STATUS & SWAP32(PSXGPU_ILACE_BITS)) == SWAP32(PSXGPU_ILACE_BITS)) + HW_GPU_STATUS |= SWAP32(frame_counter << 31); + GPU_vBlank(0, SWAP32(HW_GPU_STATUS) >> 31); } // Schedule next call, in hsyncs @@ -493,7 +494,7 @@ s32 psxRcntFreeze( void *f, s32 Mode ) u32 count; s32 i; - gzfreeze( &rcnts, sizeof(rcnts) ); + gzfreeze( &rcnts, sizeof(Rcnt) * CounterQuantity ); gzfreeze( &hSyncCount, sizeof(hSyncCount) ); gzfreeze( &spuSyncCount, sizeof(spuSyncCount) ); gzfreeze( &psxNextCounter, sizeof(psxNextCounter) ); @@ -502,13 +503,16 @@ s32 psxRcntFreeze( void *f, s32 Mode ) if (Mode == 0) { // don't trust things from a savestate + rcnts[3].rate = 1; for( i = 0; i < CounterQuantity; ++i ) { _psxRcntWmode( i, rcnts[i].mode ); count = (psxRegs.cycle - rcnts[i].cycleStart) / rcnts[i].rate; _psxRcntWcount( i, count ); } - hsync_steps = (psxRegs.cycle - rcnts[3].cycleStart) / rcnts[3].target; + hsync_steps = 0; + if (rcnts[3].target) + hsync_steps = (psxRegs.cycle - rcnts[3].cycleStart) / rcnts[3].target; psxRcntSet(); base_cycle = 0;