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

78 lines
1.8 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
{
2017-04-24 13:35:05 +00:00
// Epyx Fastload. Uppermost page is always visible at DFxx.
// They use a capacitor that is discharged by accesses to DExx
// to pull down EXROM. Also, accesses to LOROM while it is active
// discharge the capacitor.
// Thanks to VICE team for the info: http://vice-emu.sourceforge.net/vice_15.html
internal class Mapper000A : CartridgeDevice
2017-04-24 13:35:05 +00:00
{
// This constant differs depending on whose research you reference. TODO: Verify.
[SaveState.DoNotSave]
private const int RESET_CAPACITOR_CYCLES = 512;
[SaveState.SaveWithName("CapacitorCycles")]
private int _capacitorCycles;
[SaveState.DoNotSave]
private readonly int[] _rom;
public Mapper000A(IList<int[]> newData)
{
_rom = new int[0x2000];
Array.Copy(newData.First(), _rom, 0x2000);
pinGame = true;
}
public override void ExecutePhase()
{
pinExRom = !(_capacitorCycles > 0);
if (!pinExRom)
2017-04-24 13:35:05 +00:00
{
_capacitorCycles--;
2017-04-24 13:35:05 +00:00
}
}
public override void HardReset()
{
_capacitorCycles = RESET_CAPACITOR_CYCLES;
base.HardReset();
}
public override int Peek8000(int addr)
{
return _rom[addr & 0x1FFF];
}
public override int PeekDE00(int addr)
{
return 0x00;
}
public override int PeekDF00(int addr)
{
return _rom[(addr & 0xFF) | 0x1F00];
}
public override int Read8000(int addr)
{
_capacitorCycles = RESET_CAPACITOR_CYCLES;
return _rom[addr & 0x1FFF];
}
public override int ReadDE00(int addr)
{
_capacitorCycles = RESET_CAPACITOR_CYCLES;
return 0x00;
}
public override int ReadDF00(int addr)
{
return _rom[(addr & 0xFF) | 0x1F00];
2017-04-24 13:35:05 +00:00
}
}
}