From 25c2507013652f91b0fa3ef6a971246bffc79106 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 27 Sep 2014 12:56:55 +0000 Subject: [PATCH] N64 - change the expansion slot override notion. If a game in the gamdb has the expansion slot override, override the user's choice, but don't change the sync setting (otherwise all games they load will be set to this). In the N64 menu item, show the checked status based on if the core is actively using the expansion slot, not whether the sync setting is set. If the gamedb is overriding the user's choice make it clear by disabling the menu item. This commit message is longer than the changeset itself. --- BizHawk.Client.EmuHawk/MainForm.Events.cs | 7 +++++-- .../Consoles/Nintendo/N64/N64.cs | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 3edebae7dd..0f0fa1434c 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -1797,8 +1797,11 @@ namespace BizHawk.Client.EmuHawk var s = (N64Settings)Global.Emulator.GetSettings(); MupenStyleLagMenuItem.Checked = s.UseMupenStyleLag; - var ss = (N64SyncSettings)Global.Emulator.GetSyncSettings(); - N64ExpansionSlotMenuItem.Checked = !ss.DisableExpansionSlot; + //var ss = (N64SyncSettings)Global.Emulator.GetSyncSettings(); + //N64ExpansionSlotMenuItem.Checked = !ss.DisableExpansionSlot; + + N64ExpansionSlotMenuItem.Checked = (Global.Emulator as N64).UsingExpansionSlot; + N64ExpansionSlotMenuItem.Enabled = !(Global.Emulator as N64).IsOverridingUserExpansionSlotSetting; } private void N64PluginSettingsMenuItem_Click(object sender, EventArgs e) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs index 48948697a6..bde3ff0a0e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs @@ -37,6 +37,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 private Action _pendingThreadAction; + private bool _disableExpansionSlot = true; + /// /// Create mupen64plus Emulator /// @@ -58,10 +60,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 _syncSettings = (N64SyncSettings)syncSettings ?? new N64SyncSettings(); _settings = (N64Settings)settings ?? new N64Settings(); + _disableExpansionSlot = _syncSettings.DisableExpansionSlot; + // Override the user's expansion slot setting if it is mentioned in the gamedb (it is mentioned but the game MUST have this setting or else not work if (game.OptionValue("expansionpak") != null && game.OptionValue("expansionpak") == "1") { - _syncSettings.DisableExpansionSlot = false; + _disableExpansionSlot = false; + IsOverridingUserExpansionSlotSetting = true; } byte country_code = file[0x3E]; @@ -109,7 +114,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 //not sure why this works... if we put the plugin initializations in here, we get deadlocks in some SDL initialization. doesnt make sense to me... RunThreadAction(() => { - api = new mupen64plusApi(this, file, videosettings, SaveType, (int)coreType, _syncSettings.DisableExpansionSlot); + api = new mupen64plusApi(this, file, videosettings, SaveType, (int)coreType, _disableExpansionSlot); }); // Order is important because the register with the mupen core @@ -131,6 +136,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 SetControllerButtons(); } + public bool UsingExpansionSlot + { + get { return !_disableExpansionSlot; } + } + + public bool IsOverridingUserExpansionSlotSetting { get; set; } + public void Dispose() { RunThreadAction(() => @@ -341,7 +353,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 public void LoadStateBinary(BinaryReader reader) { int length = reader.ReadInt32(); - if ((_syncSettings.DisableExpansionSlot && length >= 16788288) || (!_syncSettings.DisableExpansionSlot && length < 16788288)) + if ((_disableExpansionSlot && length >= 16788288) || (!_disableExpansionSlot && length < 16788288)) { throw new SavestateSizeMismatchException("Wrong N64 savestate size"); }