AxibugEmuOnline/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper096.cs

73 lines
1.6 KiB
C#
Raw Normal View History

2024-08-04 23:37:02 +08:00
////////////////////////////////
// Mapper096 Bandai 74161 //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using BYTE = System.Byte;
2024-08-16 10:20:00 +08:00
2024-08-04 23:37:02 +08:00
namespace VirtualNes.Core
{
2024-08-16 10:20:00 +08:00
public class Mapper096 : Mapper
{
BYTE[] reg = new byte[2];
public Mapper096(NES parent) : base(parent)
{
}
2024-08-04 23:37:02 +08:00
2024-08-16 10:20:00 +08:00
public override void Reset()
{
reg[0] = reg[1] = 0;
2024-08-04 23:37:02 +08:00
2024-08-16 10:20:00 +08:00
SetPROM_32K_Bank(0, 1, 2, 3);
SetBank();
2024-08-04 23:37:02 +08:00
2024-08-16 10:20:00 +08:00
SetVRAM_Mirror(VRAM_MIRROR4L);
}
2024-08-04 23:37:02 +08:00
2024-08-16 10:20:00 +08:00
//void Mapper096::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
SetPROM_32K_Bank(data & 0x03);
2024-08-04 23:37:02 +08:00
2024-08-16 10:20:00 +08:00
reg[0] = (byte)((data & 0x04) >> 2);
SetBank();
}
2024-08-04 23:37:02 +08:00
2024-08-16 10:20:00 +08:00
public override void PPU_Latch(ushort addr)
{
if ((addr & 0xF000) == 0x2000)
{
reg[1] = (byte)((addr >> 8) & 0x03);
SetBank();
}
}
2024-08-04 23:37:02 +08:00
2024-08-16 10:20:00 +08:00
void SetBank()
{
SetCRAM_4K_Bank(0, reg[0] * 4 + reg[1]);
SetCRAM_4K_Bank(4, reg[0] * 4 + 0x03);
}
2024-08-04 23:37:02 +08:00
2024-08-16 10:20:00 +08:00
//void Mapper096::SaveState(LPBYTE p)
public override void SaveState(byte[] p)
{
p[0] = reg[0];
p[1] = reg[1];
}
2024-08-04 23:37:02 +08:00
2024-08-16 10:20:00 +08:00
//void Mapper096::LoadState(LPBYTE p)
public override void LoadState(byte[] p)
{
reg[0] = p[0];
reg[1] = p[1];
}
2024-08-04 23:37:02 +08:00
2024-08-16 10:20:00 +08:00
public override bool IsStateSave()
{
return true;
}
2024-08-04 23:37:02 +08:00
2024-08-16 10:20:00 +08:00
}
2024-08-04 23:37:02 +08:00
}