From cb66081f2cf0b88da17f13e49f90549128d777c3 Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Sat, 3 Aug 2024 23:15:19 +0800 Subject: [PATCH] transfer mapper 165-198 --- .../VirtualNes.Core/Mapper/Mapper165.cs | 197 ++++++++++ .../VirtualNes.Core/Mapper/Mapper165.cs.meta | 11 + .../VirtualNes.Core/Mapper/Mapper167.cs | 137 +++++++ .../VirtualNes.Core/Mapper/Mapper167.cs.meta | 11 + .../VirtualNes.Core/Mapper/Mapper180.cs | 37 ++ .../VirtualNes.Core/Mapper/Mapper180.cs.meta | 11 + .../VirtualNes.Core/Mapper/Mapper181.cs | 38 ++ .../VirtualNes.Core/Mapper/Mapper181.cs.meta | 11 + .../VirtualNes.Core/Mapper/Mapper182.cs | 123 ++++++ .../VirtualNes.Core/Mapper/Mapper182.cs.meta | 11 + .../VirtualNes.Core/Mapper/Mapper183.cs | 197 ++++++++++ .../VirtualNes.Core/Mapper/Mapper183.cs.meta | 11 + .../VirtualNes.Core/Mapper/Mapper185.cs | 68 ++++ .../VirtualNes.Core/Mapper/Mapper185.cs.meta | 11 + .../VirtualNes.Core/Mapper/Mapper187.cs | 371 ++++++++++++++++++ .../VirtualNes.Core/Mapper/Mapper187.cs.meta | 11 + .../VirtualNes.Core/Mapper/Mapper188.cs | 60 +++ .../VirtualNes.Core/Mapper/Mapper188.cs.meta | 11 + .../VirtualNes.Core/Mapper/Mapper189.cs | 320 +++++++++++++++ .../VirtualNes.Core/Mapper/Mapper189.cs.meta | 11 + .../VirtualNes.Core/Mapper/Mapper190.cs | 317 +++++++++++++++ .../VirtualNes.Core/Mapper/Mapper190.cs.meta | 11 + .../VirtualNes.Core/Mapper/Mapper191.cs | 138 +++++++ .../VirtualNes.Core/Mapper/Mapper191.cs.meta | 11 + .../VirtualNes.Core/Mapper/Mapper193.cs | 49 +++ .../VirtualNes.Core/Mapper/Mapper193.cs.meta | 11 + .../VirtualNes.Core/Mapper/Mapper194.cs | 31 ++ .../VirtualNes.Core/Mapper/Mapper194.cs.meta | 11 + .../VirtualNes.Core/Mapper/Mapper198.cs | 207 ++++++++++ .../VirtualNes.Core/Mapper/Mapper198.cs.meta | 11 + 30 files changed, 2455 insertions(+) create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper165.cs create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper165.cs.meta create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper167.cs create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper167.cs.meta create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper180.cs create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper180.cs.meta create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper181.cs create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper181.cs.meta create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper182.cs create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper182.cs.meta create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs.meta create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper185.cs create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper185.cs.meta create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs.meta create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper188.cs create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper188.cs.meta create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper189.cs create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper189.cs.meta create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper190.cs create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper190.cs.meta create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper191.cs create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper191.cs.meta create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper193.cs create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper193.cs.meta create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper194.cs create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper194.cs.meta create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper198.cs create mode 100644 AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper198.cs.meta diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper165.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper165.cs new file mode 100644 index 00000000..41119e6d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper165.cs @@ -0,0 +1,197 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper165 Fire Emblem Chinese version // +////////////////////////////////////////////////////////////////////////// +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 Mapper165 : Mapper + { + BYTE[] reg = new byte[8]; + BYTE prg0, prg1; + BYTE chr0, chr1, chr2, chr3; + BYTE we_sram; + BYTE latch; + public Mapper165(NES parent) : base(parent) + { + } + + public override void Reset() + + { + for (INT i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + prg0 = 0; + prg1 = 1; + SetBank_CPU(); + + chr0 = 0; + chr1 = 0; + chr2 = 4; + chr3 = 4; + latch = 0xFD; + SetBank_PPU(); + + we_sram = 0; // Disable + + nes->ppu->SetChrLatchMode(TRUE); + } + + //void Mapper165::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: + chr0 = (byte)(data & 0xFC); + if (latch == 0xFD) + SetBank_PPU(); + break; + case 0x01: + chr1 = (byte)(data & 0xFC); + if (latch == 0xFE) + SetBank_PPU(); + break; + + case 0x02: + chr2 = (byte)(data & 0xFC); + if (latch == 0xFD) + SetBank_PPU(); + break; + case 0x04: + chr3 = (byte)(data & 0xFC); + if (latch == 0xFE) + 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; + default: + break; + } + + } + + void SetBank_CPU() + { + SetPROM_32K_Bank(prg0, prg1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + + void SetBank_PPU() + { + if (latch == 0xFD) + { + SetBank_PPUSUB(0, chr0); + SetBank_PPUSUB(4, chr2); + } + else + { + SetBank_PPUSUB(0, chr1); + SetBank_PPUSUB(4, chr3); + } + } + + void SetBank_PPUSUB(int bank, int page) + { + if (page == 0) + { + SetCRAM_4K_Bank((byte)bank, page >> 2); + } + else + { + SetVROM_4K_Bank((byte)bank, page >> 2); + } + } + + //void Mapper165::PPU_ChrLatch(WORD addr) + public override void PPU_ChrLatch(ushort addr) + { + ushort mask = (ushort)(addr & 0x1FF0); + + if (mask == 0x1FD0) + { + latch = 0xFD; + SetBank_PPU(); + } + else if (mask == 0x1FE0) + { + latch = 0xFE; + SetBank_PPU(); + } + + } + + //void Mapper165::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] = chr0; + p[11] = chr1; + p[12] = chr2; + p[13] = chr3; + p[14] = latch; + } + + //void Mapper165::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]; + chr0 = p[10]; + chr1 = p[11]; + chr2 = p[12]; + chr3 = p[13]; + latch = p[14]; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper165.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper165.cs.meta new file mode 100644 index 00000000..371fc1b7 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper165.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bbfe308ca0a341f439b9c6772903cde4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper167.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper167.cs new file mode 100644 index 00000000..90ef150c --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper167.cs @@ -0,0 +1,137 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper004 Supor Computer V4.0 // +////////////////////////////////////////////////////////////////////////// +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 Mapper167 : Mapper + { + BYTE[] regs = new byte[4]; + BYTE rom_type; + public Mapper167(NES parent) : base(parent) + { + } + + public override void Reset() + { + uint crc; + + regs[0] = 0; + regs[1] = 0; + regs[2] = 0; + regs[3] = 0; + + crc = nes.rom.GetPROM_CRC(); + if (crc == 0x82F1Fb96) + { + // Subor Computer(Russia) + rom_type = 1; + } + else + { + // Subor Computer(Chinese) + rom_type = 0; + } + + SetBank_CPU(); + SetBank_PPU(); + } + + //void Mapper167::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + int idx; + + idx = (addr >> 13) & 0x03; + regs[idx] = data; + SetBank_CPU(); + SetBank_PPU(); + // DEBUGOUT("write to %04x:%02x\n", addr, data); + } + + + void SetBank_CPU() + { + int @base, bank; + + @base = ((regs[0] ^ regs[1]) & 0x10) << 1; + bank = (regs[2] ^ regs[3]) & 0x1f; + + if ((regs[1] & 0x08) != 0) + { + bank &= 0xfe; + if (rom_type == 0) + { + SetPROM_16K_Bank(4, @base + bank + 1); + SetPROM_16K_Bank(6, @base + bank + 0); + } + else + { + SetPROM_16K_Bank(6, @base + bank + 1); + SetPROM_16K_Bank(4, @base + bank + 0); + } + // DEBUGOUT("32K MODE!\n"); + } + else + { + if ((regs[1] & 0x04) != 0) + { + SetPROM_16K_Bank(4, 0x1f); + SetPROM_16K_Bank(6, @base + bank); + // DEBUGOUT("HIGH 16K MODE!\n"); + } + else + { + SetPROM_16K_Bank(4, @base + bank); + if (rom_type == 0) + { + SetPROM_16K_Bank(6, 0x20); + } + else + { + SetPROM_16K_Bank(6, 0x07); + } + // DEBUGOUT("LOW 16K MODE!\n"); + } + } + + + } + + void SetBank_PPU() + { + SetCRAM_8K_Bank(0); + } + + //void Mapper167::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = regs[0]; + p[1] = regs[1]; + p[2] = regs[2]; + p[3] = regs[3]; + p[4] = rom_type; + } + + //void Mapper167::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + regs[0] = p[0]; + regs[1] = p[1]; + regs[2] = p[2]; + regs[3] = p[3]; + rom_type = p[4]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper167.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper167.cs.meta new file mode 100644 index 00000000..bf96ff83 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper167.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cd018661871c8d34ab9fd790666e5b75 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper180.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper180.cs new file mode 100644 index 00000000..f6ffc29c --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper180.cs @@ -0,0 +1,37 @@ +////////////////////////////////////////////// +// Mapper180 Nichibutsu // +////////////////////////////////////////////////////////////////////////// +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 Mapper180 : Mapper + { + public Mapper180(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper180::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + SetPROM_16K_Bank(6, data & 0x07); + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper180.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper180.cs.meta new file mode 100644 index 00000000..84cf64b5 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper180.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0690d23936f8e3a42ad2ea112dbfb3f2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper181.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper181.cs new file mode 100644 index 00000000..b39ae4d9 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper181.cs @@ -0,0 +1,38 @@ +/////////////////////////////////////////////////////// +// Mapper181 Hacker International Type2 // +////////////////////////////////////////////////////////////////////////// +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 Mapper181 : Mapper + { + public Mapper181(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + SetVROM_8K_Bank(0); + } + + //void Mapper181::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + //DEBUGOUT( "$%04X:$%02X\n", addr, data ); + if (addr == 0x4120) + { + SetPROM_32K_Bank((data & 0x08) >> 3); + SetVROM_8K_Bank(data & 0x07); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper181.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper181.cs.meta new file mode 100644 index 00000000..01d975ae --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper181.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 62cd0f9e43adec242bc4f1ff7f2cae4f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper182.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper182.cs new file mode 100644 index 00000000..9cddc37a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper182.cs @@ -0,0 +1,123 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper182 PC-SuperDonkeyKong // +////////////////////////////////////////////////////////////////////////// +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 Mapper182 : Mapper + { + BYTE reg; + BYTE irq_enable; + BYTE irq_counter; + public Mapper182(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); + + reg = 0; + irq_enable = 0; + irq_counter = 0; + } + + //void Mapper182::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF003) + { + case 0x8001: + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + break; + case 0xA000: + reg = (byte)(data & 0x07); + break; + case 0xC000: + switch (reg) + { + case 0: + SetVROM_1K_Bank(0, (data & 0xFE) + 0); + SetVROM_1K_Bank(1, (data & 0xFE) + 1); + break; + case 1: + SetVROM_1K_Bank(5, data); + break; + case 2: + SetVROM_1K_Bank(2, (data & 0xFE) + 0); + SetVROM_1K_Bank(3, (data & 0xFE) + 1); + break; + case 3: + SetVROM_1K_Bank(7, data); + break; + case 4: + SetPROM_8K_Bank(4, data); + break; + case 5: + SetPROM_8K_Bank(5, data); + break; + case 6: + SetVROM_1K_Bank(4, data); + break; + case 7: + SetVROM_1K_Bank(6, data); + break; + } + break; + case 0xE003: + irq_enable = data; + irq_counter = data; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper182::HSync(INT scanline) + public override void HSync(int scanline) + { + if (irq_enable != 0) + { + if ((scanline >= 0 && scanline <= 239) && nes.ppu.IsDispON()) + { + if ((--irq_counter) == 0) + { + irq_enable = 0; + irq_counter = 0; + // nes.cpu.IRQ_NotPending(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + + //void Mapper182::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg; + p[1] = irq_enable; + p[2] = irq_counter; + } + + //void Mapper182::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; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper182.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper182.cs.meta new file mode 100644 index 00000000..c78ed0c4 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper182.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5b5348cd0dcfc7949b576b96ee04dee9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs new file mode 100644 index 00000000..8d60d8d5 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs @@ -0,0 +1,197 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper183 Gimmick (Bootleg) // +////////////////////////////////////////////////////////////////////////// +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 Mapper183 : Mapper + { + BYTE[] reg = new byte[8]; + BYTE irq_enable; + INT irq_counter; + public Mapper183(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); + + for (byte i = 0; i < 8; i++) + { + reg[i] = i; + } + irq_enable = 0; + irq_counter = 0; + } + + //void Mapper183::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr) + { + case 0x8800: + SetPROM_8K_Bank(4, data); + break; + case 0xA800: + SetPROM_8K_Bank(5, data); + break; + case 0xA000: + SetPROM_8K_Bank(6, data); + break; + + case 0xB000: + reg[0] = (byte)((reg[0] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(0, reg[0]); + break; + case 0xB004: + reg[0] = (byte)((reg[0] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(0, reg[0]); + break; + case 0xB008: + reg[1] = (byte)((reg[1] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(1, reg[1]); + break; + case 0xB00C: + reg[1] = (byte)((reg[1] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(1, reg[1]); + break; + + case 0xC000: + reg[2] = (byte)((reg[2] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(2, reg[2]); + break; + case 0xC004: + reg[2] = (byte)((reg[2] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(2, reg[2]); + break; + case 0xC008: + reg[3] = (byte)((reg[3] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(3, reg[3]); + break; + case 0xC00C: + reg[3] = (byte)((reg[3] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(3, reg[3]); + break; + + case 0xD000: + reg[4] = (byte)((reg[4] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(4, reg[4]); + break; + case 0xD004: + reg[4] = (byte)((reg[4] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(4, reg[4]); + break; + case 0xD008: + reg[5] = (byte)((reg[5] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(5, reg[5]); + break; + case 0xD00C: + reg[5] = (byte)((reg[5] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(5, reg[5]); + break; + + case 0xE000: + reg[6] = (byte)((reg[6] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(6, reg[6]); + break; + case 0xE004: + reg[6] = (byte)((reg[6] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(6, reg[6]); + break; + case 0xE008: + reg[7] = (byte)((reg[3] & 0xF0) | (data & 0x0F)); + SetVROM_1K_Bank(7, reg[7]); + break; + case 0xE00C: + reg[7] = (byte)((reg[3] & 0x0F) | ((data & 0x0F) << 4)); + SetVROM_1K_Bank(7, reg[7]); + break; + + case 0x9008: + if (data == 1) + { + for (byte i = 0; i < 8; i++) + { + reg[i] = i; + } + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + SetVROM_8K_Bank(0); + } + break; + + case 0x9800: + if (data == 0) SetVRAM_Mirror(VRAM_VMIRROR); + else if (data == 1) SetVRAM_Mirror(VRAM_HMIRROR); + else if (data == 2) SetVRAM_Mirror(VRAM_MIRROR4L); + else if (data == 3) SetVRAM_Mirror(VRAM_MIRROR4H); + break; + + case 0xF000: + irq_counter = (irq_counter & 0xFF00) | data; + break; + case 0xF004: + irq_counter = (irq_counter & 0x00FF) | (data << 8); + break; + case 0xF008: + irq_enable = data; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper183::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((irq_enable & 0x02) != 0) + { + if (irq_counter <= 113) + { + irq_counter = 0; + // nes.cpu.IRQ_NotPending(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + else + { + irq_counter -= 113; + } + } + } + + //void Mapper183::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //for (INT i = 0; i < 8; i++) + //{ + // p[i] = reg[i]; + //} + //p[8] = irq_enable; + //*((INT*)&p[9]) = irq_counter; + } + + //void Mapper183::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + // for (INT i = 0; i < 8; i++) + // { + // reg[i] = p[i]; + // } + // irq_enable = p[8]; + // irq_counter = *((INT*)&p[9]); + } + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs.meta new file mode 100644 index 00000000..8f1e6044 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper183.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8a30c259cae622e40a3ffe2da26883c8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper185.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper185.cs new file mode 100644 index 00000000..db8eef47 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper185.cs @@ -0,0 +1,68 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper185 Character disable protect // +////////////////////////////////////////////////////////////////////////// +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 Mapper185 : Mapper + { + BYTE patch; + public Mapper185(NES parent) : base(parent) + { + } + + public override void Reset() + + { + switch (PROM_16K_SIZE) + { + case 1: // 16K only + SetPROM_16K_Bank(4, 0); + SetPROM_16K_Bank(6, 0); + break; + case 2: // 32K + SetPROM_32K_Bank(0); + break; + } + + for (INT i = 0; i < 0x400; i++) + { + VRAM[0x800 + i] = 0xFF; + } + patch = 0; + + uint crc = nes.rom.GetPROM_CRC(); + if (crc == 0xb36457c7) + { // Spy vs Spy(J) + patch = 1; + } + } + + //void Mapper185::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if (((patch == 0) && ((data & 0x03) != 0)) || ((patch != 0) && data == 0x21)) + { + SetVROM_8K_Bank(0); + } + else + { + SetVRAM_1K_Bank(0, 2); // use vram bank 2 + SetVRAM_1K_Bank(1, 2); + SetVRAM_1K_Bank(2, 2); + SetVRAM_1K_Bank(3, 2); + SetVRAM_1K_Bank(4, 2); + SetVRAM_1K_Bank(5, 2); + SetVRAM_1K_Bank(6, 2); + SetVRAM_1K_Bank(7, 2); + } + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper185.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper185.cs.meta new file mode 100644 index 00000000..c32aa014 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper185.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5172897463091b440aa762737b586b67 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs new file mode 100644 index 00000000..58bfe378 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs @@ -0,0 +1,371 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper187 Street Fighter Zero 2 97 // +////////////////////////////////////////////////////////////////////////// +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 Mapper187 : Mapper + { + + BYTE[] prg = new byte[4]; + INT[] chr = new int[8]; + BYTE[] bank = new byte[8]; + + BYTE ext_mode; + BYTE chr_mode; + BYTE ext_enable; + + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + BYTE irq_occur; + BYTE last_write; + public Mapper187(NES parent) : base(parent) + { + } + + public override void Reset() + + { + INT i; + + for (i = 0; i < 8; i++) + { + chr[i] = 0x00; + bank[i] = 0x00; + } + + prg[0] = (byte)(PROM_8K_SIZE - 4); + prg[1] = (byte)(PROM_8K_SIZE - 3); + prg[2] = (byte)(PROM_8K_SIZE - 2); + prg[3] = (byte)(PROM_8K_SIZE - 1); + SetBank_CPU(); + + ext_mode = 0; + chr_mode = 0; + ext_enable = 0; + + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + + last_write = 0; + + nes.SetRenderMethod(EnumRenderMethod.POST_ALL_RENDER); + } + + //BYTE Mapper187::ReadLow(WORD addr) + public override byte ReadLow(ushort addr) + { + switch (last_write & 0x03) + { + case 0: + return 0x83; + case 1: + return 0x83; + case 2: + return 0x42; + case 3: + return 0x00; + } + return 0; + } + + //void Mapper187::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + last_write = data; + if (addr == 0x5000) + { + ext_mode = data; + if ((data & 0x80) != 0) + { + if ((data & 0x20) != 0) + { + prg[0] = (byte)(((data & 0x1E) << 1) + 0); + prg[1] = (byte)(((data & 0x1E) << 1) + 1); + prg[2] = (byte)(((data & 0x1E) << 1) + 2); + prg[3] = (byte)(((data & 0x1E) << 1) + 3); + } + else + { + prg[2] = (byte)(((data & 0x1F) << 1) + 0); + prg[3] = (byte)(((data & 0x1F) << 1) + 1); + } + } + else + { + prg[0] = bank[6]; + prg[1] = bank[7]; + prg[2] = (byte)(PROM_8K_SIZE - 2); + prg[3] = (byte)(PROM_8K_SIZE - 1); + } + SetBank_CPU(); + } + } + + //void Mapper187::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + last_write = data; + switch (addr) + { + case 0x8003: + ext_enable = 0xFF; + // if( (data&0x80) != (chr_mode&0x80) ) { + // for( INT i = 0; i < 4; i++ ) { + // INT temp = chr[i]; + // chr[i] = chr[i+4]; + // chr[i+4] = temp; + // } + // SetBank_PPU(); + // } + chr_mode = data; + if ((data & 0xF0) == 0) + { + prg[2] = (byte)(PROM_8K_SIZE - 2); + SetBank_CPU(); + } + break; + + case 0x8000: + ext_enable = 0; + // if( (data&0x80) != (chr_mode&0x80) ) { + // for( INT i = 0; i < 4; i++ ) { + // INT temp = chr[i]; + // chr[i] = chr[i+4]; + // chr[i+4] = temp; + // } + // SetBank_PPU(); + // } + chr_mode = data; + break; + + case 0x8001: + if (ext_enable == 0) + { + switch (chr_mode & 7) + { + case 0: + data &= 0xFE; + chr[4] = (INT)data + 0x100; + chr[5] = (INT)data + 0x100 + 1; + // chr[0+((chr_mode&0x80)?4:0)] = data; + // chr[1+((chr_mode&0x80)?4:0)] = data+1; + SetBank_PPU(); + break; + case 1: + data &= 0xFE; + chr[6] = (INT)data + 0x100; + chr[7] = (INT)data + 0x100 + 1; + // chr[2+((chr_mode&0x80)?4:0)] = data; + // chr[3+((chr_mode&0x80)?4:0)] = data+1; + SetBank_PPU(); + break; + case 2: + chr[0] = data; + // chr[0+((chr_mode&0x80)?0:4)] = data; + SetBank_PPU(); + break; + case 3: + chr[1] = data; + // chr[1+((chr_mode&0x80)?0:4)] = data; + SetBank_PPU(); + break; + case 4: + chr[2] = data; + // chr[2+((chr_mode&0x80)?0:4)] = data; + SetBank_PPU(); + break; + case 5: + chr[3] = data; + // chr[3+((chr_mode&0x80)?0:4)] = data; + SetBank_PPU(); + break; + case 6: + if ((ext_mode & 0xA0) != 0xA0) + { + prg[0] = data; + SetBank_CPU(); + } + break; + case 7: + if ((ext_mode & 0xA0) != 0xA0) + { + prg[1] = data; + SetBank_CPU(); + } + break; + default: + break; + } + } + else + { + switch (chr_mode) + { + case 0x2A: + prg[1] = 0x0F; + break; + case 0x28: + prg[2] = 0x17; + break; + case 0x26: + break; + default: + break; + } + SetBank_CPU(); + } + bank[chr_mode & 7] = data; + break; + + case 0xA000: + if ((data & 0x01) != 0) + { + SetVRAM_Mirror(VRAM_HMIRROR); + } + else + { + SetVRAM_Mirror(VRAM_VMIRROR); + } + break; + case 0xA001: + break; + + case 0xC000: + irq_counter = data; + irq_occur = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xC001: + irq_latch = data; + irq_occur = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE000: + case 0xE002: + irq_enable = 0; + irq_occur = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + case 0xE003: + irq_enable = 1; + irq_occur = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper187::Clock(INT cycles) + public override void Clock(int cycles) + { + // if( irq_occur ) { + // nes.cpu.IRQ_NotPending(); + // } + } + + // void Mapper187::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_enable = 0; + irq_occur = 0xFF; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + else + { + irq_counter--; + } + } + } + } + } + + void SetBank_CPU() + { + SetPROM_32K_Bank(prg[0], prg[1], prg[2], prg[3]); + } + + void SetBank_PPU() + { + SetVROM_8K_Bank(chr[0], chr[1], chr[2], chr[3], + chr[4], chr[5], chr[6], chr[7]); + } + + //void Mapper187::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //INT i; + + //for (i = 0; i < 4; i++) + //{ + // p[i] = prg[i]; + //} + //for (i = 0; i < 8; i++) + //{ + // p[4 + i] = bank[i]; + //} + //for (i = 0; i < 8; i++) + //{ + // *((INT*)&p[12 + i * sizeof(INT)]) = chr[i]; + //} + + //p[44] = ext_mode; + //p[45] = chr_mode; + //p[46] = ext_enable; + //p[47] = irq_enable; + //p[48] = irq_counter; + //p[49] = irq_latch; + //p[50] = irq_occur; + //p[51] = last_write; + } + + //void Mapper187::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //INT i; + + //for (i = 0; i < 4; i++) + //{ + // prg[i] = p[i]; + //} + //for (i = 0; i < 8; i++) + //{ + // bank[i] = p[4 + i]; + //} + //for (i = 0; i < 8; i++) + //{ + // chr[i] = *((INT*)&p[12 + i * sizeof(INT)]); + //} + //ext_mode = p[44]; + //chr_mode = p[45]; + //ext_enable = p[46]; + //irq_enable = p[47]; + //irq_counter = p[48]; + //irq_latch = p[49]; + //irq_occur = p[50]; + //last_write = p[51]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs.meta new file mode 100644 index 00000000..24c87de4 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper187.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: defdc0bc39e45624b958e7d2d3a40430 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper188.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper188.cs new file mode 100644 index 00000000..347e454e --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper188.cs @@ -0,0 +1,60 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper188 Bandai Karaoke Studio // +////////////////////////////////////////////////////////////////////////// +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 Mapper188 : Mapper + { + public Mapper188(NES parent) : base(parent) + { + } + public override void Reset() + { + if (PROM_8K_SIZE > 16) + { + SetPROM_32K_Bank(0, 1, 14, 15); + } + else + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + } + + //void Mapper188::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if (data != 0) + { + if ((data & 0x10) != 0) + { + data &= 0x07; + SetPROM_16K_Bank(4, data); + } + else + { + SetPROM_16K_Bank(4, data + 8); + } + } + else + { + if (PROM_8K_SIZE == 0x10) + { + SetPROM_16K_Bank(4, 7); + } + else + { + SetPROM_16K_Bank(4, 8); + } + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper188.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper188.cs.meta new file mode 100644 index 00000000..44ff8b7d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper188.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 30eeef1e68b38eb42b07dcb03d6f5e00 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper189.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper189.cs new file mode 100644 index 00000000..e07c6778 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper189.cs @@ -0,0 +1,320 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper189 Street Fighter 2/Yoko version // +// 快打傅説 Street Fighter IV (GOUDER) // +////////////////////////////////////////////////////////////////////////// +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 Mapper189 : Mapper + { + BYTE patch; + + BYTE[] reg = new BYTE[2]; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + + // SF4 + BYTE[] protect_dat = new byte[4]; + BYTE lwd; + public Mapper189(NES parent) : base(parent) + { + } + + public override void Reset() + + { + SetPROM_32K_Bank(PROM_8K_SIZE - 4, PROM_8K_SIZE - 3, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + reg[0] = reg[1] = 0; + + chr01 = 0; + chr23 = 2; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + SetBank_PPU(); + + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + + for (INT i = 0; i < 4; i++) + { + protect_dat[i] = 0; + } + lwd = 0xFF; + + patch = 0; + uint crc = nes.rom.GetPROM_CRC(); + if (crc == 0x20ca2ad3) + { // Street Fighter IV (GOUDER) + patch = 1; + SetPROM_32K_Bank(0); + + // $4000-$5FFF + SetPROM_Bank(2, XRAM, BANKTYPE_ROM); + } + } + + //void Mapper189::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if ((addr & 0xFF00) == 0x4100) + { + // Street Fighter 2 YOKO + SetPROM_32K_Bank((data & 0x30) >> 4); + } + else if ((addr & 0xFF00) == 0x6100) + { + // Master Fighter 2 + SetPROM_32K_Bank(data & 0x03); + } + + if (patch != 0) + { + // Street Fighter IV (GOUDER) + BYTE[] a5000xordat = new byte[256]{ + 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09, + 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01, + 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09, + 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01, + 0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08, + 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00, + 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08, + 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00, + 0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + if ((addr >= 0x4800) && (addr <= 0x4FFF)) + { + SetPROM_32K_Bank(((data & 0x10) >> 3) + (data & 0x1)); + + if (!nes.rom.Is4SCREEN()) + { + if ((data & 0x20) != 0) + SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + } + if ((addr >= 0x5000) && (addr <= 0x57FF)) + { + lwd = data; + } + if ((addr >= 0x5800) && (addr <= 0x5FFF)) + { + // XRAM[0x1000+(addr & 3)] = + // $5800 "JMP $xxxx" write + XRAM[0x1800 + (addr & 3)] = + protect_dat[addr & 3] = (byte)(data ^ a5000xordat[lwd]); + } + } + } + + //void Mapper189::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE001) + { + case 0x8000: + reg[0] = data; + SetBank_PPU(); + break; + + case 0x8001: + reg[1] = data; + SetBank_PPU(); + 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; + } + break; + + case 0xA000: + if ((data & 0x01) != 0) + SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + break; + + case 0xC000: + irq_counter = data; + break; + case 0xC001: + irq_latch = data; + break; + case 0xE000: + irq_enable = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + irq_enable = 0xFF; + break; + } + } + + //void Mapper189::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) + { + // if( !(irq_counter--) ) { + irq_counter = irq_latch; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + void SetBank_PPU() + { + if (patch != 0) + { + SetVROM_8K_Bank(chr01, chr01 + 1, chr23, chr23 + 1, + chr4, chr5, chr6, chr7); + } + else + { + if (VROM_1K_SIZE != 0) + { + if ((reg[0] & 0x80) != 0) + { + SetVROM_8K_Bank(chr4, chr5, chr6, chr7, + chr01, chr01 + 1, chr23, chr23 + 1); + } + else + { + SetVROM_8K_Bank(chr01, chr01 + 1, chr23, chr23 + 1, + chr4, chr5, chr6, chr7); + } + } + else + { + if ((reg[0] & 0x80) != 0) + { + SetCRAM_1K_Bank(4, (chr01 + 0) & 0x07); + SetCRAM_1K_Bank(5, (chr01 + 1) & 0x07); + SetCRAM_1K_Bank(6, (chr23 + 0) & 0x07); + SetCRAM_1K_Bank(7, (chr23 + 1) & 0x07); + SetCRAM_1K_Bank(0, chr4 & 0x07); + SetCRAM_1K_Bank(1, chr5 & 0x07); + SetCRAM_1K_Bank(2, chr6 & 0x07); + SetCRAM_1K_Bank(3, chr7 & 0x07); + } + else + { + SetCRAM_1K_Bank(0, (chr01 + 0) & 0x07); + SetCRAM_1K_Bank(1, (chr01 + 1) & 0x07); + SetCRAM_1K_Bank(2, (chr23 + 0) & 0x07); + SetCRAM_1K_Bank(3, (chr23 + 1) & 0x07); + SetCRAM_1K_Bank(4, chr4 & 0x07); + SetCRAM_1K_Bank(5, chr5 & 0x07); + SetCRAM_1K_Bank(6, chr6 & 0x07); + SetCRAM_1K_Bank(7, chr7 & 0x07); + } + } + } + } + + //void Mapper189::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg[0]; + p[1] = reg[1]; + p[2] = chr01; + p[3] = chr23; + p[4] = chr4; + p[5] = chr5; + p[6] = chr6; + p[7] = chr7; + p[8] = irq_enable; + p[9] = irq_counter; + p[10] = irq_latch; + + p[16] = protect_dat[0]; + p[17] = protect_dat[1]; + p[18] = protect_dat[2]; + p[19] = protect_dat[3]; + p[20] = lwd; + } + + //void Mapper189::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg[0] = p[0]; + reg[1] = p[1]; + chr01 = p[2]; + chr23 = p[3]; + chr4 = p[4]; + chr5 = p[5]; + chr6 = p[6]; + chr7 = p[7]; + + irq_enable = p[8]; + irq_counter = p[9]; + irq_latch = p[10]; + + protect_dat[0] = p[16]; + protect_dat[1] = p[17]; + protect_dat[2] = p[18]; + protect_dat[3] = p[19]; + lwd = p[20]; + } + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper189.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper189.cs.meta new file mode 100644 index 00000000..e131e1e7 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper189.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6cbb30a02157e92478f51fb4b8ec13e2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper190.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper190.cs new file mode 100644 index 00000000..3e65a5b2 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper190.cs @@ -0,0 +1,317 @@ +////////////////////////////////////////////////////////////// +// Mapper190 Nintendo MMC3 // +////////////////////////////////////////////////////////////////////////// +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 Mapper190 : Mapper + { + BYTE cbase; /* PowerOn OR RESET : cbase=0 */ + BYTE mp190_lcchk; /* PowerOn OR RESET */ + BYTE mp190_lcmd; + BYTE mp190_cmd; + + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + BYTE lowoutdata; + public Mapper190(NES parent) : base(parent) + { + } + + public override void Reset() + + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + // DWORD crc = nes.rom.GetPROM_CRC(); + // if( crc == 0x6F3D187A ) { + // Temp_Buf=0; //Kof96 + // } else { + // Temp_Buf=1; //ST97 + // } + + irq_enable = 0; + irq_counter = 0; + cbase = 0; /* PowerOn OR RESET : cbase=0 */ + mp190_lcchk = 0; /* PowerOn OR RESET */ + mp190_lcmd = 1; + } + + //void Mapper190::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + /* For Initial Copy Protect check (KOF'96) */ + if (addr == 0x5000) + { + mp190_lcmd = data; + switch (data) + { + case 0xE0: + SetPROM_32K_Bank(0); + break; + case 0xEE: + SetPROM_32K_Bank(3); + break; + } + } + if ((addr == 0x5001) && (mp190_lcmd == 0x00)) + { + SetPROM_32K_Bank(7); + } + if (addr == 0x5080) + { + switch (data) + { + case 0x1: lowoutdata = 0x83; break; + case 0x2: lowoutdata = 0x42; break; + case 0x3: lowoutdata = 0x00; break; + } + } + CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; + } + + //BYTE Mapper190::ReadLow(WORD addr) + public override byte ReadLow(ushort addr) + { + switch (addr) + { + case 0x5000: + return lowoutdata; + default: + return CPU_MEM_BANK[addr >> 13][addr & 0x1FFF]; + } + } + + //void Mapper190::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE003) + { + case 0x8000: + mp190_cmd = data; + if ((mp190_cmd & 0x80) != 0) + cbase = 1; + else + cbase = 0; + break; + case 0x8003: /* for Street Fighter Zero 2 '97 */ + mp190_lcchk = data; + switch (data) + { + case 0x28: + SetPROM_8K_Bank(4, 0x1F); + SetPROM_8K_Bank(5, 0x1F); + SetPROM_8K_Bank(6, 0x17); + SetPROM_8K_Bank(7, 0x1F); + break; + case 0x2A: + SetPROM_8K_Bank(4, 0x1F); + SetPROM_8K_Bank(5, 0x0F); + SetPROM_8K_Bank(6, 0x17); + SetPROM_8K_Bank(7, 0x1F); + break; + case 0x06: + SetPROM_8K_Bank(4, 0x1E); + SetPROM_8K_Bank(5, 0x1F); + SetPROM_8K_Bank(6, 0x1F); + SetPROM_8K_Bank(7, 0x1F); + break; + } + break; + case 0x8001: + if ((mp190_lcchk == 0x6) || (mp190_lcmd == 0x0)) + { + switch (mp190_cmd & 0x07) + { + case 0: + if (cbase == 0) + { + SetVROM_1K_Bank(0, data + 0x100); + SetVROM_1K_Bank(1, data + 0x101); + } + else + { + SetVROM_1K_Bank(4, data + 0x100); + SetVROM_1K_Bank(5, data + 0x101); + } + break; + case 1: + if (cbase == 0) + { + SetVROM_1K_Bank(2, data + 0x100); + SetVROM_1K_Bank(3, data + 0x101); + } + else + { + SetVROM_1K_Bank(6, data + 0x100); + SetVROM_1K_Bank(7, data + 0x101); + } + break; + case 2: + if (cbase == 0) + { + SetVROM_1K_Bank(4, data); + } + else + { + SetVROM_1K_Bank(0, data); + } + break; + case 3: + if (cbase == 0) + { + SetVROM_1K_Bank(5, data); + } + else + { + SetVROM_1K_Bank(1, data); + } + break; + case 4: + if (cbase == 0) + { + SetVROM_1K_Bank(6, data); + } + else + { + SetVROM_1K_Bank(2, data); + } + break; + case 5: + if (cbase == 0) + { + SetVROM_1K_Bank(7, data); + } + else + { + SetVROM_1K_Bank(3, data); + } + break; + case 6: + data = (byte)(data & ((PROM_8K_SIZE * 2) - 1)); + if ((mp190_lcmd & 0x40) != 0) + { + SetPROM_8K_Bank(6, data); + SetPROM_8K_Bank(4, (PROM_8K_SIZE - 1) * 2); + } + else + { + SetPROM_8K_Bank(4, data); + SetPROM_8K_Bank(6, (PROM_8K_SIZE - 1) * 2); + } + break; + case 7: + data = (byte)(data & ((PROM_8K_SIZE * 2) - 1)); + if ((mp190_lcmd & 0x40) != 0) + { + SetPROM_8K_Bank(5, data); + SetPROM_8K_Bank(4, (PROM_8K_SIZE - 1) * 2); + } + else + { + SetPROM_8K_Bank(5, data); + SetPROM_8K_Bank(6, (PROM_8K_SIZE - 1) * 2); + } + break; + } + } + break; + case 0xA000: + if ((data & 0x1) == 0x1) + SetVRAM_Mirror(VRAM_HMIRROR); + else + SetVRAM_Mirror(VRAM_VMIRROR); + break; + case 0xA001: + break; + case 0xC000: + irq_counter = (byte)(data - 1); + break; + case 0xC001: + irq_latch = (byte)(data - 1); + break; + case 0xC002: + irq_counter = data; + break; + case 0xC003: + irq_latch = data; + break; + case 0xE000: + irq_counter = irq_latch; + irq_enable = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + irq_enable = 1; + break; + case 0xE002: + irq_counter = irq_latch; + irq_enable = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE003: + irq_enable = 1; + irq_counter = irq_counter; + break; + } + } + + //void Mapper190::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) + { + // nes.cpu.IRQ_NotPending(); + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + //void Mapper190::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = irq_enable; + p[1] = irq_counter; + p[2] = irq_latch; + + p[3] = cbase; + p[4] = mp190_lcchk; + p[5] = mp190_lcmd; + p[6] = mp190_cmd; + p[7] = lowoutdata; + } + + //void Mapper190::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + irq_enable = p[0]; + irq_counter = p[1]; + irq_latch = p[2]; + + cbase = p[3]; + mp190_lcchk = p[4]; + mp190_lcmd = p[5]; + mp190_cmd = p[6]; + lowoutdata = p[7]; + } + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper190.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper190.cs.meta new file mode 100644 index 00000000..55dcc610 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper190.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1bdbb26f8b8de51448a9703b2a9b5884 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper191.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper191.cs new file mode 100644 index 00000000..8c5fd50d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper191.cs @@ -0,0 +1,138 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper191 SACHEN Super Cartridge Xin1 (Ver.1-9) // +// SACHEN Q-BOY Support // +////////////////////////////////////////////////////////////////////////// +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 Mapper191 : Mapper + { + BYTE[] reg = new BYTE[8]; + BYTE prg0, prg1; + BYTE chr0, chr1, chr2, chr3; + BYTE highbank; + public Mapper191(NES parent) : base(parent) + { + } + + public override void Reset() + + { + for (INT i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + + prg0 = 0; + // prg1 = 1; + SetBank_CPU(); + + chr0 = 0; + chr1 = 0; + chr2 = 0; + chr3 = 0; + highbank = 0; + SetBank_PPU(); + } + + //void Mapper191::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + switch (addr) + { + case 0x4100: + reg[0] = data; + break; + case 0x4101: + reg[1] = data; + switch (reg[0]) + { + case 0: + chr0 = (byte)(data & 7); + SetBank_PPU(); + break; + case 1: + chr1 = (byte)(data & 7); + SetBank_PPU(); + break; + case 2: + chr2 = (byte)(data & 7); + SetBank_PPU(); + break; + case 3: + chr3 = (byte)(data & 7); + SetBank_PPU(); + break; + case 4: + highbank = (byte)(data & 7); + SetBank_PPU(); + break; + case 5: + prg0 = (byte)(data & 7); + SetBank_CPU(); + break; + case 7: + if ((data & 0x02) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + break; + } + break; + } + } + + void SetBank_CPU() + { + SetPROM_32K_Bank(prg0); + } + + void SetBank_PPU() + { + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(0, (((highbank << 3) + chr0) << 2) + 0); + SetVROM_1K_Bank(1, (((highbank << 3) + chr0) << 2) + 1); + SetVROM_1K_Bank(2, (((highbank << 3) + chr1) << 2) + 2); + SetVROM_1K_Bank(3, (((highbank << 3) + chr1) << 2) + 3); + SetVROM_1K_Bank(4, (((highbank << 3) + chr2) << 2) + 0); + SetVROM_1K_Bank(5, (((highbank << 3) + chr2) << 2) + 1); + SetVROM_1K_Bank(6, (((highbank << 3) + chr3) << 2) + 2); + SetVROM_1K_Bank(7, (((highbank << 3) + chr3) << 2) + 3); + } + } + + public override bool IsStateSave() + { + return true; + } + + + + //void Mapper191::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = prg0; + p[1] = chr0; + p[2] = chr1; + p[3] = chr2; + p[4] = chr3; + p[5] = highbank; + } + + //void Mapper191::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + prg0 = p[0]; + chr0 = p[1]; + chr1 = p[2]; + chr2 = p[3]; + chr3 = p[4]; + highbank = p[5]; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper191.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper191.cs.meta new file mode 100644 index 00000000..9d5caf4f --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper191.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ae81a8958c1eb3f46a960c6319412523 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper193.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper193.cs new file mode 100644 index 00000000..dbe695b4 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper193.cs @@ -0,0 +1,49 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper193 MEGA SOFT (NTDEC) : Fighting Hero // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; + +namespace VirtualNes.Core +{ + public class Mapper193 : Mapper + { + public Mapper193(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(PROM_32K_SIZE - 1); + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper193::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + switch (addr) + { + case 0x6000: + SetVROM_2K_Bank(0, ((data >> 1) & 0x7e) + 0); + SetVROM_2K_Bank(2, ((data >> 1) & 0x7e) + 1); + break; + case 0x6001: + SetVROM_2K_Bank(4, data >> 1); + break; + case 0x6002: + SetVROM_2K_Bank(6, data >> 1); + break; + case 0x6003: + SetPROM_32K_Bank(data); + break; + } + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper193.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper193.cs.meta new file mode 100644 index 00000000..40141153 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper193.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e56eadb9647b3b74a9267fbb5fea29d6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper194.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper194.cs new file mode 100644 index 00000000..970e5ca4 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper194.cs @@ -0,0 +1,31 @@ +//////////////////////////////////////////// +// Mapper194 迷宮寺院ダババ // +////////////////////////////////////////////////////////////////////////// +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 Mapper194 : Mapper + { + public Mapper194(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(PROM_32K_SIZE - 1); + } + + //void Mapper194::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + SetPROM_8K_Bank(3, data); + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper194.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper194.cs.meta new file mode 100644 index 00000000..94c2bf39 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper194.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5ac8a64a71bbbfd4db4a4dca1f57883d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper198.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper198.cs new file mode 100644 index 00000000..e9a2116d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper198.cs @@ -0,0 +1,207 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper198 Nintendo MMC3 // +////////////////////////////////////////////////////////////////////////// +using static VirtualNes.MMU; +using static VirtualNes.Core.CPU; +using INT = System.Int32; +using BYTE = System.Byte; +using System; + +namespace VirtualNes.Core +{ + public class Mapper198 : Mapper + { + BYTE[] reg = new byte[8]; + BYTE prg0, prg1; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + + BYTE[] adr5000buf = new BYTE[1024 * 4]; + public Mapper198(NES parent) : base(parent) + { + } + + public override void Reset() + + { + for (INT i = 0; i < 8; i++) + { + reg[i] = 0x00; + } + + prg0 = 0; + prg1 = 1; + SetBank_CPU(); + + chr01 = 0; + chr23 = 2; + chr4 = 4; + chr5 = 5; + chr6 = 6; + chr7 = 7; + SetBank_PPU(); + } + + //void Mapper198::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if (addr > 0x4018 && addr < 0x6000) + CPU_MEM_BANK[addr >> 13][addr & 0x1FFF] = data; + else + adr5000buf[addr & 0xFFF] = data; + } + //BYTE Mapper198::ReadLow(WORD addr) + public override byte ReadLow(ushort addr) + { + if (addr > 0x4018 && addr < 0x6000) + return CPU_MEM_BANK[addr >> 13][addr & 0x1FFF]; + else + return adr5000buf[addr & 0xFFF]; + } + + //void Mapper198::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: + if (data >= 0x50) data &= 0x4F; + 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; + break; + case 0xC000: + reg[4] = data; + break; + case 0xC001: + reg[5] = data; + break; + case 0xE000: + reg[6] = data; + break; + case 0xE001: + reg[7] = data; + break; + } + } + + void SetBank_CPU() + { + if ((reg[0] & 0x40) != 0) + { + SetPROM_32K_Bank(PROM_8K_SIZE - 2, prg1, prg0, PROM_8K_SIZE - 1); + } + else + { + SetPROM_32K_Bank(prg0, prg1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + } + + void SetBank_PPU() + { + + if (VROM_1K_SIZE != 0) + { + if ((reg[0] & 0x80) != 0) + { + SetVROM_8K_Bank(chr4, chr5, chr6, chr7, + chr01, chr01 + 1, chr23, chr23 + 1); + } + else + { + SetVROM_8K_Bank(chr01, chr01 + 1, chr23, chr23 + 1, + chr4, chr5, chr6, chr7); + } + } + } + + //void Mapper198::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; + } + + //void Mapper198::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]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper198.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper198.cs.meta new file mode 100644 index 00000000..91ae3605 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper198.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f6c148d721a4eed4599b4c4e535f9f21 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: