diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF0.cs b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF0.cs index c5407ee11e..01342c2a7f 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF0.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Mappers/mF0.cs @@ -5,8 +5,50 @@ using System.Text; namespace BizHawk.Emulation.Consoles.Atari._2600 { + /* + * F0 (Megaboy) + ----- + + This was used on one game, "megaboy".. Some kind of educational cartridge. It supports + 64K of ROM making it the biggest single production game made during the original run + of the 2600. + + Bankswitching is very simple. There's 16 4K banks, and accessing 1FF0 causes the bank + number to increment. + + This means that you must keep accessing 1FF0 until the bank you want is selected. Each + bank is numbered by means of one of the ROM locations, and the code simply keeps accessing + 1FF0 until the bank it is looking for comes up. + */ + class mF0 : MapperBase { + int bank = 0; + public override byte ReadMemory(ushort addr) + { + if (addr == 0x0220) + Increment(); + + if (addr < 0x1000) return base.ReadMemory(addr); + else return core.rom[bank * 4 * 1024 + (addr & 0xFFF)]; + } + public override void WriteMemory(ushort addr, byte value) + { + if (addr < 0x1000) base.WriteMemory(addr, value); + } + + public override void SyncState(Serializer ser) + { + base.SyncState(ser); + ser.Sync("bank", ref bank); + } + + void Increment() + { + bank++; + if (bank > 15) + bank = 0; + } } }