NES - start mapper 50, but it doesn't work
This commit is contained in:
parent
10c71da526
commit
7805c460d0
|
@ -177,6 +177,7 @@
|
|||
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper046.cs" />
|
||||
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper243.cs" />
|
||||
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper246.cs" />
|
||||
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper50.cs" />
|
||||
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper60.cs" />
|
||||
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper61.cs" />
|
||||
<Compile Include="Consoles\Nintendo\NES\Boards\Mapper62.cs" />
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||
{
|
||||
class Mapper50 : NES.NESBoardBase
|
||||
{
|
||||
//http://wiki.nesdev.com/w/index.php/INES_Mapper_050
|
||||
|
||||
byte prg_bank;
|
||||
int prg_bank_mask_8k;
|
||||
|
||||
public override bool Configure(NES.EDetectionOrigin origin)
|
||||
{
|
||||
//analyze board type
|
||||
switch (Cart.board_type)
|
||||
{
|
||||
case "MAPPER050":
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
prg_bank = 0;
|
||||
prg_bank_mask_8k = Cart.prg_size / 8 - 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void SyncState(Serializer ser)
|
||||
{
|
||||
ser.Sync("prg_bank", ref prg_bank);
|
||||
base.SyncState(ser);
|
||||
}
|
||||
|
||||
public override void WriteEXP(int addr, byte value)
|
||||
{
|
||||
addr &= 0x0120;
|
||||
if (addr == 0x0020)
|
||||
{
|
||||
//byte low = (byte)((value >> 1) & 0x03);
|
||||
//byte middle = (byte)(value & 0x01);
|
||||
//byte high = (byte)((value >> 3) & 0x01);
|
||||
//prg_bank = (byte)(low | (middle << 2) | (high << 3));
|
||||
|
||||
prg_bank = (byte)(((value & 1) << 2) | ((value & 2) >> 1) | ((value & 4) >> 1) | (value & 8));
|
||||
|
||||
Console.WriteLine(prg_bank);
|
||||
}
|
||||
base.WriteEXP(addr, value);
|
||||
}
|
||||
|
||||
public override byte ReadPRG(int addr)
|
||||
{
|
||||
if (addr < 0x2000)
|
||||
{
|
||||
return ROM[(0x08 * 0x2000) + (addr & 0x1FFF)];
|
||||
}
|
||||
else if (addr < 0x4000)
|
||||
{
|
||||
return ROM[(0x09 * 0x2000) + (addr & 0x1FFF)];
|
||||
}
|
||||
else if (addr < 0x6000)
|
||||
{
|
||||
int bank = (prg_bank & prg_bank_mask_8k);
|
||||
return ROM[(bank * 0x2000) + (addr & 0x1FFF)];
|
||||
}
|
||||
else
|
||||
{
|
||||
return ROM[(0x0B * 0x2000) + (addr & 0x1FFF)];
|
||||
}
|
||||
}
|
||||
|
||||
public override byte ReadPPU(int addr)
|
||||
{
|
||||
return ROM[(0x0F * 0x2000) + (addr & 0x1FFF)];
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue