GTK : Added GB bootrom file support

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@851 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
bgk 2009-01-23 13:41:24 +00:00
parent 2b5b2a0e01
commit 72ccee1bb2
9 changed files with 179 additions and 47 deletions

View File

@ -38,6 +38,8 @@ bool gbWritePNGFile(const char *);
bool gbWriteBMPFile(const char *); bool gbWriteBMPFile(const char *);
bool gbReadGSASnapshot(const char *); bool gbReadGSASnapshot(const char *);
extern int gbHardware;
extern struct EmulatedSystem GBSystem; extern struct EmulatedSystem GBSystem;
#endif // GB_H #endif // GB_H

View File

@ -5,7 +5,6 @@
#include "gb.h" #include "gb.h"
u8 gbDaysinMonth [12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 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}; const u8 gbDisabledRam [8] = {0x80, 0xff, 0xf0, 0x00, 0x30, 0xbf, 0xbf, 0xbf};
extern int gbHardware;
extern int gbGBCColorType; extern int gbGBCColorType;
extern gbRegister PC; extern gbRegister PC;

View File

@ -4,11 +4,11 @@
#include "../Util.h" #include "../Util.h"
#include "gbGlobals.h" #include "gbGlobals.h"
#include "gbSound.h" #include "gbSound.h"
#include "gb.h"
#include "../apu/Gb_Apu.h" #include "../apu/Gb_Apu.h"
#include "../apu/Effects_Buffer.h" #include "../apu/Effects_Buffer.h"
extern int gbHardware;
extern long soundSampleRate; // current sound quality extern long soundSampleRate; // current sound quality
gb_effects_config_t gb_effects_config = { false, 0.20f, 0.15f, false }; gb_effects_config_t gb_effects_config = { false, 0.20f, 0.15f, false };

View File

@ -34,10 +34,14 @@ GameBoyConfigDialog::GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefP
refBuilder->get_widget("SystemComboBox", m_poSystemComboBox); refBuilder->get_widget("SystemComboBox", m_poSystemComboBox);
refBuilder->get_widget("BorderCheckButton", m_poBorderCheckButton); refBuilder->get_widget("BorderCheckButton", m_poBorderCheckButton);
refBuilder->get_widget("PrinterCheckButton", m_poPrinterCheckButton); 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_poSystemComboBox->signal_changed().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnSystemChanged));
m_poBorderCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnBorderChanged)); m_poBorderCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnBorderChanged));
m_poPrinterCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &GameBoyConfigDialog::vOnPrinterChanged)); 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) 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<bool>("gb_printer"); bool bPrinter = m_poConfig->oGetKey<bool>("gb_printer");
m_poPrinterCheckButton->set_active(bPrinter); m_poPrinterCheckButton->set_active(bPrinter);
bool bUseBootRom = m_poConfig->oGetKey<bool>("gb_use_bios_file");
m_poBootRomCheckButton->set_active(bUseBootRom);
m_poBootRomFileChooserButton->set_sensitive(bUseBootRom);
std::string sBootRom = m_poConfig->oGetKey<std::string>("gb_bios_file");
m_poBootRomFileChooserButton->set_filename(sBootRom);
} }
void GameBoyConfigDialog::vOnSystemChanged() void GameBoyConfigDialog::vOnSystemChanged()
@ -89,4 +100,17 @@ void GameBoyConfigDialog::vOnPrinterChanged()
m_poWindow->vApplyConfigGBPrinter(); 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 } // namespace VBA

View File

@ -19,9 +19,7 @@
#ifndef __VBA_GAMEBOYCONFIG_H__ #ifndef __VBA_GAMEBOYCONFIG_H__
#define __VBA_GAMEBOYCONFIG_H__ #define __VBA_GAMEBOYCONFIG_H__
#include <gtkmm/dialog.h> #include <gtkmm.h>
#include <gtkmm/builder.h>
#include <gtkmm/combobox.h>
#include "configfile.h" #include "configfile.h"
#include "window.h" #include "window.h"
@ -40,6 +38,8 @@ private:
void vOnSystemChanged(); void vOnSystemChanged();
void vOnBorderChanged(); void vOnBorderChanged();
void vOnPrinterChanged(); void vOnPrinterChanged();
void vOnUseBootRomChanged();
void vOnBootRomSelectionChanged();
VBA::Window * m_poWindow; VBA::Window * m_poWindow;
@ -47,6 +47,8 @@ private:
Gtk::ComboBox * m_poSystemComboBox; Gtk::ComboBox * m_poSystemComboBox;
Gtk::CheckButton * m_poBorderCheckButton; Gtk::CheckButton * m_poBorderCheckButton;
Gtk::CheckButton * m_poPrinterCheckButton; Gtk::CheckButton * m_poPrinterCheckButton;
Gtk::CheckButton * m_poBootRomCheckButton;
Gtk::FileChooserButton * m_poBootRomFileChooserButton;
}; };
} // namespace VBA } // namespace VBA

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!--Generated with glade3 3.4.5 on Tue Jan 6 21:21:29 2009 --> <!--Generated with glade3 3.4.5 on Fri Jan 23 14:39:58 2009 -->
<interface> <interface>
<object class="GtkListStore" id="model1"> <object class="GtkListStore" id="model1">
<columns> <columns>
@ -28,7 +28,7 @@
</object> </object>
<object class="GtkDialog" id="GameBoyConfigDialog"> <object class="GtkDialog" id="GameBoyConfigDialog">
<property name="border_width">5</property> <property name="border_width">5</property>
<property name="title" translatable="yes">Game Boy games settings</property> <property name="title" translatable="yes">GameBoy settings</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property> <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="has_separator">False</property> <property name="has_separator">False</property>
@ -36,61 +36,142 @@
<object class="GtkVBox" id="dialog-vbox1"> <object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
<object class="GtkVBox" id="vbox1"> <object class="GtkFrame" id="frame1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child> <child>
<object class="GtkHBox" id="hbox1"> <object class="GtkAlignment" id="alignment1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="left_padding">12</property>
<child> <child>
<object class="GtkLabel" id="label1"> <object class="GtkVBox" id="vbox1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">Emulated system : </property>
</object>
</child>
<child>
<object class="GtkComboBox" id="SystemComboBox">
<property name="visible">True</property>
<property name="model">model1</property>
<child> <child>
<object class="GtkCellRendererText" id="renderer1"/> <object class="GtkHBox" id="hbox1">
<attributes> <property name="visible">True</property>
<attribute name="text">0</attribute> <child>
</attributes> <object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">Emulated system : </property>
</object>
</child>
<child>
<object class="GtkComboBox" id="SystemComboBox">
<property name="visible">True</property>
<property name="model">model1</property>
<child>
<object class="GtkCellRendererText" id="renderer1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkCheckButton" id="BorderCheckButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Display Super Game Boy borders</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="PrinterCheckButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Emulate a Game Boy Printer</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="position">2</property>
</packing>
</child> </child>
</object> </object>
<packing>
<property name="position">1</property>
</packing>
</child> </child>
</object> </object>
</child> </child>
<child> <child type="label">
<object class="GtkCheckButton" id="BorderCheckButton"> <object class="GtkLabel" id="label2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="label" translatable="yes">&lt;b&gt;System and peripherals&lt;/b&gt;</property>
<property name="label" translatable="yes">Display Super Game Boy borders</property> <property name="use_markup">True</property>
<property name="draw_indicator">True</property>
</object> </object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="PrinterCheckButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Emulate a Game Boy Printer</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="position">2</property>
</packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<child>
<object class="GtkCheckButton" id="BootRomCheckButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Use a Game Boy boot ROM file</property>
<property name="draw_indicator">True</property>
</object>
</child>
<child>
<object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="label" translatable="yes">Boot ROM file : </property>
</object>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<object class="GtkFileChooserButton" id="BootRomFileChooserButton">
<property name="visible">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Boot ROM&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child internal-child="action_area"> <child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area1"> <object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property> <property name="visible">True</property>

View File

@ -633,8 +633,10 @@ void Window::vInitConfig()
m_poCoreConfig->vSetKey("bios_file", "" ); m_poCoreConfig->vSetKey("bios_file", "" );
m_poCoreConfig->vSetKey("save_type", SaveAuto ); m_poCoreConfig->vSetKey("save_type", SaveAuto );
m_poCoreConfig->vSetKey("flash_size", 64 ); 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_printer", false );
m_poCoreConfig->vSetKey("gb_use_bios_file", false );
m_poCoreConfig->vSetKey("gb_bios_file", "" );
m_poCoreConfig->vSetKey("emulator_type", EmulatorAuto ); m_poCoreConfig->vSetKey("emulator_type", EmulatorAuto );
// Display section // Display section
@ -735,6 +737,16 @@ void Window::vCheckConfig()
m_poCoreConfig->vSetKey("use_bios_file", false); 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<int>("save_type"); iValue = m_poCoreConfig->oGetKey<int>("save_type");
if (iValue != 0) if (iValue != 0)
{ {
@ -1031,6 +1043,21 @@ bool Window::bLoadROM(const std::string & _rsFile)
{ {
m_eCartridge = CartridgeGB; m_eCartridge = CartridgeGB;
m_stEmulator = GBSystem; m_stEmulator = GBSystem;
useBios = m_poCoreConfig->oGetKey<bool>("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<bool>("gb_use_bios_file") && ! useBios)
{
m_poCoreConfig->vSetKey("gb_bios_file", "");
}
gbReset(); gbReset();
} }
} }

View File

@ -86,8 +86,6 @@ extern void remoteOutput(const char *, u32);
extern void remoteSetProtocol(int); extern void remoteSetProtocol(int);
extern void remoteSetPort(int); extern void remoteSetPort(int);
extern int gbHardware;
struct EmulatedSystem emulator = { struct EmulatedSystem emulator = {
NULL, NULL,
NULL, NULL,

View File

@ -33,7 +33,6 @@ static char THIS_FILE[] = __FILE__;
#endif #endif
extern void remoteCleanUp(); extern void remoteCleanUp();
extern int gbHardware;
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// MainWnd // MainWnd