From 37139822ac3f7911f0b2ed2edc8267a1eb6a441a Mon Sep 17 00:00:00 2001 From: adelikat Date: Wed, 9 Apr 2014 01:57:45 +0000 Subject: [PATCH] Atari 2600 - slight fix to m3F, attempt to fix 3E, the mapper is still broken, I guess, the only Roms that use it are a Boulder Dash wip that is broken, and a Boulder Dash Intro Tune that seems to fail. --- .../Consoles/Atari/2600/Mappers/m3E.cs | 104 ++++++++---------- .../Consoles/Atari/2600/Mappers/m3F.cs | 2 +- 2 files changed, 44 insertions(+), 62 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Mappers/m3E.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Mappers/m3E.cs index c7f35c9d31..73d40f540b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Mappers/m3E.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Mappers/m3E.cs @@ -20,26 +20,26 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 enough space for 256K of RAM. When RAM is selected, 1000-13FF is the read port while 1400-17FF is the write port. */ - internal class m3E : MapperBase + internal class m3E : MapperBase { - private int _lowbank_2K; - private int _rambank_1K; + private int _lowbank2K; + private int _rambank1K; private bool _hasRam; private ByteBuffer _ram = new ByteBuffer(256 * 1024); // Up to 256k public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("lowbank_2k", ref _lowbank_2K); - ser.Sync("rambank_1k", ref _rambank_1K); + ser.Sync("lowbank_2k", ref _lowbank2K); + ser.Sync("rambank_1k", ref _rambank1K); ser.Sync("cart_ram", ref _ram); ser.Sync("hasRam", ref _hasRam); } public override void HardReset() { - _lowbank_2K = 0; - _rambank_1K = 0; + _lowbank2K = 0; + _rambank1K = 0; _hasRam = false; _ram = new ByteBuffer(256 * 1024); base.HardReset(); @@ -57,25 +57,25 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 { return base.ReadMemory(addr); } - - if (addr < 0x17FF) // Low 2k Bank + + if (addr < 0x1800) // Low 2k Bank { if (_hasRam) { - if (addr < 0x13FF) + if (addr < 0x1400) { - return _ram[(addr & 0x03FF) + (_rambank_1K << 10)]; + return _ram[(addr & 0x03FF) + (_rambank1K << 10)]; } - return _ram[(addr & 0x03FF) + (_rambank_1K << 10)] = 0xFF; // Reading from the write port triggers an unwanted write + return _ram[(addr & 0x03FF) + (_rambank1K << 10)] = 0xFF; // Reading from the write port triggers an unwanted write } - - return Core.Rom[(_lowbank_2K << 11) + (addr & 0x07FF)]; + + return Core.Rom[(_lowbank2K << 11) + (addr & 0x07FF)]; } - + if (addr < 0x2000) // High bank fixed to last 2k of ROM { - return Core.Rom[(Core.Rom.Length - 2048) + (addr & 0x07FF)]; + return Core.Rom[(Core.Rom.Length - 0x800) + (addr & 0x07FF)]; } return base.ReadMemory(addr); @@ -83,56 +83,38 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public override byte PeekMemory(ushort addr) { - if (addr < 0x1000) - { - return base.ReadMemory(addr); - } - - if (addr < 0x17FF) // Low 2k Bank - { - if (_hasRam) - { - if (addr < 0x13FF) - { - return _ram[(addr & 0x03FF) + (_rambank_1K << 10)]; - } - - return _ram[(addr & 0x03FF) + (_rambank_1K << 10)]; // Reading from the write port triggers an unwanted write - } - - return Core.Rom[(_lowbank_2K << 11) + (addr & 0x07FF)]; - } - - if (addr < 0x2000) // High bank fixed to last 2k of ROM - { - return Core.Rom[(Core.Rom.Length - 2048) + (addr & 0x07FF)]; - } - - return base.ReadMemory(addr); + return ReadMemory(addr); } public override void WriteMemory(ushort addr, byte value) { + if (addr == 0x003E) + { + _hasRam = true; + _rambank1K = value; + if (_rambank1K > 0) + { + int xxx = 0; + xxx++; + int yyy = xxx; + yyy++; + } + } + else if (addr < 0x0040) + { + _hasRam = false; + if ((value << 11) < Core.Rom.Length) + { + _lowbank2K = value; + } + else + { + _lowbank2K = value & (Core.Rom.Length >> 11); + } + } + if (addr < 0x1000) { - if (addr == 0x003E) - { - _hasRam = true; - _rambank_1K = value; - } - else if (addr == 0x003F) - { - _hasRam = false; - if ((value << 11) < Core.Rom.Length) - { - _lowbank_2K = value; - } - else - { - _lowbank_2K = value & (Core.Rom.Length >> 11); - } - } - base.WriteMemory(addr, value); } else if (addr < 0x1400) @@ -141,7 +123,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } else if (addr < 0x1800) // Write port { - _ram[(_rambank_1K << 10) + (addr & 0x3FF)] = value; + _ram[(_rambank1K << 10) + (addr & 0x3FF)] = value; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Mappers/m3F.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Mappers/m3F.cs index e37a028b84..9454c68743 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Mappers/m3F.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Mappers/m3F.cs @@ -44,7 +44,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 return base.ReadMemory(addr); } - if (addr < 0x17FF) // Low 2k Bank + if (addr < 0x1800) // Low 2k Bank { return Core.Rom[(_lowbank2K << 11) + (addr & 0x07FF)]; }