diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper164.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper164.cs index c474459a24..e141344429 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper164.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/Mapper164.cs @@ -7,11 +7,42 @@ namespace BizHawk.Emulation.Consoles.Nintendo { class Mapper164 : NES.NESBoardBase { - //Mapper 164 - //Final Fantasy V (Unl) + /* + * Here are Disch's original notes: + ======================== + = Mapper 164 = + ======================== + + Example Game: + -------------------------- + Final Fantasy V + + + + Registers: + --------------------------- + + Range,Mask: $5000-FFFF, $F300 + + $5000, $D000: PRG reg (32k @ $8000) + + $6000-7FFF may have SRAM (not sure) + + + On Reset + --------------------------- + Reg seems to contain $FF on powerup/reset + + + Notes: + --------------------------- + + Swapping is really simple -- the thing that is funky is the register range/mask. $5000 and $D000 will access + the register, however $5100, $5200, etc will not. + */ - //state - int prg; + int prg_bank; + int prg_bank_mask_32k; public override bool Configure(NES.EDetectionOrigin origin) { @@ -22,34 +53,40 @@ namespace BizHawk.Emulation.Consoles.Nintendo default: return false; } - SetMirrorType(Cart.pad_h, Cart.pad_v); - prg = 0xFF; + prg_bank = 0xFF; + prg_bank_mask_32k = Cart.prg_size / 32 - 1; return true; } public override void WriteEXP(int addr, byte value) { - addr &= 0xF300; - if (addr == 0x5000) - prg = value; + addr = (addr + 0x4000) & 0xF300; + if (addr == 0x5000 || addr == 0xD000) + prg_bank = value; } public override void WritePRG(int addr, byte value) { - addr &= 0xF300; - if (addr == 0xD000) - prg = value; + addr = (addr + 0x8000) & 0xF300; + if (addr == 0x5000 || addr == 0xD000) + prg_bank = value; } - public override byte ReadPPU(int addr) + public override byte ReadPRG(int addr) { - return VROM[addr + (prg * 0x8000)]; + return ROM[addr + ((prg_bank & prg_bank_mask_32k) * 0x8000)]; } public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("prg", ref prg); + ser.Sync("prg", ref prg_bank); + } + + public override void NESSoftReset() + { + prg_bank = 0xFF; + base.NESSoftReset(); } } }