Clean up ti 83 loading. Probably works, but I have nothing to test against it

This commit is contained in:
nattthebear 2020-07-11 20:31:36 -04:00
parent 8900618ce1
commit 502aef73a0
3 changed files with 11 additions and 23 deletions

View File

@ -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, TI83.TI83Settings>()
);
ti83.LinkPort.SendFileToCalc(File.OpenRead(path.SubstringBefore('|')), false);
nextEmulator = ti83;
}
return;
case "SNES":
var name = game.ForcedCore?.ToLower() switch
{

View File

@ -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<TI83.TI83Settings, object>
{
[CoreConstructor("TI83")]
public TI83(GameInfo game, byte[] rom, TI83.TI83Settings settings)
[CoreConstructor("83P")]
public TI83(CoreLoadParameters<TI83Settings, object> 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<ITraceable>(_tracer);
ser.Register<IDisassemblable>(_cpu);
ser.Register<IStatable>(new StateSerializer(SyncState));
LinkPort.SendFileToCalc(new MemoryStream(lp.Roms[0].RomData, false), false);
}
private readonly TraceBuffer _tracer;

View File

@ -13,7 +13,7 @@ namespace BizHawk.Emulation.Cores.Calculators
private readonly TI83 Parent;
private readonly Queue<byte> CurrentData = new Queue<byte>();
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 };