From: S?bastien G. <kx...@us...> - 2004-04-16 01:12:10
|
Update of /cvsroot/vba/VisualBoyAdvance/src/gtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4424/src/gtk Modified Files: system.cpp vba.glade window.cpp window.h Log Message: Added show speed and save type support. Index: system.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/gtk/system.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** system.cpp 12 Apr 2004 22:59:24 -0000 1.2 --- system.cpp 16 Apr 2004 01:12:01 -0000 1.3 *************** *** 42,45 **** --- 42,48 ---- bool systemSoundOn; + int systemRenderedFrames; + int systemFPS; + int emulating; bool debugger; *************** *** 68,71 **** --- 71,75 ---- { gui()->vDrawScreen(); + systemRenderedFrames++; } *************** *** 82,88 **** void systemShowSpeed(int _iSpeed) { ! char csTitle[50]; ! snprintf(csTitle, 50, "VisualBoyAdvance-%d%%", _iSpeed); ! gui()->set_title(csTitle); } --- 86,93 ---- void systemShowSpeed(int _iSpeed) { ! systemFPS = systemRenderedFrames; ! systemRenderedFrames = 0; ! ! gui()->vShowSpeed(_iSpeed); } Index: vba.glade =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/gtk/vba.glade,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** vba.glade 15 Apr 2004 03:58:45 -0000 1.3 --- vba.glade 16 Apr 2004 01:12:01 -0000 1.4 *************** *** 5,10 **** <widget class="GtkWindow" id="MainWindow"> ! <property name="visible">True</property> ! <property name="title" translatable="yes">VisualBoyAdvance</property> <property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="window_position">GTK_WIN_POS_NONE</property> --- 5,9 ---- <widget class="GtkWindow" id="MainWindow"> ! <property name="title" translatable="yes">VBA</property> <property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="window_position">GTK_WIN_POS_NONE</property> Index: window.h =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/gtk/window.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** window.h 15 Apr 2004 03:58:45 -0000 1.4 --- window.h 16 Apr 2004 01:12:01 -0000 1.5 *************** *** 45,59 **** enum ECartridge { ! NO_CARTRIDGE, ! GB_CARTRIDGE, ! GBA_CARTRIDGE }; void vDrawScreen(); void vComputeFrameskip(int _iRate); inline u32 uiReadJoypad() { return m_uiJoypadState; } inline ECartridge eGetCartridge() { return m_eCartridge; } protected: virtual void vOnFileOpen(); virtual void vOnFilePauseToggled(Gtk::CheckMenuItem * _poCMI); --- 45,85 ---- enum ECartridge { ! CartridgeNone, ! CartridgeGB, ! CartridgeGBA }; + // GB/GBA screen sizes + const int m_iGBScreenWidth; + const int m_iGBScreenHeight; + const int m_iSGBScreenWidth; + const int m_iSGBScreenHeight; + const int m_iGBAScreenWidth; + const int m_iGBAScreenHeight; + void vDrawScreen(); void vComputeFrameskip(int _iRate); + void vShowSpeed(int _iSpeed); inline u32 uiReadJoypad() { return m_uiJoypadState; } inline ECartridge eGetCartridge() { return m_eCartridge; } protected: + enum EShowSpeed + { + ShowSpeedNone, + ShowSpeedPercentage, + ShowSpeedDetailed + }; + + enum ESaveType + { + SaveTypeAuto, + SaveTypeEEPROM, + SaveTypeSRAM, + SaveTypeFlash, + SaveTypeEEPROMSensor, + SaveTypeNone + }; + virtual void vOnFileOpen(); virtual void vOnFilePauseToggled(Gtk::CheckMenuItem * _poCMI); *************** *** 64,69 **** virtual void vOnThrottleToggled(Gtk::CheckMenuItem * _poCMI, int _iPercent); virtual void vOnThrottleOther(Gtk::CheckMenuItem * _poCMI); - virtual void vOnLayerToggled(Gtk::CheckMenuItem * _poCMI, int _iLayer); virtual void vOnVideoScaleToggled(Gtk::CheckMenuItem * _poCMI, int _iScale); virtual void vOnFilter2xToggled(Gtk::CheckMenuItem * _poCMI, int _iFilter2x); virtual void vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB); --- 90,98 ---- virtual void vOnThrottleToggled(Gtk::CheckMenuItem * _poCMI, int _iPercent); virtual void vOnThrottleOther(Gtk::CheckMenuItem * _poCMI); virtual void vOnVideoScaleToggled(Gtk::CheckMenuItem * _poCMI, int _iScale); + virtual void vOnLayerToggled(Gtk::CheckMenuItem * _poCMI, int _iLayer); + virtual void vOnShowSpeedToggled(Gtk::CheckMenuItem * _poCMI, int _iShowSpeed); + virtual void vOnSaveTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iSaveType); + virtual void vOnFlashSizeToggled(Gtk::CheckMenuItem * _poCMI, int _iFlashSize); virtual void vOnFilter2xToggled(Gtk::CheckMenuItem * _poCMI, int _iFilter2x); virtual void vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB); *************** *** 81,84 **** --- 110,129 ---- const Glib::RefPtr<Gnome::Glade::Xml> & _poXml); + // Config limits + const int m_iFrameskipMin; + const int m_iFrameskipMax; + const int m_iThrottleMin; + const int m_iThrottleMax; + const int m_iScaleMin; + const int m_iScaleMax; + const int m_iShowSpeedMin; + const int m_iShowSpeedMax; + const int m_iSaveTypeMin; + const int m_iSaveTypeMax; + const int m_iFilter2xMin; + const int m_iFilter2xMax; + const int m_iFilterIBMin; + const int m_iFilterIBMax; + static Window * m_poInstance; *************** *** 110,113 **** --- 155,159 ---- u32 m_uiThrottleLastTime; u32 m_uiThrottleDelay; + EShowSpeed m_eShowSpeed; void vInitSystem(); *************** *** 120,123 **** --- 166,170 ---- void vUpdateScreen(); void vDrawDefaultScreen(); + void vSetDefaultTitle(); bool bLoadROM(const std::string & _rsFilename); void vLoadBattery(); Index: window.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/gtk/window.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** window.cpp 15 Apr 2004 03:58:45 -0000 1.4 --- window.cpp 16 Apr 2004 01:12:01 -0000 1.5 *************** *** 32,35 **** --- 32,37 ---- #include "intl.h" + extern int systemRenderedFrames; + extern int systemFPS; extern bool debugger; extern int RGB_LOW_BITS_MASK; *************** *** 46,78 **** Window * Window::m_poInstance = NULL; - // GB/GBA screen sizes - const int iGBScreenWidth = 160; - const int iGBScreenHeight = 144; - const int iSGBScreenWidth = 256; - const int iSGBScreenHeight = 224; - const int iGBAScreenWidth = 240; - const int iGBAScreenHeight = 160; - - // Config limits - const int iFrameskipMin = 0; - const int iFrameskipMax = 9; - const int iThrottleMin = 5; - const int iThrottleMax = 1000; - const int iScaleMin = 1; - const int iScaleMax = 6; - const int iFilter2xMin = (int)FirstFilter; - const int iFilter2xMax = (int)LastFilter; - const int iFilterIBMin = (int)FirstFilterIB; - const int iFilterIBMax = (int)LastFilterIB; - Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr<Xml> & _poXml) : ! Gtk::Window(_pstWindow), ! m_poXml(_poXml), ! m_poFileOpenDialog(NULL), ! m_iScreenWidth(iGBAScreenWidth), ! m_iScreenHeight(iGBAScreenHeight), ! m_eCartridge(NO_CARTRIDGE), ! m_uiJoypadState(0) { vInitSystem(); vInitSDL(); --- 48,81 ---- Window * Window::m_poInstance = NULL; Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr<Xml> & _poXml) : ! Gtk::Window (_pstWindow), ! m_iGBScreenWidth (160), ! m_iGBScreenHeight (144), ! m_iSGBScreenWidth (256), ! m_iSGBScreenHeight(224), ! m_iGBAScreenWidth (240), ! m_iGBAScreenHeight(160), ! m_iFrameskipMin (0), ! m_iFrameskipMax (9), ! m_iThrottleMin (5), ! m_iThrottleMax (1000), ! m_iScaleMin (1), ! m_iScaleMax (6), ! m_iShowSpeedMin (ShowSpeedNone), ! m_iShowSpeedMax (ShowSpeedDetailed), ! m_iSaveTypeMin (SaveTypeAuto), ! m_iSaveTypeMax (SaveTypeNone), ! m_iFilter2xMin (FirstFilter), ! m_iFilter2xMax (LastFilter), ! m_iFilterIBMin (FirstFilterIB), ! m_iFilterIBMax (LastFilterIB) { + m_poXml = _poXml; + m_poFileOpenDialog = NULL; + m_iScreenWidth = m_iGBAScreenWidth; + m_iScreenHeight = m_iGBAScreenHeight; + m_eCartridge = CartridgeNone; + m_uiJoypadState = 0; + vInitSystem(); vInitSDL(); *************** *** 266,269 **** --- 269,355 ---- } + // Show speed menu + // + struct + { + const char * m_csName; + const EShowSpeed m_eShowSpeed; + } + astShowSpeed[] = + { + { "ShowSpeedNone", ShowSpeedNone }, + { "ShowSpeedPercentage", ShowSpeedPercentage }, + { "ShowSpeedDetailed", ShowSpeedDetailed } + }; + EShowSpeed eDefaultShowSpeed = (EShowSpeed)m_poDisplayConfig->oGetKey<int>("show_speed"); + for (guint i = 0; i < sizeof(astShowSpeed) / sizeof(astShowSpeed[0]); i++) + { + poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astShowSpeed[i].m_csName)); + if (astShowSpeed[i].m_eShowSpeed == eDefaultShowSpeed) + { + poCMI->set_active(); + vOnShowSpeedToggled(poCMI, eDefaultShowSpeed); + } + poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>( + SigC::slot(*this, &Window::vOnShowSpeedToggled), + poCMI, astShowSpeed[i].m_eShowSpeed)); + } + + // Save type menu + // + struct + { + const char * m_csName; + const ESaveType m_eSaveType; + } + astSaveType[] = + { + { "SaveTypeAutomatic", SaveTypeAuto }, + { "SaveTypeEeprom", SaveTypeEEPROM }, + { "SaveTypeSram", SaveTypeSRAM }, + { "SaveTypeFlash", SaveTypeFlash }, + { "SaveTypeEepromSensor", SaveTypeEEPROMSensor }, + { "SaveTypeNone", SaveTypeNone } + }; + ESaveType eDefaultSaveType = (ESaveType)m_poCoreConfig->oGetKey<int>("save_type"); + for (guint i = 0; i < sizeof(astSaveType) / sizeof(astSaveType[0]); i++) + { + poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astSaveType[i].m_csName)); + if (astSaveType[i].m_eSaveType == eDefaultSaveType) + { + poCMI->set_active(); + vOnSaveTypeToggled(poCMI, eDefaultSaveType); + } + poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>( + SigC::slot(*this, &Window::vOnSaveTypeToggled), + poCMI, astSaveType[i].m_eSaveType)); + } + + // Flash size menu + // + struct + { + const char * m_csName; + const int m_iFlashSize; + } + astFlashSize[] = + { + { "SaveTypeFlash64K", 64 }, + { "SaveTypeFlash128K", 128 } + }; + int iDefaultFlashSize = m_poCoreConfig->oGetKey<int>("flash_size"); + for (guint i = 0; i < sizeof(astFlashSize) / sizeof(astFlashSize[0]); i++) + { + poCMI = dynamic_cast<Gtk::CheckMenuItem *>(_poXml->get_widget(astFlashSize[i].m_csName)); + if (astFlashSize[i].m_iFlashSize == iDefaultFlashSize) + { + poCMI->set_active(); + vOnFlashSizeToggled(poCMI, iDefaultFlashSize); + } + poCMI->signal_toggled().connect(SigC::bind<Gtk::CheckMenuItem *, int>( + SigC::slot(*this, &Window::vOnFlashSizeToggled), + poCMI, astFlashSize[i].m_iFlashSize)); + } + // Filter menu // *************** *** 394,397 **** --- 480,486 ---- systemSoundOn = false; + systemRenderedFrames = 0; + systemFPS = 0; + emulating = 0; debugger = true; *************** *** 441,463 **** // m_poCoreConfig = m_oConfig.poAddSection("Core"); ! m_poCoreConfig->vSetKey("frameskip", "auto" ); ! m_poCoreConfig->vSetKey("throttle", 0 ); ! m_poCoreConfig->vSetKey("layer_bg0", true ); ! m_poCoreConfig->vSetKey("layer_bg1", true ); ! m_poCoreConfig->vSetKey("layer_bg2", true ); ! m_poCoreConfig->vSetKey("layer_bg3", true ); ! m_poCoreConfig->vSetKey("layer_obj", true ); ! m_poCoreConfig->vSetKey("layer_win0", true ); ! m_poCoreConfig->vSetKey("layer_win1", true ); ! m_poCoreConfig->vSetKey("layer_objwin", true ); // Display section // m_poDisplayConfig = m_oConfig.poAddSection("Display"); ! m_poDisplayConfig->vSetKey ("scale", 1 ); ! m_poDisplayConfig->vSetKey<int>("filter2x", FilterNone ); ! m_poDisplayConfig->vSetKey<int>("filterIB", FilterIBNone ); #ifdef MMX ! m_poDisplayConfig->vSetKey ("filter_disable_mmx", false ); #endif // MMX } --- 530,555 ---- // m_poCoreConfig = m_oConfig.poAddSection("Core"); ! m_poCoreConfig->vSetKey ("frameskip", "auto" ); ! m_poCoreConfig->vSetKey ("throttle", 0 ); ! m_poCoreConfig->vSetKey ("layer_bg0", true ); ! m_poCoreConfig->vSetKey ("layer_bg1", true ); ! m_poCoreConfig->vSetKey ("layer_bg2", true ); ! m_poCoreConfig->vSetKey ("layer_bg3", true ); ! m_poCoreConfig->vSetKey ("layer_obj", true ); ! m_poCoreConfig->vSetKey ("layer_win0", true ); ! m_poCoreConfig->vSetKey ("layer_win1", true ); ! m_poCoreConfig->vSetKey ("layer_objwin", true ); ! m_poCoreConfig->vSetKey<int>("save_type", SaveTypeAuto ); ! m_poCoreConfig->vSetKey<int>("flash_size", 64 ); // Display section // m_poDisplayConfig = m_oConfig.poAddSection("Display"); ! m_poDisplayConfig->vSetKey ("scale", 1 ); ! m_poDisplayConfig->vSetKey<int>("show_speed", ShowSpeedPercentage ); ! m_poDisplayConfig->vSetKey<int>("filter2x", FilterNone ); ! m_poDisplayConfig->vSetKey<int>("filterIB", FilterIBNone ); #ifdef MMX ! m_poDisplayConfig->vSetKey ("filter_disable_mmx", false ); #endif // MMX } *************** *** 468,475 **** int iAdjusted; if (m_poCoreConfig->sGetKey("frameskip") != "auto") { iValue = m_poCoreConfig->oGetKey<int>("frameskip"); ! iAdjusted = CLAMP(iValue, iFrameskipMin, iFrameskipMax); if (iValue != iAdjusted) { --- 560,569 ---- int iAdjusted; + // Core section + // if (m_poCoreConfig->sGetKey("frameskip") != "auto") { iValue = m_poCoreConfig->oGetKey<int>("frameskip"); ! iAdjusted = CLAMP(iValue, m_iFrameskipMin, m_iFrameskipMax); if (iValue != iAdjusted) { *************** *** 481,485 **** if (iValue != 0) { ! iAdjusted = CLAMP(iValue, iThrottleMin, iThrottleMax); if (iValue != iAdjusted) { --- 575,579 ---- if (iValue != 0) { ! iAdjusted = CLAMP(iValue, m_iThrottleMin, m_iThrottleMax); if (iValue != iAdjusted) { *************** *** 488,493 **** } iValue = m_poDisplayConfig->oGetKey<int>("scale"); ! iAdjusted = CLAMP(iValue, iScaleMin, iScaleMax); if (iValue != iAdjusted) { --- 582,605 ---- } + iValue = m_poCoreConfig->oGetKey<int>("save_type"); + if (iValue != 0) + { + iAdjusted = CLAMP(iValue, m_iSaveTypeMin, m_iSaveTypeMax); + if (iValue != iAdjusted) + { + m_poCoreConfig->vSetKey("save_type", iAdjusted); + } + } + + iValue = m_poCoreConfig->oGetKey<int>("flash_size"); + if (iValue != 64 && iValue != 128) + { + m_poCoreConfig->vSetKey("flash_size", 64); + } + + // Display section + // iValue = m_poDisplayConfig->oGetKey<int>("scale"); ! iAdjusted = CLAMP(iValue, m_iScaleMin, m_iScaleMax); if (iValue != iAdjusted) { *************** *** 495,500 **** } iValue = m_poDisplayConfig->oGetKey<int>("filter2x"); ! iAdjusted = CLAMP(iValue, iFilter2xMin, iFilter2xMax); if (iValue != iAdjusted) { --- 607,619 ---- } + iValue = m_poDisplayConfig->oGetKey<int>("show_speed"); + iAdjusted = CLAMP(iValue, m_iShowSpeedMin, m_iShowSpeedMax); + if (iValue != iAdjusted) + { + m_poDisplayConfig->vSetKey("show_speed", iAdjusted); + } + iValue = m_poDisplayConfig->oGetKey<int>("filter2x"); ! iAdjusted = CLAMP(iValue, m_iFilter2xMin, m_iFilter2xMax); if (iValue != iAdjusted) { *************** *** 503,507 **** iValue = m_poDisplayConfig->oGetKey<int>("filterIB"); ! iAdjusted = CLAMP(iValue, iFilterIBMin, iFilterIBMax); if (iValue != iAdjusted) { --- 622,626 ---- iValue = m_poDisplayConfig->oGetKey<int>("filterIB"); ! iAdjusted = CLAMP(iValue, m_iFilterIBMin, m_iFilterIBMax); if (iValue != iAdjusted) { *************** *** 593,596 **** --- 712,737 ---- } + void Window::vSetDefaultTitle() + { + set_title("VBA"); + } + + void Window::vShowSpeed(int _iSpeed) + { + char csTitle[50]; + + if (m_eShowSpeed == ShowSpeedPercentage) + { + snprintf(csTitle, 50, "VBA - %d%%", _iSpeed); + set_title(csTitle); + } + else if (m_eShowSpeed == ShowSpeedDetailed) + { + snprintf(csTitle, 50, "VBA - %3d%% (%d, %d fps)", + _iSpeed, systemFrameSkip, systemFPS); + set_title(csTitle); + } + } + void Window::vComputeFrameskip(int _iRate) { *************** *** 692,696 **** if (bLoaded) { ! m_eCartridge = GB_CARTRIDGE; m_stEmulator = GBSystem; --- 833,837 ---- if (bLoaded) { ! m_eCartridge = CartridgeGB; m_stEmulator = GBSystem; *************** *** 707,721 **** if (gbBorderOn) { ! m_iScreenWidth = iSGBScreenWidth; ! m_iScreenHeight = iSGBScreenHeight; ! gbBorderLineSkip = iSGBScreenWidth; ! gbBorderColumnSkip = (iSGBScreenWidth - iGBScreenWidth) / 2; ! gbBorderRowSkip = (iSGBScreenHeight - iGBScreenHeight) / 2; } else { ! m_iScreenWidth = iGBScreenWidth; ! m_iScreenHeight = iGBScreenHeight; ! gbBorderLineSkip = iGBScreenWidth; gbBorderColumnSkip = 0; gbBorderRowSkip = 0; --- 848,862 ---- if (gbBorderOn) { ! m_iScreenWidth = m_iSGBScreenWidth; ! m_iScreenHeight = m_iSGBScreenHeight; ! gbBorderLineSkip = m_iSGBScreenWidth; ! gbBorderColumnSkip = (m_iSGBScreenWidth - m_iGBScreenWidth) / 2; ! gbBorderRowSkip = (m_iSGBScreenHeight - m_iGBScreenHeight) / 2; } else { ! m_iScreenWidth = m_iGBScreenWidth; ! m_iScreenHeight = m_iGBScreenHeight; ! gbBorderLineSkip = m_iGBScreenWidth; gbBorderColumnSkip = 0; gbBorderRowSkip = 0; *************** *** 731,735 **** //sdlApplyPerImagePreferences(); ! m_eCartridge = GBA_CARTRIDGE; m_stEmulator = GBASystem; --- 872,876 ---- //sdlApplyPerImagePreferences(); ! m_eCartridge = CartridgeGBA; m_stEmulator = GBASystem; *************** *** 748,753 **** //} ! m_iScreenWidth = iGBAScreenWidth; ! m_iScreenHeight = iGBAScreenHeight; } } --- 889,894 ---- //} ! m_iScreenWidth = m_iGBAScreenWidth; ! m_iScreenHeight = m_iGBAScreenHeight; } } *************** *** 864,868 **** if (m_poFileOpenDialog == NULL) { ! m_poFileOpenDialog = new Gtk::FileSelection(_("Open a ROM")); m_poFileOpenDialog->set_transient_for(*this); } --- 1005,1009 ---- if (m_poFileOpenDialog == NULL) { ! m_poFileOpenDialog = new Gtk::FileSelection(_("Open")); m_poFileOpenDialog->set_transient_for(*this); } *************** *** 909,913 **** vSaveBattery(); m_stEmulator.emuCleanUp(); ! m_eCartridge = NO_CARTRIDGE; emulating = 0; } --- 1050,1054 ---- vSaveBattery(); m_stEmulator.emuCleanUp(); ! m_eCartridge = CartridgeNone; emulating = 0; } *************** *** 1028,1031 **** --- 1169,1216 ---- } + void Window::vOnShowSpeedToggled(Gtk::CheckMenuItem * _poCMI, int _iShowSpeed) + { + if (! _poCMI->get_active()) + { + return; + } + + m_eShowSpeed = (EShowSpeed)_iShowSpeed; + if (m_eShowSpeed == ShowSpeedNone) + { + vSetDefaultTitle(); + } + m_poDisplayConfig->vSetKey("show_speed", _iShowSpeed); + } + + void Window::vOnSaveTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iSaveType) + { + if (! _poCMI->get_active()) + { + return; + } + + cpuSaveType = _iSaveType; + m_poCoreConfig->vSetKey("save_type", _iSaveType); + } + + void Window::vOnFlashSizeToggled(Gtk::CheckMenuItem * _poCMI, int _iFlashSize) + { + if (! _poCMI->get_active()) + { + return; + } + + if (_iFlashSize == 64) + { + flashSetSize(0x10000); + } + else + { + flashSetSize(0x20000); + } + m_poCoreConfig->vSetKey("flash_size", _iFlashSize); + } + void Window::vOnFilter2xToggled(Gtk::CheckMenuItem * _poCMI, int _iFilter2x) { |