From 7c054f247a01f46ba4bbcb5f2710cd6cc4a6f7ca Mon Sep 17 00:00:00 2001 From: ramapcsx2 Date: Fri, 14 Nov 2008 16:36:40 +0000 Subject: [PATCH] A commit for review, there's some unclear counters code. Also added a more precise NTSC vsync rate. git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@326 a6443dda-0b58-4228-96e9-037be469359c --- pcsx2/Common.h | 6 +++--- pcsx2/Counters.c | 13 ++++++++----- pcsx2/Counters.h | 10 +++++++--- pcsx2/Misc.h | 4 ++-- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/pcsx2/Common.h b/pcsx2/Common.h index 37efa1702b..c65b38c8eb 100644 --- a/pcsx2/Common.h +++ b/pcsx2/Common.h @@ -158,7 +158,7 @@ extern TESTRUNARGS g_TestRun; HBlank 15.73426573 KHz */ //VBlanks per second -#define VBLANK_NTSC ((Config.PsxType & 2) ? 59.94 : 59.82) +#define VBLANK_NTSC ((Config.PsxType & 2) ? 59.94005994 : 59.82) #define VBLANK_PAL ((Config.PsxType & 2) ? 50.00 : 49.76) //HBlanks per second @@ -168,10 +168,10 @@ extern TESTRUNARGS g_TestRun; //VBlank timers for EE, bit more accurate. #define VBLANKCNT(count) ((u32)((Config.PsxType & 1) ? (VBLANKPALSELECT * count) : (VBLANKNTSCSELECT * count))) #define VBLANKPALSELECT ((Config.PsxType & 2) ? (PS2CLK / 50.00) : (PS2CLK / 49.76)) -#define VBLANKNTSCSELECT ((Config.PsxType & 2) ? (PS2CLK / 59.94) : (PS2CLK / 59.82)) +#define VBLANKNTSCSELECT ((Config.PsxType & 2) ? (PS2CLK / 59.94005994) : (PS2CLK / 59.82)) //EE VBlank speeds -#define PS2VBLANK_NTSC_INT ((PS2CLK / 59.94)) +#define PS2VBLANK_NTSC_INT ((PS2CLK / 59.94005994)) #define PS2VBLANK_NTSC ((PS2CLK / 59.82)) #define PS2VBLANK_PAL_INT ((PS2CLK / 50.00)) #define PS2VBLANK_PAL ((PS2CLK / 49.76)) diff --git a/pcsx2/Counters.c b/pcsx2/Counters.c index 3f000f2397..4c2d9a5273 100644 --- a/pcsx2/Counters.c +++ b/pcsx2/Counters.c @@ -73,22 +73,25 @@ static __forceinline void _rcntSet( int i ) } static __forceinline void cpuRcntSet() { - int i; // Calculate our target cycle deltas. // This must be done regardless of if the hblank/vblank counters updated since // cpuRegs.cycle changes, even if sCycle hasn't! - u32 counter4CycleT = ( counters[4].mode == MODE_HBLANK ) ? HBLANK_TIME_ : HRENDER_TIME_; + //fixme : HBLANK_TIME_ and HRENDER_TIME_ are both SCANLINE_NTSC (or _PAL) / 2.. was that intended? (rama) + //u32 counter4CycleT = ( counters[4].mode == MODE_HBLANK ) ? HBLANK_TIME_ : HRENDER_TIME_; + u32 counter4CycleT = HBLANK_TIME_; u32 counter5CycleT = VSYNC_HALF_ - (cpuRegs.cycle - counters[5].sCycle); counter4CycleT -= (cpuRegs.cycle - counters[4].sCycle); nextCounter = (counter4CycleT < counter5CycleT) ? counter4CycleT : counter5CycleT; nextsCounter = cpuRegs.cycle; - - for (i = 0; i < 4; i++) - _rcntSet( i ); + + _rcntSet( 0 ); + _rcntSet( 1 ); + _rcntSet( 2 ); + _rcntSet( 3 ); } void rcntInit() { diff --git a/pcsx2/Counters.h b/pcsx2/Counters.h index 23ecd5a8ff..40e70c1f40 100644 --- a/pcsx2/Counters.h +++ b/pcsx2/Counters.h @@ -35,11 +35,13 @@ typedef struct { //------------------------------------------------------------------ // NTSC Timing Information!!! (some scanline info is guessed) //------------------------------------------------------------------ -#define SCANLINE_NTSC (u32)(PS2CLK / 15734.25)//18743 +#define SCANLINE_NTSC (u32)(PS2CLK / 15734.27)//18743 +// fixme : Both, HRENDER_TIME_NTSC and HBLANK_TIME_NTSC the same? +// also see cpuRcntSet() and possibly hScanline() for this issue (rama) #define HRENDER_TIME_NTSC (u32)(SCANLINE_NTSC / 2)//15528 //time from hblank end to hblank start (PS2CLK / 18991.368423051722991900181367568) #define HBLANK_TIME_NTSC (u32)(SCANLINE_NTSC / 2)//3215 //time from hblank start to hblank end (PS2CLK / 91738.91105912572817760653181028) -#define VSYNC_NTSC (u32)(PS2CLK / 59.94) //hz -#define VSYNC_HALF_NTSC (u32)(VSYNC_NTSC / 2) //hz +#define VSYNC_NTSC (u32)(PS2CLK / 59.94005994) //hz +#define VSYNC_HALF_NTSC (u32)(VSYNC_NTSC / 2) //hz //should be 2460058 but rounding puts it to 2460060 #define SCANLINES_TOTAL_NTSC 525 // total number of scanlines #define SCANLINES_VSYNC_NTSC 3 // scanlines that are used for syncing every half-frame @@ -53,6 +55,8 @@ typedef struct { // PAL Timing Information!!! (some scanline info is guessed) //------------------------------------------------------------------ #define SCANLINE_PAL (u32)(PS2CLK / 15625)//18874 +// fixme : Both, HRENDER_TIME_PAL and HBLANK_TIME_PAL the same? +// also see cpuRcntSet() and possibly hScanline() for this issue (rama) #define HRENDER_TIME_PAL (u32)(SCANLINE_PAL / 2)//15335 //time from hblank end to hblank start #define HBLANK_TIME_PAL (u32)(SCANLINE_PAL / 2)//3539 //time from hblank start to hblank end #define VSYNC_PAL (u32)(PS2CLK / 50) //hz diff --git a/pcsx2/Misc.h b/pcsx2/Misc.h index 7a7948ce38..fd3e8ffc24 100644 --- a/pcsx2/Misc.h +++ b/pcsx2/Misc.h @@ -123,8 +123,8 @@ typedef struct { int Hacks; int GameFixes; int CustomFrameSkip; - int CustomConsecutiveFrames; - int CustomConsecutiveSkip; + u8 CustomConsecutiveFrames; + u8 CustomConsecutiveSkip; u32 sseMXCSR; u32 sseVUMXCSR; } PcsxConfig;