2017-04-24 15:09:17 +00:00
|
|
|
|
using BizHawk.Common;
|
2014-04-06 23:25:59 +00:00
|
|
|
|
|
|
|
|
|
namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|
|
|
|
{
|
|
|
|
|
internal class Multicart4K : MapperBase
|
|
|
|
|
{
|
|
|
|
|
private int _gameTotal;
|
|
|
|
|
private int _currentGame;
|
|
|
|
|
|
2020-03-18 15:37:53 +00:00
|
|
|
|
public Multicart4K(Atari2600 core, int gameTotal)
|
|
|
|
|
: base(core)
|
2014-04-06 23:25:59 +00:00
|
|
|
|
{
|
2020-02-18 00:07:51 +00:00
|
|
|
|
_gameTotal = gameTotal;
|
2014-04-06 23:25:59 +00:00
|
|
|
|
_currentGame = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void SyncState(Serializer ser)
|
|
|
|
|
{
|
|
|
|
|
ser.Sync("gameTotal", ref _gameTotal);
|
|
|
|
|
ser.Sync("currentGame", ref _currentGame);
|
|
|
|
|
base.SyncState(ser);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void HardReset()
|
|
|
|
|
{
|
|
|
|
|
IncrementGame();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override byte ReadMemory(ushort addr)
|
|
|
|
|
{
|
|
|
|
|
if (addr < 0x1000)
|
|
|
|
|
{
|
|
|
|
|
return base.ReadMemory(addr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Core.Rom[(addr & 0xFFF) + (_currentGame * 4096)];
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 00:07:51 +00:00
|
|
|
|
public override byte PeekMemory(ushort addr) => ReadMemory(addr);
|
2020-03-18 20:46:17 +00:00
|
|
|
|
|
|
|
|
|
private void IncrementGame()
|
|
|
|
|
{
|
|
|
|
|
_currentGame++;
|
|
|
|
|
if (_currentGame >= _gameTotal)
|
|
|
|
|
{
|
|
|
|
|
_currentGame = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-06 23:25:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|