2013-11-04 00:36:15 +00:00
|
|
|
|
using BizHawk.Common;
|
|
|
|
|
|
2013-11-13 03:32:25 +00:00
|
|
|
|
namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
2012-03-31 20:53:14 +00:00
|
|
|
|
{
|
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.
|
|
|
|
|
*/
|
2012-04-02 02:53:43 +00:00
|
|
|
|
|
2014-04-02 21:27:14 +00:00
|
|
|
|
internal class mFA : MapperBase
|
2012-03-31 20:53:14 +00:00
|
|
|
|
{
|
2013-04-16 00:42:57 +00:00
|
|
|
|
int toggle;
|
2012-04-02 02:53:43 +00:00
|
|
|
|
ByteBuffer aux_ram = new ByteBuffer(256);
|
2012-04-02 01:54:51 +00:00
|
|
|
|
|
2013-03-11 01:46:12 +00:00
|
|
|
|
private byte ReadMem(ushort addr, bool peek)
|
2012-04-02 01:54:51 +00:00
|
|
|
|
{
|
2013-03-11 01:46:12 +00:00
|
|
|
|
if (!peek)
|
|
|
|
|
{
|
|
|
|
|
Address(addr);
|
|
|
|
|
}
|
2012-04-02 01:54:51 +00:00
|
|
|
|
|
2013-03-11 01:46:12 +00:00
|
|
|
|
if (addr < 0x1000)
|
|
|
|
|
{
|
2012-04-02 01:54:51 +00:00
|
|
|
|
return base.ReadMemory(addr);
|
2013-03-11 01:46:12 +00:00
|
|
|
|
}
|
2012-04-02 02:53:43 +00:00
|
|
|
|
else if (addr < 0x1100)
|
2013-03-11 01:46:12 +00:00
|
|
|
|
{
|
|
|
|
|
return 0xFF;
|
|
|
|
|
}
|
2012-04-02 02:53:43 +00:00
|
|
|
|
else if (addr < 0x1200)
|
2013-03-11 01:46:12 +00:00
|
|
|
|
{
|
2012-04-02 02:53:43 +00:00
|
|
|
|
return aux_ram[addr & 0xFF];
|
2013-03-11 01:46:12 +00:00
|
|
|
|
}
|
2012-04-02 01:54:51 +00:00
|
|
|
|
else
|
2013-03-11 01:46:12 +00:00
|
|
|
|
{
|
2013-04-16 00:42:57 +00:00
|
|
|
|
return core.rom[(toggle << 12) + (addr & 0xFFF)];
|
2013-03-11 01:46:12 +00:00
|
|
|
|
}
|
2012-04-02 01:54:51 +00:00
|
|
|
|
}
|
2013-03-11 01:46:12 +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);
|
2012-04-02 02:53:43 +00:00
|
|
|
|
if (addr < 0x1000)
|
|
|
|
|
base.WriteMemory(addr, value);
|
2012-04-02 03:02:49 +00:00
|
|
|
|
else if (addr < 0x1100)
|
2012-04-02 02:53:43 +00:00
|
|
|
|
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);
|
2012-04-02 02:53:43 +00:00
|
|
|
|
ser.Sync("ram", ref aux_ram);
|
2012-04-02 01:54:51 +00:00
|
|
|
|
}
|
2012-03-31 20:53:14 +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;
|
|
|
|
|
}
|
2012-03-31 20:53:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|