Intellivision - misc reorg

This commit is contained in:
adelikat 2015-06-18 16:44:30 +00:00
parent b7bf0b38cc
commit 212f94814d
6 changed files with 138 additions and 105 deletions

View File

@ -332,7 +332,12 @@
<Compile Include="Consoles\Intellivision\ICart.cs" /> <Compile Include="Consoles\Intellivision\ICart.cs" />
<Compile Include="Consoles\Intellivision\Intellicart.cs" /> <Compile Include="Consoles\Intellivision\Intellicart.cs" />
<Compile Include="Consoles\Intellivision\Intellivision.cs" /> <Compile Include="Consoles\Intellivision\Intellivision.cs" />
<Compile Include="Consoles\Intellivision\MemoryMap.cs" /> <Compile Include="Consoles\Intellivision\Intellivision.IEmulator.cs">
<DependentUpon>Intellivision.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Intellivision\Intellivision.MemoryMap.cs">
<DependentUpon>Intellivision.cs</DependentUpon>
</Compile>
<Compile Include="Consoles\Intellivision\PSG.cs" /> <Compile Include="Consoles\Intellivision\PSG.cs" />
<Compile Include="Consoles\Intellivision\STIC.cs" /> <Compile Include="Consoles\Intellivision\STIC.cs" />
<Compile Include="Consoles\Nintendo\Gameboy\Gambatte.cs" /> <Compile Include="Consoles\Nintendo\Gameboy\Gambatte.cs" />
@ -780,6 +785,8 @@
<DependentUpon>WonderSwan.cs</DependentUpon> <DependentUpon>WonderSwan.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="CoreInventory.cs" /> <Compile Include="CoreInventory.cs" />
<Compile Include="CPUs\CP1610\CP1610.Disassembler.cs" />
<Compile Include="CPUs\CP1610\CP1610.Execute.cs" />
<Compile Include="CPUs\W65816\Disassembler.cs" /> <Compile Include="CPUs\W65816\Disassembler.cs" />
<Compile Include="CPUs\68000\Diassembler.cs" /> <Compile Include="CPUs\68000\Diassembler.cs" />
<Compile Include="CPUs\68000\Instructions\BitArithemetic.cs" /> <Compile Include="CPUs\68000\Instructions\BitArithemetic.cs" />
@ -793,8 +800,6 @@
<Compile Include="CPUs\68000\Tables.cs" /> <Compile Include="CPUs\68000\Tables.cs" />
<Compile Include="CPUs\ARM\Darm.cs" /> <Compile Include="CPUs\ARM\Darm.cs" />
<Compile Include="CPUs\CP1610\CP1610.cs" /> <Compile Include="CPUs\CP1610\CP1610.cs" />
<Compile Include="CPUs\CP1610\Disassembler.cs" />
<Compile Include="CPUs\CP1610\Execute.cs" />
<Compile Include="CPUs\HuC6280\CDL.cs" /> <Compile Include="CPUs\HuC6280\CDL.cs" />
<Compile Include="CPUs\HuC6280\CDLOpcodes.cs" /> <Compile Include="CPUs\HuC6280\CDLOpcodes.cs" />
<Compile Include="CPUs\HuC6280\Disassembler.cs" /> <Compile Include="CPUs\HuC6280\Disassembler.cs" />

View File

@ -0,0 +1,75 @@
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Intellivision
{
public sealed partial class Intellivision : IEmulator
{
public IEmulatorServiceProvider ServiceProvider { get; private set; }
[FeatureNotImplemented]
public ISoundProvider SoundProvider
{
get { return NullSound.SilenceProvider; }
}
[FeatureNotImplemented]
public ISyncSoundProvider SyncSoundProvider
{
get { return new FakeSyncSound(NullSound.SilenceProvider, 735); }
}
public bool StartAsyncSound()
{
return true;
}
public void EndAsyncSound()
{
}
public ControllerDefinition ControllerDefinition
{
get { return IntellivisionController; }
}
public IController Controller { get; set; }
public void FrameAdvance(bool render, bool rendersound)
{
Frame++;
_cpu.AddPendingCycles(14934);
while (_cpu.GetPendingCycles() > 0)
{
int cycles = _cpu.Execute();
_stic.Execute(cycles);
Connect();
_cpu.LogData();
}
}
public int Frame { get; private set; }
public string SystemId
{
get { return "INTV"; }
}
public bool DeterministicEmulation { get { return true; } }
[FeatureNotImplemented]
public string BoardName { get { return null; } }
public void ResetCounters()
{
Frame = 0;
}
public CoreComm CoreComm { get; private set; }
public void Dispose()
{
}
}
}

View File

@ -12,9 +12,9 @@
public ushort ReadMemory(ushort addr) public ushort ReadMemory(ushort addr)
{ {
ushort? cart = Cart.ReadCart(addr); ushort? cart = _cart.ReadCart(addr);
ushort? stic = Stic.ReadSTIC(addr); ushort? stic = _stic.ReadSTIC(addr);
ushort? psg = Psg.ReadPSG(addr); ushort? psg = _psg.ReadPSG(addr);
ushort? core = null; ushort? core = null;
switch (addr & 0xF000) switch (addr & 0xF000)
@ -185,9 +185,9 @@
public bool WriteMemory(ushort addr, ushort value) public bool WriteMemory(ushort addr, ushort value)
{ {
bool cart = Cart.WriteCart(addr, value); bool cart = _cart.WriteCart(addr, value);
bool stic = Stic.WriteSTIC(addr, value); bool stic = _stic.WriteSTIC(addr, value);
bool psg = Psg.WritePSG(addr, value); bool psg = _psg.WritePSG(addr, value);
switch (addr & 0xF000) switch (addr & 0xF000)
{ {
case 0x0000: case 0x0000:

View File

@ -16,19 +16,57 @@ namespace BizHawk.Emulation.Cores.Intellivision
[ServiceNotApplicable(typeof(ISaveRam))] [ServiceNotApplicable(typeof(ISaveRam))]
public sealed partial class Intellivision : IEmulator public sealed partial class Intellivision : IEmulator
{ {
byte[] Rom; [CoreConstructor("INTV")]
GameInfo Game; public Intellivision(CoreComm comm, GameInfo game, byte[] rom)
{
ServiceProvider = new BasicServiceProvider(this);
CoreComm = comm;
CP1610 Cpu; _rom = rom;
ICart Cart; _gameInfo = game;
STIC Stic; _cart = new Intellicart();
PSG Psg; if (_cart.Parse(_rom) == -1)
{
_cart = new Cartridge();
_cart.Parse(_rom);
}
_cpu = new CP1610();
_cpu.ReadMemory = ReadMemory;
_cpu.WriteMemory = WriteMemory;
_cpu.Reset();
_stic = new STIC();
_stic.ReadMemory = ReadMemory;
_stic.WriteMemory = WriteMemory;
_stic.Reset();
(ServiceProvider as BasicServiceProvider).Register<IVideoProvider>(_stic);
_psg = new PSG();
_psg.ReadMemory = ReadMemory;
_psg.WriteMemory = WriteMemory;
Connect();
_cpu.LogData();
LoadExecutiveRom(CoreComm.CoreFileProvider.GetFirmware("INTV", "EROM", true, "Executive ROM is required."));
LoadGraphicsRom(CoreComm.CoreFileProvider.GetFirmware("INTV", "GROM", true, "Graphics ROM is required."));
}
private byte[] _rom;
private GameInfo _gameInfo;
private CP1610 _cpu;
private ICart _cart;
private STIC _stic;
private PSG _psg;
public void Connect() public void Connect()
{ {
Cpu.SetIntRM(Stic.GetSr1()); _cpu.SetIntRM(_stic.GetSr1());
Cpu.SetBusRq(Stic.GetSr2()); _cpu.SetBusRq(_stic.GetSr2());
Stic.SetSst(Cpu.GetBusAk()); _stic.SetSst(_cpu.GetBusAk());
} }
public void LoadExecutiveRom(byte[] erom) public void LoadExecutiveRom(byte[] erom)
@ -37,6 +75,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
{ {
throw new ApplicationException("EROM file is wrong size - expected 8192 bytes"); throw new ApplicationException("EROM file is wrong size - expected 8192 bytes");
} }
int index = 0; int index = 0;
// Combine every two bytes into a word. // Combine every two bytes into a word.
while (index + 1 < erom.Length) while (index + 1 < erom.Length)
@ -51,67 +90,10 @@ namespace BizHawk.Emulation.Cores.Intellivision
{ {
throw new ApplicationException("GROM file is wrong size - expected 2048 bytes"); throw new ApplicationException("GROM file is wrong size - expected 2048 bytes");
} }
GraphicsRom = grom; GraphicsRom = grom;
} }
[CoreConstructor("INTV")]
public Intellivision(CoreComm comm, GameInfo game, byte[] rom)
{
ServiceProvider = new BasicServiceProvider(this);
CoreComm = comm;
Rom = rom;
Game = game;
Cart = new Intellicart();
if (Cart.Parse(Rom) == -1)
{
Cart = new Cartridge();
Cart.Parse(Rom);
}
Cpu = new CP1610();
Cpu.ReadMemory = ReadMemory;
Cpu.WriteMemory = WriteMemory;
Cpu.Reset();
Stic = new STIC();
Stic.ReadMemory = ReadMemory;
Stic.WriteMemory = WriteMemory;
Stic.Reset();
(ServiceProvider as BasicServiceProvider).Register<IVideoProvider>(Stic);
Psg = new PSG();
Psg.ReadMemory = ReadMemory;
Psg.WriteMemory = WriteMemory;
Connect();
Cpu.LogData();
LoadExecutiveRom(CoreComm.CoreFileProvider.GetFirmware("INTV", "EROM", true, "Executive ROM is required."));
LoadGraphicsRom(CoreComm.CoreFileProvider.GetFirmware("INTV", "GROM", true, "Graphics ROM is required."));
}
public IEmulatorServiceProvider ServiceProvider { get; private set; }
public void FrameAdvance(bool render, bool rendersound)
{
Frame++;
Cpu.AddPendingCycles(14934);
while (Cpu.GetPendingCycles() > 0)
{
int cycles = Cpu.Execute();
Stic.Execute(cycles);
Connect();
Cpu.LogData();
}
}
public ISoundProvider SoundProvider { get { return NullSound.SilenceProvider; } }
public ISyncSoundProvider SyncSoundProvider { get { return new FakeSyncSound(NullSound.SilenceProvider, 735); } }
public bool StartAsyncSound() { return true; }
public void EndAsyncSound() { }
public static readonly ControllerDefinition IntellivisionController = public static readonly ControllerDefinition IntellivisionController =
new ControllerDefinition new ControllerDefinition
{ {
@ -128,34 +110,5 @@ namespace BizHawk.Emulation.Cores.Intellivision
"P2 Key 6", "P2 Key 7", "P2 Key 8", "P2 Key 9", "P2 Enter", "P2 Clear" "P2 Key 6", "P2 Key 7", "P2 Key 8", "P2 Key 9", "P2 Enter", "P2 Clear"
} }
}; };
public ControllerDefinition ControllerDefinition
{
get { return IntellivisionController; }
}
public IController Controller { get; set; }
public int Frame { get; set; }
public string SystemId
{
get { return "INTV"; }
}
[FeatureNotImplemented]
public string BoardName { get { return null; } }
public bool DeterministicEmulation { get { return true; } }
public void ResetCounters()
{
Frame = 0;
}
public CoreComm CoreComm { get; private set; }
public void Dispose()
{
}
} }
} }