Finish mapper 245

This commit is contained in:
adelikat 2012-07-31 01:01:15 +00:00
parent f66d92f2a5
commit c04b750d6a
1 changed files with 45 additions and 65 deletions

View File

@ -7,65 +7,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
{ {
class Mapper245 : MMC3Board_Base class Mapper245 : MMC3Board_Base
{ {
/* //http://wiki.nesdev.com/w/index.php/INES_Mapper_245
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.
*/
bool chr_mode; bool chr_mode;
public override bool Configure(NES.EDetectionOrigin origin) public override bool Configure(NES.EDetectionOrigin origin)
@ -83,12 +25,17 @@ namespace BizHawk.Emulation.Consoles.Nintendo
return true; return true;
} }
public override void SyncState(Serializer ser)
{
ser.Sync("chr_mode", ref chr_mode);
base.SyncState(ser);
}
public override byte ReadPRG(int addr) public override byte ReadPRG(int addr)
{ {
int bank_8k = Get_PRGBank_8K(addr); int bank_8k = Get_PRGBank_8K(addr);
bank_8k &= 0x3F;
bank_8k &= prg_mask; bank_8k &= prg_mask;
bank_8k &= 0x3F;
int reg0 = ((base.mmc3.chr_regs_1k[0] >> 1) & 0x01); int reg0 = ((base.mmc3.chr_regs_1k[0] >> 1) & 0x01);
if (reg0 == 1) if (reg0 == 1)
{ {
@ -114,15 +61,22 @@ namespace BizHawk.Emulation.Consoles.Nintendo
public override byte ReadPPU(int addr) 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 else
{ {
return VRAM[addr - 0x1000]; return VRAM[addr];
} }
} }
else else
@ -130,5 +84,31 @@ namespace BizHawk.Emulation.Consoles.Nintendo
return base.ReadPPU(addr); 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);
}
}
} }
} }