Start Mappers 154, 112
This commit is contained in:
parent
3ae3a52f7a
commit
c9128cc78e
|
@ -30,7 +30,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
||||||
switch (Cart.board_type)
|
switch (Cart.board_type)
|
||||||
{
|
{
|
||||||
case "NAMCOT-3443":
|
case "NAMCOT-3443":
|
||||||
case "NAMCOT-3433": //TODO: just a guess, find a ROM with this
|
case "NAMCOT-3433":
|
||||||
case "MAPPER088":
|
case "MAPPER088":
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -59,7 +59,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
||||||
|
|
||||||
public override byte ReadPPU(int addr)
|
public override byte ReadPPU(int addr)
|
||||||
{
|
{
|
||||||
//if (addr < 0x2000) return VROM[Get_CHRBank_1K(addr)];
|
|
||||||
if (addr < 0x2000) return VROM[RewireCHR(addr)];
|
if (addr < 0x2000) return VROM[RewireCHR(addr)];
|
||||||
else return base.ReadPPU(addr);
|
else return base.ReadPPU(addr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,154 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||||
|
{
|
||||||
|
class Mapper112 : NES.NESBoardBase
|
||||||
|
{
|
||||||
|
//TODO: this doesn't work
|
||||||
|
public override bool Configure(NES.EDetectionOrigin origin)
|
||||||
|
{
|
||||||
|
//analyze board type
|
||||||
|
switch (Cart.board_type)
|
||||||
|
{
|
||||||
|
case "MAPPER112":
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int num_prg_banks = Cart.prg_size / 8;
|
||||||
|
prg_mask = num_prg_banks - 1;
|
||||||
|
|
||||||
|
int num_chr_banks = (Cart.chr_size);
|
||||||
|
chr_mask = num_chr_banks - 1;
|
||||||
|
SetMirrorType(EMirrorType.Vertical);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//state
|
||||||
|
int reg_addr;
|
||||||
|
int prg_mask, chr_mask;
|
||||||
|
ByteBuffer regs = new ByteBuffer(8);
|
||||||
|
|
||||||
|
//volatile state
|
||||||
|
ByteBuffer chr_regs_1k = new ByteBuffer(8);
|
||||||
|
ByteBuffer prg_regs_8k = new ByteBuffer(4);
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
regs.Dispose();
|
||||||
|
chr_regs_1k.Dispose();
|
||||||
|
prg_regs_8k.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SyncState(Serializer ser)
|
||||||
|
{
|
||||||
|
ser.Sync("reg_addr", ref reg_addr);
|
||||||
|
ser.Sync("regs", ref regs);
|
||||||
|
Sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WritePRG(int addr, byte value)
|
||||||
|
{
|
||||||
|
//($8001-$9FFF, odd)
|
||||||
|
if (addr == 0x6000)
|
||||||
|
{
|
||||||
|
if ((value & 1) == 0)
|
||||||
|
{
|
||||||
|
SetMirrorType(EMirrorType.Vertical);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetMirrorType(EMirrorType.Horizontal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (addr & 0x6001)
|
||||||
|
{
|
||||||
|
case 0x0000: //$8000
|
||||||
|
reg_addr = (value & 7);
|
||||||
|
break;
|
||||||
|
case 0x0001: //$8001
|
||||||
|
regs[reg_addr] = value;
|
||||||
|
Sync();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sync()
|
||||||
|
{
|
||||||
|
prg_regs_8k[0] = regs[0];
|
||||||
|
prg_regs_8k[1] = regs[1];
|
||||||
|
prg_regs_8k[2] = 0xFE;
|
||||||
|
prg_regs_8k[3] = 0xFF;
|
||||||
|
|
||||||
|
byte r0_0 = (byte)(regs[2] & ~1);
|
||||||
|
byte r0_1 = (byte)(regs[2] | 1);
|
||||||
|
byte r1_0 = (byte)(regs[3] & ~1);
|
||||||
|
byte r1_1 = (byte)(regs[3] | 1);
|
||||||
|
|
||||||
|
chr_regs_1k[0] = r0_0;
|
||||||
|
chr_regs_1k[1] = r0_1;
|
||||||
|
chr_regs_1k[2] = r1_0;
|
||||||
|
chr_regs_1k[3] = r1_1;
|
||||||
|
chr_regs_1k[4] = regs[4];
|
||||||
|
chr_regs_1k[5] = regs[5];
|
||||||
|
chr_regs_1k[6] = regs[6];
|
||||||
|
chr_regs_1k[7] = regs[7];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Get_PRGBank_8K(int addr)
|
||||||
|
{
|
||||||
|
int bank_8k = addr >> 13;
|
||||||
|
bank_8k = prg_regs_8k[bank_8k];
|
||||||
|
return bank_8k;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Get_CHRBank_1K(int addr)
|
||||||
|
{
|
||||||
|
int bank_1k = addr >> 10;
|
||||||
|
bank_1k = chr_regs_1k[bank_1k];
|
||||||
|
return bank_1k;
|
||||||
|
}
|
||||||
|
|
||||||
|
int RewireCHR(int addr)
|
||||||
|
{
|
||||||
|
if (addr < 0x1000)
|
||||||
|
{
|
||||||
|
int mapper_addr = addr >> 1;
|
||||||
|
int bank_1k = Get_CHRBank_1K(mapper_addr);
|
||||||
|
int ofs = addr & ((1 << 10) - 1);
|
||||||
|
return (bank_1k << 11) + ofs;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int bank_1k = Get_CHRBank_1K(addr);
|
||||||
|
int ofs = addr & ((1 << 10) - 1);
|
||||||
|
return (bank_1k << 11) + ofs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte ReadPPU(int addr)
|
||||||
|
{
|
||||||
|
if (addr < 0x2000) return VROM[RewireCHR(addr)];
|
||||||
|
else return base.ReadPPU(addr);
|
||||||
|
}
|
||||||
|
public override void WritePPU(int addr, byte value)
|
||||||
|
{
|
||||||
|
if (addr < 0x2000) { }
|
||||||
|
else base.WritePPU(addr, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte ReadPRG(int addr)
|
||||||
|
{
|
||||||
|
int bank_8k = Get_PRGBank_8K(addr);
|
||||||
|
bank_8k &= prg_mask;
|
||||||
|
addr = (bank_8k << 13) | (addr & 0x1FFF);
|
||||||
|
return ROM[addr];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace BizHawk.Emulation.Consoles.Nintendo
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Example Games:
|
||||||
|
--------------------------
|
||||||
|
Devil Man
|
||||||
|
|
||||||
|
Similar to Mapper 88 except for mirroing
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class Mapper154 : Namcot108Board_Base
|
||||||
|
{
|
||||||
|
//configuration
|
||||||
|
int chr_bank_mask_1k;
|
||||||
|
|
||||||
|
public override bool Configure(NES.EDetectionOrigin origin)
|
||||||
|
{
|
||||||
|
//analyze board type
|
||||||
|
switch (Cart.board_type)
|
||||||
|
{
|
||||||
|
case "NAMCOT-3453":
|
||||||
|
case "MAPPER154":
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseSetup();
|
||||||
|
SetMirrorType(EMirrorType.OneScreenA);
|
||||||
|
|
||||||
|
chr_bank_mask_1k = Cart.chr_size - 1;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int RewireCHR(int addr)
|
||||||
|
{
|
||||||
|
int bank_1k = mapper.Get_CHRBank_1K(addr);
|
||||||
|
bank_1k &= 0x3F;
|
||||||
|
if (addr >= 0x1000)
|
||||||
|
bank_1k |= 0x40;
|
||||||
|
bank_1k &= chr_bank_mask_1k;
|
||||||
|
int ofs = addr & ((1 << 10) - 1);
|
||||||
|
addr = (bank_1k << 10) + ofs;
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte ReadPPU(int addr)
|
||||||
|
{
|
||||||
|
if (addr < 0x2000) return VROM[RewireCHR(addr)];
|
||||||
|
else return base.ReadPPU(addr);
|
||||||
|
}
|
||||||
|
public override void WritePPU(int addr, byte value)
|
||||||
|
{
|
||||||
|
if (addr < 0x2000) { }
|
||||||
|
else base.WritePPU(addr, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WritePRG(int addr, byte value)
|
||||||
|
{
|
||||||
|
if ((addr & 0x6001) == 0)
|
||||||
|
{
|
||||||
|
if (((value >> 6) & 1) == 0)
|
||||||
|
{
|
||||||
|
SetMirrorType(EMirrorType.OneScreenA);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetMirrorType(EMirrorType.OneScreenB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
base.WritePRG(addr, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue