[NES] assorted mapper cleanup and add MMC2

This commit is contained in:
zeromus 2011-06-13 09:55:25 +00:00
parent 7705e3f6f1
commit 2d20ab84ca
8 changed files with 142 additions and 20 deletions

View File

@ -94,6 +94,7 @@
<Compile Include="Consoles\Nintendo\NES\Boards\NROM.cs"> <Compile Include="Consoles\Nintendo\NES\Boards\NROM.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="Consoles\Nintendo\NES\Boards\PxROM.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Sunsoft1.cs" /> <Compile Include="Consoles\Nintendo\NES\Boards\Sunsoft1.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Sunsoft4.cs" /> <Compile Include="Consoles\Nintendo\NES\Boards\Sunsoft4.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\SxROM.cs"> <Compile Include="Consoles\Nintendo\NES\Boards\SxROM.cs">

View File

@ -21,7 +21,7 @@ Open bus and bus conflict emulation is not considered complete or thorough in an
004 MMC3 Decent 004 MMC3 Decent
005 ExRom=MMC5 Minimal 005 ExRom=MMC5 Minimal
007 AxROM Good 007 AxROM Good
009 PxROM=MMC2 ~NEEDED~ 009 PxROM=MMC2 Complete
010 MMC4 Needed (easy once 009 is done) 010 MMC4 Needed (easy once 009 is done)
011 Misc Complete 011 Misc Complete
013 CPROM Complete 013 CPROM Complete
@ -98,7 +98,7 @@ Open bus and bus conflict emulation is not considered complete or thorough in an
180 Misc (J) Nothing 180 Misc (J) Nothing
182 MMC3Variant Nothing 182 MMC3Variant Nothing
184 Sunsoft-1 Complete 184 Sunsoft-1 Complete
185 Misc (J) Nothing 185 Misc (J) {{See 003}} This one will be an organizational pain as the games need additional data in gamedb
189 MMC3Variant Nothing 189 MMC3Variant Nothing
191 Pirate Junk 191 Pirate Junk
192 Pirate Junk 192 Pirate Junk

View File

@ -4,7 +4,7 @@ using System.Diagnostics;
namespace BizHawk.Emulation.Consoles.Nintendo namespace BizHawk.Emulation.Consoles.Nintendo
{ {
//generally mapper3 //generally mapper 3
//Solomon's Key //Solomon's Key
//Arkanoid //Arkanoid
@ -46,6 +46,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
public override void WritePRG(int addr, byte value) public override void WritePRG(int addr, byte value)
{ {
if (bus_conflict) value = HandleNormalPRGConflict(addr,value); if (bus_conflict) value = HandleNormalPRGConflict(addr,value);
value &= 3;
chr = value&chr_mask; chr = value&chr_mask;
//Console.WriteLine("at {0}, set chr={1}", NES.ppu.ppur.status.sl, chr); //Console.WriteLine("at {0}, set chr={1}", NES.ppu.ppur.status.sl, chr);
} }

View File

@ -9,14 +9,14 @@ namespace BizHawk.Emulation.Consoles.Nintendo
//Crystal Mines //Crystal Mines
//Metal Fighter //Metal Fighter
public class Discrete_74x377 : NES.NESBoardBase public class IC_74x377 : NES.NESBoardBase
{ {
//configuration //configuration
int prg_mask, chr_mask; int prg_bank_mask_32k, chr_bank_mask_8k;
bool bus_conflict = true; bool bus_conflict = true;
//state //state
int prg, chr; int prg_bank_32k, chr_bank_8k;
public override bool Configure(NES.EDetectionOrigin origin) public override bool Configure(NES.EDetectionOrigin origin)
{ {
@ -31,22 +31,22 @@ namespace BizHawk.Emulation.Consoles.Nintendo
default: default:
return false; return false;
} }
prg_mask = (Cart.prg_size/8/2)-1; prg_bank_mask_32k = Cart.prg_size / 32 - 1;
chr_mask = (Cart.chr_size / 8 - 1); chr_bank_mask_8k = Cart.chr_size / 8 - 1;
return true; return true;
} }
public override byte ReadPRG(int addr) public override byte ReadPRG(int addr)
{ {
return ROM[addr + (prg<<15)]; return ROM[addr + (prg_bank_32k << 15)];
} }
public override byte ReadPPU(int addr) public override byte ReadPPU(int addr)
{ {
if (addr < 0x2000) if (addr < 0x2000)
{ {
return VROM[addr + (chr << 13)]; return VROM[addr + (chr_bank_8k << 13)];
} }
else return base.ReadPPU(addr); else return base.ReadPPU(addr);
} }
@ -60,15 +60,15 @@ namespace BizHawk.Emulation.Consoles.Nintendo
Debug.Assert(old_value == value, "Found a test case of Discrete_74x377 bus conflict. please report."); Debug.Assert(old_value == value, "Found a test case of Discrete_74x377 bus conflict. please report.");
} }
prg = (value & 3) & prg_mask; prg_bank_32k = (value & 3) & prg_bank_mask_32k;
chr = (value >> 4) & chr_mask; chr_bank_8k = ((value >> 4) & 0xF) & chr_bank_mask_8k;
} }
public override void SyncState(Serializer ser) public override void SyncState(Serializer ser)
{ {
base.SyncState(ser); base.SyncState(ser);
ser.Sync("chr", ref chr); ser.Sync("prg_bank_32k", ref prg_bank_32k);
ser.Sync("prg", ref prg); ser.Sync("chr_bank_8k", ref chr_bank_8k);
} }
} }

View File

@ -87,6 +87,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo
AssertPrg(128); AssertChr(128); AssertVram(0); AssertWram(0); AssertPrg(128); AssertChr(128); AssertVram(0); AssertWram(0);
AssertBattery(false); AssertBattery(false);
break; break;
case "HVC-TNROM": //Final Fantasy 3 (J)
AssertPrg(128, 256, 512); AssertChr(0, 8); AssertVram(0, 8); AssertWram(8);
break;
case "NES-TSROM": //super mario bros. 3 (U) case "NES-TSROM": //super mario bros. 3 (U)
AssertPrg(128, 256, 512); AssertChr(128, 256); AssertVram(0); AssertWram(8); AssertPrg(128, 256, 512); AssertChr(128, 256); AssertVram(0); AssertWram(8);
AssertBattery(false); AssertBattery(false);

View File

@ -19,16 +19,15 @@ namespace BizHawk.Emulation.Consoles.Nintendo
{ {
case "HVC-NROM-256": //super mario bros. case "HVC-NROM-256": //super mario bros.
case "NES-NROM-256": //10 yard fight case "NES-NROM-256": //10 yard fight
AssertPrg(32); AssertChr(8); AssertVram(0); AssertWram(0,8);
break;
case "HVC-RROM": //balloon fight case "HVC-RROM": //balloon fight
case "HVC-NROM-128": case "HVC-NROM-128":
case "IREM-NROM-128": case "IREM-NROM-128":
case "KONAMI-NROM-128": case "KONAMI-NROM-128":
case "NES-NROM-128": case "NES-NROM-128":
case "NAMCOT-3301": case "NAMCOT-3301":
AssertPrg(16); AssertChr(8); AssertVram(0); AssertWram(0,8); case "HVC-HROM": //Donkey Kong Jr. (J)
case "JALECO-JF-01": //Exerion (J)
AssertPrg(16, 32); AssertChr(8); AssertVram(0); AssertWram(0, 8);
break; break;
case "NROM-HOMEBREW": case "NROM-HOMEBREW":
@ -38,7 +37,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
default: default:
return false; return false;
} }
if (origin != NES.EDetectionOrigin.INES) AssertWram(0);
prg_byte_mask = (Cart.prg_size*1024) - 1; prg_byte_mask = (Cart.prg_size*1024) - 1;
SetMirrorType(Cart.pad_h, Cart.pad_v); SetMirrorType(Cart.pad_h, Cart.pad_v);

View File

@ -0,0 +1,115 @@
using System;
using System.IO;
using System.Diagnostics;
namespace BizHawk.Emulation.Consoles.Nintendo
{
//AKA MMC2 AKA Mike Tyson's Punch-Out!!
class PxROM : NES.NESBoardBase
{
//configuration
int prg_bank_mask_8k, chr_bank_mask_4k;
//state
IntBuffer prg_banks_8k = new IntBuffer(4);
IntBuffer chr_banks_4k = new IntBuffer(4);
IntBuffer chr_latches = new IntBuffer(2);
public override void SyncState(Serializer ser)
{
base.SyncState(ser);
ser.Sync("prg_banks_8k", ref prg_banks_8k);
ser.Sync("chr_banks_4k", ref chr_banks_4k);
ser.Sync("chr_latches", ref chr_latches);
}
public override void Dispose()
{
base.Dispose();
prg_banks_8k.Dispose();
chr_banks_4k.Dispose();
chr_latches.Dispose();
}
public override bool Configure(NES.EDetectionOrigin origin)
{
switch (Cart.board_type)
{
case "NES-PNROM": //punch-out!!
case "HVC-PEEOROM":
AssertPrg(128); AssertChr(128); AssertWram(0); AssertVram(0);
break;
default:
return false;
}
prg_bank_mask_8k = Cart.prg_size / 8 - 1;
chr_bank_mask_4k = Cart.chr_size / 4 - 1;
prg_banks_8k[0] = 0;
prg_banks_8k[1] = 0xFD & prg_bank_mask_8k;
prg_banks_8k[2] = 0xFE & prg_bank_mask_8k; ;
prg_banks_8k[3] = 0xFF & prg_bank_mask_8k; ;
return true;
}
public override void WritePRG(int addr, byte value)
{
switch (addr & 0xF000)
{
case 0x2000: //$A000: PRG Reg
prg_banks_8k[0] = value & prg_bank_mask_8k;
break;
case 0x3000: //$B000: CHR Reg 0A
chr_banks_4k[0] = value & chr_bank_mask_4k;
break;
case 0x4000: //$C000: CHR Reg 0B
chr_banks_4k[1] = value & chr_bank_mask_4k;
break;
case 0x5000: //$D000: CHR Reg 1A
chr_banks_4k[2] = value & chr_bank_mask_4k;
break;
case 0x6000: //$E000: CHR Reg 1B
chr_banks_4k[3] = value & chr_bank_mask_4k;
break;
case 0x7000: //$F000: [.... ...M] Mirroring:
SetMirrorType(value.Bit(0) ? EMirrorType.Horizontal : EMirrorType.Vertical);
break;
}
}
public override byte ReadPPU(int addr)
{
int side = addr>>12;
int tile = (addr>>4)&0xFF;
if (addr < 0x2000)
{
switch (tile)
{
case 0xFD: chr_latches[side] = 0; break;
case 0xFE: chr_latches[side] = 1; break;
}
int reg = side * 2 + chr_latches[side];
int ofs = addr & ((1 << 12) - 1);
int bank_4k = chr_banks_4k[reg];
addr = (bank_4k << 12) | ofs;
return VROM[addr];
}
else return base.ReadPPU(addr);
}
public override byte ReadPRG(int addr)
{
int bank_8k = addr >> 13;
int ofs = addr & ((1 << 13) - 1);
bank_8k = prg_banks_8k[bank_8k];
addr = (bank_8k << 13) | ofs;
return ROM[addr];
}
}
}

View File

@ -2270,6 +2270,8 @@ sha1:894F20405286F5F75133CE4648300E2C67972B40 Solomon's Key (U) NES board=NES-
sha1:0C53B06E1D13AE917536BB39010914EA3D111FF5 Thunder & Lightning (U) NES board=NES-GNROM;PRG=128;CHR=32;bad sha1:0C53B06E1D13AE917536BB39010914EA3D111FF5 Thunder & Lightning (U) NES board=NES-GNROM;PRG=128;CHR=32;bad
sha1:9BDFF9A19265D84979F43F0F6E925A735DDEB38B Wai Xing Zhan Shi (Ch) NES board=Mapper242;PRG=512;CHR=0;VRAM=8;WRAM=8 sha1:9BDFF9A19265D84979F43F0F6E925A735DDEB38B Wai Xing Zhan Shi (Ch) NES board=Mapper242;PRG=512;CHR=0;VRAM=8;WRAM=8
sha1:91CECCFCAC90E417E9AEE80E8F7B560A20EB33CC Ai Sensei No Oshiete - Watashi No Hoshi (J) NES board=IREM-G101;PRG=256;CHR=128;WRAM=8 sha1:91CECCFCAC90E417E9AEE80E8F7B560A20EB33CC Ai Sensei No Oshiete - Watashi No Hoshi (J) NES board=IREM-G101;PRG=256;CHR=128;WRAM=8
sha1:B6F6BD9D78CDD264A117D4B647AEE3309993E9A9 Mike Tyson's Punch-Out!! (U) NES board=NES-PNROM;PRG=128;CHR=128;WRAM=0
sha1:A0C4D4172A0037B7D9BA729A93E809978D0F10D2 Punch-Out!! (U) NES board=NES-PNROM;PRG=128;CHR=128;WRAM=0
;and these are even labeled as bad in goodNES ;and these are even labeled as bad in goodNES
sha1:984ADAEB85403EEF1BA85CDCF310FAAECEB409A0 Adventures of Captain Comic, The (Bad Dump) (U) NES board=COLORDREAMS-74*377;PRG=64;CHR=64;WRAM=0;VRAM=0;bad sha1:984ADAEB85403EEF1BA85CDCF310FAAECEB409A0 Adventures of Captain Comic, The (Bad Dump) (U) NES board=COLORDREAMS-74*377;PRG=64;CHR=64;WRAM=0;VRAM=0;bad
@ -2288,6 +2290,8 @@ sha1:0AE47BD83202A5A2235B0BC16278F56D66038AB5 Deathbots (U) NES board=AVE-NINA
;these roms are in goodNES but theyre junk ;these roms are in goodNES but theyre junk
sha1:4D6117577CE301BB987C5C32FEEF7B132A21B046 Afro Man (Mega Man 3 Hack) (UNL) NES board=TXROM-HOMEBREW;PRG=256;CHR=128;WRAM=8 sha1:4D6117577CE301BB987C5C32FEEF7B132A21B046 Afro Man (Mega Man 3 Hack) (UNL) NES board=TXROM-HOMEBREW;PRG=256;CHR=128;WRAM=8
sha1:7BD102770FE7766BF8430ACDB3C17EE51E30478C Mike Tyson's Punch-Out!! (Hacked) (U) NES board=NES-PNROM;PRG=128;CHR=128;WRAM=0
sha1:536D623BA02A622BDE8E2D7D514AE9785B5E0357 Punch Out!! Kirby (Hack) (U) NES board=NES-PNROM;PRG=128;CHR=128;WRAM=0
;other assorted roms ;other assorted roms
sha1:92D9695FEB774F60965A8303CFE3E6AAEE7B7B62 Magic Dragon (Unl) NES board=Mapper107;PRG=128;CHR=64;WRAM=8;PAD_H=1 sha1:92D9695FEB774F60965A8303CFE3E6AAEE7B7B62 Magic Dragon (Unl) NES board=Mapper107;PRG=128;CHR=64;WRAM=8;PAD_H=1