diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper069.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper069.cs new file mode 100644 index 0000000..f386f82 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper069.cs @@ -0,0 +1,177 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper069 SunSoft FME-7 // +////////////////////////////////////////////////////////////////////////// +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 Mapper069 : Mapper + { + BYTE patch; + + BYTE reg; + BYTE irq_enable; + INT irq_counter; + public Mapper069(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); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + nes.apu.SelectExSound(32); + nes.SetIrqType(NES.IRQMETHOD.IRQ_CLOCK); + patch = 0; + + uint crc = nes.rom.GetPROM_CRC(); + + if (crc == 0xfeac6916) + { // Honoo no Toukyuuji - Dodge Danpei 2(J) + // nes.SetIrqType( NES::IRQ_HSYNC ); + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + + if (crc == 0xad28aef6) + { // Dynamite Batman(J) / Dynamite Batman - Return of the Joker(U) + patch = 1; + } + } + + //void Mapper069::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xE000) + { + case 0x8000: + reg = data; + break; + + case 0xA000: + switch (reg & 0x0F) + { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + SetVROM_1K_Bank((byte)(reg & 0x07), data); + break; + case 0x08: + if (patch == 0 && (data & 0x40) == 0) + { + SetPROM_8K_Bank(3, data); + } + break; + case 0x09: + SetPROM_8K_Bank(4, data); + break; + case 0x0A: + SetPROM_8K_Bank(5, data); + break; + case 0x0B: + SetPROM_8K_Bank(6, data); + break; + + case 0x0C: + 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 0x0D: + irq_enable = data; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + + case 0x0E: + irq_counter = (irq_counter & 0xFF00) | data; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + + case 0x0F: + irq_counter = (irq_counter & 0x00FF) | (data << 8); + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + break; + + case 0xC000: + case 0xE000: + nes.apu.ExWrite(addr, data); + break; + } + } + + //void Mapper069::Clock(INT cycles) + public override void Clock(int cycles) + { + //if (irq_enable && (nes.GetIrqType() == NES::IRQ_CLOCK)) + if (irq_enable != 0 && (nes.GetIrqType() == (int)NES.IRQMETHOD.IRQ_HSYNC)) + { + irq_counter -= cycles; + if (irq_counter <= 0) + { + nes.cpu.SetIRQ(IRQ_MAPPER); + irq_enable = 0; + irq_counter = 0xFFFF; + } + } + } + + //void Mapper069::HSync(INT scanline) + public override void HSync(int scanline) + { + if (irq_enable != 0 && (nes.GetIrqType() == (int)NES.IRQMETHOD.IRQ_HSYNC)) + { + irq_counter -= 114; + if (irq_counter <= 0) + { + nes.cpu.SetIRQ(IRQ_MAPPER); + irq_enable = 0; + irq_counter = 0xFFFF; + } + } + } + + //void Mapper069::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = reg; + //p[1] = irq_enable; + //*(INT*)&p[2] = irq_counter; + } + + //void Mapper069::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //reg = p[0]; + //irq_enable = p[1]; + //irq_counter = *(INT*)&p[2]; + } + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper069.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper069.cs.meta new file mode 100644 index 0000000..2b2cb79 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper069.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 280c64d4deb538a448bba3eb071b3aef +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper070.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper070.cs new file mode 100644 index 0000000..04153e2 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper070.cs @@ -0,0 +1,64 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper070 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 Mapper070 : Mapper + { + BYTE patch; + public Mapper070(NES parent) : base(parent) + { + } + + public override void Reset() + { + patch = 0; + + uint crc = nes.rom.GetPROM_CRC(); + + if (crc == 0xa59ca2ef) + { // Kamen Rider Club(J) + patch = 1; + nes.SetRenderMethod(EnumRenderMethod.POST_ALL_RENDER); + } + if (crc == 0x10bb8f9a) + { // Family Trainer - Manhattan Police(J) + patch = 1; + } + if (crc == 0x0cd00488) + { // Space Shadow(J) + patch = 1; + } + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + SetVROM_8K_Bank(0); + } + + //void Mapper070::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + SetPROM_16K_Bank(4, (data & 0x70) >> 4); + SetVROM_8K_Bank(data & 0x0F); + + if (patch != 0) + { + if ((data & 0x80) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + } + else + { + if ((data & 0x80) != 0) SetVRAM_Mirror(VRAM_MIRROR4H); + else SetVRAM_Mirror(VRAM_MIRROR4L); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper070.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper070.cs.meta new file mode 100644 index 0000000..393d52c --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper070.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0202c8b68faec5a4ea96ec3fc07aebae +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper071.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper071.cs new file mode 100644 index 0000000..5d07deb --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper071.cs @@ -0,0 +1,54 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper071 Camerica // +////////////////////////////////////////////////////////////////////////// +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 Mapper071 : Mapper + { + public Mapper071(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + + //void Mapper071::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if ((addr & 0xE000) == 0x6000) + { + SetPROM_16K_Bank(4, data); + } + } + + //void Mapper071::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF000) + { + case 0x9000: + if ((data & 0x10) != 0) SetVRAM_Mirror(VRAM_MIRROR4H); + else SetVRAM_Mirror(VRAM_MIRROR4L); + break; + + case 0xC000: + case 0xD000: + case 0xE000: + case 0xF000: + SetPROM_16K_Bank(4, data); + break; + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper071.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper071.cs.meta new file mode 100644 index 0000000..e173f6f --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper071.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 379a8d27ad5b5854ba2bc0db093734f2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper072.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper072.cs new file mode 100644 index 0000000..67dec03 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper072.cs @@ -0,0 +1,59 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper072 Jaleco/Type1 lower bank switch // +////////////////////////////////////////////////////////////////////////// +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 Mapper072 : Mapper + { + public Mapper072(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_8K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper072::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + if (data & 0x80) + { + SetPROM_16K_Bank(4, data & 0x0F); + } + else if (data & 0x40) + { + SetVROM_8K_Bank(data & 0x0F); + } + else + { + if (addr >= 0xC100 && addr <= 0xC11F && data == 0x20) + { + //DEBUGOUT( "ADDR:%04X DATA:%02X\n", addr, data ); + DEBUGOUT("SOUND CODE:%02X\n", addr & 0x1F); + + // OSDにするべきか… + if (Config.sound.bExtraSoundEnable) + { + DirectSound.EsfAllStop(); + DirectSound.EsfPlay(ESF_MOETENNIS_00 + (addr & 0x1F)); + } + } + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper072.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper072.cs.meta new file mode 100644 index 0000000..27c73ba --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper072.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 556683ab44781ae41b79420d171afb0d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper073.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper073.cs new file mode 100644 index 0000000..ce69fe0 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper073.cs @@ -0,0 +1,94 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper073 Konami VRC3 // +////////////////////////////////////////////////////////////////////////// +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 Mapper073 : Mapper + { + BYTE irq_enable; + INT irq_counter; + public Mapper073(NES parent) : base(parent) + { + } + + public override void Reset() + { + irq_enable = 0; + irq_counter = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + + //void Mapper073::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr) + { + case 0xF000: + SetPROM_16K_Bank(4, data); + break; + + case 0x8000: + irq_counter = (irq_counter & 0xFFF0) | (data & 0x0F); + break; + case 0x9000: + irq_counter = (irq_counter & 0xFF0F) | ((data & 0x0F) << 4); + break; + case 0xA000: + irq_counter = (irq_counter & 0xF0FF) | ((data & 0x0F) << 8); + break; + case 0xB000: + irq_counter = (irq_counter & 0x0FFF) | ((data & 0x0F) << 12); + break; + case 0xC000: + irq_enable = (byte)(data & 0x02); + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xD000: + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper073::Clock(INT cycles) + public override void Clock(int cycles) + { + if (irq_enable != 0) + { + if ((irq_counter += cycles) >= 0xFFFF) + { + irq_enable = 0; + irq_counter &= 0xFFFF; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + + //void Mapper073::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = irq_enable; + //*(INT*)&p[1] = irq_counter; + } + + //void Mapper073::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //irq_enable = p[0]; + //irq_counter = *(INT*)&p[1]; + } + + public override bool IsStateSave() + { + return true; + } + } +} + diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper073.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper073.cs.meta new file mode 100644 index 0000000..f90c467 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper073.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 47872c8286a0123479efa9809f188d62 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper074.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper074.cs new file mode 100644 index 0000000..26602d9 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper074.cs @@ -0,0 +1,312 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper074 // +////////////////////////////////////////////////////////////////////////// +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 Mapper074 : Mapper + { + BYTE[] reg = new byte[8]; + BYTE prg0, prg1; + BYTE chr01, chr23, chr4, chr5, chr6, chr7; + BYTE we_sram; + + BYTE irq_type; + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + BYTE irq_request; + + BYTE patch; + public Mapper074(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(); + + we_sram = 0; // Disable + irq_enable = 0; // Disable + irq_counter = 0; + irq_latch = 0; + irq_request = 0; + uint crc = nes.rom.GetPROM_CRC(); + + patch = 0; + if (crc == 0x37ae04a8) + { + patch = 1; + nes.SetRenderMethod(EnumRenderMethod.TILE_RENDER); + } + } + + //void Mapper074::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + //DEBUGOUT( "MPRWR A=%04X D=%02X L=%3d CYC=%d\n", addr&0xFFFF, data&0xFF, nes.GetScanline(), nes.cpu.GetTotalCycles() ); + + 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; + break; + case 0xC000: + reg[4] = data; + irq_counter = data; + irq_request = 0; + break; + case 0xC001: + reg[5] = data; + irq_latch = data; + irq_request = 0; + break; + case 0xE000: + reg[6] = data; + irq_enable = 0; + irq_request = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + case 0xE001: + reg[7] = data; + irq_enable = 1; + irq_request = 0; + break; + } + + } + + //void Mapper074::HSync(INT scanline) + public override void HSync(int scanline) + { + if ((scanline >= 0 && scanline <= 239)) + { + if (nes.ppu.IsDispON()) + { + if (irq_enable != 0 && irq_request == 0) + { + if (scanline == 0) + { + if (irq_counter != 0) + { + irq_counter--; + } + } + if ((irq_counter--) == 0) + { + irq_request = 0xFF; + irq_counter = irq_latch; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + } + + 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 ); + SetBank_PPUSUB(4, chr01 + 0); + SetBank_PPUSUB(5, chr01 + 1); + SetBank_PPUSUB(6, chr23 + 0); + SetBank_PPUSUB(7, chr23 + 1); + SetBank_PPUSUB(0, chr4); + SetBank_PPUSUB(1, chr5); + SetBank_PPUSUB(2, chr6); + SetBank_PPUSUB(3, chr7); + } + else + { + // SetVROM_8K_Bank( chr01, chr01+1, chr23, chr23+1, + // chr4, chr5, chr6, chr7 ); + SetBank_PPUSUB(0, chr01 + 0); + SetBank_PPUSUB(1, chr01 + 1); + SetBank_PPUSUB(2, chr23 + 0); + SetBank_PPUSUB(3, chr23 + 1); + SetBank_PPUSUB(4, chr4); + SetBank_PPUSUB(5, chr5); + SetBank_PPUSUB(6, chr6); + SetBank_PPUSUB(7, 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 SetBank_PPUSUB(int bank, int page) + { + if (patch == 0 && (page == 8 || page == 9)) + { + SetCRAM_1K_Bank((byte)bank, page & 7); + } + else if (patch == 1 && page >= 128) + { + SetCRAM_1K_Bank((byte)bank, page & 7); + } + else + { + SetVROM_1K_Bank((byte)bank, page); + } + } + + //void Mapper074::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] = irq_request; + } + + //void Mapper074::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]; + irq_request = p[19]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper074.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper074.cs.meta new file mode 100644 index 0000000..751c217 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper074.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 45d37052d02fe374d8ba3c4e2a631cfd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper075.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper075.cs new file mode 100644 index 0000000..b5f57ce --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper075.cs @@ -0,0 +1,90 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper075 Konami VRC1/Jaleco D65005 // +////////////////////////////////////////////////////////////////////////// +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 Mapper075 : Mapper + { + BYTE[] reg = new byte[2]; + public Mapper075(NES parent) : base(parent) + { + } + + public override void Reset() + + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_8K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + reg[0] = 0; + reg[1] = 1; + } + + //void Mapper075::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF000) + { + case 0x8000: + SetPROM_8K_Bank(4, data); + break; + + case 0x9000: + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_HMIRROR); + else SetVRAM_Mirror(VRAM_VMIRROR); + + reg[0] = (byte)((reg[0] & 0x0F) | ((data & 0x02) << 3)); + reg[1] = (byte)((reg[1] & 0x0F) | ((data & 0x04) << 2)); + SetVROM_4K_Bank(0, reg[0]); + SetVROM_4K_Bank(4, reg[1]); + break; + + case 0xA000: + SetPROM_8K_Bank(5, data); + break; + case 0xC000: + SetPROM_8K_Bank(6, data); + break; + + case 0xE000: + reg[0] = (byte)((reg[0] & 0x10) | (data & 0x0F)); + SetVROM_4K_Bank(0, reg[0]); + break; + + case 0xF000: + reg[1] = (byte)((reg[1] & 0x10) | (data & 0x0F)); + SetVROM_4K_Bank(4, reg[1]); + break; + } + } + + //void Mapper075::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg[0]; + p[1] = reg[1]; + } + + //void Mapper075::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg[0] = p[0]; + reg[1] = p[1]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper075.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper075.cs.meta new file mode 100644 index 0000000..1107729 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper075.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a9e28ba92f769664690091c1434038a6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper076.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper076.cs new file mode 100644 index 0000000..d654835 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper076.cs @@ -0,0 +1,82 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper076 Namcot 109 (女神転生) // +////////////////////////////////////////////////////////////////////////// +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 Mapper076 : Mapper + { + BYTE reg; + public Mapper076(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_1K_SIZE >= 8) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper076::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr) + { + case 0x8000: + reg = data; + break; + case 0x8001: + switch (reg & 0x07) + { + case 2: + SetVROM_2K_Bank(0, data); + break; + case 3: + SetVROM_2K_Bank(2, data); + break; + case 4: + SetVROM_2K_Bank(4, data); + break; + case 5: + SetVROM_2K_Bank(6, data); + break; + case 6: + SetPROM_8K_Bank(4, data); + break; + case 7: + SetPROM_8K_Bank(5, data); + break; + } + break; + } + } + + //void Mapper076::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg; + } + + //void Mapper076::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg = p[0]; + } + + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper076.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper076.cs.meta new file mode 100644 index 0000000..5cc1aab --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper076.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 672c100cc4c4c70448bb51f3a9b62d5b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper077.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper077.cs new file mode 100644 index 0000000..017025f --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper077.cs @@ -0,0 +1,39 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper077 Irem Early Mapper #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 Mapper077 : Mapper + { + public Mapper077(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + + SetVROM_2K_Bank(0, 0); + SetCRAM_2K_Bank(2, 1); + SetCRAM_2K_Bank(4, 2); + SetCRAM_2K_Bank(6, 3); + } + + //void Mapper077::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + SetPROM_32K_Bank(data & 0x07); + + SetVROM_2K_Bank(0, (data & 0xF0) >> 4); + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper077.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper077.cs.meta new file mode 100644 index 0000000..5b15e65 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper077.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7ad6987edcff779409890da9965d4891 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper078.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper078.cs new file mode 100644 index 0000000..2fbd0ba --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper078.cs @@ -0,0 +1,45 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper078 Jaleco(Cosmo Carrier) // +////////////////////////////////////////////////////////////////////////// +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 Mapper078 : Mapper + { + public Mapper078(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_8K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper078::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + //DEBUGOUT( "MAP78 WR $%04X=$%02X L=%d\n", addr, data, nes->GetScanline() ); + SetPROM_16K_Bank(4, data & 0x0F); + SetVROM_8K_Bank((data & 0xF0) >> 4); + + if ((addr & 0xFE00) != 0xFE00) + { + if ((data & 0x08) != 0) SetVRAM_Mirror(VRAM_MIRROR4H); + else SetVRAM_Mirror(VRAM_MIRROR4L); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper078.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper078.cs.meta new file mode 100644 index 0000000..d9c5bda --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper078.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5be432aeb39d2d24e98b2bb52e85cbe9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper079.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper079.cs new file mode 100644 index 0000000..f4db416 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper079.cs @@ -0,0 +1,41 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper079 Nina-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 Mapper079 : Mapper + { + public Mapper079(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0); + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper079::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + if ((addr & 0x0100) != 0) + { + SetPROM_32K_Bank((data >> 3) & 0x01); + SetVROM_8K_Bank(data & 0x07); + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper079.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper079.cs.meta new file mode 100644 index 0000000..b023f72 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper079.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c81e9813295f4434aa6e54baec3e0752 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper080.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper080.cs new file mode 100644 index 0000000..9e1fd76 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper080.cs @@ -0,0 +1,106 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper080 Taito X1-005 // +////////////////////////////////////////////////////////////////////////// +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 Mapper080 : Mapper + { + public Mapper080(NES parent) : base(parent) + { + } + + public override void Reset() + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_8K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + } + + //void Mapper080::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + switch (addr) + { + case 0x7EF0: + SetVROM_2K_Bank(0, (data >> 1) & 0x3F); + if (PROM_8K_SIZE == 32) + { + if ((data & 0x80) != 0) + { + SetVRAM_1K_Bank(8, 1); + SetVRAM_1K_Bank(9, 1); + } + else + { + SetVRAM_1K_Bank(8, 0); + SetVRAM_1K_Bank(9, 0); + } + } + break; + + case 0x7EF1: + SetVROM_2K_Bank(2, (data >> 1) & 0x3F); + if (PROM_8K_SIZE == 32) + { + if ((data & 0x80) != 0) + { + SetVRAM_1K_Bank(10, 1); + SetVRAM_1K_Bank(11, 1); + } + else + { + SetVRAM_1K_Bank(10, 0); + SetVRAM_1K_Bank(11, 0); + } + } + break; + + case 0x7EF2: + SetVROM_1K_Bank(4, data); + break; + case 0x7EF3: + SetVROM_1K_Bank(5, data); + break; + case 0x7EF4: + SetVROM_1K_Bank(6, data); + break; + case 0x7EF5: + SetVROM_1K_Bank(7, data); + break; + + case 0x7EF6: + if ((data & 0x01) != 0) SetVRAM_Mirror(VRAM_VMIRROR); + else SetVRAM_Mirror(VRAM_HMIRROR); + break; + + case 0x7EFA: + case 0x7EFB: + SetPROM_8K_Bank(4, data); + break; + case 0x7EFC: + case 0x7EFD: + SetPROM_8K_Bank(5, data); + break; + case 0x7EFE: + case 0x7EFF: + SetPROM_8K_Bank(6, data); + break; + default: + base.WriteLow(addr, data); + break; + } + } + + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper080.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper080.cs.meta new file mode 100644 index 0000000..bb697cf --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper080.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 233bc8a8511fd30458e7e8c01e43f9fe +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper082.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper082.cs new file mode 100644 index 0000000..43266b3 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper082.cs @@ -0,0 +1,119 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper082 Taito C075 // +////////////////////////////////////////////////////////////////////////// +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 Mapper082 : Mapper + { + BYTE reg; + + public Mapper082(NES parent) : base(parent) + { + } + + public override void Reset() + + { + reg = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + + if (VROM_8K_SIZE!=0) + { + SetVROM_8K_Bank(0); + } + + SetVRAM_Mirror(VRAM_VMIRROR); + } + + //void Mapper082::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + switch (addr) + { + case 0x7EF0: + if (reg!=0) + { + SetVROM_2K_Bank(4, data >> 1); + } + else + { + SetVROM_2K_Bank(0, data >> 1); + } + break; + + case 0x7EF1: + if (reg!=0) + { + SetVROM_2K_Bank(6, data >> 1); + } + else + { + SetVROM_2K_Bank(2, data >> 1); + } + break; + + case 0x7EF2: + if (reg!=0) SetVROM_1K_Bank(0, data); + else SetVROM_1K_Bank(4, data); + break; + case 0x7EF3: + if (reg!=0) SetVROM_1K_Bank(1, data); + else SetVROM_1K_Bank(5, data); + break; + case 0x7EF4: + if (reg!=0) SetVROM_1K_Bank(2, data); + else SetVROM_1K_Bank(6, data); + break; + case 0x7EF5: + if (reg!=0) SetVROM_1K_Bank(3, data); + else SetVROM_1K_Bank(7, data); + break; + + case 0x7EF6: + reg = (byte)(data & 0x02); + if ((data & 0x01)!=0) SetVRAM_Mirror(VRAM_VMIRROR); + else SetVRAM_Mirror(VRAM_HMIRROR); + break; + + case 0x7EFA: + SetPROM_8K_Bank(4, data >> 2); + break; + case 0x7EFB: + SetPROM_8K_Bank(5, data >> 2); + break; + case 0x7EFC: + SetPROM_8K_Bank(6, data >> 2); + break; + default: + base.WriteLow(addr, data); + break; + } + } + + //void Mapper082::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + p[0] = reg; + } + + //void Mapper082::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + reg = p[0]; + } + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper082.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper082.cs.meta new file mode 100644 index 0000000..4b02e06 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper082.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 826a6bd0c5ff43b4e907171f2a901343 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper083.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper083.cs new file mode 100644 index 0000000..c6b3077 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper083.cs @@ -0,0 +1,243 @@ +///////////////////////////// +// Mapper083 Cony // +////////////////////////////////////////////////////////////////////////// +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 Mapper083 : Mapper + { + BYTE[] reg = new byte[3]; + INT chr_bank; + BYTE irq_enable; + INT irq_counter; + + BYTE patch; + public Mapper083(NES parent) : base(parent) + { + } + + public override void Reset() + + { + for (INT i = 0; i < 3; i++) + { + reg[i] = 0x00; + } + + if (PROM_8K_SIZE >= 32) + { + SetPROM_32K_Bank(0, 1, 30, 31); + reg[1] = 0x30; + } + else + { + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + } + + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + + chr_bank = 0; + + irq_enable = 0; // Disable + irq_counter = 0; + + patch = 0; + if (nes.rom.GetPROM_CRC() == 0x1461D1F8) + { + patch = 1; + } + } + + //BYTE Mapper083::ReadLow(WORD addr) + public override byte ReadLow(ushort addr) + { + if ((addr & 0x5100) == 0x5100) + { + return reg[2]; + } + else if (addr >= 0x6000) + { + return base.ReadLow(addr); + } + return (BYTE)(addr >> 8); + } + + //void Mapper083::WriteLow(WORD addr, BYTE data) + public override void WriteLow(ushort addr, byte data) + { + //DEBUGOUT( "MPRWR A=%04X D=%02X L=%3d CYC=%d\n", addr&0xFFFF, data&0xFF, nes.GetScanline(), nes.cpu.GetTotalCycles() ); + switch (addr) + { + case 0x5101: + case 0x5102: + case 0x5103: + reg[2] = data; + break; + } + + if (addr >= 0x6000) + { + base.WriteLow(addr, data); + } + } + + //void Mapper083::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + //DEBUGOUT( "MPRWR A=%04X D=%02X L=%3d CYC=%d\n", addr&0xFFFF, data&0xFF, nes.GetScanline(), nes.cpu.GetTotalCycles() ); + switch (addr) + { + case 0x8000: + case 0xB000: + case 0xB0FF: + case 0xB1FF: + reg[0] = data; + chr_bank = (data & 0x30) << 4; + SetPROM_16K_Bank(4, data); + SetPROM_16K_Bank(6, (data & 0x30) | 0x0F); + break; + + case 0x8100: + reg[1] = (byte)(data & 0x80); + 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 0x8200: + irq_counter = (irq_counter & 0xFF00) | (INT)data; + // nes.cpu.ClrIRQ( IRQ_MAPPER ); + break; + case 0x8201: + irq_counter = (irq_counter & 0x00FF) | ((INT)data << 8); + irq_enable = reg[1]; + // nes.cpu.ClrIRQ( IRQ_MAPPER ); + break; + + case 0x8300: + SetPROM_8K_Bank(4, data); + break; + case 0x8301: + SetPROM_8K_Bank(5, data); + break; + case 0x8302: + SetPROM_8K_Bank(6, data); + break; + + case 0x8310: + if (patch != 0) + { + SetVROM_2K_Bank(0, chr_bank | data); + } + else + { + SetVROM_1K_Bank(0, chr_bank | data); + } + break; + case 0x8311: + if (patch != 0) + { + SetVROM_2K_Bank(2, chr_bank | data); + } + else + { + SetVROM_1K_Bank(1, chr_bank | data); + } + break; + case 0x8312: + SetVROM_1K_Bank(2, chr_bank | data); + break; + case 0x8313: + SetVROM_1K_Bank(3, chr_bank | data); + break; + case 0x8314: + SetVROM_1K_Bank(4, chr_bank | data); + break; + case 0x8315: + SetVROM_1K_Bank(5, chr_bank | data); + break; + case 0x8316: + if (patch != 0) + { + SetVROM_2K_Bank(4, chr_bank | data); + } + else + { + SetVROM_1K_Bank(6, chr_bank | data); + } + break; + case 0x8317: + if (patch != 0) + { + SetVROM_2K_Bank(6, chr_bank | data); + } + else + { + SetVROM_1K_Bank(7, chr_bank | data); + } + break; + + case 0x8318: + SetPROM_16K_Bank(4, (reg[0] & 0x30) | data); + break; + } + } + + //void Mapper083::HSync(INT scanline) + public override void HSync(int scanline) + { + if (irq_enable != 0) + { + if (irq_counter <= 113) + { + // nes.cpu.IRQ(); + irq_enable = 0; + // nes.cpu.SetIRQ( IRQ_MAPPER ); + nes.cpu.SetIRQ(IRQ_TRIGGER); + } + else + { + irq_counter -= 113; + } + } + } + + //void Mapper083::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = reg[0]; + //p[1] = reg[1]; + //p[2] = reg[2]; + //*(INT*)&p[3] = chr_bank; + //p[7] = irq_enable; + //*(INT*)&p[8] = irq_counter; + } + + //void Mapper083::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //reg[0] = p[0]; + //reg[1] = p[1]; + //reg[2] = p[2]; + //chr_bank = *(INT*)&p[3]; + //irq_enable = p[7]; + //irq_counter = *(INT*)&p[8]; + } + + public override bool IsStateSave() + { + return true; + } + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper083.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper083.cs.meta new file mode 100644 index 0000000..39796bd --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper083.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a5c413bf733d7fa4d96862f1324ff4ef +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper085.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper085.cs new file mode 100644 index 0000000..b359ff0 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper085.cs @@ -0,0 +1,238 @@ +////////////////////////////////////////////////////////////////////////// +// Mapper085 Konami VRC7 // +////////////////////////////////////////////////////////////////////////// +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 Mapper085 : Mapper + { + + BYTE irq_enable; + BYTE irq_counter; + BYTE irq_latch; + INT irq_clock; + public Mapper085(NES parent) : base(parent) + { + } + + public override void Reset() + + { + irq_enable = 0; + irq_counter = 0; + irq_latch = 0; + irq_clock = 0; + + SetPROM_32K_Bank(0, 1, PROM_8K_SIZE - 2, PROM_8K_SIZE - 1); + if (VROM_1K_SIZE != 0) + { + SetVROM_8K_Bank(0); + } + else + { + SetCRAM_8K_Bank(0); + } + +#if FALSE//0 +// DWORD crc = nes.rom.GetPROM_CRC(); +// if( crc == 0x1aa0479c ) { // For Tiny Toon Adventures 2 - Montana Land he Youkoso(J) +// nes.SetRenderMethod( NES::PRE_RENDER ); +// } +// if( crc == 0x33ce3ff0 ) { // For Lagrange Point(J) +// nes.SetRenderMethod( NES::TILE_RENDER ); +// } +#endif + nes.apu.SelectExSound(2); + } + + //void Mapper085::Write(WORD addr, BYTE data) + public override void Write(ushort addr, byte data) + { + switch (addr & 0xF038) + { + case 0x8000: + SetPROM_8K_Bank(4, data); + break; + case 0x8008: + case 0x8010: + SetPROM_8K_Bank(5, data); + break; + case 0x9000: + SetPROM_8K_Bank(6, data); + break; + + case 0x9010: + case 0x9030: + nes.apu.ExWrite(addr, data); + break; + + case 0xA000: + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(0, data); + } + else + { + SetCRAM_1K_Bank(0, data); + } + break; + + case 0xA008: + case 0xA010: + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(1, data); + } + else + { + SetCRAM_1K_Bank(1, data); + } + break; + + case 0xB000: + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(2, data); + } + else + { + SetCRAM_1K_Bank(2, data); + } + break; + + case 0xB008: + case 0xB010: + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(3, data); + } + else + { + SetCRAM_1K_Bank(3, data); + } + break; + + case 0xC000: + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(4, data); + } + else + { + SetCRAM_1K_Bank(4, data); + } + break; + + case 0xC008: + case 0xC010: + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(5, data); + } + else + { + SetCRAM_1K_Bank(5, data); + } + break; + + case 0xD000: + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(6, data); + } + else + { + SetCRAM_1K_Bank(6, data); + } + break; + + case 0xD008: + case 0xD010: + if (VROM_1K_SIZE != 0) + { + SetVROM_1K_Bank(7, data); + } + else + { + SetCRAM_1K_Bank(7, data); + } + break; + + case 0xE000: + 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 0xE008: + case 0xE010: + irq_latch = data; + break; + + case 0xF000: + irq_enable = (byte)(data & 0x03); + irq_counter = irq_latch; + irq_clock = 0; + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + + case 0xF008: + case 0xF010: + irq_enable = (byte)((irq_enable & 0x01) * 3); + nes.cpu.ClrIRQ(IRQ_MAPPER); + break; + } + } + + //void Mapper085::Clock(INT cycles) + public override void Clock(int cycles) + { + if ((irq_enable & 0x02) != 0) + { + irq_clock += cycles * 4; + while (irq_clock >= 455) + { + irq_clock -= 455; + irq_counter++; + if (irq_counter == 0) + { + irq_counter = irq_latch; + nes.cpu.SetIRQ(IRQ_MAPPER); + } + } + } + } + + //void Mapper085::SaveState(LPBYTE p) + public override void SaveState(byte[] p) + { + //p[0] = irq_enable; + //p[1] = irq_counter; + //p[2] = irq_latch; + //*((INT*)&p[4]) = irq_clock; + } + + //void Mapper085::LoadState(LPBYTE p) + public override void LoadState(byte[] p) + { + //irq_enable = p[0]; + //irq_counter = p[1]; + //irq_latch = p[2]; + //irq_clock = *((INT*)&p[4]); + } + + public override bool IsStateSave() + { + return true; + } + + } +} diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper085.cs.meta b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper085.cs.meta new file mode 100644 index 0000000..bd6681a --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/Mapper085.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 18265e8a35d3835459de279c318124ce +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/_MapName - 复制.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/_MapName - 复制.cs new file mode 100644 index 0000000..44a133c --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Mapper/_MapName - 复制.cs @@ -0,0 +1,20 @@ +using static VirtualNes.MMU; +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 override void Reset() + { + } + + } +}