From 4f9539b73c8b0ffdca99a0ad1e1eddcb33313f1c Mon Sep 17 00:00:00 2001 From: brandman211 Date: Sun, 15 Jul 2012 08:38:50 +0000 Subject: [PATCH] -Made Executive ROM and Graphics ROM read-only. I still haven't made the memory map accessibility limited by the VBlank Period, but I'm assuming that should come way later. -Initialized the memory devices with a tentative size that ignores the unofficial ranges. -Masked addresses to match those sizes (That's my understanding of what the memory map needs to do based on other examples). -Added the ICart interface. -Started the Intellicart parser; got far enough to know that the files I'm working with are not Intellicarts. ^_^ --- BizHawk.Emulation/BizHawk.Emulation.csproj | 2 + .../Consoles/Intellivision/Intellicart.cs | 30 +++ .../Consoles/Intellivision/Intellivision.cs | 175 +++++++++--------- .../Consoles/Intellivision/MemoryMap.cs | 42 ++--- BizHawk.Emulation/Interfaces/ICart.cs | 13 ++ 5 files changed, 150 insertions(+), 112 deletions(-) create mode 100644 BizHawk.Emulation/Consoles/Intellivision/Intellicart.cs create mode 100644 BizHawk.Emulation/Interfaces/ICart.cs diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj index 6f2bb02f78..fe59dd79db 100644 --- a/BizHawk.Emulation/BizHawk.Emulation.csproj +++ b/BizHawk.Emulation/BizHawk.Emulation.csproj @@ -114,6 +114,7 @@ + @@ -311,6 +312,7 @@ + diff --git a/BizHawk.Emulation/Consoles/Intellivision/Intellicart.cs b/BizHawk.Emulation/Consoles/Intellivision/Intellicart.cs new file mode 100644 index 0000000000..e110c7ea3d --- /dev/null +++ b/BizHawk.Emulation/Consoles/Intellivision/Intellicart.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk.Emulation.Consoles.Intellivision +{ + public sealed partial class Intellivision : ICart + { + private ushort[] memory = new ushort[65536]; + + public void Parse() + { + // Check to see if the header is valid. + if (Rom[0] != 0xA8 || Rom[1] != (0xFF ^ Rom[2])) + throw new ArgumentException(); + } + + public ushort ReadMemory(ushort addr, out bool responded) + { + responded = false; + return 0; + } + + public void WriteMemory(ushort addr, ushort value, out bool responded) + { + responded = false; + } + } +} diff --git a/BizHawk.Emulation/Consoles/Intellivision/Intellivision.cs b/BizHawk.Emulation/Consoles/Intellivision/Intellivision.cs index 19a8e009fa..f219570cc5 100644 --- a/BizHawk.Emulation/Consoles/Intellivision/Intellivision.cs +++ b/BizHawk.Emulation/Consoles/Intellivision/Intellivision.cs @@ -5,117 +5,118 @@ using BizHawk.Emulation.CPUs.CP1610; namespace BizHawk.Emulation.Consoles.Intellivision { - public sealed partial class Intellivision : IEmulator - { - byte[] Rom; - GameInfo Game; + public sealed partial class Intellivision : IEmulator + { + byte[] Rom; + GameInfo Game; - CP1610 Cpu ; + CP1610 Cpu; - public Intellivision(GameInfo game, byte[] rom) - { - Rom = rom; - Game = game; - - Cpu = new CP1610(); - Cpu.ReadMemory = ReadMemory; - Cpu.WriteMemory = WriteMemory; + public Intellivision(GameInfo game, byte[] rom) + { + Rom = rom; + Game = game; + Parse(); + + Cpu = new CP1610(); + Cpu.ReadMemory = ReadMemory; + Cpu.WriteMemory = WriteMemory; Cpu.RegisterPC = 0x1000; - - CoreOutputComm = new CoreOutputComm(); - } - public void FrameAdvance(bool render) - { - Cpu.Execute(999); // execute some cycles. this will do nothing useful until a memory mapper is created. - } + CoreOutputComm = new CoreOutputComm(); + } + + public void FrameAdvance(bool render) + { + Cpu.Execute(999); // execute some cycles. this will do nothing useful until a memory mapper is created. + } - // This is all crap to worry about later. + // This is all crap to worry about later. - public IVideoProvider VideoProvider { get { return new NullEmulator(); } } - public ISoundProvider SoundProvider { get { return NullSound.SilenceProvider; } } + public IVideoProvider VideoProvider { get { return new NullEmulator(); } } + public ISoundProvider SoundProvider { get { return NullSound.SilenceProvider; } } - public ControllerDefinition ControllerDefinition - { - get { return null; } - } + public ControllerDefinition ControllerDefinition + { + get { return null; } + } - public IController Controller { get; set; } + public IController Controller { get; set; } - - public int Frame - { - get { return 0; } - } - public int LagCount - { - get { return 0; } - set { } - } + public int Frame + { + get { return 0; } + } - public bool IsLagFrame { get { return false; } } - public string SystemId - { - get { return "INTV"; } - } + public int LagCount + { + get { return 0; } + set { } + } - public bool DeterministicEmulation { get; set; } + public bool IsLagFrame { get { return false; } } + public string SystemId + { + get { return "INTV"; } + } - public byte[] SaveRam { get { return null; } } + public bool DeterministicEmulation { get; set; } - public bool SaveRamModified - { - get { return false; } - set { } - } + public byte[] SaveRam { get { return null; } } - public void ResetFrameCounter() - { - } + public bool SaveRamModified + { + get { return false; } + set { } + } - public void SaveStateText(TextWriter writer) - { - throw new NotImplementedException(); - } + public void ResetFrameCounter() + { + } - public void LoadStateText(TextReader reader) - { - throw new NotImplementedException(); - } + public void SaveStateText(TextWriter writer) + { + throw new NotImplementedException(); + } - public void SaveStateBinary(BinaryWriter writer) - { - throw new NotImplementedException(); - } + public void LoadStateText(TextReader reader) + { + throw new NotImplementedException(); + } - public void LoadStateBinary(BinaryReader reader) - { - throw new NotImplementedException(); - } + public void SaveStateBinary(BinaryWriter writer) + { + throw new NotImplementedException(); + } - public byte[] SaveStateBinary() - { - return new byte[0]; - } + public void LoadStateBinary(BinaryReader reader) + { + throw new NotImplementedException(); + } - public CoreInputComm CoreInputComm { get; set; } - public CoreOutputComm CoreOutputComm { get; private set; } + public byte[] SaveStateBinary() + { + return new byte[0]; + } - public IList MemoryDomains - { - get { throw new NotImplementedException(); } - } + public CoreInputComm CoreInputComm { get; set; } + public CoreOutputComm CoreOutputComm { get; private set; } - public MemoryDomain MainMemory - { - get { throw new NotImplementedException(); } - } + public IList MemoryDomains + { + get { throw new NotImplementedException(); } + } - public void Dispose() - { - } - } + public MemoryDomain MainMemory + { + get { throw new NotImplementedException(); } + } + + public void Dispose() + { + } + } } \ No newline at end of file diff --git a/BizHawk.Emulation/Consoles/Intellivision/MemoryMap.cs b/BizHawk.Emulation/Consoles/Intellivision/MemoryMap.cs index 94591780bb..dbeb167cb7 100644 --- a/BizHawk.Emulation/Consoles/Intellivision/MemoryMap.cs +++ b/BizHawk.Emulation/Consoles/Intellivision/MemoryMap.cs @@ -7,13 +7,13 @@ namespace BizHawk.Emulation.Consoles.Intellivision { public sealed partial class Intellivision { - private ushort[] STIC_Registers; - private ushort[] Scratchpad_RAM; - private ushort[] PSG_Registers; - private ushort[] System_RAM; - private ushort[] Executive_ROM; - private ushort[] Graphics_ROM; - private ushort[] Graphics_RAM; + private ushort[] STIC_Registers = new ushort[64]; + private ushort[] Scratchpad_RAM = new ushort[240]; + private ushort[] PSG_Registers = new ushort[16]; + private ushort[] System_RAM = new ushort[352]; + private ushort[] Executive_ROM = new ushort[4096]; + private ushort[] Graphics_ROM = new ushort[2048]; + private ushort[] Graphics_RAM = new ushort[512]; public ushort ReadMemory(ushort addr) { @@ -21,19 +21,19 @@ namespace BizHawk.Emulation.Consoles.Intellivision { case 0x0000: if (addr >= 0x0100 && addr <= 0x01EF) - return Scratchpad_RAM[addr]; + return Scratchpad_RAM[addr & 0x00EF]; if (addr >= 0x01F0 && addr <= 0x01FF) - return PSG_Registers[addr]; + return PSG_Registers[addr & 0x000F]; if (addr >= 0x0200 && addr <= 0x035F) - return System_RAM[addr]; + return System_RAM[addr & 0x015F]; break; case 0x1000: - return Executive_ROM[addr]; + return Executive_ROM[addr & 0x0FFF]; case 0x3000: if (addr >= 0x3000 && addr <= 0x37FF) - return Graphics_ROM[addr]; + return Graphics_ROM[addr & 0x07FF]; if (addr >= 0x3800 && addr <= 0x39FF) - return Graphics_RAM[addr]; + return Graphics_RAM[addr & 0x01FF]; break; } throw new NotImplementedException(); @@ -46,32 +46,24 @@ namespace BizHawk.Emulation.Consoles.Intellivision case 0x0000: if (addr >= 0x0100 && addr <= 0x01EF) { - Scratchpad_RAM[addr] = value; + Scratchpad_RAM[addr & 0x00EF] = value; return; } if (addr >= 0x01F0 && addr <= 0x01FF) { - PSG_Registers[addr] = value; + PSG_Registers[addr & 0x000F] = value; return; } if (addr >= 0x0200 && addr <= 0x035F) { - System_RAM[addr] = value; + System_RAM[addr & 0x015F] = value; return; } break; - case 0x1000: - Executive_ROM[addr] = value; - return; case 0x3000: - if (addr >= 0x3000 && addr <= 0x37FF) - { - Graphics_ROM[addr] = value; - return; - } if (addr >= 0x3800 && addr <= 0x39FF) { - Graphics_RAM[addr] = value; + Graphics_RAM[addr & 0x01FF] = value; return; } break; diff --git a/BizHawk.Emulation/Interfaces/ICart.cs b/BizHawk.Emulation/Interfaces/ICart.cs new file mode 100644 index 0000000000..29c07ae47e --- /dev/null +++ b/BizHawk.Emulation/Interfaces/ICart.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace BizHawk +{ + public interface ICart + { + ushort ReadMemory(ushort addr, out bool responded); + void WriteMemory(ushort addr, ushort value, out bool responded); + } +}