From 8e1ba79e0a2b691e17489ccc844eb37155d421f2 Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Sun, 19 Nov 2017 10:17:23 -0500 Subject: [PATCH] GBHawk: Add core picker --- BizHawk.Client.Common/RomLoader.cs | 26 +++++++++- BizHawk.Client.Common/config/Config.cs | 1 + BizHawk.Client.EmuHawk/MainForm.Designer.cs | 53 ++++++++++++++++----- BizHawk.Client.EmuHawk/MainForm.Events.cs | 16 +++++++ 4 files changed, 84 insertions(+), 12 deletions(-) diff --git a/BizHawk.Client.Common/RomLoader.cs b/BizHawk.Client.Common/RomLoader.cs index 6a9c8b68d7..99e355081e 100644 --- a/BizHawk.Client.Common/RomLoader.cs +++ b/BizHawk.Client.Common/RomLoader.cs @@ -936,7 +936,31 @@ namespace BizHawk.Client.Common break; case "GB": - core = CoreInventory.Instance["GB", "GBHawk"]; + if (!Global.Config.GB_AsSGB) + { + if (Global.Config.GB_UseGBHawk) + { + core = CoreInventory.Instance["GB", "GBHawk"]; + } + else + { + core = CoreInventory.Instance["GB", "Gambatte"]; + } + } + else + { + if (Global.Config.SGB_UseBsnes) + { + game.System = "SNES"; + game.AddOption("SGB"); + var snes = new LibsnesCore(game, rom.FileData, null, nextComm, GetCoreSettings(), GetCoreSyncSettings()); + nextEmulator = snes; + } + else + { + core = CoreInventory.Instance["SGB", "SameBoy"]; + } + } break; case "GBC": if (!Global.Config.GB_AsSGB) diff --git a/BizHawk.Client.Common/config/Config.cs b/BizHawk.Client.Common/config/Config.cs index bcdeb39420..4dea2406f2 100644 --- a/BizHawk.Client.Common/config/Config.cs +++ b/BizHawk.Client.Common/config/Config.cs @@ -557,6 +557,7 @@ namespace BizHawk.Client.Common public bool SNES_InSnes9x = true; public bool GBA_UsemGBA = true; public bool SGB_UseBsnes = false; + public bool GB_UseGBHawk = false; public bool CoreForcingViaGameDB = true; public string LibretroCore; } diff --git a/BizHawk.Client.EmuHawk/MainForm.Designer.cs b/BizHawk.Client.EmuHawk/MainForm.Designer.cs index 9d6774638e..0e250d1e01 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Designer.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Designer.cs @@ -194,9 +194,12 @@ this.MgbaCoreMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.Atari7800HawkCoreMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.SGBCoreSubmenu = new System.Windows.Forms.ToolStripMenuItem(); - this.SgbBsnesMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.SgbBsnesMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.SgbSameBoyMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.GBInSGBMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.GBCoreSubmenu = new System.Windows.Forms.ToolStripMenuItem(); + this.GBGambatteMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.GBGBHawkMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.GBInSGBMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem16 = new System.Windows.Forms.ToolStripSeparator(); this.allowGameDBCoreOverridesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator(); @@ -1810,7 +1813,8 @@ this.CoreSNESSubMenu, this.GbaCoreSubMenu, this.SGBCoreSubmenu, - this.GBInSGBMenuItem, + this.GBCoreSubmenu, + this.GBInSGBMenuItem, this.toolStripMenuItem16, this.allowGameDBCoreOverridesToolStripMenuItem, this.toolStripSeparator8, @@ -1908,10 +1912,20 @@ this.SGBCoreSubmenu.Size = new System.Drawing.Size(239, 22); this.SGBCoreSubmenu.Text = "SGB"; this.SGBCoreSubmenu.DropDownOpened += new System.EventHandler(this.SGBCoreSubmenu_DropDownOpened); - // - // SgbBsnesMenuItem - // - this.SgbBsnesMenuItem.Name = "SgbBsnesMenuItem"; + // + // GBCoreSubmenu + // + this.GBCoreSubmenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.GBGambatteMenuItem, + this.GBGBHawkMenuItem}); + this.GBCoreSubmenu.Name = "GBCoreSubmenu"; + this.GBCoreSubmenu.Size = new System.Drawing.Size(239, 22); + this.GBCoreSubmenu.Text = "GB"; + this.GBCoreSubmenu.DropDownOpened += new System.EventHandler(this.GBCoreSubmenu_DropDownOpened); + // + // SgbBsnesMenuItem + // + this.SgbBsnesMenuItem.Name = "SgbBsnesMenuItem"; this.SgbBsnesMenuItem.Size = new System.Drawing.Size(152, 22); this.SgbBsnesMenuItem.Text = "BSNES"; this.SgbBsnesMenuItem.Click += new System.EventHandler(this.SgbCorePick_Click); @@ -1922,10 +1936,24 @@ this.SgbSameBoyMenuItem.Size = new System.Drawing.Size(152, 22); this.SgbSameBoyMenuItem.Text = "SameBoy"; this.SgbSameBoyMenuItem.Click += new System.EventHandler(this.SgbCorePick_Click); - // - // GBInSGBMenuItem - // - this.GBInSGBMenuItem.Name = "GBInSGBMenuItem"; + // + // GBGambatteMenuItem + // + this.GBGambatteMenuItem.Name = "GBGambatteMenuItem"; + this.GBGambatteMenuItem.Size = new System.Drawing.Size(152, 22); + this.GBGambatteMenuItem.Text = "Gambatte"; + this.GBGambatteMenuItem.Click += new System.EventHandler(this.GBCorePick_Click); + // + // GBGBHawkMenuItem + // + this.GBGBHawkMenuItem.Name = "GBGBHawkMenuItem"; + this.GBGBHawkMenuItem.Size = new System.Drawing.Size(152, 22); + this.GBGBHawkMenuItem.Text = "GBHawk"; + this.GBGBHawkMenuItem.Click += new System.EventHandler(this.GBCorePick_Click); + // + // GBInSGBMenuItem + // + this.GBInSGBMenuItem.Name = "GBInSGBMenuItem"; this.GBInSGBMenuItem.Size = new System.Drawing.Size(239, 22); this.GBInSGBMenuItem.Text = "GB in SGB"; this.GBInSGBMenuItem.Click += new System.EventHandler(this.GbInSgbMenuItem_Click); @@ -4407,6 +4435,9 @@ private System.Windows.Forms.ToolStripMenuItem SGBCoreSubmenu; private System.Windows.Forms.ToolStripMenuItem SgbBsnesMenuItem; private System.Windows.Forms.ToolStripMenuItem SgbSameBoyMenuItem; + private System.Windows.Forms.ToolStripMenuItem GBCoreSubmenu; + private System.Windows.Forms.ToolStripMenuItem GBGambatteMenuItem; + private System.Windows.Forms.ToolStripMenuItem GBGBHawkMenuItem; private System.Windows.Forms.ToolStripMenuItem pCFXToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem preferencesToolStripMenuItem3; private System.Windows.Forms.ToolStripMenuItem SMSControllerToolStripMenuItem; diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index fd1d42f241..026adb32be 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -1244,6 +1244,12 @@ namespace BizHawk.Client.EmuHawk SgbSameBoyMenuItem.Checked = !Global.Config.SGB_UseBsnes; } + private void GBCoreSubmenu_DropDownOpened(object sender, EventArgs e) + { + GBGambatteMenuItem.Checked = !Global.Config.GB_UseGBHawk; + GBGBHawkMenuItem.Checked = Global.Config.GB_UseGBHawk; + } + private void SgbCorePick_Click(object sender, EventArgs e) { Global.Config.SGB_UseBsnes ^= true; @@ -1254,6 +1260,16 @@ namespace BizHawk.Client.EmuHawk } } + private void GBCorePick_Click(object sender, EventArgs e) + { + Global.Config.GB_UseGBHawk ^= true; + // TODO: only flag if one of these cores + if (!Emulator.IsNull()) + { + FlagNeedsReboot(); + } + } + private void GbInSgbMenuItem_Click(object sender, EventArgs e) { Global.Config.GB_AsSGB ^= true;