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 16:51:41 +00:00
|
|
|
|
/*
|
2012-04-29 21:01:06 +00:00
|
|
|
|
F0 (Megaboy)
|
2012-04-02 16:51:41 +00:00
|
|
|
|
-----
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
*/
|
|
|
|
|
|
2014-04-02 21:27:14 +00:00
|
|
|
|
internal class mF0 : MapperBase
|
2012-03-31 20:53:14 +00:00
|
|
|
|
{
|
2013-04-16 00:42:57 +00:00
|
|
|
|
int bank;
|
2012-04-02 16:51:41 +00:00
|
|
|
|
|
2013-03-11 01:46:12 +00:00
|
|
|
|
private byte ReadMem(ushort addr, bool peek)
|
2012-04-02 16:51:41 +00:00
|
|
|
|
{
|
2013-03-11 01:46:12 +00:00
|
|
|
|
if (!peek)
|
|
|
|
|
{
|
|
|
|
|
if (addr == 0x1FF0)
|
|
|
|
|
Increment();
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-02 16:51:41 +00:00
|
|
|
|
if (addr < 0x1000) return base.ReadMemory(addr);
|
2013-04-16 00:42:57 +00:00
|
|
|
|
else return core.rom[(bank << 12) + (addr & 0xFFF)];
|
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 16:51:41 +00:00
|
|
|
|
}
|
2013-03-11 01:46:12 +00:00
|
|
|
|
|
2012-04-02 16:51:41 +00:00
|
|
|
|
public override void WriteMemory(ushort addr, byte value)
|
|
|
|
|
{
|
|
|
|
|
if (addr < 0x1000) base.WriteMemory(addr, value);
|
2012-10-15 15:17:20 +00:00
|
|
|
|
else if (addr == 0x1ff0)
|
|
|
|
|
Increment();
|
2012-04-02 16:51:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void SyncState(Serializer ser)
|
|
|
|
|
{
|
|
|
|
|
base.SyncState(ser);
|
|
|
|
|
ser.Sync("bank", ref bank);
|
|
|
|
|
}
|
2012-03-31 20:53:14 +00:00
|
|
|
|
|
2012-04-02 16:51:41 +00:00
|
|
|
|
void Increment()
|
|
|
|
|
{
|
|
|
|
|
bank++;
|
2012-04-05 23:46:01 +00:00
|
|
|
|
bank &= 0x0F;
|
2012-04-02 16:51:41 +00:00
|
|
|
|
}
|
2012-03-31 20:53:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|