diff options
author | twinaphex | 2012-11-28 06:35:30 +0100 |
---|---|---|
committer | twinaphex | 2012-11-28 06:35:30 +0100 |
commit | b194a2ecd43debbb3724e332b660b993725acd52 (patch) | |
tree | a41deacfa7a6841e97d67fce60bb7f39b54b12be /libpcsxcore/psxcounters.c | |
parent | b6514bd168106e978a0af0f5043d5da6fd35800a (diff) | |
parent | 06d2e1a58b6eb7fb449f79f7e807343bd8d39b59 (diff) | |
download | pcsx_rearmed-b194a2ecd43debbb3724e332b660b993725acd52.tar.gz pcsx_rearmed-b194a2ecd43debbb3724e332b660b993725acd52.tar.bz2 pcsx_rearmed-b194a2ecd43debbb3724e332b660b993725acd52.zip |
Merge git://github.com/notaz/pcsx_rearmed
Diffstat (limited to 'libpcsxcore/psxcounters.c')
-rw-r--r-- | libpcsxcore/psxcounters.c | 107 |
1 files changed, 63 insertions, 44 deletions
diff --git a/libpcsxcore/psxcounters.c b/libpcsxcore/psxcounters.c index 8fc33b4..3e6d417 100644 --- a/libpcsxcore/psxcounters.c +++ b/libpcsxcore/psxcounters.c @@ -152,6 +152,52 @@ u32 _psxRcntRcount( u32 index ) return count; } +static +void _psxRcntWmode( u32 index, u32 value ) +{ + rcnts[index].mode = value; + + switch( index ) + { + case 0: + if( value & Rc0PixelClock ) + { + rcnts[index].rate = 5; + } + else + { + rcnts[index].rate = 1; + } + break; + case 1: + if( value & Rc1HSyncClock ) + { + rcnts[index].rate = (PSXCLK / (FrameRate[Config.PsxType] * HSyncTotal[Config.PsxType])); + } + else + { + rcnts[index].rate = 1; + } + break; + case 2: + if( value & Rc2OneEighthClock ) + { + rcnts[index].rate = 8; + } + else + { + rcnts[index].rate = 1; + } + + // TODO: wcount must work. + if( value & Rc2Disable ) + { + rcnts[index].rate = 0xffffffff; + } + break; + } +} + /******************************************************************************/ static @@ -357,50 +403,10 @@ void psxRcntWmode( u32 index, u32 value ) { verboseLog( 1, "[RCNT %i] wmode: %x\n", index, value ); - rcnts[index].mode = value; - rcnts[index].irqState = 0; - - switch( index ) - { - case 0: - if( value & Rc0PixelClock ) - { - rcnts[index].rate = 5; - } - else - { - rcnts[index].rate = 1; - } - break; - case 1: - if( value & Rc1HSyncClock ) - { - rcnts[index].rate = (PSXCLK / (FrameRate[Config.PsxType] * HSyncTotal[Config.PsxType])); - } - else - { - rcnts[index].rate = 1; - } - break; - case 2: - if( value & Rc2OneEighthClock ) - { - rcnts[index].rate = 8; - } - else - { - rcnts[index].rate = 1; - } - - // TODO: wcount must work. - if( value & Rc2Disable ) - { - rcnts[index].rate = 0xffffffff; - } - break; - } - + _psxRcntWmode( index, value ); _psxRcntWcount( index, 0 ); + + rcnts[index].irqState = 0; psxRcntSet(); } @@ -497,6 +503,9 @@ void psxRcntInit() s32 psxRcntFreeze( gzFile f, s32 Mode ) { + u32 count; + s32 i; + gzfreeze( &rcnts, sizeof(rcnts) ); gzfreeze( &hSyncCount, sizeof(hSyncCount) ); gzfreeze( &spuSyncCount, sizeof(spuSyncCount) ); @@ -504,9 +513,19 @@ s32 psxRcntFreeze( gzFile f, s32 Mode ) gzfreeze( &psxNextsCounter, sizeof(psxNextsCounter) ); if (Mode == 0) + { + // don't trust things from a savestate + 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; + psxRcntSet(); - base_cycle = 0; + base_cycle = 0; + } return 0; } |