Atari - a stab at implementing mapper m4A50, don't work, oh well, the mapper is garbage and overly complicated, and can't really exist
This commit is contained in:
parent
33e9f23e75
commit
4f045eb20d
|
@ -32,6 +32,222 @@ namespace BizHawk.Emulation.Consoles.Atari._2600
|
|||
|
||||
class m4A50 : MapperBase
|
||||
{
|
||||
int myLastData = 0xFF;
|
||||
int myLastAddress = 0xFFFF;
|
||||
|
||||
bool myIsRomHigh = true;
|
||||
bool myBankChanged = true;
|
||||
bool myIsRomLow = true;
|
||||
bool myIsRomMiddle = true;
|
||||
|
||||
int mySliceHigh = 0;
|
||||
int mySliceLow = 0;
|
||||
int mySliceMiddle = 0;
|
||||
|
||||
ByteBuffer myRAM = new ByteBuffer(32768);
|
||||
|
||||
|
||||
public override byte ReadMemory(ushort addr)
|
||||
{
|
||||
byte val = 0;
|
||||
if (addr < 0x1000)
|
||||
{
|
||||
val = base.ReadMemory(addr);
|
||||
checkBankSwitch(addr, val);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((addr & 0x1800) == 0x1000) // 2K region from 0x1000 - 0x17ff
|
||||
{
|
||||
val = myIsRomLow ? core.rom[(addr & 0x7ff) + mySliceLow]
|
||||
: myRAM[(addr & 0x7ff) + mySliceLow];
|
||||
}
|
||||
else if (((addr & 0x1fff) >= 0x1800) && // 1.5K region from 0x1800 - 0x1dff
|
||||
((addr & 0x1fff) <= 0x1dff))
|
||||
{
|
||||
val = myIsRomMiddle ? core.rom[(addr & 0x7ff) + mySliceMiddle]
|
||||
: myRAM[(addr & 0x7ff) + mySliceMiddle];
|
||||
}
|
||||
else if ((addr & 0x1f00) == 0x1e00) // 256B region from 0x1e00 - 0x1eff
|
||||
{
|
||||
val = myIsRomHigh ? core.rom[(addr & 0xff) + mySliceHigh]
|
||||
: myRAM[(addr & 0xff) + mySliceHigh];
|
||||
}
|
||||
else if ((addr & 0x1f00) == 0x1f00) // 256B region from 0x1f00 - 0x1fff
|
||||
{
|
||||
val = core.rom[(addr & 0xff) + (core.rom.Length - 256)];
|
||||
if (((myLastData & 0xe0) == 0x60) &&
|
||||
((myLastAddress >= 0x1000) || (myLastAddress < 0x200)))
|
||||
mySliceHigh = (mySliceHigh & 0xf0ff) | ((addr & 0x8) << 8) |
|
||||
((addr & 0x70) << 4);
|
||||
}
|
||||
}
|
||||
|
||||
myLastData = val;
|
||||
myLastAddress = addr & 0x1fff;
|
||||
return val;
|
||||
}
|
||||
|
||||
public override void WriteMemory(ushort addr, byte value)
|
||||
{
|
||||
if (addr < 0x1000) // Hotspots below 0x1000
|
||||
{
|
||||
base.WriteMemory(addr, value);
|
||||
checkBankSwitch(addr, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (addr < 0x1800) // 2K region at 0x1000 - 0x17ff
|
||||
{
|
||||
if (!myIsRomLow)
|
||||
{
|
||||
myRAM[(addr & 0x7ff) + mySliceLow] = value;
|
||||
myBankChanged = true;
|
||||
}
|
||||
}
|
||||
else if (((addr & 0x1fff) >= 0x1800) && // 1.5K region at 0x1800 - 0x1dff
|
||||
((addr & 0x1fff) <= 0x1dff))
|
||||
{
|
||||
if (!myIsRomMiddle)
|
||||
{
|
||||
myRAM[(addr & 0x7ff) + mySliceMiddle] = value;
|
||||
myBankChanged = true;
|
||||
}
|
||||
}
|
||||
else if ((addr & 0x1f00) == 0x1e00) // 256B region at 0x1e00 - 0x1eff
|
||||
{
|
||||
if (!myIsRomHigh)
|
||||
{
|
||||
myRAM[(addr & 0xff) + mySliceHigh] = value;
|
||||
myBankChanged = true;
|
||||
}
|
||||
}
|
||||
else if ((addr & 0x1f00) == 0x1f00) // 256B region at 0x1f00 - 0x1fff
|
||||
{
|
||||
if (((myLastData & 0xe0) == 0x60) &&
|
||||
((myLastAddress >= 0x1000) || (myLastAddress < 0x200)))
|
||||
{
|
||||
mySliceHigh = (mySliceHigh & 0xf0ff) | ((addr & 0x8) << 8) |
|
||||
((addr & 0x70) << 4);
|
||||
myBankChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
myLastData = value;
|
||||
myLastAddress = addr & 0x1fff;
|
||||
}
|
||||
|
||||
void checkBankSwitch(ushort address, byte value)
|
||||
{
|
||||
if (((myLastData & 0xe0) == 0x60) && // Switch lower/middle/upper bank
|
||||
((myLastAddress >= 0x1000) || (myLastAddress < 0x200)))
|
||||
{
|
||||
if ((address & 0x0f00) == 0x0c00) // Enable 256B of ROM at 0x1e00 - 0x1eff
|
||||
{
|
||||
myIsRomHigh = true;
|
||||
mySliceHigh = (address & 0xff) << 8;
|
||||
myBankChanged = true;
|
||||
}
|
||||
else if ((address & 0x0f00) == 0x0d00) // Enable 256B of RAM at 0x1e00 - 0x1eff
|
||||
{
|
||||
myIsRomHigh = false;
|
||||
mySliceHigh = (address & 0x7f) << 8;
|
||||
myBankChanged = true;
|
||||
}
|
||||
else if ((address & 0x0f40) == 0x0e00) // Enable 2K of ROM at 0x1000 - 0x17ff
|
||||
{
|
||||
myIsRomLow = true;
|
||||
mySliceLow = (address & 0x1f) << 11;
|
||||
myBankChanged = true;
|
||||
}
|
||||
else if ((address & 0x0f40) == 0x0e40) // Enable 2K of RAM at 0x1000 - 0x17ff
|
||||
{
|
||||
myIsRomLow = false;
|
||||
mySliceLow = (address & 0xf) << 11;
|
||||
myBankChanged = true;
|
||||
}
|
||||
else if ((address & 0x0f40) == 0x0f00) // Enable 1.5K of ROM at 0x1800 - 0x1dff
|
||||
{
|
||||
myIsRomMiddle = true;
|
||||
mySliceMiddle = (address & 0x1f) << 11;
|
||||
myBankChanged = true;
|
||||
}
|
||||
else if ((address & 0x0f50) == 0x0f40) // Enable 1.5K of RAM at 0x1800 - 0x1dff
|
||||
{
|
||||
myIsRomMiddle = false;
|
||||
mySliceMiddle = (address & 0xf) << 11;
|
||||
myBankChanged = true;
|
||||
}
|
||||
else if ((address & 0x0f00) == 0x0400) // Toggle bit A11 of lower block address
|
||||
{
|
||||
mySliceLow = mySliceLow ^ 0x800;
|
||||
myBankChanged = true;
|
||||
}
|
||||
else if ((address & 0x0f00) == 0x0500) // Toggle bit A12 of lower block address
|
||||
{
|
||||
mySliceLow = mySliceLow ^ 0x1000;
|
||||
myBankChanged = true;
|
||||
}
|
||||
else if ((address & 0x0f00) == 0x0800) // Toggle bit A11 of middle block address
|
||||
{
|
||||
mySliceMiddle = mySliceMiddle ^ 0x800;
|
||||
myBankChanged = true;
|
||||
}
|
||||
else if ((address & 0x0f00) == 0x0900) // Toggle bit A12 of middle block address
|
||||
{
|
||||
mySliceMiddle = mySliceMiddle ^ 0x1000;
|
||||
myBankChanged = true;
|
||||
}
|
||||
|
||||
// Zero-page hotspots for upper page
|
||||
// 0xf4, 0xf6, 0xfc, 0xfe for ROM
|
||||
// 0xf5, 0xf7, 0xfd, 0xff for RAM
|
||||
// 0x74 - 0x7f (0x80 bytes lower)
|
||||
if ((address & 0xf75) == 0x74) // Enable 256B of ROM at 0x1e00 - 0x1eff
|
||||
{
|
||||
myIsRomHigh = true;
|
||||
mySliceHigh = value << 8;
|
||||
myBankChanged = true;
|
||||
}
|
||||
else if ((address & 0xf75) == 0x75) // Enable 256B of RAM at 0x1e00 - 0x1eff
|
||||
{
|
||||
myIsRomHigh = false;
|
||||
mySliceHigh = (value & 0x7f) << 8;
|
||||
myBankChanged = true;
|
||||
}
|
||||
|
||||
// Zero-page hotspots for lower and middle blocks
|
||||
// 0xf8, 0xf9, 0xfa, 0xfb
|
||||
// 0x78, 0x79, 0x7a, 0x7b (0x80 bytes lower)
|
||||
else if ((address & 0xf7c) == 0x78)
|
||||
{
|
||||
if ((value & 0xf0) == 0) // Enable 2K of ROM at 0x1000 - 0x17ff
|
||||
{
|
||||
myIsRomLow = true;
|
||||
mySliceLow = (value & 0xf) << 11;
|
||||
myBankChanged = true;
|
||||
}
|
||||
else if ((value & 0xf0) == 0x40) // Enable 2K of RAM at 0x1000 - 0x17ff
|
||||
{
|
||||
myIsRomLow = false;
|
||||
mySliceLow = (value & 0xf) << 11;
|
||||
myBankChanged = true;
|
||||
}
|
||||
else if ((value & 0xf0) == 0x90) // Enable 1.5K of ROM at 0x1800 - 0x1dff
|
||||
{
|
||||
myIsRomMiddle = true;
|
||||
mySliceMiddle = ((value & 0xf) | 0x10) << 11;
|
||||
myBankChanged = true;
|
||||
}
|
||||
else if ((value & 0xf0) == 0xc0) // Enable 1.5K of RAM at 0x1800 - 0x1dff
|
||||
{
|
||||
myIsRomMiddle = false;
|
||||
mySliceMiddle = (value & 0xf) << 11;
|
||||
myBankChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2691,4 +2691,6 @@ sha1:080deaf5fe7c0e3b132365bfe9e8003becf3498d Ko Avgn - Ntsc - 2009-08-16 A26
|
|||
sha1:63C12146C183BCCBF05C0044A961DC40790E3212 Pleiades (1983) (UA Limited) (Prototype) A26 m=UA
|
||||
sha1:86BBE6E62DACF6E5CD771BD9249C4ED51BF60092 dungeon_rc4 A26 m=F4
|
||||
sha1:C11F59AE0ECD376AF52AE57B5BE8B6F039DE0D0E MegaBoy (X07 Bankswitching Conversion) (2008) (Fred Quimby) A26 m=X07
|
||||
sha1:54399CE15B443E789B8537306BC5AC3BB48B888D MegaBoy (EF Bankswitching Conversion) (2008) (Fred Quimby) A26 m=EF
|
||||
sha1:54399CE15B443E789B8537306BC5AC3BB48B888D MegaBoy (EF Bankswitching Conversion) (2008) (Fred Quimby) A26 m=EF
|
||||
sha1:3797959E4A3236B6562CE15AF7D96633F6720FC8 Fu Kung! - 2 Dancing Babies Demo (3F Bankswitching) (Andrew Davie) A26 m=3F
|
||||
sha1:95D67B058EC40E8C5525365714D221E4C6B3C97D Ruby Runner Demo (4A50 Bankswitching) (2006) (John Payson) (WIP) A26 m=4A50
|
Loading…
Reference in New Issue