diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Mappers/m0840.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Mappers/m0840.cs index 5ff0bc572c..51a71e0543 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Mappers/m0840.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Mappers/m0840.cs @@ -1,4 +1,4 @@ -using System; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Atari.Atari2600 { @@ -23,9 +23,59 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 */ internal class m0840 : MapperBase { - public m0840() + private int _bank4K; + + private byte ReadMem(ushort addr, bool peek) { - throw new NotImplementedException(); + if (!peek) + { + Address(addr); + } + + if (addr < 0x1000) + { + return base.ReadMemory(addr); + } + + return core.rom[(_bank4K << 12) + (addr & 0xFFF)]; + } + + public override byte ReadMemory(ushort addr) + { + return ReadMem(addr, false); + } + + public override byte PeekMemory(ushort addr) + { + return ReadMem(addr, true); + } + + public override void WriteMemory(ushort addr, byte value) + { + Address(addr); + if (addr < 0x1000) + { + base.WriteMemory(addr, value); + } + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("bank_4k", ref _bank4K); + } + + private void Address(ushort addr) + { + switch (addr & 0x1840) + { + case 0x0800: + _bank4K = 0; + break; + case 0x0840: + _bank4K = 1; + break; + } } } } diff --git a/output/gamedb/gamedb_a2600.txt b/output/gamedb/gamedb_a2600.txt index 2ef25837ef..9f1c2787d6 100644 --- a/output/gamedb/gamedb_a2600.txt +++ b/output/gamedb/gamedb_a2600.txt @@ -2696,4 +2696,5 @@ sha1:3797959E4A3236B6562CE15AF7D96633F6720FC8 Fu Kung! - 2 Dancing Babies Demo sha1:95D67B058EC40E8C5525365714D221E4C6B3C97D Ruby Runner Demo (4A50 Bankswitching) (2006) (John Payson) (WIP) A26 m=4A50 sha1:9CD8217DCCBE60F9A25A930D614EE5384F432A83 Boulder Dash (2005) (Andrew Davie) (WIP) A26 m=3E sha1:00CCF622E7BA4D0A39DCBABAB771CE815B0FB8FE Boulder Dash (2005) (Andrew Davie) (WIP) (PAL A26 m=3E -sha1:650DA2339D41D1D2F180A6CAFE8DC311AC588ACD Boulder Dash Intro Tune (2005) (Erik Ehrling) A26 m=3E \ No newline at end of file +sha1:650DA2339D41D1D2F180A6CAFE8DC311AC588ACD Boulder Dash Intro Tune (2005) (Erik Ehrling) A26 m=3E +sha1:F28E52921646A18467577370808454F494C15EFE 0840 EconoBanking A26 m=0840 \ No newline at end of file