dev_4VirtualNes #23

Merged
sin365 merged 35 commits from dev_4VirtualNes into master 2024-08-05 17:49:44 +08:00
39 changed files with 2758 additions and 8 deletions
Showing only changes of commit f82237b7a5 - Show all commits

View File

@ -2,17 +2,17 @@
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using System;
namespace VirtualNes.Core
{
public class _MapName : Mapper
{
public _MapName(NES parent) : base(parent)
{
}
public class Mapper043 : Mapper
{
public Mapper043(NES parent) : base(parent)
{
}
public override void Reset()
public override void Reset()
{
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2867bd866aa4459469bc4f3506ac516f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,289 @@
//////////////////////////////////////////////////////////////////////////
// Mapper044 Super HiK 7-in-1 //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using Codice.CM.Client.Differences;
namespace VirtualNes.Core
{
public class Mapper044 : Mapper
{
BYTE[] reg = new byte[8];
BYTE patch;
BYTE bank;
BYTE prg0, prg1;
BYTE chr01, chr23, chr4, chr5, chr6, chr7;
BYTE irq_enable;
BYTE irq_counter;
BYTE irq_latch;
public Mapper044(NES parent) : base(parent)
{
}
public override void Reset()
{
patch = 0;
if (nes.rom.GetPROM_CRC() == 0x7eef434c)
{
patch = 1;
}
for (INT i = 0; i < 8; i++)
{
reg[i] = 0;
}
bank = 0;
prg0 = 0;
prg1 = 1;
// set VROM banks
if (VROM_1K_SIZE!=0)
{
chr01 = 0;
chr23 = 2;
chr4 = 4;
chr5 = 5;
chr6 = 6;
chr7 = 7;
}
else
{
chr01 = chr23 = chr4 = chr5 = chr6 = chr7 = 0;
}
SetBank_CPU();
SetBank_PPU();
irq_enable = 0;
irq_counter = 0;
irq_latch = 0;
}
//void Mapper044::WriteLow(WORD addr, BYTE data)
public override void WriteLow(ushort addr, byte data)
{
if (addr == 0x6000)
{
if (patch!=0)
{
bank = (byte)((data & 0x06) >> 1);
}
else
{
bank = (byte)((data & 0x01) << 1);
}
SetBank_CPU();
SetBank_PPU();
}
}
//void Mapper044::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
switch (addr & 0xE001)
{
case 0x8000:
reg[0] = data;
SetBank_CPU();
SetBank_PPU();
break;
case 0x8001:
reg[1] = data;
switch (reg[0] & 0x07)
{
case 0x00:
chr01 = (byte)(data & 0xFE);
SetBank_PPU();
break;
case 0x01:
chr23 = (byte)(data & 0xFE);
SetBank_PPU();
break;
case 0x02:
chr4 = data;
SetBank_PPU();
break;
case 0x03:
chr5 = data;
SetBank_PPU();
break;
case 0x04:
chr6 = data;
SetBank_PPU();
break;
case 0x05:
chr7 = data;
SetBank_PPU();
break;
case 0x06:
prg0 = data;
SetBank_CPU();
break;
case 0x07:
prg1 = data;
SetBank_CPU();
break;
}
break;
case 0xA000:
reg[2] = data;
if (!nes.rom.Is4SCREEN())
{
if ((data & 0x01)!=0) SetVRAM_Mirror(VRAM_HMIRROR);
else SetVRAM_Mirror(VRAM_VMIRROR);
}
break;
case 0xA001:
reg[3] = data;
bank = (byte)(data & 0x07);
if (bank == 7)
{
bank = 6;
}
SetBank_CPU();
SetBank_PPU();
break;
case 0xC000:
reg[4] = data;
irq_counter = data;
break;
case 0xC001:
reg[5] = data;
irq_latch = data;
break;
case 0xE000:
reg[6] = data;
irq_enable = 0;
nes.cpu.ClrIRQ(IRQ_MAPPER);
break;
case 0xE001:
reg[7] = data;
irq_enable = 1;
// nes.cpu.ClrIRQ( IRQ_MAPPER );
break;
}
}
//void Mapper044::HSync(INT scanline)
public override void HSync(int scanline)
{
if ((scanline >= 0 && scanline <= 239))
{
if (nes.ppu.IsDispON())
{
if (irq_enable!=0)
{
if ((--irq_counter)==0)
{
irq_counter = irq_latch;
// nes.cpu.IRQ();
nes.cpu.SetIRQ(IRQ_MAPPER);
}
}
}
}
}
void SetBank_CPU()
{
if ((reg[0] & 0x40)!=0)
{
SetPROM_8K_Bank(4, ((bank == 6) ? 0x1e : 0x0e) | (bank << 4));
SetPROM_8K_Bank(5, ((bank == 6) ? 0x1f & prg1 : 0x0f & prg1) | (bank << 4));
SetPROM_8K_Bank(6, ((bank == 6) ? 0x1f & prg0 : 0x0f & prg0) | (bank << 4));
SetPROM_8K_Bank(7, ((bank == 6) ? 0x1f : 0x0f) | (bank << 4));
}
else
{
SetPROM_8K_Bank(4, ((bank == 6) ? 0x1f & prg0 : 0x0f & prg0) | (bank << 4));
SetPROM_8K_Bank(5, ((bank == 6) ? 0x1f & prg1 : 0x0f & prg1) | (bank << 4));
SetPROM_8K_Bank(6, ((bank == 6) ? 0x1e : 0x0e) | (bank << 4));
SetPROM_8K_Bank(7, ((bank == 6) ? 0x1f : 0x0f) | (bank << 4));
}
}
void SetBank_PPU()
{
if (VROM_1K_SIZE!=0)
{
if ((reg[0] & 0x80)!=0)
{
SetVROM_1K_Bank(0, ((bank == 6) ? 0xff & chr4 : 0x7f & chr4) | (bank << 7));
SetVROM_1K_Bank(1, ((bank == 6) ? 0xff & chr5 : 0x7f & chr5) | (bank << 7));
SetVROM_1K_Bank(2, ((bank == 6) ? 0xff & chr6 : 0x7f & chr6) | (bank << 7));
SetVROM_1K_Bank(3, ((bank == 6) ? 0xff & chr7 : 0x7f & chr7) | (bank << 7));
SetVROM_1K_Bank(4, ((bank == 6) ? 0xff & chr01 : 0x7f & chr01) | (bank << 7));
SetVROM_1K_Bank(5, ((bank == 6) ? 0xff & (chr01 + 1) : 0x7f & (chr01 + 1)) | (bank << 7));
SetVROM_1K_Bank(6, ((bank == 6) ? 0xff & chr23 : 0x7f & chr23) | (bank << 7));
SetVROM_1K_Bank(7, ((bank == 6) ? 0xff & (chr23 + 1) : 0x7f & (chr23 + 1)) | (bank << 7));
}
else
{
SetVROM_1K_Bank(0, ((bank == 6) ? 0xff & chr01 : 0x7f & chr01) | (bank << 7));
SetVROM_1K_Bank(1, ((bank == 6) ? 0xff & (chr01 + 1) : 0x7f & (chr01 + 1)) | (bank << 7));
SetVROM_1K_Bank(2, ((bank == 6) ? 0xff & chr23 : 0x7f & chr23) | (bank << 7));
SetVROM_1K_Bank(3, ((bank == 6) ? 0xff & (chr23 + 1) : 0x7f & (chr23 + 1)) | (bank << 7));
SetVROM_1K_Bank(4, ((bank == 6) ? 0xff & chr4 : 0x7f & chr4) | (bank << 7));
SetVROM_1K_Bank(5, ((bank == 6) ? 0xff & chr5 : 0x7f & chr5) | (bank << 7));
SetVROM_1K_Bank(6, ((bank == 6) ? 0xff & chr6 : 0x7f & chr6) | (bank << 7));
SetVROM_1K_Bank(7, ((bank == 6) ? 0xff & chr7 : 0x7f & chr7) | (bank << 7));
}
}
}
//void Mapper044::SaveState(LPBYTE p)
public override void SaveState(byte[] p)
{
for (INT i = 0; i < 8; i++)
{
p[i] = reg[i];
}
p[8] = prg0;
p[9] = prg1;
p[10] = chr01;
p[11] = chr23;
p[12] = chr4;
p[13] = chr5;
p[14] = chr6;
p[15] = chr7;
p[16] = irq_enable;
p[17] = irq_counter;
p[18] = irq_latch;
p[19] = bank;
}
//void Mapper044::LoadState(LPBYTE p)
public override void LoadState(byte[] p)
{
for (INT i = 0; i < 8; i++)
{
reg[i] = p[i];
}
prg0 = p[8];
prg1 = p[9];
chr01 = p[10];
chr23 = p[11];
chr4 = p[12];
chr5 = p[13];
chr6 = p[14];
chr7 = p[15];
irq_enable = p[16];
irq_counter = p[17];
irq_latch = p[18];
bank = p[19];
}
public override bool IsStateSave()
{
return true;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4cc48452689c58d4b9272c29c9a812b6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,387 @@
//////////////////////////////////////////////////////////////////////////
// Mapper045 1000000-in-1 //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using Codice.CM.Client.Differences;
namespace VirtualNes.Core
{
public class Mapper045 : Mapper
{
BYTE[] reg = new byte[8];
BYTE patch;
BYTE prg0, prg1, prg2, prg3;
BYTE chr0, chr1, chr2, chr3, chr4, chr5, chr6, chr7;
BYTE[] p = new byte[4];
INT[] c = new int[8];
BYTE irq_enable;
BYTE irq_counter;
BYTE irq_latch;
BYTE irq_latched;
BYTE irq_reset;
public Mapper045(NES parent) : base(parent)
{
}
public override void Reset()
{
patch = 0;
for (INT i = 0; i < 8; i++)
{
reg[i] = 0;
}
prg0 = 0;
prg1 = 1;
prg2 = (byte)(PROM_8K_SIZE - 2);
prg3 = (byte)(PROM_8K_SIZE - 1);
uint crc = nes.rom.GetPROM_CRC();
if (crc == 0x58bcacf6 // Kunio 8-in-1 (Pirate Cart)
|| crc == 0x9103cfd6 // HIK 7-in-1 (Pirate Cart)
|| crc == 0xc082e6d3)
{ // Super 8-in-1 (Pirate Cart)
patch = 1;
prg2 = 62;
prg3 = 63;
}
if (crc == 0xe0dd259d)
{ // Super 3-in-1 (Pirate Cart)
patch = 2;
}
SetPROM_32K_Bank(prg0, prg1, prg2, prg3);
p[0] = prg0;
p[1] = prg1;
p[2] = prg2;
p[3] = prg3;
SetVROM_8K_Bank(0);
// chr0 = c[0] = 0;
// chr1 = c[1] = 0
// chr2 = c[2] = 0;
// chr3 = c[3] = 0;
// chr4 = c[4] = 0;
// chr5 = c[5] = 0;
// chr6 = c[6] = 0;
// chr7 = c[7] = 0;
c[0] = chr0 = 0;
c[1] = chr1 = 1;
c[2] = chr2 = 2;
c[3] = chr3 = 3;
c[4] = chr4 = 4;
c[5] = chr5 = 5;
c[6] = chr6 = 6;
c[7] = chr7 = 7;
irq_enable = 0;
irq_counter = 0;
irq_latch = 0;
irq_latched = 0;
irq_reset = 0;
}
//void Mapper045::WriteLow(WORD addr, BYTE data)
public override void WriteLow(ushort addr, byte data)
{
// if( addr == 0x6000 ) {
// if( addr == 0x6000 && !(reg[3]&0x40) ) {
if ((reg[3] & 0x40) == 0)
{
reg[reg[5]] = data;
reg[5] = (byte)((reg[5] + 1) & 0x03);
SetBank_CPU_4(prg0);
SetBank_CPU_5(prg1);
SetBank_CPU_6(prg2);
SetBank_CPU_7(prg3);
SetBank_PPU();
}
}
//void Mapper045::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
switch (addr & 0xE001)
{
case 0x8000:
if ((data & 0x40) != (reg[6] & 0x40))
{
BYTE swp;
swp = prg0; prg0 = prg2; prg2 = swp;
swp = p[0]; p[0] = p[2]; p[2] = swp;
SetBank_CPU_4(p[0]);
SetBank_CPU_5(p[1]);
}
if (VROM_1K_SIZE != 0)
{
if ((data & 0x80) != (reg[6] & 0x80))
{
INT swp;
swp = chr4; chr4 = chr0; chr0 = (byte)swp;
swp = chr5; chr5 = chr1; chr1 = (byte)swp;
swp = chr6; chr6 = chr2; chr2 = (byte)swp;
swp = chr7; chr7 = chr3; chr3 = (byte)swp;
swp = c[4]; c[4] = c[0]; c[0] = swp;
swp = c[5]; c[5] = c[1]; c[1] = swp;
swp = c[6]; c[6] = c[2]; c[2] = swp;
swp = c[7]; c[7] = c[3]; c[3] = swp;
SetVROM_8K_Bank(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
}
}
reg[6] = data;
break;
case 0x8001:
switch (reg[6] & 0x07)
{
case 0x00:
chr0 = (byte)((data & 0xFE) + 0);
chr1 = (byte)((data & 0xFE) + 1);
SetBank_PPU();
break;
case 0x01:
chr2 = (byte)((data & 0xFE) + 0);
chr3 = (byte)((data & 0xFE) + 1);
SetBank_PPU();
break;
case 0x02:
chr4 = data;
SetBank_PPU();
break;
case 0x03:
chr5 = data;
SetBank_PPU();
break;
case 0x04:
chr6 = data;
SetBank_PPU();
break;
case 0x05:
chr7 = data;
SetBank_PPU();
break;
case 0x06:
if ((reg[6] & 0x40) != 0)
{
prg2 = (byte)(data & 0x3F);
SetBank_CPU_6(data);
}
else
{
prg0 = (byte)(data & 0x3F);
SetBank_CPU_4(data);
}
break;
case 0x07:
prg1 = (byte)(data & 0x3F);
SetBank_CPU_5(data);
break;
}
break;
case 0xA000:
if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR);
else SetVRAM_Mirror(VRAM_VMIRROR);
break;
case 0xC000:
if (patch == 2)
{
if (data == 0x29 || data == 0x70)
data = 0x07;
}
irq_latch = data;
irq_latched = 1;
if (irq_reset != 0)
{
irq_counter = data;
irq_latched = 0;
}
// irq_counter = data;
break;
case 0xC001:
// irq_latch = data;
irq_counter = irq_latch;
break;
case 0xE000:
irq_enable = 0;
irq_reset = 1;
nes.cpu.ClrIRQ(IRQ_MAPPER);
break;
case 0xE001:
irq_enable = 1;
if (irq_latched != 0)
{
irq_counter = irq_latch;
}
break;
}
}
//void Mapper045::HSync(INT scanline)
public override void HSync(int scanline)
{
irq_reset = 0;
if ((scanline >= 0 && scanline <= 239) && nes.ppu.IsDispON())
{
if (irq_counter != 0)
{
irq_counter--;
if (irq_counter == 0)
{
if (irq_enable != 0)
{
nes.cpu.SetIRQ(IRQ_MAPPER);
}
}
}
}
}
void SetBank_CPU_4(INT data)
{
data &= (reg[3] & 0x3F) ^ 0xFF;
data &= 0x3F;
data |= reg[1];
SetPROM_8K_Bank(4, data);
p[0] = (byte)data;
}
void SetBank_CPU_5(INT data)
{
data &= (reg[3] & 0x3F) ^ 0xFF;
data &= 0x3F;
data |= reg[1];
SetPROM_8K_Bank(5, data);
p[1] = (byte)data;
}
void SetBank_CPU_6(INT data)
{
data &= (reg[3] & 0x3F) ^ 0xFF;
data &= 0x3F;
data |= reg[1];
SetPROM_8K_Bank(6, data);
p[2] = (byte)data;
}
void SetBank_CPU_7(INT data)
{
data &= (reg[3] & 0x3F) ^ 0xFF;
data &= 0x3F;
data |= reg[1];
SetPROM_8K_Bank(7, data);
p[3] = (byte)data;
}
void SetBank_PPU()
{
BYTE[] table = new byte[] {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF
};
c[0] = chr0;
c[1] = chr1;
c[2] = chr2;
c[3] = chr3;
c[4] = chr4;
c[5] = chr5;
c[6] = chr6;
c[7] = chr7;
for (INT i = 0; i < 8; i++)
{
c[i] &= table[reg[2] & 0x0F];
c[i] |= reg[0] & ((patch != 1) ? 0xFF : 0xC0);
c[i] += (reg[2] & ((patch != 1) ? 0x10 : 0x30)) << 4;
}
if ((reg[6] & 0x80) != 0)
{
SetVROM_8K_Bank(c[4], c[5], c[6], c[7], c[0], c[1], c[2], c[3]);
}
else
{
SetVROM_8K_Bank(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
}
}
//void Mapper045::SaveState(LPBYTE ps)
public override void SaveState(byte[] p)
{
//INT i;
//for (i = 0; i < 8; i++)
//{
// ps[i] = reg[i];
//}
//for (i = 0; i < 4; i++)
//{
// ps[i + 8] = p[i];
//}
//for (i = 0; i < 8; i++)
//{
// *(INT*)&ps[i * 4 + 64] = c[i];
//}
//ps[20] = prg0;
//ps[21] = prg1;
//ps[22] = prg2;
//ps[23] = prg3;
//ps[24] = chr0;
//ps[25] = chr1;
//ps[26] = chr2;
//ps[27] = chr3;
//ps[28] = chr4;
//ps[29] = chr5;
//ps[30] = chr6;
//ps[31] = chr7;
//ps[32] = irq_enable;
//ps[33] = irq_counter;
//ps[34] = irq_latch;
}
//void Mapper045::LoadState(LPBYTE ps)
public override void LoadState(byte[] p)
{
//INT i;
//for (i = 0; i < 8; i++)
//{
// reg[i] = ps[i];
//}
//for (i = 0; i < 4; i++)
//{
// p[i] = ps[i + 8];
//}
//for (i = 0; i < 8; i++)
//{
// c[i] = *(INT*)&ps[i * 4 + 64];
//}
//prg0 = ps[20];
//prg1 = ps[21];
//prg2 = ps[22];
//prg3 = ps[23];
//chr0 = ps[24];
//chr1 = ps[25];
//chr2 = ps[26];
//chr3 = ps[27];
//chr4 = ps[28];
//chr5 = ps[29];
//chr6 = ps[30];
//chr7 = ps[31];
//irq_enable = ps[32];
//irq_counter = ps[33];
//irq_latch = ps[34];
}
public override bool IsStateSave()
{
return true;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ddce49834ab1fac44bde0b09928875e0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,88 @@
//////////////////////////////////////////////////////////////////////////
// Mapper046 Rumble Station //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using Codice.CM.Client.Differences;
namespace VirtualNes.Core
{
public class Mapper046 : Mapper
{
int[] reg = new int[4];
public Mapper046(NES parent) : base(parent)
{
}
public override void Reset()
{
reg[0] = 0;
reg[1] = 0;
reg[2] = 0;
reg[3] = 0;
SetBank();
SetVRAM_Mirror(VRAM_VMIRROR);
}
//void Mapper046::WriteLow(WORD addr, BYTE data)
public override void WriteLow(ushort addr, byte data)
{
reg[0] = data & 0x0F;
reg[1] = (data & 0xF0) >> 4;
SetBank();
}
//void Mapper046::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
reg[2] = data & 0x01;
reg[3] = (data & 0x70) >> 4;
SetBank();
}
void SetBank()
{
SetPROM_8K_Bank(4, reg[0] * 8 + reg[2] * 4 + 0);
SetPROM_8K_Bank(5, reg[0] * 8 + reg[2] * 4 + 1);
SetPROM_8K_Bank(6, reg[0] * 8 + reg[2] * 4 + 2);
SetPROM_8K_Bank(7, reg[0] * 8 + reg[2] * 4 + 3);
SetVROM_1K_Bank(0, reg[1] * 64 + reg[3] * 8 + 0);
SetVROM_1K_Bank(1, reg[1] * 64 + reg[3] * 8 + 1);
SetVROM_1K_Bank(2, reg[1] * 64 + reg[3] * 8 + 2);
SetVROM_1K_Bank(3, reg[1] * 64 + reg[3] * 8 + 3);
SetVROM_1K_Bank(4, reg[1] * 64 + reg[3] * 8 + 4);
SetVROM_1K_Bank(5, reg[1] * 64 + reg[3] * 8 + 5);
SetVROM_1K_Bank(6, reg[1] * 64 + reg[3] * 8 + 6);
SetVROM_1K_Bank(7, reg[1] * 64 + reg[3] * 8 + 7);
}
//void Mapper046::SaveState(LPBYTE p)
public override void SaveState(byte[] p)
{
p[0] = (byte)reg[0];
p[1] = (byte)reg[1];
p[2] = (byte)reg[2];
p[3] = (byte)reg[3];
}
//void Mapper046::LoadState(LPBYTE p)
public override void LoadState(byte[] p)
{
reg[0] = p[0];
reg[1] = p[1];
reg[2] = p[2];
reg[3] = p[3];
}
public override bool IsStateSave()
{
return true;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 869faf0ac5d44c14eacb8e913bdcc1af
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,275 @@
//////////////////////////////////////////////////////////////////////////
// Mapper047 NES-QJ //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using System;
using Codice.CM.Client.Differences;
namespace VirtualNes.Core
{
public class Mapper047 : Mapper
{
BYTE[] reg = new byte[8];
BYTE patch;
BYTE bank;
BYTE prg0, prg1;
BYTE chr01, chr23, chr4, chr5, chr6, chr7;
BYTE irq_enable;
BYTE irq_counter;
BYTE irq_latch;
public Mapper047(NES parent) : base(parent)
{
}
public override void Reset()
{
patch = 0;
if (nes.rom.GetPROM_CRC() == 0x7eef434c)
{
patch = 1;
}
for (INT i = 0; i < 8; i++)
{
reg[i] = 0;
}
bank = 0;
prg0 = 0;
prg1 = 1;
// set VROM banks
if (VROM_1K_SIZE != 0)
{
chr01 = 0;
chr23 = 2;
chr4 = 4;
chr5 = 5;
chr6 = 6;
chr7 = 7;
}
else
{
chr01 = chr23 = chr4 = chr5 = chr6 = chr7 = 0;
}
SetBank_CPU();
SetBank_PPU();
irq_enable = 0;
irq_counter = 0;
irq_latch = 0;
}
//void Mapper047::WriteLow(WORD addr, BYTE data)
public override void WriteLow(ushort addr, byte data)
{
if (addr == 0x6000)
{
if (patch != 0)
{
bank = (byte)((data & 0x06) >> 1);
}
else
{
bank = (byte)((data & 0x01) << 1);
}
SetBank_CPU();
SetBank_PPU();
}
}
//void Mapper047::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
switch (addr & 0xE001)
{
case 0x8000:
reg[0] = data;
SetBank_CPU();
SetBank_PPU();
break;
case 0x8001:
reg[1] = data;
switch (reg[0] & 0x07)
{
case 0x00:
chr01 = (byte)(data & 0xFE);
SetBank_PPU();
break;
case 0x01:
chr23 = (byte)(data & 0xFE);
SetBank_PPU();
break;
case 0x02:
chr4 = data;
SetBank_PPU();
break;
case 0x03:
chr5 = data;
SetBank_PPU();
break;
case 0x04:
chr6 = data;
SetBank_PPU();
break;
case 0x05:
chr7 = data;
SetBank_PPU();
break;
case 0x06:
prg0 = data;
SetBank_CPU();
break;
case 0x07:
prg1 = data;
SetBank_CPU();
break;
}
break;
case 0xA000:
reg[2] = data;
if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR);
else SetVRAM_Mirror(VRAM_VMIRROR);
break;
case 0xA001:
reg[3] = data;
break;
case 0xC000:
reg[4] = data;
irq_counter = data;
break;
case 0xC001:
reg[5] = data;
irq_latch = data;
break;
case 0xE000:
reg[6] = data;
irq_enable = 0;
nes.cpu.ClrIRQ(IRQ_MAPPER);
break;
case 0xE001:
reg[7] = data;
irq_enable = 1;
break;
}
}
//void Mapper047::HSync(INT scanline)
public override void HSync(int scanline)
{
if ((scanline >= 0 && scanline <= 239))
{
if (nes.ppu.IsDispON())
{
if (irq_enable != 0)
{
if ((--irq_counter) == 0)
{
irq_counter = irq_latch;
// nes.cpu.IRQ();
nes.cpu.SetIRQ(IRQ_MAPPER);
}
}
}
}
}
void SetBank_CPU()
{
if ((reg[0] & 0x40) != 0)
{
SetPROM_8K_Bank(4, bank * 8 + ((patch != 0 && bank != 2) ? 6 : 14));
SetPROM_8K_Bank(5, bank * 8 + prg1);
SetPROM_8K_Bank(6, bank * 8 + prg0);
SetPROM_8K_Bank(7, bank * 8 + ((patch != 0 && bank != 2) ? 7 : 15));
}
else
{
SetPROM_8K_Bank(4, bank * 8 + prg0);
SetPROM_8K_Bank(5, bank * 8 + prg1);
SetPROM_8K_Bank(6, bank * 8 + ((patch != 0 && bank != 2) ? 6 : 14));
SetPROM_8K_Bank(7, bank * 8 + ((patch != 0 && bank != 2) ? 7 : 15));
}
}
void SetBank_PPU()
{
if (VROM_1K_SIZE != 0)
{
if ((reg[0] & 0x80) != 0)
{
SetVROM_1K_Bank(0, (bank & 0x02) * 64 + chr4);
SetVROM_1K_Bank(1, (bank & 0x02) * 64 + chr5);
SetVROM_1K_Bank(2, (bank & 0x02) * 64 + chr6);
SetVROM_1K_Bank(3, (bank & 0x02) * 64 + chr7);
SetVROM_1K_Bank(4, (bank & 0x02) * 64 + chr01 + 0);
SetVROM_1K_Bank(5, (bank & 0x02) * 64 + chr01 + 1);
SetVROM_1K_Bank(6, (bank & 0x02) * 64 + chr23 + 0);
SetVROM_1K_Bank(7, (bank & 0x02) * 64 + chr23 + 1);
}
else
{
SetVROM_1K_Bank(0, (bank & 0x02) * 64 + chr01 + 0);
SetVROM_1K_Bank(1, (bank & 0x02) * 64 + chr01 + 1);
SetVROM_1K_Bank(2, (bank & 0x02) * 64 + chr23 + 0);
SetVROM_1K_Bank(3, (bank & 0x02) * 64 + chr23 + 1);
SetVROM_1K_Bank(4, (bank & 0x02) * 64 + chr4);
SetVROM_1K_Bank(5, (bank & 0x02) * 64 + chr5);
SetVROM_1K_Bank(6, (bank & 0x02) * 64 + chr6);
SetVROM_1K_Bank(7, (bank & 0x02) * 64 + chr7);
}
}
}
//void Mapper047::SaveState(LPBYTE p)
public override void SaveState(byte[] p)
{
for (INT i = 0; i < 8; i++)
{
p[i] = reg[i];
}
p[8] = prg0;
p[9] = prg1;
p[10] = chr01;
p[11] = chr23;
p[12] = chr4;
p[13] = chr5;
p[14] = chr6;
p[15] = chr7;
p[16] = irq_enable;
p[17] = irq_counter;
p[18] = irq_latch;
p[19] = bank;
}
//void Mapper047::LoadState(LPBYTE p)
public override void LoadState(byte[] p)
{
for (INT i = 0; i < 8; i++)
{
reg[i] = p[i];
}
prg0 = p[8];
prg1 = p[9];
chr01 = p[10];
chr23 = p[11];
chr4 = p[12];
chr5 = p[13];
chr6 = p[14];
chr7 = p[15];
irq_enable = p[16];
irq_counter = p[17];
irq_latch = p[18];
bank = p[19];
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b35280f1894671747ba810b657054e8e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,143 @@
//////////////////////////////////////////////////////////////////////////
// Mapper048 Taito TC190V //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using System;
using Codice.CM.Client.Differences;
namespace VirtualNes.Core
{
public class Mapper048 : Mapper
{
BYTE reg;
BYTE irq_enable;
BYTE irq_counter;
public Mapper048(NES parent) : base(parent)
{
}
public override void Reset()
{
reg = 0;
irq_enable = 0;
irq_counter = 0;
SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1);
SetVROM_8K_Bank(0);
uint crc = nes.rom.GetPROM_CRC();
// if( crc == 0x547e6cc1 ) { // Flintstones - The Rescue of Dino & Hoppy(J)
// nes.SetRenderMethod( NES::POST_RENDER );
// }
}
//void Mapper048::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
switch (addr)
{
case 0x8000:
if (reg == 0)
{
if ((data & 0x40) != 0) SetVRAM_Mirror(VRAM_HMIRROR);
else SetVRAM_Mirror(VRAM_VMIRROR);
}
SetPROM_8K_Bank(4, data);
break;
case 0x8001:
SetPROM_8K_Bank(5, data);
break;
case 0x8002:
SetVROM_2K_Bank(0, data);
break;
case 0x8003:
SetVROM_2K_Bank(2, data);
break;
case 0xA000:
SetVROM_1K_Bank(4, data);
break;
case 0xA001:
SetVROM_1K_Bank(5, data);
break;
case 0xA002:
SetVROM_1K_Bank(6, data);
break;
case 0xA003:
SetVROM_1K_Bank(7, data);
break;
case 0xC000:
irq_counter = data;
irq_enable = 0;
// nes.cpu.ClrIRQ( IRQ_MAPPER );
break;
case 0xC001:
irq_counter = data;
irq_enable = 1;
// irq_enable = data & 0x01;
// nes.cpu.ClrIRQ( IRQ_MAPPER );
break;
case 0xC002:
break;
case 0xC003:
break;
case 0xE000:
if ((data & 0x40) != 0) SetVRAM_Mirror(VRAM_HMIRROR);
else SetVRAM_Mirror(VRAM_VMIRROR);
reg = 1;
break;
}
}
//void Mapper048::HSync(INT scanline)
public override void HSync(int scanline)
{
if ((scanline >= 0 && scanline <= 239))
{
if (nes.ppu.IsDispON())
{
if (irq_enable != 0)
{
if (irq_counter == 0xFF)
{
// nes.cpu.IRQ_NotPending();
// nes.cpu.SetIRQ( IRQ_MAPPER );
nes.cpu.SetIRQ(IRQ_TRIGGER2);
}
irq_counter++;
}
}
}
}
//void Mapper048::SaveState(LPBYTE p)
public override void SaveState(byte[] p)
{
p[0] = reg;
p[1] = irq_enable;
p[2] = irq_counter;
}
//void Mapper048::LoadState(LPBYTE p)
public override void LoadState(byte[] p)
{
reg = p[0];
irq_enable = p[1];
irq_counter = p[2];
}
public override bool IsStateSave()
{
return true;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e83144b10b1ec0546b0d4f40b8d5f305
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,100 @@
//////////////////////////////////////////////////////////////////////////
// Mapper050 SMB2J //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using System;
using Codice.CM.Client.Differences;
namespace VirtualNes.Core
{
public class Mapper050 : Mapper
{
BYTE irq_enable;
public Mapper050(NES parent) : base(parent)
{
}
public override void Reset()
{
irq_enable = 0;
SetPROM_8K_Bank(3, 15);
SetPROM_8K_Bank(4, 8);
SetPROM_8K_Bank(5, 9);
SetPROM_8K_Bank(6, 0);
SetPROM_8K_Bank(7, 11);
if (VROM_1K_SIZE != 0)
{
SetVROM_8K_Bank(0);
}
}
//void Mapper050::ExWrite(WORD addr, BYTE data)
public override void ExWrite(ushort addr, byte data)
{
if ((addr & 0xE060) == 0x4020)
{
if ((addr & 0x0100) != 0)
{
irq_enable = (byte)(data & 0x01);
nes.cpu.ClrIRQ(IRQ_MAPPER);
}
else
{
SetPROM_8K_Bank(6, (data & 0x08) | ((data & 0x01) << 2) | ((data & 0x06) >> 1));
}
}
}
//void Mapper050::WriteLow(WORD addr, BYTE data)
public override void WriteLow(ushort addr, byte data)
{
if ((addr & 0xE060) == 0x4020)
{
if ((addr & 0x0100) != 0)
{
irq_enable = (byte)(data & 0x01);
nes.cpu.ClrIRQ(IRQ_MAPPER);
}
else
{
SetPROM_8K_Bank(6, (data & 0x08) | ((data & 0x01) << 2) | ((data & 0x06) >> 1));
}
}
}
//void Mapper050::HSync(INT scanline)
public override void HSync(int scanline)
{
if (irq_enable != 0)
{
if (scanline == 21)
{
// nes.cpu.IRQ();
nes.cpu.SetIRQ(IRQ_MAPPER);
}
}
}
//void Mapper050::SaveState(LPBYTE p)
public override void SaveState(byte[] p)
{
p[0] = irq_enable;
}
//void Mapper050::LoadState(LPBYTE p)
public override void LoadState(byte[] p)
{
irq_enable = p[0];
}
public override bool IsStateSave()
{
return true;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 189113b0ca31017448ec750a72e57ddc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,109 @@
//////////////////////////////////////////////////////////////////////////
// Mapper051 11-in-1 //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using System;
using Codice.CM.Client.Differences;
namespace VirtualNes.Core
{
public class Mapper051 : Mapper
{
int mode, bank;
public Mapper051(NES parent) : base(parent)
{
}
public override void Reset()
{
bank = 0;
mode = 1;
SetBank_CPU();
SetCRAM_8K_Bank(0);
}
//void Mapper051::WriteLow(WORD addr, BYTE data)
public override void WriteLow(ushort addr, byte data)
{
if (addr >= 0x6000)
{
mode = ((data & 0x10) >> 3) | ((data & 0x02) >> 1);
SetBank_CPU();
}
}
//void Mapper051::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
bank = (data & 0x0f) << 2;
if (0xC000 <= addr && addr <= 0xDFFF)
{
mode = (mode & 0x01) | ((data & 0x10) >> 3);
}
SetBank_CPU();
}
void SetBank_CPU()
{
switch (mode)
{
case 0:
SetVRAM_Mirror(VRAM_VMIRROR);
SetPROM_8K_Bank(3, (bank | 0x2c | 3));
SetPROM_8K_Bank(4, (bank | 0x00 | 0));
SetPROM_8K_Bank(5, (bank | 0x00 | 1));
SetPROM_8K_Bank(6, (bank | 0x0c | 2));
SetPROM_8K_Bank(7, (bank | 0x0c | 3));
break;
case 1:
SetVRAM_Mirror(VRAM_VMIRROR);
SetPROM_8K_Bank(3, (bank | 0x20 | 3));
SetPROM_8K_Bank(4, (bank | 0x00 | 0));
SetPROM_8K_Bank(5, (bank | 0x00 | 1));
SetPROM_8K_Bank(6, (bank | 0x00 | 2));
SetPROM_8K_Bank(7, (bank | 0x00 | 3));
break;
case 2:
SetVRAM_Mirror(VRAM_VMIRROR);
SetPROM_8K_Bank(3, (bank | 0x2e | 3));
SetPROM_8K_Bank(4, (bank | 0x02 | 0));
SetPROM_8K_Bank(5, (bank | 0x02 | 1));
SetPROM_8K_Bank(6, (bank | 0x0e | 2));
SetPROM_8K_Bank(7, (bank | 0x0e | 3));
break;
case 3:
SetVRAM_Mirror(VRAM_HMIRROR);
SetPROM_8K_Bank(3, (bank | 0x20 | 3));
SetPROM_8K_Bank(4, (bank | 0x00 | 0));
SetPROM_8K_Bank(5, (bank | 0x00 | 1));
SetPROM_8K_Bank(6, (bank | 0x00 | 2));
SetPROM_8K_Bank(7, (bank | 0x00 | 3));
break;
}
}
//void Mapper051::SaveState(LPBYTE p)
public override void SaveState(byte[] p)
{
p[0] = (byte)mode;
p[1] = (byte)bank;
}
//void Mapper051::LoadState(LPBYTE p)
public override void LoadState(byte[] p)
{
mode = p[0];
bank = p[1];
}
public override bool IsStateSave()
{
return true;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 571fbd114543cf2498b886722d4db2c9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,87 @@
//////////////////////////////////////////////////////////////////////////
// Mapper057 //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using System;
using Codice.CM.Client.Differences;
namespace VirtualNes.Core
{
public class Mapper057 : Mapper
{
BYTE reg;
public Mapper057(NES parent) : base(parent)
{
}
public override void Reset()
{
SetPROM_32K_Bank(0, 1, 0, 1);
SetVROM_8K_Bank(0);
reg = 0;
}
//void Mapper057::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
switch (addr)
{
case 0x8000:
case 0x8001:
case 0x8002:
case 0x8003:
if ((data & 0x40) != 0)
{
SetVROM_8K_Bank((data & 0x03) + ((reg & 0x10) >> 1) + (reg & 0x07));
}
break;
case 0x8800:
reg = data;
if ((data & 0x80) != 0)
{
SetPROM_8K_Bank(4, ((data & 0x40) >> 6) * 4 + 8 + 0);
SetPROM_8K_Bank(5, ((data & 0x40) >> 6) * 4 + 8 + 1);
SetPROM_8K_Bank(6, ((data & 0x40) >> 6) * 4 + 8 + 2);
SetPROM_8K_Bank(7, ((data & 0x40) >> 6) * 4 + 8 + 3);
}
else
{
SetPROM_8K_Bank(4, ((data & 0x60) >> 5) * 2 + 0);
SetPROM_8K_Bank(5, ((data & 0x60) >> 5) * 2 + 1);
SetPROM_8K_Bank(6, ((data & 0x60) >> 5) * 2 + 0);
SetPROM_8K_Bank(7, ((data & 0x60) >> 5) * 2 + 1);
}
SetVROM_8K_Bank((data & 0x07) + ((data & 0x10) >> 1));
if ((data & 0x08) != 0) SetVRAM_Mirror(VRAM_HMIRROR);
else SetVRAM_Mirror(VRAM_VMIRROR);
break;
}
}
//void Mapper057::SaveState(LPBYTE p)
public override void SaveState(byte[] p)
{
p[0] = reg;
}
//void Mapper057::LoadState(LPBYTE p)
public override void LoadState(byte[] p)
{
reg = p[0];
}
public override bool IsStateSave()
{
return true;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4e308cd2cba2bd046b2174191bd85e40
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,53 @@
//////////////////////////////////////////////////////////////////////////
// Mapper058 //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using System;
using Codice.CM.Client.Differences;
namespace VirtualNes.Core
{
public class Mapper058 : Mapper
{
public Mapper058(NES parent) : base(parent)
{
}
public override void Reset()
{
SetPROM_32K_Bank(0, 1, 0, 1);
if (VROM_1K_SIZE != 0)
{
SetVROM_8K_Bank(0);
}
}
//void Mapper058::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
if ((addr & 0x40) != 0)
{
SetPROM_16K_Bank(4, addr & 0x07);
SetPROM_16K_Bank(6, addr & 0x07);
}
else
{
SetPROM_32K_Bank((addr & 0x06) >> 1);
}
if (VROM_1K_SIZE != 0)
{
SetVROM_8K_Bank((addr & 0x38) >> 3);
}
if ((data & 0x02) != 0) SetVRAM_Mirror(VRAM_VMIRROR);
else SetVRAM_Mirror(VRAM_HMIRROR);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1aa707df3277a794ca6410f942a25620
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,66 @@
//////////////////////////////////////////////////////////////////////////
// Mapper060 //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using System;
using Codice.CM.Client.Differences;
namespace VirtualNes.Core
{
public class Mapper060 : Mapper
{
BYTE patch;
BYTE game_sel;
public Mapper060(NES parent) : base(parent)
{
}
public override void Reset()
{
patch = 0;
uint crc = nes.rom.GetPROM_CRC();
if (crc == 0xf9c484a0)
{ // Reset Based 4-in-1(Unl)
SetPROM_16K_Bank(4, game_sel);
SetPROM_16K_Bank(6, game_sel);
SetVROM_8K_Bank(game_sel);
game_sel++;
game_sel &= 3;
}
else
{
patch = 1;
SetPROM_32K_Bank(0);
SetVROM_8K_Bank(0);
}
}
//void Mapper060::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
if (patch != 0)
{
if ((addr & 0x80) != 0)
{
SetPROM_16K_Bank(4, (addr & 0x70) >> 4);
SetPROM_16K_Bank(6, (addr & 0x70) >> 4);
}
else
{
SetPROM_32K_Bank((addr & 0x70) >> 5);
}
SetVROM_8K_Bank(addr & 0x07);
if ((data & 0x08) != 0) SetVRAM_Mirror(VRAM_VMIRROR);
else SetVRAM_Mirror(VRAM_HMIRROR);
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ec235304463428e49bf1df24c3e82799
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,47 @@
//////////////////////////////////////////////////////////////////////////
// Mapper061 //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using System;
using Codice.CM.Client.Differences;
namespace VirtualNes.Core
{
public class Mapper061 : Mapper
{
public Mapper061(NES parent) : base(parent)
{
}
public override void Reset()
{
SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1);
}
//void Mapper061::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
switch (addr & 0x30)
{
case 0x00:
case 0x30:
SetPROM_32K_Bank(addr & 0x0F);
break;
case 0x10:
case 0x20:
SetPROM_16K_Bank(4, ((addr & 0x0F) << 1) | ((addr & 0x20) >> 4));
SetPROM_16K_Bank(6, ((addr & 0x0F) << 1) | ((addr & 0x20) >> 4));
break;
}
if ((addr & 0x80) != 0) SetVRAM_Mirror(VRAM_HMIRROR);
else SetVRAM_Mirror(VRAM_VMIRROR);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 99e17dde8c75db54f9ece9eeb0767f7a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,53 @@
//////////////////////////////////////////////////////////////////////////
// Mapper062 //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using System;
using Codice.CM.Client.Differences;
namespace VirtualNes.Core
{
public class Mapper062 : Mapper
{
public Mapper062(NES parent) : base(parent)
{
}
public override void Reset()
{
SetPROM_32K_Bank(0);
SetVROM_8K_Bank(0);
}
//void Mapper062::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
switch (addr & 0xFF00)
{
case 0x8100:
SetPROM_8K_Bank(4, data);
SetPROM_8K_Bank(5, data + 1);
break;
case 0x8500:
SetPROM_8K_Bank(4, data);
break;
case 0x8700:
SetPROM_8K_Bank(5, data);
break;
SetVROM_1K_Bank(0, data + 0);
SetVROM_1K_Bank(1, data + 1);
SetVROM_1K_Bank(2, data + 2);
SetVROM_1K_Bank(3, data + 3);
SetVROM_1K_Bank(4, data + 4);
SetVROM_1K_Bank(5, data + 5);
SetVROM_1K_Bank(6, data + 6);
SetVROM_1K_Bank(7, data + 7);
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 939ee4b96ee5c424bba241dc62b5f6d4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,283 @@
//////////////////////////////////////////////////////////////////////////
// Mapper064 Tengen Rambo-1 //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using System;
using Codice.CM.Client.Differences;
namespace VirtualNes.Core
{
public class Mapper064 : Mapper
{
BYTE[] reg = new byte[3];
BYTE irq_enable;
BYTE irq_mode;
INT irq_counter;
INT irq_counter2;
BYTE irq_latch;
BYTE irq_reset;
public Mapper064(NES parent) : base(parent)
{
}
public override void Reset()
{
SetPROM_32K_Bank(PROM_8K_SIZE - 1, PROM_8K_SIZE - 1, PROM_8K_SIZE - 1, PROM_8K_SIZE - 1);
if (VROM_1K_SIZE != 0)
{
SetVROM_8K_Bank(0);
}
reg[0] = reg[1] = reg[2] = 0;
irq_enable = 0;
irq_mode = 0;
irq_counter = 0;
irq_counter2 = 0;
irq_latch = 0;
irq_reset = 0;
}
//void Mapper064::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
//DEBUGOUT( "$%04X:$%02X\n", addr, data );
switch (addr & 0xF003)
{
case 0x8000:
reg[0] = (byte)(data & 0x0F);
reg[1] = (byte)(data & 0x40);
reg[2] = (byte)(data & 0x80);
break;
case 0x8001:
switch (reg[0])
{
case 0x00:
if (reg[2] != 0)
{
SetVROM_1K_Bank(4, data + 0);
SetVROM_1K_Bank(5, data + 1);
}
else
{
SetVROM_1K_Bank(0, data + 0);
SetVROM_1K_Bank(1, data + 1);
}
break;
case 0x01:
if (reg[2] != 0)
{
SetVROM_1K_Bank(6, data + 0);
SetVROM_1K_Bank(7, data + 1);
}
else
{
SetVROM_1K_Bank(2, data + 0);
SetVROM_1K_Bank(3, data + 1);
}
break;
case 0x02:
if (reg[2] != 0)
{
SetVROM_1K_Bank(0, data);
}
else
{
SetVROM_1K_Bank(4, data);
}
break;
case 0x03:
if (reg[2] != 0)
{
SetVROM_1K_Bank(1, data);
}
else
{
SetVROM_1K_Bank(5, data);
}
break;
case 0x04:
if (reg[2] != 0)
{
SetVROM_1K_Bank(2, data);
}
else
{
SetVROM_1K_Bank(6, data);
}
break;
case 0x05:
if (reg[2] != 0)
{
SetVROM_1K_Bank(3, data);
}
else
{
SetVROM_1K_Bank(7, data);
}
break;
case 0x06:
if (reg[1] != 0)
{
SetPROM_8K_Bank(5, data);
}
else
{
SetPROM_8K_Bank(4, data);
}
break;
case 0x07:
if (reg[1] != 0)
{
SetPROM_8K_Bank(6, data);
}
else
{
SetPROM_8K_Bank(5, data);
}
break;
case 0x08:
SetVROM_1K_Bank(1, data);
break;
case 0x09:
SetVROM_1K_Bank(3, data);
break;
case 0x0F:
if (reg[1] != 0)
{
SetPROM_8K_Bank(4, data);
}
else
{
SetPROM_8K_Bank(6, data);
}
break;
}
break;
case 0xA000:
if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR);
else SetVRAM_Mirror(VRAM_VMIRROR);
break;
case 0xC000:
irq_latch = data;
if (irq_reset != 0)
{
irq_counter = irq_latch;
}
break;
case 0xC001:
irq_reset = 0xFF;
irq_counter = irq_latch;
irq_mode = (byte)(data & 0x01);
break;
case 0xE000:
irq_enable = 0;
if (irq_reset != 0)
{
irq_counter = irq_latch;
}
nes.cpu.ClrIRQ(IRQ_MAPPER);
break;
case 0xE001:
irq_enable = 0xFF;
if (irq_reset != 0)
{
irq_counter = irq_latch;
}
break;
}
}
//void Mapper064::Clock(INT cycles)
public override void Clock(int cycles)
{
if (irq_mode == 0)
return;
irq_counter2 += cycles;
while (irq_counter2 >= 4)
{
irq_counter2 -= 4;
if (irq_counter >= 0)
{
irq_counter--;
if (irq_counter < 0)
{
if (irq_enable != 0)
{
nes.cpu.SetIRQ(IRQ_MAPPER);
}
}
}
}
}
//void Mapper064::HSync(INT scanline)
public override void HSync(int scanline)
{
if (irq_mode != 0)
return;
irq_reset = 0;
if ((scanline >= 0 && scanline <= 239))
{
if (nes.ppu.IsDispON())
{
if (irq_counter >= 0)
{
irq_counter--;
if (irq_counter < 0)
{
if (irq_enable != 0)
{
irq_reset = 1;
nes.cpu.SetIRQ(IRQ_MAPPER);
}
}
}
}
}
}
//void Mapper064::SaveState(LPBYTE p)
public override void SaveState(byte[] p)
{
//p[0] = reg[0];
//p[1] = reg[1];
//p[2] = reg[2];
//p[3] = irq_enable;
//p[4] = irq_mode;
//p[5] = irq_latch;
//p[6] = irq_reset;
//*((INT*)&p[8]) = irq_counter;
//*((INT*)&p[12]) = irq_counter2;
}
//void Mapper064::LoadState(LPBYTE p)
public override void LoadState(byte[] p)
{
//reg[0] = p[0];
//reg[1] = p[1];
//reg[2] = p[2];
//irq_enable = p[3];
//irq_mode = p[4];
//irq_latch = p[5];
//irq_reset = p[6];
//irq_counter = *((INT*)&p[8]);
//irq_counter2 = *((INT*)&p[12]);
}
public override bool IsStateSave()
{
return true;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e265ca28ccd66d948996bae491315162
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,189 @@
//////////////////////////////////////////////////////////////////////////
// Mapper065 Irem H3001 //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using System;
using Codice.CM.Client.Differences;
namespace VirtualNes.Core
{
public class Mapper065 : Mapper
{
BYTE patch;
BYTE irq_enable;
INT irq_counter;
INT irq_latch;
public Mapper065(NES parent) : base(parent)
{
}
public override void Reset()
{
patch = 0;
// Kaiketsu Yanchamaru 3(J)
if (nes.rom.GetPROM_CRC() == 0xe30b7f64)
{
patch = 1;
}
SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1);
if (VROM_8K_SIZE != 0)
{
SetVROM_8K_Bank(0);
}
irq_enable = 0;
irq_counter = 0;
}
//void Mapper065::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
switch (addr)
{
case 0x8000:
SetPROM_8K_Bank(4, data);
break;
case 0x9000:
if (patch == 0)
{
if ((data & 0x40) != 0) SetVRAM_Mirror(VRAM_VMIRROR);
else SetVRAM_Mirror(VRAM_HMIRROR);
}
break;
case 0x9001:
if (patch != 0)
{
if ((data & 0x80) != 0) SetVRAM_Mirror(VRAM_HMIRROR);
else SetVRAM_Mirror(VRAM_VMIRROR);
}
break;
case 0x9003:
if (patch == 0)
{
irq_enable = (byte)(data & 0x8);
nes.cpu.ClrIRQ(IRQ_MAPPER);
}
break;
case 0x9004:
if (patch == 0)
{
irq_counter = irq_latch;
}
break;
case 0x9005:
if (patch != 0)
{
irq_counter = (BYTE)(data << 1);
irq_enable = data;
nes.cpu.ClrIRQ(IRQ_MAPPER);
}
else
{
irq_latch = (irq_latch & 0x00FF) | ((INT)data << 8);
}
break;
case 0x9006:
if (patch != 0)
{
irq_enable = 1;
}
else
{
irq_latch = (irq_latch & 0xFF00) | data;
}
break;
case 0xB000:
case 0xB001:
case 0xB002:
case 0xB003:
case 0xB004:
case 0xB005:
case 0xB006:
case 0xB007:
SetVROM_1K_Bank((byte)(addr & 0x0007), data);
break;
case 0xA000:
SetPROM_8K_Bank(5, data);
break;
case 0xC000:
SetPROM_8K_Bank(6, data);
break;
}
}
//void Mapper065::HSync(INT scanline)
public override void HSync(int scanline)
{
if (patch != 0)
{
if (irq_enable != 0)
{
if (irq_counter == 0)
{
// nes.cpu.IRQ_NotPending();
nes.cpu.SetIRQ(IRQ_MAPPER);
}
else
{
irq_counter--;
}
}
}
}
//void Mapper065::Clock(INT cycles)
public override void Clock(int cycles)
{
if (patch == 0)
{
if (irq_enable != 0)
{
if (irq_counter <= 0)
{
// nes.cpu.IRQ_NotPending();
nes.cpu.SetIRQ(IRQ_MAPPER);
}
else
{
irq_counter -= cycles;
}
}
}
}
//void Mapper065::SaveState(LPBYTE p)
public override void SaveState(byte[] p)
{
//p[0] = irq_enable;
//*(INT*)&p[1] = irq_counter;
//*(INT*)&p[5] = irq_latch;
}
//void Mapper065::LoadState(LPBYTE p)
public override void LoadState(byte[] p)
{
//irq_enable = p[0];
//irq_counter = *(INT*)&p[1];
//irq_latch = *(INT*)&p[5];
}
public override bool IsStateSave()
{
return true;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 953f2e26ba82ff64b9aac6ad4476afb5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,48 @@
//////////////////////////////////////////////////////////////////////////
// Mapper066 Bandai 74161 //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using System;
using Codice.CM.Client.Differences;
namespace VirtualNes.Core
{
public class Mapper066 : Mapper
{
public Mapper066(NES parent) : base(parent)
{
}
public override void Reset()
{
SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1);
SetVROM_8K_Bank(0);
// if( nes->rom->GetPROM_CRC() == 0xe30552db ) { // Paris-Dakar Rally Special
// nes->SetFrameIRQmode( FALSE );
// }
}
//void Mapper066::WriteLow(WORD addr, BYTE data)
public override void WriteLow(ushort addr, byte data)
{
if (addr >= 0x6000)
{
SetPROM_32K_Bank((data & 0xF0) >> 4);
SetVROM_8K_Bank(data & 0x0F);
}
}
//void Mapper066::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
SetPROM_32K_Bank((data & 0xF0) >> 4);
SetVROM_8K_Bank(data & 0x0F);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: de0206b3dc89c224b89aa969c373434c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,140 @@
//////////////////////////////////////////////////////////////////////////
// Mapper067 SunSoft Mapper 3 //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using System;
using Codice.CM.Client.Differences;
namespace VirtualNes.Core
{
public class Mapper067 : Mapper
{
BYTE irq_enable;
BYTE irq_occur;
BYTE irq_toggle;
INT irq_counter;
public Mapper067(NES parent) : base(parent)
{
}
public override void Reset()
{
irq_enable = 0;
irq_toggle = 0;
irq_counter = 0;
irq_occur = 0;
SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1);
SetVROM_4K_Bank(0, 0);
SetVROM_4K_Bank(4, VROM_4K_SIZE - 1);
uint crc = nes.rom.GetPROM_CRC();
if (crc == 0x7f2a04bf)
{ // For Fantasy Zone 2(J)
nes.SetRenderMethod(EnumRenderMethod.PRE_ALL_RENDER);
}
}
//void Mapper067::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
switch (addr & 0xF800)
{
case 0x8800:
SetVROM_2K_Bank(0, data);
break;
case 0x9800:
SetVROM_2K_Bank(2, data);
break;
case 0xA800:
SetVROM_2K_Bank(4, data);
break;
case 0xB800:
SetVROM_2K_Bank(6, data);
break;
case 0xC800:
if (irq_toggle == 0)
{
irq_counter = (irq_counter & 0x00FF) | ((INT)data << 8);
}
else
{
irq_counter = (irq_counter & 0xFF00) | ((INT)data & 0xFF);
}
irq_toggle ^= 1;
irq_occur = 0;
nes.cpu.ClrIRQ(IRQ_MAPPER);
break;
case 0xD800:
irq_enable = (byte)(data & 0x10);
irq_toggle = 0;
irq_occur = 0;
nes.cpu.ClrIRQ(IRQ_MAPPER);
break;
case 0xE800:
data &= 0x03;
if (data == 0) SetVRAM_Mirror(VRAM_VMIRROR);
else if (data == 1) SetVRAM_Mirror(VRAM_HMIRROR);
else if (data == 2) SetVRAM_Mirror(VRAM_MIRROR4L);
else SetVRAM_Mirror(VRAM_MIRROR4H);
break;
case 0xF800:
SetPROM_16K_Bank(4, data);
break;
}
}
//void Mapper067::Clock(INT cycles)
public override void Clock(int cycles)
{
if (irq_enable != 0)
{
if ((irq_counter -= cycles) <= 0)
{
irq_enable = 0;
irq_occur = 0xFF;
irq_counter = 0xFFFF;
nes.cpu.SetIRQ(IRQ_MAPPER);
}
}
// if( irq_occur ) {
// nes.cpu.IRQ_NotPending();
// }
}
//void Mapper067::SaveState(LPBYTE p)
public override void SaveState(byte[] p)
{
//p[0] = irq_enable;
//p[1] = irq_occur;
//p[2] = irq_toggle;
//*((INT*)&p[3]) = irq_counter;
}
//void Mapper067::LoadState(LPBYTE p)
public override void LoadState(byte[] p)
{
//irq_enable = p[0];
//irq_occur = p[1];
//irq_toggle = p[2];
//irq_counter = *((INT*)&p[3]);
}
public override bool IsStateSave()
{
return true;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5a6da4cd8de113e4c915b45d95b21e48
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,164 @@
//////////////////////////////////////////////////////////////////////////
// Mapper068 SunSoft Mapper 4 (After Burner II) //
//////////////////////////////////////////////////////////////////////////
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
using System;
using Codice.CM.Client.Differences;
namespace VirtualNes.Core
{
public class Mapper068 : Mapper
{
BYTE[] reg = new byte[4];
BYTE coin;
public Mapper068(NES parent) : base(parent)
{
}
public override void Reset()
{
reg[0] = reg[1] = reg[2] = reg[3] = 0;
coin = 0;
SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1);
}
#if FALSE //0
BYTE Mapper068::ExRead( WORD addr )
{
if( addr == 0x4020 ) {
DEBUGOUT( "RD $4020:%02X\n", coin );
return coin;
}
return addr>>8;
}
void Mapper068::ExWrite( WORD addr, BYTE data )
{
if( addr == 0x4020 ) {
DEBUGOUT( "WR $4020:%02X\n", data );
coin = data;
}
}
#endif
//void Mapper068::Write(WORD addr, BYTE data)
public override void Write(ushort addr, byte data)
{
switch (addr & 0xF000)
{
case 0x8000:
SetVROM_2K_Bank(0, data);
break;
case 0x9000:
SetVROM_2K_Bank(2, data);
break;
case 0xA000:
SetVROM_2K_Bank(4, data);
break;
case 0xB000:
SetVROM_2K_Bank(6, data);
break;
case 0xC000:
reg[2] = data;
SetBank();
break;
case 0xD000:
reg[3] = data;
SetBank();
break;
case 0xE000:
reg[0] = (byte)((data & 0x10) >> 4);
reg[1] = (byte)(data & 0x03);
SetBank();
break;
case 0xF000:
SetPROM_16K_Bank(4, data);
break;
}
}
void SetBank()
{
if (reg[0] != 0)
{
switch (reg[1])
{
case 0:
SetVROM_1K_Bank(8, (INT)reg[2] + 0x80);
SetVROM_1K_Bank(9, (INT)reg[3] + 0x80);
SetVROM_1K_Bank(10, (INT)reg[2] + 0x80);
SetVROM_1K_Bank(11, (INT)reg[3] + 0x80);
break;
case 1:
SetVROM_1K_Bank(8, (INT)reg[2] + 0x80);
SetVROM_1K_Bank(9, (INT)reg[2] + 0x80);
SetVROM_1K_Bank(10, (INT)reg[3] + 0x80);
SetVROM_1K_Bank(11, (INT)reg[3] + 0x80);
break;
case 2:
SetVROM_1K_Bank(8, (INT)reg[2] + 0x80);
SetVROM_1K_Bank(9, (INT)reg[2] + 0x80);
SetVROM_1K_Bank(10, (INT)reg[2] + 0x80);
SetVROM_1K_Bank(11, (INT)reg[2] + 0x80);
break;
case 3:
SetVROM_1K_Bank(8, (INT)reg[3] + 0x80);
SetVROM_1K_Bank(9, (INT)reg[3] + 0x80);
SetVROM_1K_Bank(10, (INT)reg[3] + 0x80);
SetVROM_1K_Bank(11, (INT)reg[3] + 0x80);
break;
}
}
else
{
switch (reg[1])
{
case 0:
SetVRAM_Mirror(VRAM_VMIRROR);
break;
case 1:
SetVRAM_Mirror(VRAM_HMIRROR);
break;
case 2:
SetVRAM_Mirror(VRAM_MIRROR4L);
break;
case 3:
SetVRAM_Mirror(VRAM_MIRROR4H);
break;
}
}
}
//void Mapper068::SaveState(LPBYTE p)
public override void SaveState(byte[] p)
{
p[0] = reg[0];
p[1] = reg[1];
p[2] = reg[2];
p[3] = reg[3];
}
//void Mapper068::LoadState(LPBYTE p)
public override void LoadState(byte[] p)
{
reg[0] = p[0];
reg[1] = p[1];
reg[2] = p[2];
reg[3] = p[3];
}
public override bool IsStateSave()
{
return true;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d94fb8248e814774caf84e3c8e2c508d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: e83144b10b1ec0546b0d4f40b8d5f305
guid: 2ddf7290610bea74593ad83b43909036
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -0,0 +1,20 @@
using static VirtualNes.MMU;
using static VirtualNes.Core.CPU;
using INT = System.Int32;
using BYTE = System.Byte;
namespace VirtualNes.Core
{
public class _Mapper : Mapper
{
public _Mapper(NES parent) : base(parent)
{
}
public override void Reset()
{
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a56d9f749be056e4b9ccf087899369ad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: