From: Theo B. <cyb...@us...> - 2007-09-30 23:48:48
|
Update of /cvsroot/yabause/yabause/src In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv6876 Modified Files: vdp2.c vdp2.h yabause.c yabause.h Log Message: -Adjusted YabauseGetTicks and fps code so it allows for greater precision -Changed windows code so it uses performance counters from now on. Index: vdp2.h =================================================================== RCS file: /cvsroot/yabause/yabause/src/vdp2.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- vdp2.h 17 Aug 2006 22:57:28 -0000 1.7 +++ vdp2.h 30 Sep 2007 23:48:49 -0000 1.8 @@ -358,7 +358,7 @@ } Vdp2Internal_struct; extern Vdp2Internal_struct Vdp2Internal; -extern u32 lastticks; +extern u64 lastticks; int Vdp2Init(void); void Vdp2DeInit(void); Index: yabause.h =================================================================== RCS file: /cvsroot/yabause/yabause/src/yabause.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- yabause.h 12 Jun 2007 21:02:41 -0000 1.13 +++ yabause.h 30 Sep 2007 23:48:49 -0000 1.14 @@ -58,7 +58,7 @@ int YabauseExec(void); void YabauseStartSlave(void); void YabauseStopSlave(void); -u32 YabauseGetTicks(void); +u64 YabauseGetTicks(void); void YabauseSetVideoFormat(int type); void YabauseSpeedySetup(void); int YabauseQuickLoadGame(void); @@ -76,7 +76,8 @@ int IsPal; u8 IsSSH2Running; u8 IsM68KRunning; - u32 OneFrameTime; + u64 OneFrameTime; + u64 tickfreq; int emulatebios; int usequickload; } yabsys_struct; Index: yabause.c =================================================================== RCS file: /cvsroot/yabause/yabause/src/yabause.c,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- yabause.c 10 Aug 2007 20:08:07 -0000 1.37 +++ yabause.c 30 Sep 2007 23:48:49 -0000 1.38 @@ -63,6 +63,7 @@ yabsys_struct yabsys; const char *bupfilename = NULL; +u64 tickfreq; ////////////////////////////////////////////////////////////////////////////// @@ -429,17 +430,19 @@ ////////////////////////////////////////////////////////////////////////////// -u32 YabauseGetTicks(void) { +u64 YabauseGetTicks(void) { #ifdef WIN32 - return timeGetTime(); + u64 ticks; + QueryPerformanceCounter((LARGE_INTEGER *)&ticks); + return ticks; #elif defined(HAVE_LIBSDL) return SDL_GetTicks(); #elif defined(_arch_dreamcast) - return (u32) timer_ms_gettime64(); + return (u64) timer_ms_gettime64(); #elif defined(__APPLE__) struct timeval Time; gettimeofday(&Time, NULL); - return (u32)(Time.tv_usec/1000); + return (u64)(Time.tv_usec/1000); #endif } @@ -448,7 +451,12 @@ void YabauseSetVideoFormat(int type) { yabsys.IsPal = type; yabsys.MaxLineCount = type ? 313 : 263; - yabsys.OneFrameTime = 1000 / (type ? 50 : 60); +#ifdef WIN32 + QueryPerformanceFrequency((LARGE_INTEGER *)&yabsys.tickfreq); +#else + yabsys.tickfreq = 1000; +#endif + yabsys.OneFrameTime = yabsys.tickfreq / (type ? 50 : 60); Vdp2Regs->TVSTAT = Vdp2Regs->TVSTAT | (type & 0x1); ScspChangeVideoFormat(type); YabauseChangeTiming(yabsys.CurSH2FreqType); Index: vdp2.c =================================================================== RCS file: /cvsroot/yabause/yabause/src/vdp2.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- vdp2.c 12 Jun 2007 21:02:40 -0000 1.21 +++ vdp2.c 30 Sep 2007 23:48:49 -0000 1.22 @@ -36,14 +36,14 @@ static int framesskipped=0; static int throttlespeed=0; static int skipnextframe=0; -u32 lastticks=0; -static u32 curticks=0; -static u32 diffticks=0; +u64 lastticks=0; +static u64 curticks=0; +static u64 diffticks=0; static u32 framecount=0; -static u32 onesecondticks=0; +static u64 onesecondticks=0; static int fps; static int fpsframecount=0; -static u32 fpsticks; +static u64 fpsticks; static int fpstoggle=0; ////////////////////////////////////////////////////////////////////////////// @@ -280,7 +280,7 @@ VIDCore->OnScreenDebugMessage("%02d/%02d FPS", fps, yabsys.IsPal ? 50 : 60); fpsframecount++; - if(YabauseGetTicks() >= fpsticks + 1000) + if(YabauseGetTicks() >= fpsticks + yabsys.tickfreq) { fps = fpsframecount; fpsframecount = 0; @@ -365,7 +365,7 @@ curticks = YabauseGetTicks(); diffticks = curticks-lastticks; - if ((onesecondticks+diffticks) > (yabsys.OneFrameTime * framecount) && + if ((onesecondticks+diffticks) > (yabsys.OneFrameTime * (u64)framecount) && framesskipped < 9) { // Skip the next frame @@ -374,14 +374,14 @@ // How many frames should we skip? framestoskip = 1; } - else if ((onesecondticks+diffticks) < (yabsys.OneFrameTime * framecount)) + else if ((onesecondticks+diffticks) < (yabsys.OneFrameTime * (u64)framecount)) { // Check to see if we need to limit speed at all for (;;) { curticks = YabauseGetTicks(); diffticks = curticks-lastticks; - if ((onesecondticks+diffticks) >= (yabsys.OneFrameTime * framecount)) + if ((onesecondticks+diffticks) >= (yabsys.OneFrameTime * (u64)framecount)) break; } } |