Atari 2600 - Implement mapper FA2

This commit is contained in:
adelikat 2014-04-05 00:58:43 +00:00
parent cf1a50c195
commit a2b2651330
1 changed files with 70 additions and 3 deletions

View File

@ -1,4 +1,4 @@
using System;
using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
@ -10,9 +10,76 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
*/
internal class mFA2 : MapperBase
{
public mFA2()
private int _bank4k;
private ByteBuffer _auxRam = new ByteBuffer(256);
private byte ReadMem(ushort addr, bool peek)
{
throw new NotImplementedException();
if (!peek)
{
Address(addr);
}
if (addr < 0x1000)
{
return base.ReadMemory(addr);
}
if (addr < 0x1100)
{
return 0xFF;
}
if (addr < 0x1200)
{
return _auxRam[addr & 0xFF];
}
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);
}
else if (addr < 0x1100)
{
_auxRam[addr & 0xFF] = value;
}
}
public override void SyncState(Serializer ser)
{
base.SyncState(ser);
ser.Sync("bank4k", ref _bank4k);
ser.Sync("auxRam", ref _auxRam);
}
private void Address(ushort addr)
{
if (addr == 0x1FF5) _bank4k = 0;
if (addr == 0x1FF6) _bank4k = 1;
if (addr == 0x1FF7) _bank4k = 2;
if (addr == 0x1FF8) _bank4k = 3;
if (addr == 0x1FF9) _bank4k = 4;
if (addr == 0x1FFA) _bank4k = 5;
if (addr == 0x1FFB && core.rom.Length == 28 * 1024) // Only available on 28k Roms
{
_bank4k = 6;
}
}
}
}