BizHawk/BizHawk.Emulation.Cores/Consoles/Atari/2600/Mappers/mFA.cs

81 lines
1.7 KiB
C#
Raw Normal View History

using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
2012-04-02 01:54:51 +00:00
/*
FA (RAM Plus)
-----
CBS Thought they'd throw a few tricks of their own at the 2600 with this. It's got
12K of ROM and 256 bytes of RAM.
This works similar to F8, except there's only 3 4K ROM banks. The banks are selected by
accessing 1FF8, 1FF9, and 1FFA. There's also 256 bytes of RAM mapped into 1000-11FF.
The write port is at 1000-10FF, and the read port is 1100-11FF.
*/
internal class mFA : MapperBase
{
2013-04-16 00:42:57 +00:00
int toggle;
ByteBuffer aux_ram = new ByteBuffer(256);
2012-04-02 01:54:51 +00:00
private byte ReadMem(ushort addr, bool peek)
2012-04-02 01:54:51 +00:00
{
if (!peek)
{
Address(addr);
}
2012-04-02 01:54:51 +00:00
if (addr < 0x1000)
{
2012-04-02 01:54:51 +00:00
return base.ReadMemory(addr);
}
else if (addr < 0x1100)
{
return 0xFF;
}
else if (addr < 0x1200)
{
return aux_ram[addr & 0xFF];
}
2012-04-02 01:54:51 +00:00
else
{
2013-04-16 00:42:57 +00:00
return core.rom[(toggle << 12) + (addr & 0xFFF)];
}
2012-04-02 01:54:51 +00:00
}
public override byte ReadMemory(ushort addr)
{
return ReadMem(addr, false);
}
public override byte PeekMemory(ushort addr)
{
return ReadMem(addr, true);
}
2012-04-02 01:54:51 +00:00
public override void WriteMemory(ushort addr, byte value)
{
Address(addr);
if (addr < 0x1000)
base.WriteMemory(addr, value);
2012-04-02 03:02:49 +00:00
else if (addr < 0x1100)
aux_ram[addr & 0xFF] = value;
2012-04-02 01:54:51 +00:00
}
public override void SyncState(Serializer ser)
{
base.SyncState(ser);
ser.Sync("toggle", ref toggle);
ser.Sync("ram", ref aux_ram);
2012-04-02 01:54:51 +00:00
}
2012-04-02 01:54:51 +00:00
void Address(ushort addr)
{
if (addr == 0x1FF8) toggle = 0;
if (addr == 0x1FF9) toggle = 1;
if (addr == 0x1FFA) toggle = 2;
}
}
}