AxibugEmuOnline/AxibugEmuOnline.Client/Assets/MyNes.Core/Mapper076.cs

78 lines
1.9 KiB
C#
Raw Normal View History

2024-07-03 18:15:28 +08:00
using System.IO;
2024-07-03 18:22:22 +08:00
namespace MyNes.Core
2024-07-03 18:15:28 +08:00
{
2024-07-03 18:22:22 +08:00
[BoardInfo("Namco 109", 76)]
internal class Mapper076 : Board
{
private int address_8001;
2024-07-03 18:15:28 +08:00
2024-07-03 18:22:22 +08:00
private bool prg_a;
2024-07-03 18:15:28 +08:00
2024-07-03 18:22:22 +08:00
private byte prg_reg;
2024-07-03 18:15:28 +08:00
2024-07-03 18:22:22 +08:00
internal override void HardReset()
{
base.HardReset();
Switch08KPRG(PRG_ROM_08KB_Mask - 1, PRGArea.AreaC000);
Switch08KPRG(PRG_ROM_08KB_Mask, PRGArea.AreaE000);
address_8001 = 0;
prg_a = false;
}
2024-07-03 18:15:28 +08:00
2024-07-03 18:22:22 +08:00
internal override void WritePRG(ref ushort address, ref byte data)
{
switch (address & 0xE001)
{
case 32768:
address_8001 = data & 7;
prg_a = (data & 0x40) == 64;
Switch08KPRG(prg_reg, prg_a ? PRGArea.AreaC000 : PRGArea.Area8000);
break;
case 32769:
switch (address_8001)
{
case 2:
Switch02KCHR(data, CHRArea.Area0000);
break;
case 3:
Switch02KCHR(data, CHRArea.Area0800);
break;
case 4:
Switch02KCHR(data, CHRArea.Area1000);
break;
case 5:
Switch02KCHR(data, CHRArea.Area1800);
break;
case 6:
Switch08KPRG(prg_reg = data, prg_a ? PRGArea.AreaC000 : PRGArea.Area8000);
break;
case 7:
Switch08KPRG(data, PRGArea.AreaA000);
break;
}
break;
case 40960:
Switch01KNMTFromMirroring(((data & 1) == 1) ? Mirroring.Horz : Mirroring.Vert);
break;
}
}
2024-07-03 18:15:28 +08:00
2024-07-03 18:22:22 +08:00
internal override void WriteStateData(ref BinaryWriter stream)
{
base.WriteStateData(ref stream);
stream.Write(address_8001);
stream.Write(prg_a);
stream.Write(prg_reg);
}
2024-07-03 18:15:28 +08:00
2024-07-03 18:22:22 +08:00
internal override void ReadStateData(ref BinaryReader stream)
{
base.ReadStateData(ref stream);
address_8001 = stream.ReadInt32();
prg_a = stream.ReadBoolean();
prg_reg = stream.ReadByte();
}
}
2024-07-03 15:40:13 +08:00
}