BizHawk/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000B.cs

68 lines
1.4 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using BizHawk.Common;
2016-02-22 23:50:11 +00:00
namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
{
2017-04-24 13:35:05 +00:00
// Westermann Learning mapper.
// Starts up with both banks enabled, any read to DFxx
// turns off the high bank by bringing GAME high.
// I suspect that the game loads by copying all hirom to
// the RAM underneath (BASIC variable values probably)
// and then disables once loaded.
internal sealed class Mapper000B : CartridgeDevice
2017-04-24 13:35:05 +00:00
{
private readonly int[] _rom = new int[0x4000];
2016-02-22 23:50:11 +00:00
public Mapper000B(IList<int> newAddresses, IList<int[]> newData)
{
validCartridge = false;
2016-02-22 23:50:11 +00:00
for (var i = 0; i < 0x4000; i++)
2017-05-30 17:09:46 +00:00
{
_rom[i] = 0xFF;
2017-05-30 17:09:46 +00:00
}
2016-02-22 23:50:11 +00:00
if (newAddresses[0] != 0x8000)
2017-04-24 13:35:05 +00:00
{
return;
2017-04-24 13:35:05 +00:00
}
2016-02-22 23:50:11 +00:00
Array.Copy(newData[0], _rom, Math.Min(newData[0].Length, 0x4000));
validCartridge = true;
}
2016-02-22 23:50:11 +00:00
protected override void SyncStateInternal(Serializer ser)
{
// Nothing to save
}
public override int Peek8000(int addr)
{
return _rom[addr];
}
2016-02-22 23:50:11 +00:00
public override int PeekA000(int addr)
{
return _rom[addr | 0x2000];
}
2016-02-22 23:50:11 +00:00
public override int Read8000(int addr)
{
return _rom[addr];
}
public override int ReadA000(int addr)
{
return _rom[addr | 0x2000];
2017-04-24 13:35:05 +00:00
}
2016-02-22 23:50:11 +00:00
public override int ReadDF00(int addr)
{
pinGame = true;
return base.ReadDF00(addr);
}
}
}