diff --git a/BizHawk.Client.Common/CoreFileProvider.cs b/BizHawk.Client.Common/CoreFileProvider.cs index 411833a910..814ca9355e 100644 --- a/BizHawk.Client.Common/CoreFileProvider.cs +++ b/BizHawk.Client.Common/CoreFileProvider.cs @@ -23,5 +23,58 @@ namespace BizHawk.Client.Common { return Path.Combine(Path.GetDirectoryName(SubfileDirectory) ?? String.Empty, fname); } + + public static void SyncCoreCommInputSignals() + { + CoreComm target = Global.CoreComm; + + var cfp = new CoreFileProvider(); + target.CoreFileProvider = cfp; + cfp.FirmwareManager = Global.FirmwareManager; + + target.NES_BackdropColor = Global.Config.NESBackgroundColor; + target.NES_UnlimitedSprites = Global.Config.NESAllowMoreThanEightSprites; + target.NES_ShowBG = Global.Config.NESDispBackground; + target.NES_ShowOBJ = Global.Config.NESDispSprites; + target.PCE_ShowBG1 = Global.Config.PCEDispBG1; + target.PCE_ShowOBJ1 = Global.Config.PCEDispOBJ1; + target.PCE_ShowBG2 = Global.Config.PCEDispBG2; + target.PCE_ShowOBJ2 = Global.Config.PCEDispOBJ2; + target.SMS_ShowBG = Global.Config.SMSDispBG; + target.SMS_ShowOBJ = Global.Config.SMSDispOBJ; + + target.PSX_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPath, null); // PathManager.MakeAbsolutePath(Global.Config.PathPSXFirmwares, "PSX"); + + target.C64_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPath, null); // PathManager.MakeAbsolutePath(Global.Config.PathC64Firmwares, "C64"); + + target.SNES_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPath, null); // PathManager.MakeAbsolutePath(Global.Config.PathSNESFirmwares, "SNES"); + target.SNES_ShowBG1_0 = Global.Config.SNES_ShowBG1_0; + target.SNES_ShowBG1_1 = Global.Config.SNES_ShowBG1_1; + target.SNES_ShowBG2_0 = Global.Config.SNES_ShowBG2_0; + target.SNES_ShowBG2_1 = Global.Config.SNES_ShowBG2_1; + target.SNES_ShowBG3_0 = Global.Config.SNES_ShowBG3_0; + target.SNES_ShowBG3_1 = Global.Config.SNES_ShowBG3_1; + target.SNES_ShowBG4_0 = Global.Config.SNES_ShowBG4_0; + target.SNES_ShowBG4_1 = Global.Config.SNES_ShowBG4_1; + target.SNES_ShowOBJ_0 = Global.Config.SNES_ShowOBJ1; + target.SNES_ShowOBJ_1 = Global.Config.SNES_ShowOBJ2; + target.SNES_ShowOBJ_2 = Global.Config.SNES_ShowOBJ3; + target.SNES_ShowOBJ_3 = Global.Config.SNES_ShowOBJ4; + + target.SNES_Profile = Global.Config.SNESProfile; + target.SNES_UseRingBuffer = Global.Config.SNESUseRingBuffer; + target.SNES_AlwaysDoubleSize = Global.Config.SNESAlwaysDoubleSize; + + target.GG_HighlightActiveDisplayRegion = Global.Config.GGHighlightActiveDisplayRegion; + target.GG_ShowClippedRegions = Global.Config.GGShowClippedRegions; + + target.Atari2600_ShowBG = Global.Config.Atari2600_ShowBG; + target.Atari2600_ShowPlayer1 = Global.Config.Atari2600_ShowPlayer1; + target.Atari2600_ShowPlayer2 = Global.Config.Atari2600_ShowPlayer2; + target.Atari2600_ShowMissle1 = Global.Config.Atari2600_ShowMissle1; + target.Atari2600_ShowMissle2 = Global.Config.Atari2600_ShowMissle2; + target.Atari2600_ShowBall = Global.Config.Atari2600_ShowBall; + target.Atari2600_ShowPF = Global.Config.Atari2600_ShowPlayfield; + } } } \ No newline at end of file diff --git a/BizHawk.Client.Common/Global.cs b/BizHawk.Client.Common/Global.cs index a2f01733d9..5f727f4845 100644 --- a/BizHawk.Client.Common/Global.cs +++ b/BizHawk.Client.Common/Global.cs @@ -10,6 +10,7 @@ namespace BizHawk.Client.Common public static Config Config; public static GameInfo Game; public static CheatList CheatList; + public static FirmwareManager FirmwareManager; //Movie diff --git a/BizHawk.MultiClient/MainForm.Events.cs b/BizHawk.MultiClient/MainForm.Events.cs index 0a32af3780..67731ae57d 100644 --- a/BizHawk.MultiClient/MainForm.Events.cs +++ b/BizHawk.MultiClient/MainForm.Events.cs @@ -1230,7 +1230,7 @@ namespace BizHawk.MultiClient private void NESGraphicSettingsMenuItem_Click(object sender, EventArgs e) { new NESGraphicsConfig().ShowDialog(); - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); } private void NESSoundChannelsMenuItem_Click(object sender, EventArgs e) @@ -1275,7 +1275,7 @@ namespace BizHawk.MultiClient private void PCEGraphicsSettingsMenuItem_Click(object sender, EventArgs e) { new PCEGraphicsConfig().ShowDialog(); - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); } #endregion @@ -1341,7 +1341,7 @@ namespace BizHawk.MultiClient private void SMSGraphicsSettingsMenuItem_Click(object sender, EventArgs e) { new SMSGraphicsConfig().ShowDialog(); - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); } private void GGGameGenieMenuItem_Click(object sender, EventArgs e) @@ -1472,43 +1472,43 @@ namespace BizHawk.MultiClient private void AtariShowBGMenuItem_Click(object sender, EventArgs e) { Global.Config.Atari2600_ShowBG ^= true; - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); } private void AtariShowPlayfieldMenuItem_Click(object sender, EventArgs e) { Global.Config.Atari2600_ShowPlayfield ^= true; - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); } private void ShowPlayer1MenuItem_Click(object sender, EventArgs e) { Global.Config.Atari2600_ShowPlayer1 ^= true; - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); } private void ShowPlayer2MenuItem_Click(object sender, EventArgs e) { Global.Config.Atari2600_ShowPlayer2 ^= true; - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); } private void ShowMissle1MenuItem_Click(object sender, EventArgs e) { Global.Config.Atari2600_ShowMissle1 ^= true; - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); } private void ShowMissle2MenuItem_Click(object sender, EventArgs e) { Global.Config.Atari2600_ShowMissle2 ^= true; - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); } private void ShowBallMenuItem_Click(object sender, EventArgs e) { Global.Config.Atari2600_ShowBall ^= true; - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); } #endregion @@ -1697,7 +1697,7 @@ namespace BizHawk.MultiClient { FlagNeedsReboot(); } - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); } } diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index 4ce39302db..ed8df9da47 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -77,8 +77,6 @@ namespace BizHawk.MultiClient private readonly Throttle throttle; private bool unthrottled; - public FirmwareManager FirmwareManager = new FirmwareManager(); - //For handling automatic pausing when entering the menu private bool wasPaused; private bool didMenuPause; @@ -181,6 +179,7 @@ namespace BizHawk.MultiClient public MainForm(string[] args) { GlobalWinF.MainForm = this; + Global.FirmwareManager = new FirmwareManager(); Global.MovieSession = new MovieSession { Movie = new Movie(GlobalWinF.MainForm.GetEmuVersion()), @@ -214,9 +213,6 @@ namespace BizHawk.MultiClient return Util.ReadAllBytes(NesCartFile.GetStream()); }; - //Global.CoreComm = new CoreComm(); - //SyncCoreCommInputSignals(); - Database.LoadDatabase(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "gamedb.txt")); SyncPresentationMode(); @@ -251,7 +247,7 @@ namespace BizHawk.MultiClient Input.Initialize(); InitControls(); Global.CoreComm = new CoreComm(); - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); Global.Emulator = new NullEmulator(Global.CoreComm); Global.ActiveController = Global.NullControls; Global.AutoFireController = Global.AutofireNullControls; @@ -517,7 +513,7 @@ namespace BizHawk.MultiClient { var cfp = new CoreFileProvider(); target.CoreFileProvider = cfp; - cfp.FirmwareManager = FirmwareManager; + cfp.FirmwareManager = Global.FirmwareManager; target.NES_BackdropColor = Global.Config.NESBackgroundColor; target.NES_UnlimitedSprites = Global.Config.NESAllowMoreThanEightSprites; @@ -564,11 +560,6 @@ namespace BizHawk.MultiClient target.Atari2600_ShowPF = Global.Config.Atari2600_ShowPlayfield; } - public void SyncCoreCommInputSignals() - { - SyncCoreCommInputSignals(Global.CoreComm); - } - void SyncPresentationMode() { GlobalWinF.DisplayManager.Suspend(); @@ -1169,7 +1160,7 @@ namespace BizHawk.MultiClient { case "SAT": { - string biosPath = this.FirmwareManager.Request("SAT", "J"); + string biosPath = Global.FirmwareManager.Request("SAT", "J"); if (!File.Exists(biosPath)) { MessageBox.Show("Saturn BIOS not found. Please check firmware configurations."); @@ -1197,7 +1188,7 @@ namespace BizHawk.MultiClient case "PCE": case "PCECD": { - string biosPath = this.FirmwareManager.Request("PCECD", "Bios"); + string biosPath = Global.FirmwareManager.Request("PCECD", "Bios"); if (File.Exists(biosPath) == false) { MessageBox.Show("PCE-CD System Card not found. Please check the BIOS path in Config->Paths->PC Engine."); @@ -1397,7 +1388,7 @@ namespace BizHawk.MultiClient } else { - string sgbromPath = this.FirmwareManager.Request("SNES", "Rom_SGB"); + string sgbromPath = Global.FirmwareManager.Request("SNES", "Rom_SGB"); byte[] sgbrom = null; try { @@ -1433,7 +1424,7 @@ namespace BizHawk.MultiClient //} break; case "Coleco": - string colbiosPath = this.FirmwareManager.Request("Coleco", "Bios"); + string colbiosPath = Global.FirmwareManager.Request("Coleco", "Bios"); FileInfo colfile = colbiosPath != null ? new FileInfo(colbiosPath) : null; if (colfile == null || !colfile.Exists) { @@ -1449,11 +1440,11 @@ namespace BizHawk.MultiClient case "INTV": { Intellivision intv = new Intellivision(nextComm, game, rom.RomData); - string eromPath = this.FirmwareManager.Request("INTV", "EROM"); + string eromPath = Global.FirmwareManager.Request("INTV", "EROM"); if (!File.Exists(eromPath)) throw new InvalidOperationException("Specified EROM path does not exist:\n\n" + eromPath); intv.LoadExecutiveRom(eromPath); - string gromPath = this.FirmwareManager.Request("INTV", "GROM"); + string gromPath = Global.FirmwareManager.Request("INTV", "GROM"); if (!File.Exists(gromPath)) throw new InvalidOperationException("Specified GROM path does not exist:\n\n" + gromPath); intv.LoadGraphicsRom(gromPath); @@ -1461,9 +1452,9 @@ namespace BizHawk.MultiClient } break; case "A78": - string ntsc_biospath = this.FirmwareManager.Request("A78", "Bios_NTSC"); - string pal_biospath = this.FirmwareManager.Request("A78", "Bios_PAL"); - string hsbiospath = this.FirmwareManager.Request("A78", "Bios_HSC"); + string ntsc_biospath = Global.FirmwareManager.Request("A78", "Bios_NTSC"); + string pal_biospath = Global.FirmwareManager.Request("A78", "Bios_PAL"); + string hsbiospath = Global.FirmwareManager.Request("A78", "Bios_HSC"); FileInfo ntscfile = ntsc_biospath != null ? new FileInfo(ntsc_biospath) : null; FileInfo palfile = pal_biospath != null ? new FileInfo(pal_biospath) : null; @@ -1522,7 +1513,7 @@ namespace BizHawk.MultiClient case "GBA": if (INTERIM) { - string gbabiospath = FirmwareManager.Request("GBA", "Bios"); + string gbabiospath = Global.FirmwareManager.Request("GBA", "Bios"); byte[] gbabios = null; if (File.Exists(gbabiospath)) @@ -1569,7 +1560,7 @@ namespace BizHawk.MultiClient Global.Emulator = nextEmulator; Global.CoreComm = nextComm; Global.Game = game; - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); SyncControls(); if (nextEmulator is LibsnesCore) @@ -3201,7 +3192,7 @@ namespace BizHawk.MultiClient StopAVI(); Global.Emulator.Dispose(); Global.CoreComm = new CoreComm(); - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); Global.Emulator = new NullEmulator(Global.CoreComm); Global.ActiveController = Global.NullControls; Global.AutoFireController = Global.AutofireNullControls; @@ -3214,7 +3205,7 @@ namespace BizHawk.MultiClient { CloseGame(clearSRAM); Global.CoreComm = new CoreComm(); - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); Global.Emulator = new NullEmulator(Global.CoreComm); Global.Game = GameInfo.GetNullGame(); @@ -4262,7 +4253,7 @@ namespace BizHawk.MultiClient Global.Config.SNES_ShowBG1_1 = Global.Config.SNES_ShowBG1_0 ^= true; } - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); if (Global.Config.SNES_ShowBG1_1) { GlobalWinF.OSD.AddMessage("BG 1 Layer On"); @@ -4286,7 +4277,7 @@ namespace BizHawk.MultiClient { Global.Config.SNES_ShowBG2_1 = Global.Config.SNES_ShowBG2_0 ^= true; } - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); if (Global.Config.SNES_ShowBG2_1) { GlobalWinF.OSD.AddMessage("BG 2 Layer On"); @@ -4310,7 +4301,7 @@ namespace BizHawk.MultiClient { Global.Config.SNES_ShowBG3_1 = Global.Config.SNES_ShowBG3_0 ^= true; } - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); if (Global.Config.SNES_ShowBG3_1) { GlobalWinF.OSD.AddMessage("BG 3 Layer On"); @@ -4334,7 +4325,7 @@ namespace BizHawk.MultiClient { Global.Config.SNES_ShowBG4_1 = Global.Config.SNES_ShowBG4_0 ^= true; } - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); if (Global.Config.SNES_ShowBG4_1) { GlobalWinF.OSD.AddMessage("BG 4 Layer On"); @@ -4358,7 +4349,7 @@ namespace BizHawk.MultiClient { Global.Config.SNES_ShowOBJ1 ^= true; } - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); if (Global.Config.SNES_ShowOBJ1) { GlobalWinF.OSD.AddMessage("OBJ 1 Layer On"); @@ -4382,7 +4373,7 @@ namespace BizHawk.MultiClient { Global.Config.SNES_ShowOBJ2 ^= true; } - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); if (Global.Config.SNES_ShowOBJ2) { GlobalWinF.OSD.AddMessage("OBJ 2 Layer On"); @@ -4406,7 +4397,7 @@ namespace BizHawk.MultiClient { Global.Config.SNES_ShowOBJ3 ^= true; } - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); if (Global.Config.SNES_ShowOBJ3) { GlobalWinF.OSD.AddMessage("OBJ 3 Layer On"); @@ -4430,7 +4421,7 @@ namespace BizHawk.MultiClient { Global.Config.SNES_ShowOBJ4 ^= true; } - SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); if (Global.Config.SNES_ShowOBJ4) { GlobalWinF.OSD.AddMessage("OBJ 4 Layer On"); diff --git a/BizHawk.MultiClient/config/FirmwaresConfig.cs b/BizHawk.MultiClient/config/FirmwaresConfig.cs index 98757b424f..f99d6b7fdb 100644 --- a/BizHawk.MultiClient/config/FirmwaresConfig.cs +++ b/BizHawk.MultiClient/config/FirmwaresConfig.cs @@ -177,7 +177,7 @@ namespace BizHawk.MultiClient DoScan(); } - FirmwareManager Manager { get { return GlobalWinF.MainForm.FirmwareManager; } } + FirmwareManager Manager { get { return Global.FirmwareManager; } } private void DoScan() { diff --git a/BizHawk.MultiClient/tools/Lua/Libraries/EmuLuaLibrary.NES.cs b/BizHawk.MultiClient/tools/Lua/Libraries/EmuLuaLibrary.NES.cs index 2405f77f35..1b9d766d3f 100644 --- a/BizHawk.MultiClient/tools/Lua/Libraries/EmuLuaLibrary.NES.cs +++ b/BizHawk.MultiClient/tools/Lua/Libraries/EmuLuaLibrary.NES.cs @@ -139,13 +139,13 @@ namespace BizHawk.MultiClient public static void nes_setdispbackground(bool show) { Global.Config.NESDispBackground = show; - GlobalWinF.MainForm.SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); } public static void nes_setdispsprites(bool show) { Global.Config.NESDispSprites = show; - GlobalWinF.MainForm.SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); } public static void nes_setscanlines(object top, object bottom, bool pal = false) diff --git a/BizHawk.MultiClient/tools/SNES/SNESGraphicsDebugger.cs b/BizHawk.MultiClient/tools/SNES/SNESGraphicsDebugger.cs index e3cfd386e4..1a6b4a98c5 100644 --- a/BizHawk.MultiClient/tools/SNES/SNESGraphicsDebugger.cs +++ b/BizHawk.MultiClient/tools/SNES/SNESGraphicsDebugger.cs @@ -1387,7 +1387,7 @@ namespace BizHawk.MultiClient suppression = false; } - GlobalWinF.MainForm.SyncCoreCommInputSignals(); + CoreFileProvider.SyncCoreCommInputSignals(); } private void lblEnPrio0_Click(object sender, EventArgs e)