diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper245.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper245.cs index 052f905c98..931fc394a8 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper245.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper245.cs @@ -7,65 +7,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo { class Mapper245 : MMC3Board_Base { - /* - Here are Disch's original notes: - ======================== - = Mapper 245 = - ======================== - - - Example Games: - -------------------------- - Chu Han Zheng Ba - The War Between Chu & Han - Xing Ji Wu Shi - Super Fighter - Yin He Shi Dai - Yong Zhe Dou e Long - Dragon Quest VII (As) - Dong Fang de Chuan Shuo - The Hyrule Fantasy - - - Notes: - --------------------------- - Another ?Chinese? MMC3 clone. Very similar to your typical MMC3. For MMC3 info, see mapper 004. - - Register layout is identical to a typical MMC3. - - - - CHR Setup: - --------------------------- - - CHR-RAM is not swappable. When there is no CHR-ROM present, 8k CHR-RAM is fixed. However the CHR Mode bit - ($8000.7) can still "flip" the left/right pattern tables. - - Example: - - $0000 $0400 $0800 $0C00 $1000 $1400 $1800 $1C00 - +-------------------------------+-------------------------------+ - CHR-RAM, Mode 0: | { 0 } | { 1 } | - +-------------------------------+-------------------------------+ - CHR-RAM, Mode 1: | { 1 } | { 0 } | - +---------------------------------------------------------------+ - CHR-ROM: | Typical MMC3 | - +---------------------------------------------------------------+ - - - PRG Setup: - --------------------------- - - PRG Setup is the same as a normal MMC3, although there's a PRG-AND of $3F, and games select a 512k Block with - bit 1 of R:0. Pretty simple really: - - R:0: [.... ..P.] - - 'P' PRG-AND PRG-OR - -------------------------- - 0 $3F $00 - 1 $3F $40 - - - R:0 remains the normal MMC3 CHR reg, as well. Although the game that uses it as a PRG block selector ("DQ7") - uses CHR-RAM, so it is normally ignored. - */ + //http://wiki.nesdev.com/w/index.php/INES_Mapper_245 bool chr_mode; public override bool Configure(NES.EDetectionOrigin origin) @@ -83,12 +25,17 @@ namespace BizHawk.Emulation.Consoles.Nintendo return true; } + public override void SyncState(Serializer ser) + { + ser.Sync("chr_mode", ref chr_mode); + base.SyncState(ser); + } + public override byte ReadPRG(int addr) { int bank_8k = Get_PRGBank_8K(addr); - bank_8k &= 0x3F; bank_8k &= prg_mask; - + bank_8k &= 0x3F; int reg0 = ((base.mmc3.chr_regs_1k[0] >> 1) & 0x01); if (reg0 == 1) { @@ -114,15 +61,22 @@ namespace BizHawk.Emulation.Consoles.Nintendo public override byte ReadPPU(int addr) { - if (chr_mode) //All games seem to have 0 Chr-ROM + if (addr < 0x2000) { - if (addr < 0x1000) + if (chr_mode) { - return VRAM[addr + 0x1000]; + if (addr < 0x1000) + { + return VRAM[addr + 0x1000]; + } + else + { + return VRAM[addr - 0x1000]; + } } else { - return VRAM[addr - 0x1000]; + return VRAM[addr]; } } else @@ -130,5 +84,31 @@ namespace BizHawk.Emulation.Consoles.Nintendo return base.ReadPPU(addr); } } + + public override void WritePPU(int addr, byte value) + { + if (addr < 0x2000) + { + if (chr_mode) + { + if (addr < 0x1000) + { + VRAM[addr + 0x1000] = value; + } + else + { + VRAM[addr - 0x1000] = value; + } + } + else + { + VRAM[addr] = value; + } + } + else + { + base.WritePPU(addr, value); + } + } } }