2024-08-05 00:44:30 +08:00
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Mapper050 SMB2J //
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
using static VirtualNes.Core.CPU;
|
2024-08-16 10:20:00 +08:00
|
|
|
|
using static VirtualNes.MMU;
|
2024-08-05 00:44:30 +08:00
|
|
|
|
using BYTE = System.Byte;
|
2024-08-16 10:20:00 +08:00
|
|
|
|
|
2024-08-05 00:44:30 +08:00
|
|
|
|
|
|
|
|
|
namespace VirtualNes.Core
|
|
|
|
|
{
|
2024-08-16 10:20:00 +08:00
|
|
|
|
public class Mapper050 : Mapper
|
|
|
|
|
{
|
|
|
|
|
BYTE irq_enable;
|
|
|
|
|
public Mapper050(NES parent) : base(parent)
|
|
|
|
|
{
|
|
|
|
|
}
|
2024-08-05 00:44:30 +08:00
|
|
|
|
|
2024-08-16 10:20:00 +08:00
|
|
|
|
public override void Reset()
|
|
|
|
|
{
|
|
|
|
|
irq_enable = 0;
|
|
|
|
|
SetPROM_8K_Bank(3, 15);
|
|
|
|
|
SetPROM_8K_Bank(4, 8);
|
|
|
|
|
SetPROM_8K_Bank(5, 9);
|
|
|
|
|
SetPROM_8K_Bank(6, 0);
|
|
|
|
|
SetPROM_8K_Bank(7, 11);
|
|
|
|
|
if (VROM_1K_SIZE != 0)
|
|
|
|
|
{
|
|
|
|
|
SetVROM_8K_Bank(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-05 00:44:30 +08:00
|
|
|
|
|
2024-08-16 10:20:00 +08:00
|
|
|
|
//void Mapper050::ExWrite(WORD addr, BYTE data)
|
|
|
|
|
public override void ExWrite(ushort addr, byte data)
|
|
|
|
|
{
|
|
|
|
|
if ((addr & 0xE060) == 0x4020)
|
|
|
|
|
{
|
|
|
|
|
if ((addr & 0x0100) != 0)
|
|
|
|
|
{
|
|
|
|
|
irq_enable = (byte)(data & 0x01);
|
|
|
|
|
nes.cpu.ClrIRQ(IRQ_MAPPER);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SetPROM_8K_Bank(6, (data & 0x08) | ((data & 0x01) << 2) | ((data & 0x06) >> 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-05 00:44:30 +08:00
|
|
|
|
|
2024-08-16 10:20:00 +08:00
|
|
|
|
//void Mapper050::WriteLow(WORD addr, BYTE data)
|
|
|
|
|
public override void WriteLow(ushort addr, byte data)
|
|
|
|
|
{
|
|
|
|
|
if ((addr & 0xE060) == 0x4020)
|
|
|
|
|
{
|
|
|
|
|
if ((addr & 0x0100) != 0)
|
|
|
|
|
{
|
|
|
|
|
irq_enable = (byte)(data & 0x01);
|
|
|
|
|
nes.cpu.ClrIRQ(IRQ_MAPPER);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SetPROM_8K_Bank(6, (data & 0x08) | ((data & 0x01) << 2) | ((data & 0x06) >> 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-05 00:44:30 +08:00
|
|
|
|
|
2024-08-16 10:20:00 +08:00
|
|
|
|
//void Mapper050::HSync(INT scanline)
|
|
|
|
|
public override void HSync(int scanline)
|
|
|
|
|
{
|
|
|
|
|
if (irq_enable != 0)
|
|
|
|
|
{
|
|
|
|
|
if (scanline == 21)
|
|
|
|
|
{
|
|
|
|
|
// nes.cpu.IRQ();
|
|
|
|
|
nes.cpu.SetIRQ(IRQ_MAPPER);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-05 00:44:30 +08:00
|
|
|
|
|
2024-08-16 10:20:00 +08:00
|
|
|
|
//void Mapper050::SaveState(LPBYTE p)
|
|
|
|
|
public override void SaveState(byte[] p)
|
|
|
|
|
{
|
|
|
|
|
p[0] = irq_enable;
|
|
|
|
|
}
|
2024-08-05 00:44:30 +08:00
|
|
|
|
|
2024-08-16 10:20:00 +08:00
|
|
|
|
//void Mapper050::LoadState(LPBYTE p)
|
|
|
|
|
public override void LoadState(byte[] p)
|
|
|
|
|
{
|
|
|
|
|
irq_enable = p[0];
|
|
|
|
|
}
|
2024-08-05 00:44:30 +08:00
|
|
|
|
|
|
|
|
|
|
2024-08-16 10:20:00 +08:00
|
|
|
|
public override bool IsStateSave()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2024-08-05 00:44:30 +08:00
|
|
|
|
|
2024-08-16 10:20:00 +08:00
|
|
|
|
}
|
2024-08-05 00:44:30 +08:00
|
|
|
|
}
|