[NES] add board: sunsoft-4 (mapper 068)

This commit is contained in:
zeromus 2011-06-08 02:42:36 +00:00
parent 8247fca267
commit 969341f691
5 changed files with 129 additions and 1 deletions

View File

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

View File

@ -100,7 +100,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
}
}
int ApplyMirroring(int addr)
protected int ApplyMirroring(int addr)
{
int block = (addr >> 10) & 3;
block = mirroring[block];

View File

@ -0,0 +1,125 @@
using System;
using System.IO;
using System.Diagnostics;
namespace BizHawk.Emulation.Consoles.Nintendo
{
//AKA mapper 068
//After Burner 2
//Maharaja
class Sunsoft4 : NES.NESBoardBase
{
//configuration
int prg_bank_mask, chr_bank_mask, nt_bank_mask;
//state
ByteBuffer chr_regs_2k = new ByteBuffer(4);
ByteBuffer nt_regs = new ByteBuffer(2);
ByteBuffer prg_regs_16k = new ByteBuffer(2);
bool flag_m, flag_r;
public override void Dispose()
{
base.Dispose();
chr_regs_2k.Dispose();
nt_regs.Dispose();
prg_regs_16k.Dispose();
}
public override bool Configure(NES.EDetectionOrigin origin)
{
//configure
switch (Cart.board_type)
{
case "SUNSOFT-4":
AssertPrg(128); AssertChr(128,256); AssertVram(0); AssertWram(8);
break;
default:
return false;
}
SetMirrorType(EMirrorType.Vertical);
prg_regs_16k[1] = 0xFF;
prg_bank_mask = Cart.prg_size / 16 - 1;
chr_bank_mask = Cart.chr_size / 2 - 1;
nt_bank_mask = Cart.chr_size - 1;
return true;
}
public override byte ReadPRG(int addr)
{
int bank_16k = addr >> 14;
int ofs = addr & ((1 << 14) - 1);
bank_16k = prg_regs_16k[bank_16k];
bank_16k &= prg_bank_mask;
addr = (bank_16k << 14) | ofs;
return ROM[addr];
}
public override byte ReadPPU(int addr)
{
if (addr < 0x2000)
{
//chr comes from normal chr mapping
int bank_2k = addr >> 11;
int ofs = addr & ((1 << 11) - 1);
bank_2k = chr_regs_2k[bank_2k];
bank_2k &= chr_bank_mask;
addr = (bank_2k << 11) | ofs;
return VROM[addr];
}
else
{
//nametable may come from "NT-ROM"
//which means from extra CHR data starting at bank 0x80
if (flag_r)
{
addr = ApplyMirroring(addr);
int bank_1k = (addr >> 10) & 3;
int ofs = addr & ((1 << 10) - 1);
bank_1k = nt_regs[bank_1k] + 0x80;
bank_1k &= nt_bank_mask;
addr = (bank_1k << 10) | ofs;
return VROM[addr];
}
else return base.ReadPPU(addr);
}
}
public override void WritePRG(int addr, byte value)
{
switch (addr & 0xF000)
{
case 0x0000: //$8000
chr_regs_2k[0] = value;
break;
case 0x1000: //$9000
chr_regs_2k[1] = value;
break;
case 0x2000: //$A000
chr_regs_2k[2] = value;
break;
case 0x3000: //$B000
chr_regs_2k[3] = value;
break;
case 0x4000: //$C000
nt_regs[0] = (byte)(value & 0x7F);
break;
case 0x5000: //$D000
nt_regs[1] = (byte)(value & 0x7F);
break;
case 0x6000: //$E000
flag_m = (value & 1) != 0;
flag_r = ((value >> 4) & 1) != 0;
if (flag_m) SetMirrorType(EMirrorType.Horizontal);
else SetMirrorType(EMirrorType.Vertical);
break;
case 0x7000: //$F000
prg_regs_16k[0] = value;
break;
}
}
}
}

View File

@ -91,6 +91,7 @@ static string ClassifyTable = @"
13 32 0 8 16 NES-CPROM; videomation
66 64 16 8 0 NES-MHROM; super mario bros / duck hunt
66 128 32 8 0 NES-GNROM; gumshoe
68 128 256 8 0 SUNSOFT-4; After Burner 2 (J)
";
}

View File

@ -2263,6 +2263,7 @@ D4448D09BBFDE687C04F9E3310E023AB ti83_1.rom TI83 initPC=6ce
;--nes--;
;these games seem to be in goodNES but not bootgod's DB
sha1:22E6986903141495BA4589AC65982F3FB4D0E37B Adventures of Lolo (U) NES board=NES-SEROM;PRG=32;CHR=32
sha1:99C18C91F051BFBA6836A7B6B213C77569D83767 After Burner 2 (J) NES board=SUNSOFT-4;PRG=128;CHR=256;WRAM=8
sha1:CF655333DCE649A3C7060E9989860F2FC74E473A Demon Sword (U) NES board=NES-SL1ROM;PRG=128;CHR=128
sha1:7786BA1FE8E7E9E542EEB13CF2A6E2A1AD7F696D Metal Gear (U) NES board=KONAMI-UNROM;PRG=128
sha1:894F20405286F5F75133CE4648300E2C67972B40 Solomon's Key (U) NES board=NES-CNROM;PRG=32;CHR=32