Update of /cvsroot/vba/VisualBoyAdvance/src/win32 In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv20723/src/win32 Modified Files: GDIDisplay.cpp MainWnd.cpp MainWndFile.cpp MainWndOptions.cpp MainWndTools.cpp VBA.cpp VBA.h Log Message: added yuansyuan's smooth feature rewind state is now NOT reseted after loadState Index: VBA.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/win32/VBA.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** VBA.cpp 7 Jun 2006 18:14:17 -0000 1.17 --- VBA.cpp 21 Jun 2006 16:58:15 -0000 1.18 *************** *** 20,24 **** // #include "stdafx.h" - #include <mmsystem.h> #include "AVIWrite.h" --- 20,23 ---- *************** *** 131,134 **** --- 130,150 ---- #endif + namespace Sm60FPS + { + float K_fCpuSpeed = 98.0f; + float K_fTargetFps = 60.0f * K_fCpuSpeed / 100; + float K_fDT = 1000.0f / K_fTargetFps; + + u32 dwTimeElapse; + u32 dwTime0; + u32 dwTime1; + u32 nFrameCnt; + float fWantFPS; + float fCurFPS; + bool bLastSkip; + int nCurSpeed; + int bSaveMoreCPU; + }; + void directXMessage(const char *msg) { *************** *** 186,190 **** menu = NULL; popup = NULL; ! cartridgeType = 0; soundInitialized = false; useBiosFile = false; --- 202,206 ---- menu = NULL; popup = NULL; ! cartridgeType = IMAGE_GBA; soundInitialized = false; useBiosFile = false; *************** *** 364,368 **** VBA theApp; - #include <afxdisp.h> ///////////////////////////////////////////////////////////////////////////// // VBA initialization --- 380,383 ---- *************** *** 421,430 **** BOOL VBA::InitInstance() { - AfxEnableControlContainer(); - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - #if _MSC_VER < 1400 #ifdef _AFXDLL --- 436,439 ---- *************** *** 828,831 **** --- 837,843 ---- } + if (Sm60FPS_CanSkipFrame()) + return; + if(theApp.aviRecording && !theApp.painting) { int width = 240; *************** *** 873,886 **** } ! if(theApp.ifbFunction) { ! if(systemColorDepth == 16) ! theApp.ifbFunction(pix+theApp.filterWidth*2+4, theApp.filterWidth*2+4, ! theApp.filterWidth, theApp.filterHeight); ! else ! theApp.ifbFunction(pix+theApp.filterWidth*4+4, theApp.filterWidth*4+4, ! theApp.filterWidth, theApp.filterHeight); } theApp.display->render(); } --- 885,897 ---- } ! if( theApp.ifbFunction ) { ! theApp.ifbFunction( pix + (theApp.filterWidth * (systemColorDepth>>3)) + 4, ! (theApp.filterWidth * (systemColorDepth>>3)) + 4, ! theApp.filterWidth, theApp.filterHeight ); } theApp.display->render(); + + Sm60FPS_Sleep(); } *************** *** 893,897 **** u32 systemGetClock() { ! return timeGetTime(); } --- 904,908 ---- u32 systemGetClock() { ! return GetTickCount(); } *************** *** 950,981 **** { u32 time = systemGetClock(); ! if(!theApp.wasPaused && theApp.autoFrameSkip && !theApp.throttle) { u32 diff = time - theApp.autoFrameSkipLastTime; ! int speed = 100; - if(diff) - speed = (1000000/rate)/diff; - - if(speed >= 98) { - theApp.frameskipadjust++; - if(theApp.frameskipadjust >= 3) { - theApp.frameskipadjust=0; - if(systemFrameSkip > 0) - systemFrameSkip--; - } - } else { - if(speed < 80) - theApp.frameskipadjust -= (90 - speed)/5; - else if(systemFrameSkip < 9) - theApp.frameskipadjust--; - if(theApp.frameskipadjust <= -2) { - theApp.frameskipadjust += 2; - if(systemFrameSkip < 9) - systemFrameSkip++; - } - } - } if(!theApp.wasPaused && theApp.throttle) { if(!speedup) { --- 961,976 ---- { u32 time = systemGetClock(); ! ! if (theApp.autoFrameSkip) ! { u32 diff = time - theApp.autoFrameSkipLastTime; ! Sm60FPS::nCurSpeed = 100; ! ! if (diff) ! Sm60FPS::nCurSpeed = (1000000/rate)/diff; ! } if(!theApp.wasPaused && theApp.throttle) { if(!speedup) { *************** *** 1092,1096 **** void systemGbBorderOn() { ! if(emulating && theApp.cartridgeType == 1 && gbBorderOn) { theApp.updateWindowSize(theApp.videoOption); } --- 1087,1091 ---- void systemGbBorderOn() { ! if(emulating && theApp.cartridgeType == IMAGE_GB && gbBorderOn) { theApp.updateWindowSize(theApp.videoOption); } *************** *** 1188,1192 **** winSetLanguageOption(languageOption, true); ! frameSkip = regQueryDwordValue("frameSkip", 2); if(frameSkip < 0 || frameSkip > 9) frameSkip = 2; --- 1183,1187 ---- winSetLanguageOption(languageOption, true); ! frameSkip = regQueryDwordValue("frameSkip", 1); if(frameSkip < 0 || frameSkip > 9) frameSkip = 2; *************** *** 1429,1432 **** --- 1424,1436 ---- if(throttle < 5 || throttle > 1000) throttle = 0; + + if (autoFrameSkip) + { + throttle = 0; + frameSkip = 0; + systemFrameSkip = 0; + } + + Sm60FPS::bSaveMoreCPU = regQueryDwordValue("saveMoreCPU", 0); } *************** *** 1590,1594 **** videoOption = value; ! if(cartridgeType == 1) { if(gbBorderOn) { sizeX = 256; --- 1594,1598 ---- videoOption = value; ! if(cartridgeType == IMAGE_GB) { if(gbBorderOn) { sizeX = 256; *************** *** 1699,1702 **** --- 1703,1707 ---- bool VBA::updateRenderMethod(bool force) { + Sm60FPS_Init(); bool res = updateRenderMethod0(force); *************** *** 2245,2248 **** --- 2250,2255 ---- regSetDwordValue("fsMaxScale", fsMaxScale); regSetDwordValue("throttle", throttle); + + regSetDwordValue("saveMoreCPU", Sm60FPS::bSaveMoreCPU); } *************** *** 2272,2273 **** --- 2279,2350 ---- } } + + + void Sm60FPS_Init() + { + Sm60FPS::dwTimeElapse = 0; + Sm60FPS::fWantFPS = 60.f; + Sm60FPS::fCurFPS = 0.f; + Sm60FPS::nFrameCnt = 0; + Sm60FPS::bLastSkip = false; + Sm60FPS::nCurSpeed = 100; + } + + + bool Sm60FPS_CanSkipFrame() + { + if( theApp.autoFrameSkip ) { + if( Sm60FPS::nFrameCnt == 0 ) { + Sm60FPS::nFrameCnt = 0; + Sm60FPS::dwTimeElapse = 0; + Sm60FPS::dwTime0 = timeGetTime(); + } else { + if( Sm60FPS::nFrameCnt >= 10 ) { + Sm60FPS::nFrameCnt = 0; + Sm60FPS::dwTimeElapse = 0; + + if( Sm60FPS::nCurSpeed > Sm60FPS::K_fCpuSpeed ) { + Sm60FPS::fWantFPS += 1; + if( Sm60FPS::fWantFPS > Sm60FPS::K_fTargetFps ){ + Sm60FPS::fWantFPS = Sm60FPS::K_fTargetFps; + } + } else { + if( Sm60FPS::nCurSpeed < (Sm60FPS::K_fCpuSpeed - 5) ) { + Sm60FPS::fWantFPS -= 1; + if( Sm60FPS::fWantFPS < 30.f ) { + Sm60FPS::fWantFPS = 30.f; + } + } + } + } else { // between frame 1-10 + Sm60FPS::dwTime1 = timeGetTime(); + Sm60FPS::dwTimeElapse += (Sm60FPS::dwTime1 - Sm60FPS::dwTime0); + Sm60FPS::dwTime0 = Sm60FPS::dwTime1; + if( !Sm60FPS::bLastSkip && + ( (Sm60FPS::fWantFPS < Sm60FPS::K_fTargetFps) || Sm60FPS::bSaveMoreCPU) ) { + Sm60FPS::fCurFPS = (float)Sm60FPS::nFrameCnt * 1000 / Sm60FPS::dwTimeElapse; + if( (Sm60FPS::fCurFPS < Sm60FPS::K_fTargetFps) || Sm60FPS::bSaveMoreCPU ) { + Sm60FPS::bLastSkip = true; + Sm60FPS::nFrameCnt++; + return true; + } + } + } + } + Sm60FPS::bLastSkip = false; + Sm60FPS::nFrameCnt++; + } + return false; + } + + + void Sm60FPS_Sleep() + { + if( theApp.autoFrameSkip ) { + u32 dwTimePass = Sm60FPS::dwTimeElapse + (timeGetTime() - Sm60FPS::dwTime0); + u32 dwTimeShould = (u32)(Sm60FPS::nFrameCnt * Sm60FPS::K_fDT); + if( dwTimeShould > dwTimePass ) { + Sleep(dwTimeShould - dwTimePass); + } + } + } Index: MainWndFile.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/win32/MainWndFile.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** MainWndFile.cpp 12 Jun 2006 11:09:04 -0000 1.17 --- MainWndFile.cpp 21 Jun 2006 16:58:15 -0000 1.18 *************** *** 254,260 **** systemDrawScreen(); ! theApp.rewindCount = 0; ! theApp.rewindCounter = 0; ! theApp.rewindSaveNeeded = false; return res; --- 254,260 ---- systemDrawScreen(); ! //theApp.rewindCount = 0; ! //theApp.rewindCounter = 0; ! //theApp.rewindSaveNeeded = false; return res; Index: VBA.h =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/win32/VBA.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** VBA.h 6 Jun 2006 21:04:21 -0000 1.9 --- VBA.h 21 Jun 2006 16:58:15 -0000 1.10 *************** *** 21,30 **** // - #if !defined(AFX_VBA_H__57514A10_49F9_4B83_A928_0D8A4A7306A3__INCLUDED_) - #define AFX_VBA_H__57514A10_49F9_4B83_A928_0D8A4A7306A3__INCLUDED_ - - #if _MSC_VER > 1000 #pragma once - #endif // _MSC_VER > 1000 #ifndef __AFXWIN_H__ --- 21,25 ---- *************** *** 32,39 **** #endif ! #include <afxtempl.h> #include "AcceleratorManager.h" - #include "resource.h" // main symbols #include "Display.h" #include "Input.h" --- 27,35 ---- #endif ! #include "stdafx.h" ! #include "resource.h" ! //#include <afxtempl.h> #include "AcceleratorManager.h" #include "Display.h" #include "Input.h" *************** *** 41,44 **** --- 37,41 ---- #include "Sound.h" #include "../System.h" + #include "../Util.h" ///////////////////////////////////////////////////////////////////////////// *************** *** 48,53 **** enum { ! VIDEO_1X, VIDEO_2X, VIDEO_3X, VIDEO_4X, ! VIDEO_320x240, VIDEO_640x480, VIDEO_800x600, VIDEO_OTHER }; --- 45,56 ---- enum { ! VIDEO_1X, ! VIDEO_2X, ! VIDEO_3X, ! VIDEO_4X, ! VIDEO_320x240, ! VIDEO_640x480, ! VIDEO_800x600, ! VIDEO_OTHER }; *************** *** 97,101 **** bool menuToggle; IDisplay *display; ! int cartridgeType; bool soundInitialized; bool useBiosFile; --- 100,104 ---- bool menuToggle; IDisplay *display; ! IMAGE_TYPE cartridgeType; bool soundInitialized; bool useBiosFile; *************** *** 261,270 **** #ifdef MMX extern "C" bool cpu_mmx; ! #endif ! ! ///////////////////////////////////////////////////////////////////////////// ! ! //{{AFX_INSERT_LOCATION}} ! // Microsoft Visual C++ will insert additional declarations immediately before the previous line. ! ! #endif // !defined(AFX_VBA_H__57514A10_49F9_4B83_A928_0D8A4A7306A3__INCLUDED_) --- 264,266 ---- #ifdef MMX extern "C" bool cpu_mmx; ! #endif \ No newline at end of file Index: MainWndTools.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/win32/MainWndTools.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MainWndTools.cpp 6 Jun 2006 21:04:21 -0000 1.4 --- MainWndTools.cpp 21 Jun 2006 16:58:15 -0000 1.5 *************** *** 206,210 **** debugger = true; emulating = 1; ! theApp.cartridgeType = 0; theApp.filename = "\\gnu_stub"; rom = (u8 *)malloc(0x2000000); --- 206,210 ---- debugger = true; emulating = 1; ! theApp.cartridgeType = IMAGE_GBA; theApp.filename = "\\gnu_stub"; rom = (u8 *)malloc(0x2000000); Index: GDIDisplay.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/win32/GDIDisplay.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** GDIDisplay.cpp 15 Sep 2004 22:11:20 -0000 1.8 --- GDIDisplay.cpp 21 Jun 2006 16:58:15 -0000 1.9 *************** *** 2,5 **** --- 2,6 ---- // Copyright (C) 1999-2003 Forgotten // Copyright (C) 2004 Forgotten and the VBA development team + // Copyright (C) 2005-2006 VBA development team // This program is free software; you can redistribute it and/or modify *************** *** 18,22 **** #include "stdafx.h" ! #include <stdio.h> #include "../System.h" --- 19,24 ---- #include "stdafx.h" ! ! #include "Display.h" #include "../System.h" Index: MainWnd.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/win32/MainWnd.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** MainWnd.cpp 12 Jun 2006 11:09:04 -0000 1.20 --- MainWnd.cpp 21 Jun 2006 16:58:15 -0000 1.21 *************** *** 477,481 **** } systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; ! theApp.cartridgeType = (int)type; if(type == IMAGE_GB) { genericflashcardEnable = theApp.winGenericflashcardEnable; --- 477,481 ---- } systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; ! theApp.cartridgeType = type; if(type == IMAGE_GB) { genericflashcardEnable = theApp.winGenericflashcardEnable; Index: MainWndOptions.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/win32/MainWndOptions.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** MainWndOptions.cpp 7 Jun 2006 18:13:54 -0000 1.10 --- MainWndOptions.cpp 21 Jun 2006 16:58:15 -0000 1.11 *************** *** 54,57 **** --- 54,58 ---- { theApp.throttle = 0; + theApp.autoFrameSkip = false; } *************** *** 64,67 **** --- 65,69 ---- { theApp.throttle = 25; + theApp.autoFrameSkip = false; } *************** *** 74,77 **** --- 76,80 ---- { theApp.throttle = 50; + theApp.autoFrameSkip = false; } *************** *** 84,87 **** --- 87,91 ---- { theApp.throttle = 100; + theApp.autoFrameSkip = false; } *************** *** 94,97 **** --- 98,102 ---- { theApp.throttle = 150; + theApp.autoFrameSkip = false; } *************** *** 104,107 **** --- 109,113 ---- { theApp.throttle = 200; + theApp.autoFrameSkip = false; } *************** *** 119,122 **** --- 125,129 ---- if( v ) { theApp.throttle = v; + theApp.autoFrameSkip = false; } } *************** *** 135,139 **** theApp.autoFrameSkip = !theApp.autoFrameSkip; if(!theApp.autoFrameSkip && emulating) ! theApp.updateFrameSkip(); } --- 142,152 ---- theApp.autoFrameSkip = !theApp.autoFrameSkip; if(!theApp.autoFrameSkip && emulating) ! theApp.updateFrameSkip(); ! else ! { ! theApp.throttle = false; ! frameSkip = 0; ! systemFrameSkip = 0; ! } } *************** *** 152,156 **** case ID_OPTIONS_VIDEO_FRAMESKIP_4: case ID_OPTIONS_VIDEO_FRAMESKIP_5: ! if(theApp.cartridgeType == 0) { frameSkip = nID - ID_OPTIONS_VIDEO_FRAMESKIP_0; } else { --- 165,169 ---- case ID_OPTIONS_VIDEO_FRAMESKIP_4: case ID_OPTIONS_VIDEO_FRAMESKIP_5: ! if(theApp.cartridgeType == IMAGE_GBA) { frameSkip = nID - ID_OPTIONS_VIDEO_FRAMESKIP_0; } else { *************** *** 159,162 **** --- 172,176 ---- if(emulating) theApp.updateFrameSkip(); + theApp.autoFrameSkip = false; return TRUE; break; *************** *** 165,169 **** case ID_OPTIONS_VIDEO_FRAMESKIP_8: case ID_OPTIONS_VIDEO_FRAMESKIP_9: ! if(theApp.cartridgeType == 0) { frameSkip = 6 + nID - ID_OPTIONS_VIDEO_FRAMESKIP_6; } else { --- 179,183 ---- case ID_OPTIONS_VIDEO_FRAMESKIP_8: case ID_OPTIONS_VIDEO_FRAMESKIP_9: ! if(theApp.cartridgeType == IMAGE_GBA) { frameSkip = 6 + nID - ID_OPTIONS_VIDEO_FRAMESKIP_6; } else { *************** *** 172,175 **** --- 186,190 ---- if(emulating) theApp.updateFrameSkip(); + theApp.autoFrameSkip = false; return TRUE; break; *************** *** 180,229 **** void MainWnd::OnUpdateOptionsVideoFrameskip0(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 0 : gbFrameSkip == 0); } void MainWnd::OnUpdateOptionsVideoFrameskip1(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 1 : gbFrameSkip == 1); } void MainWnd::OnUpdateOptionsVideoFrameskip2(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 2 : gbFrameSkip == 2); } void MainWnd::OnUpdateOptionsVideoFrameskip3(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 3 : gbFrameSkip == 3); } void MainWnd::OnUpdateOptionsVideoFrameskip4(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 4 : gbFrameSkip == 4); } void MainWnd::OnUpdateOptionsVideoFrameskip5(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 5 : gbFrameSkip == 5); } void MainWnd::OnUpdateOptionsVideoFrameskip6(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 6 : gbFrameSkip == 6); } void MainWnd::OnUpdateOptionsVideoFrameskip7(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 7 : gbFrameSkip == 7); } void MainWnd::OnUpdateOptionsVideoFrameskip8(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 8 : gbFrameSkip == 8); } void MainWnd::OnUpdateOptionsVideoFrameskip9(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == 0 ? frameSkip == 9 : gbFrameSkip == 9); } --- 195,244 ---- void MainWnd::OnUpdateOptionsVideoFrameskip0(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == IMAGE_GBA ? frameSkip == 0 : gbFrameSkip == 0); } void MainWnd::OnUpdateOptionsVideoFrameskip1(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == IMAGE_GBA ? frameSkip == 1 : gbFrameSkip == 1); } void MainWnd::OnUpdateOptionsVideoFrameskip2(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == IMAGE_GBA ? frameSkip == 2 : gbFrameSkip == 2); } void MainWnd::OnUpdateOptionsVideoFrameskip3(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == IMAGE_GBA ? frameSkip == 3 : gbFrameSkip == 3); } void MainWnd::OnUpdateOptionsVideoFrameskip4(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == IMAGE_GBA ? frameSkip == 4 : gbFrameSkip == 4); } void MainWnd::OnUpdateOptionsVideoFrameskip5(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == IMAGE_GBA ? frameSkip == 5 : gbFrameSkip == 5); } void MainWnd::OnUpdateOptionsVideoFrameskip6(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == IMAGE_GBA ? frameSkip == 6 : gbFrameSkip == 6); } void MainWnd::OnUpdateOptionsVideoFrameskip7(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == IMAGE_GBA ? frameSkip == 7 : gbFrameSkip == 7); } void MainWnd::OnUpdateOptionsVideoFrameskip8(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == IMAGE_GBA ? frameSkip == 8 : gbFrameSkip == 8); } void MainWnd::OnUpdateOptionsVideoFrameskip9(CCmdUI* pCmdUI) { ! pCmdUI->SetCheck(theApp.cartridgeType == IMAGE_GBA ? frameSkip == 9 : gbFrameSkip == 9); } *************** *** 349,353 **** { cpuDisableSfx = !cpuDisableSfx; ! if(emulating && theApp.cartridgeType == 0) CPUUpdateRender(); } --- 364,368 ---- { cpuDisableSfx = !cpuDisableSfx; ! if(emulating && theApp.cartridgeType == IMAGE_GBA) CPUUpdateRender(); } *************** *** 672,675 **** --- 687,692 ---- { synchronize = !synchronize; + if (synchronize) + theApp.throttle = false; } *************** *** 986,989 **** --- 1003,1007 ---- soundOffFlag = true; soundShutdown(); + theApp.soundInitialized = false; } |