nes-support mapper 178 and fix a regression from yesterday that made most roms not loadable

This commit is contained in:
zeromus 2012-06-23 18:30:27 +00:00
parent dcdd98fc03
commit 5b356c5157
5 changed files with 77 additions and 0 deletions

View File

@ -150,6 +150,7 @@
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper116.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper164.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper176.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper178.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper180.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper193.cs" />
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper227.cs" />

View File

@ -97,6 +97,7 @@ Open bus and bus conflict emulation is not considered complete or thorough in an
164 Pirate Junk - Started
165 Pirate Junk
176 Chinese WXN Decent
178 Chinese Decent
180 Misc (J) Complete (but we don't implement the crazy climber controller)
182 MMC3Variant Decent
184 Sunsoft-1 Complete

View File

@ -256,6 +256,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo
//this will be used to track classes that implement boards
[AttributeUsage(AttributeTargets.Class)]
public class INESBoardImplAttribute : Attribute { }
//this tracks derived boards that shouldnt be used by the implementation scanner
[AttributeUsage(AttributeTargets.Class)]
public class INESBoardImplCancelAttribute : Attribute { }
static List<Type> INESBoardImplementors = new List<Type>();
static NES()
@ -266,6 +269,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
var attrs = type.GetCustomAttributes(typeof(INESBoardImplAttribute), true);
if (attrs.Length == 0) continue;
if (type.IsAbstract) continue;
var cancelAttrs = type.GetCustomAttributes(typeof(INESBoardImplCancelAttribute), true);
if (cancelAttrs.Length != 0) continue;
INESBoardImplementors.Add(type);
}
}

View File

@ -8,6 +8,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
{
class Mapper116 : NES.NESBoardBase
{
[NES.INESBoardImplCancel]
class MMC3_CustomBoard : MMC3Board_Base
{
public override void WritePRG(int addr, byte value)

View File

@ -0,0 +1,69 @@
using System;
using System.IO;
using System.Diagnostics;
namespace BizHawk.Emulation.Consoles.Nintendo
{
class Mapper178 : NES.NESBoardBase
{
//configuration
int prg_bank_mask_32k;
//state
ByteBuffer prg_banks_32k = new ByteBuffer(1);
int reg4802;
public override bool Configure(NES.EDetectionOrigin origin)
{
//configure
switch (Cart.board_type)
{
case "MAPPER178":
break;
default:
return false;
}
prg_bank_mask_32k = (Cart.prg_size / 32) - 1;
prg_banks_32k[0] = 0;
SetMirrorType(EMirrorType.Vertical);
return true;
}
public override void WriteEXP(int addr, byte value)
{
switch (addr)
{
case 0x0800: //$4800
SetMirrorType(value.Bit(0) ? EMirrorType.Horizontal : EMirrorType.Vertical);
break;
case 0x0801: //$4801
{
int reg4801 = (value >> 1) & 0xF;
int prg = reg4801 + (reg4802 << 2);
prg_banks_32k[0] = (byte)prg;
ApplyMemoryMapMask(prg_bank_mask_32k, prg_banks_32k);
break;
}
case 0x0802: //$4802
reg4802 = value;
break;
}
}
public override byte ReadPRG(int addr)
{
addr = ApplyMemoryMap(15, prg_banks_32k, addr);
return ROM[addr];
}
public override void SyncState(Serializer ser)
{
base.SyncState(ser);
ser.Sync("prg_banks_32k", ref prg_banks_32k);
ser.Sync("reg4802", ref reg4802);
}
}
}