From 502aef73a04f19779e62a634bd39b458db793e5a Mon Sep 17 00:00:00 2001 From: nattthebear Date: Sat, 11 Jul 2020 20:31:36 -0400 Subject: [PATCH] Clean up ti 83 loading. Probably works, but I have nothing to test against it --- src/BizHawk.Client.Common/RomLoader.cs | 18 ++---------------- src/BizHawk.Emulation.Cores/Calculator/TI83.cs | 10 ++++++---- .../Calculator/TI83LinkPort.cs | 6 +++--- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/BizHawk.Client.Common/RomLoader.cs b/src/BizHawk.Client.Common/RomLoader.cs index 0791b98ad0..6407da9591 100644 --- a/src/BizHawk.Client.Common/RomLoader.cs +++ b/src/BizHawk.Client.Common/RomLoader.cs @@ -441,26 +441,12 @@ namespace BizHawk.Client.Common } nextEmulator = null; - if (game.System == null) return; // The user picked nothing in the Core picker + if (game.System == null) + return; // The user picked nothing in the Core picker CoreInventory.Core core; switch (game.System) { - case "83P": - var ti83Bios = nextComm.CoreFileProvider.GetFirmware("TI83", "Rom", true); - var ti83BiosPath = _firmwareManager.Request(_config.PathEntries, _config.FirmwareUserSpecifications, "TI83", "Rom"); // TODO: make the ti-83 a proper firmware file - using (var ti83AsHawkFile = new HawkFile(ti83BiosPath)) - { - var ti83BiosAsRom = new RomGame(ti83AsHawkFile); - var ti83 = new TI83( - ti83BiosAsRom.GameInfo, - ti83Bios, - GetCoreSettings() - ); - ti83.LinkPort.SendFileToCalc(File.OpenRead(path.SubstringBefore('|')), false); - nextEmulator = ti83; - } - return; case "SNES": var name = game.ForcedCore?.ToLower() switch { diff --git a/src/BizHawk.Emulation.Cores/Calculator/TI83.cs b/src/BizHawk.Emulation.Cores/Calculator/TI83.cs index 8b1a32afc4..41ff2f8604 100644 --- a/src/BizHawk.Emulation.Cores/Calculator/TI83.cs +++ b/src/BizHawk.Emulation.Cores/Calculator/TI83.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Components.Z80A; @@ -13,12 +14,12 @@ namespace BizHawk.Emulation.Cores.Calculators [ServiceNotApplicable(new[] { typeof(IBoardInfo), typeof(IDriveLight), typeof(IRegionable), typeof(ISaveRam), typeof(ISoundProvider) })] public partial class TI83 : IEmulator, IVideoProvider, IDebuggable, IInputPollable, ISettable { - [CoreConstructor("TI83")] - public TI83(GameInfo game, byte[] rom, TI83.TI83Settings settings) + [CoreConstructor("83P")] + public TI83(CoreLoadParameters lp) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; - PutSettings((TI83Settings)settings ?? new TI83Settings()); + PutSettings(lp.Settings ?? new TI83Settings()); _cpu.FetchMemory = ReadMemory; _cpu.ReadMemory = ReadMemory; @@ -29,7 +30,7 @@ namespace BizHawk.Emulation.Cores.Calculators _cpu.NMICallback = NMICallback; _cpu.MemoryCallbacks = MemoryCallbacks; - _rom = rom; + _rom = lp.Comm.CoreFileProvider.GetFirmware("TI83", "Rom", true); LinkPort = new TI83LinkPort(this); HardReset(); @@ -40,6 +41,7 @@ namespace BizHawk.Emulation.Cores.Calculators ser.Register(_tracer); ser.Register(_cpu); ser.Register(new StateSerializer(SyncState)); + LinkPort.SendFileToCalc(new MemoryStream(lp.Roms[0].RomData, false), false); } private readonly TraceBuffer _tracer; diff --git a/src/BizHawk.Emulation.Cores/Calculator/TI83LinkPort.cs b/src/BizHawk.Emulation.Cores/Calculator/TI83LinkPort.cs index 9c2be108bb..d9c1890fa2 100644 --- a/src/BizHawk.Emulation.Cores/Calculator/TI83LinkPort.cs +++ b/src/BizHawk.Emulation.Cores/Calculator/TI83LinkPort.cs @@ -13,7 +13,7 @@ namespace BizHawk.Emulation.Cores.Calculators private readonly TI83 Parent; private readonly Queue CurrentData = new Queue(); - private FileStream _currentFile; + private Stream _currentFile; private byte[] _variableData; private Action _nextStep; @@ -185,7 +185,7 @@ namespace BizHawk.Emulation.Cores.Calculators } } - public void SendFileToCalc(FileStream fs, bool verify) + public void SendFileToCalc(Stream fs, bool verify) { if (verify) { @@ -197,7 +197,7 @@ namespace BizHawk.Emulation.Cores.Calculators SendNextFile(); } - private void VerifyFile(FileStream fs) + private void VerifyFile(Stream fs) { // Verify the file format. byte[] expected = { 0x2a, 0x2a, 0x54, 0x49, 0x38, 0x33, 0x2a, 0x2a, 0x1a, 0x0a, 0x00 };