From 72ccee1bb22111e1d070f7bf325f094b8264ac4f Mon Sep 17 00:00:00 2001 From: bgk Date: Fri, 23 Jan 2009 13:41:24 +0000 Subject: [PATCH] GTK : Added GB bootrom file support git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@851 a31d4220-a93d-0410-bf67-fe4944624d44 --- src/gb/gb.h | 2 + src/gb/gbMemory.cpp | 1 - src/gb/gbSound.cpp | 2 +- src/gtk/gameboyconfig.cpp | 24 ++++++ src/gtk/gameboyconfig.h | 8 +- src/gtk/ui/gameboy.ui | 157 +++++++++++++++++++++++++++++--------- src/gtk/window.cpp | 29 ++++++- src/sdl/SDL.cpp | 2 - src/win32/MainWnd.cpp | 1 - 9 files changed, 179 insertions(+), 47 deletions(-) diff --git a/src/gb/gb.h b/src/gb/gb.h index c031099e..669c0c95 100644 --- a/src/gb/gb.h +++ b/src/gb/gb.h @@ -38,6 +38,8 @@ bool gbWritePNGFile(const char *); bool gbWriteBMPFile(const char *); bool gbReadGSASnapshot(const char *); +extern int gbHardware; + extern struct EmulatedSystem GBSystem; #endif // GB_H diff --git a/src/gb/gbMemory.cpp b/src/gb/gbMemory.cpp index 22d62785..53a7f69e 100644 --- a/src/gb/gbMemory.cpp +++ b/src/gb/gbMemory.cpp @@ -5,7 +5,6 @@ #include "gb.h" u8 gbDaysinMonth [12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const u8 gbDisabledRam [8] = {0x80, 0xff, 0xf0, 0x00, 0x30, 0xbf, 0xbf, 0xbf}; -extern int gbHardware; extern int gbGBCColorType; extern gbRegister PC; diff --git a/src/gb/gbSound.cpp b/src/gb/gbSound.cpp index bd8d5170..3f57496b 100644 --- a/src/gb/gbSound.cpp +++ b/src/gb/gbSound.cpp @@ -4,11 +4,11 @@ #include "../Util.h" #include "gbGlobals.h" #include "gbSound.h" +#include "gb.h" #include "../apu/Gb_Apu.h" #include "../apu/Effects_Buffer.h" -extern int gbHardware; extern long soundSampleRate; // current sound quality gb_effects_config_t gb_effects_config = { false, 0.20f, 0.15f, false }; diff --git a/src/gtk/gameboyconfig.cpp b/src/gtk/gameboyconfig.cpp index a864a377..ba4306de 100644 --- a/src/gtk/gameboyconfig.cpp +++ b/src/gtk/gameboyconfig.cpp @@ -34,10 +34,14 @@ GameBoyConfigDialog::GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefP refBuilder->get_widget("SystemComboBox", m_poSystemComboBox); refBuilder->get_widget("BorderCheckButton", m_poBorderCheckButton); refBuilder->get_widget("PrinterCheckButton", m_poPrinterCheckButton); + refBuilder->get_widget("BootRomCheckButton", m_poBootRomCheckButton); + refBuilder->get_widget("BootRomFileChooserButton", m_poBootRomFileChooserButton); m_poSystemComboBox->signal_changed().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnSystemChanged)); m_poBorderCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnBorderChanged)); m_poPrinterCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnPrinterChanged)); + m_poBootRomCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnUseBootRomChanged)); + m_poBootRomFileChooserButton->signal_selection_changed().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnBootRomSelectionChanged)); } void GameBoyConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Window * _poWindow) @@ -55,6 +59,13 @@ void GameBoyConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Window * bool bPrinter = m_poConfig->oGetKey("gb_printer"); m_poPrinterCheckButton->set_active(bPrinter); + + bool bUseBootRom = m_poConfig->oGetKey("gb_use_bios_file"); + m_poBootRomCheckButton->set_active(bUseBootRom); + m_poBootRomFileChooserButton->set_sensitive(bUseBootRom); + + std::string sBootRom = m_poConfig->oGetKey("gb_bios_file"); + m_poBootRomFileChooserButton->set_filename(sBootRom); } void GameBoyConfigDialog::vOnSystemChanged() @@ -89,4 +100,17 @@ void GameBoyConfigDialog::vOnPrinterChanged() m_poWindow->vApplyConfigGBPrinter(); } +void GameBoyConfigDialog::vOnUseBootRomChanged() +{ + bool bUseBootRom = m_poBootRomCheckButton->get_active(); + m_poConfig->vSetKey("gb_use_bios_file", bUseBootRom); + m_poBootRomFileChooserButton->set_sensitive(bUseBootRom); +} + +void GameBoyConfigDialog::vOnBootRomSelectionChanged() +{ + std::string sBootRom = m_poBootRomFileChooserButton->get_filename(); + m_poConfig->vSetKey("gb_bios_file", sBootRom); +} + } // namespace VBA diff --git a/src/gtk/gameboyconfig.h b/src/gtk/gameboyconfig.h index ddbc8be3..5253e0c8 100644 --- a/src/gtk/gameboyconfig.h +++ b/src/gtk/gameboyconfig.h @@ -19,9 +19,7 @@ #ifndef __VBA_GAMEBOYCONFIG_H__ #define __VBA_GAMEBOYCONFIG_H__ -#include -#include -#include +#include #include "configfile.h" #include "window.h" @@ -40,6 +38,8 @@ private: void vOnSystemChanged(); void vOnBorderChanged(); void vOnPrinterChanged(); + void vOnUseBootRomChanged(); + void vOnBootRomSelectionChanged(); VBA::Window * m_poWindow; @@ -47,6 +47,8 @@ private: Gtk::ComboBox * m_poSystemComboBox; Gtk::CheckButton * m_poBorderCheckButton; Gtk::CheckButton * m_poPrinterCheckButton; + Gtk::CheckButton * m_poBootRomCheckButton; + Gtk::FileChooserButton * m_poBootRomFileChooserButton; }; } // namespace VBA diff --git a/src/gtk/ui/gameboy.ui b/src/gtk/ui/gameboy.ui index f5b648e6..d3005037 100644 --- a/src/gtk/ui/gameboy.ui +++ b/src/gtk/ui/gameboy.ui @@ -1,5 +1,5 @@ - + @@ -28,7 +28,7 @@ 5 - Game Boy games settings + GameBoy settings GTK_WIN_POS_CENTER_ON_PARENT GDK_WINDOW_TYPE_HINT_DIALOG False @@ -36,61 +36,142 @@ True - + True + 0 + GTK_SHADOW_NONE - + True + 12 - + True - Emulated system : - - - - - True - model1 - - - 0 - + + True + + + True + Emulated system : + + + + + True + model1 + + + + 0 + + + + + 1 + + + + + + + True + True + Display Super Game Boy borders + True + + + 1 + + + + + True + True + Emulate a Game Boy Printer + True + + + 2 + - - 1 - - - + + True - True - Display Super Game Boy borders - True + <b>System and peripherals</b> + True - - 1 - - - - - True - True - Emulate a Game Boy Printer - True - - - 2 - 1 + + + True + 0 + GTK_SHADOW_NONE + + + True + 12 + + + True + + + True + True + Use a Game Boy boot ROM file + True + + + + + True + + + True + Boot ROM file : + + + False + + + + + True + + + 1 + + + + + 1 + + + + + + + + + True + <b>Boot ROM</b> + True + + + + + 2 + + True diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 91360ae5..2fbe581d 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -633,8 +633,10 @@ void Window::vInitConfig() m_poCoreConfig->vSetKey("bios_file", "" ); m_poCoreConfig->vSetKey("save_type", SaveAuto ); m_poCoreConfig->vSetKey("flash_size", 64 ); - m_poCoreConfig->vSetKey("gb_border", true ); + m_poCoreConfig->vSetKey("gb_border", false ); m_poCoreConfig->vSetKey("gb_printer", false ); + m_poCoreConfig->vSetKey("gb_use_bios_file", false ); + m_poCoreConfig->vSetKey("gb_bios_file", "" ); m_poCoreConfig->vSetKey("emulator_type", EmulatorAuto ); // Display section @@ -735,6 +737,16 @@ void Window::vCheckConfig() m_poCoreConfig->vSetKey("use_bios_file", false); } + sValue = m_poCoreConfig->sGetKey("gb_bios_file"); + if (sValue != "" && ! Glib::file_test(sValue, Glib::FILE_TEST_IS_REGULAR)) + { + m_poCoreConfig->vSetKey("gb_bios_file", ""); + } + if (m_poCoreConfig->sGetKey("gb_bios_file") == "") + { + m_poCoreConfig->vSetKey("gb_use_bios_file", false); + } + iValue = m_poCoreConfig->oGetKey("save_type"); if (iValue != 0) { @@ -1031,6 +1043,21 @@ bool Window::bLoadROM(const std::string & _rsFile) { m_eCartridge = CartridgeGB; m_stEmulator = GBSystem; + + useBios = m_poCoreConfig->oGetKey("gb_use_bios_file"); + gbGetHardwareType(); + + if (gbHardware & 5) + { + gbCPUInit(m_poCoreConfig->sGetKey("gb_bios_file").c_str(), useBios); + } + + // If the bios file was rejected by gbCPUInit + if (m_poCoreConfig->oGetKey("gb_use_bios_file") && ! useBios) + { + m_poCoreConfig->vSetKey("gb_bios_file", ""); + } + gbReset(); } } diff --git a/src/sdl/SDL.cpp b/src/sdl/SDL.cpp index d4695d4b..47767ff6 100644 --- a/src/sdl/SDL.cpp +++ b/src/sdl/SDL.cpp @@ -86,8 +86,6 @@ extern void remoteOutput(const char *, u32); extern void remoteSetProtocol(int); extern void remoteSetPort(int); -extern int gbHardware; - struct EmulatedSystem emulator = { NULL, NULL, diff --git a/src/win32/MainWnd.cpp b/src/win32/MainWnd.cpp index db3f253e..b7c38593 100644 --- a/src/win32/MainWnd.cpp +++ b/src/win32/MainWnd.cpp @@ -33,7 +33,6 @@ static char THIS_FILE[] = __FILE__; #endif extern void remoteCleanUp(); -extern int gbHardware; ///////////////////////////////////////////////////////////////////////////// // MainWnd