diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings index 4d4aba23bb..1bfd3018f5 100644 --- a/BizHawk.sln.DotSettings +++ b/BizHawk.sln.DotSettings @@ -412,7 +412,6 @@ True True True - True True True True @@ -449,7 +448,6 @@ True True True - True True True True diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AVE-NINA.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AVE-NINA.cs index 9f1bb662a6..eadb157277 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AVE-NINA.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AVE-NINA.cs @@ -51,8 +51,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = (bank_4k << 12) | ofs; return Vrom[addr]; } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } public override byte ReadPrg(int addr) @@ -83,6 +82,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES break; } } + } // according to the latest on nesdev: @@ -127,6 +127,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return false; AssertPrg(32, 64); AssertChr(32, 64); AssertWram(0); AssertVram(0); break; + default: return false; } @@ -191,8 +192,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr |= ((chr_bank_8k & chr_bank_mask_8k) << 13); return Vrom[addr]; } - - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AxROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AxROM.cs index e17bebb6ed..4b19a02d10 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AxROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AxROM.cs @@ -52,6 +52,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES AssertPrg(256); AssertChr(0); AssertVram(8); AssertWram(0); bus_conflict = true; // not enough chips on the pcb to disable bus conflicts? break; + default: return false; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI-FCG-1.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI-FCG-1.cs index d957ee65ed..3a8cbe1637 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI-FCG-1.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI-FCG-1.cs @@ -29,6 +29,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES I have no idea what [6] does. Every real instance of [1], [2], [3], [4] had 128K or 256K of each of chr and prg. */ + internal sealed class BANDAI_FCG_1 : NesBoardBase { //configuration @@ -40,10 +41,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private bool vram = false; // is this a VRAM board? (also set to true for JUMP2) private byte jump2_outer_bank; // needed to select between banks in 512K jump2 board - // regenerable state + //regenerable state private readonly int[] prg_banks_16k = new int[2]; - // state + //state private int prg_reg_16k; private byte[] regs = new byte[8]; private bool irq_enabled; @@ -161,7 +162,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES prg_bank_mask_16k = (Cart.PrgSize / 16) - 1; - // for Jump2 boards, we only mask up to 256K, the outer bank is determined separately + // for Jump2 boards, we only mask up to 256K, the outer bank is determined seperately if (jump2) prg_bank_mask_16k = 256 / 16 - 1; @@ -231,7 +232,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES irq_enabled = value.Bit(0); if (jump2) irq_counter = irq_latch; - // all write acknowledge + // all write acknolwedge IrqSignal = false; break; case 0xB: @@ -345,6 +346,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES reader?.Clock(); } + public override byte ReadPrg(int addr) { int bank_16k = addr >> 14; @@ -369,7 +371,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x2000) { - return vram ? Vram[addr] : Vrom[CalcPPUAddress(addr)]; + if (vram) + return Vram[addr]; + else + return Vrom[CalcPPUAddress(addr)]; } return base.ReadPpu(addr); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI_74_161_02_74.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI_74_161_02_74.cs index 9220736b6a..30c603d438 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI_74_161_02_74.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI_74_161_02_74.cs @@ -57,19 +57,27 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Vram[(0x1000 * 3 * 2) + addr]; } - - return Vram[(0x1000 * 3) + addr]; + else + { + return Vram[(0x1000 * 3) + addr]; + } } - - if (chr_block == 1) + else { - return Vram[(0x1000 * chr_pos * 2) + addr]; + if (chr_block == 1) + { + return Vram[(0x1000 * chr_pos * 2) + addr]; + } + else + { + return Vram[(0x1000 * chr_pos * 2) + addr]; + } } - - return Vram[(0x1000 * chr_pos * 2) + addr]; } - - return base.ReadPpu(addr); + else + { + return base.ReadPpu(addr); + } } public override void WritePpu(int addr, byte value) @@ -106,9 +114,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void AddressPpu(int addr) { + byte newpos; if ((addr & 0x3000) != 0x2000) return; if ((addr & 0x3FF) >= 0x3C0) return; - var newpos = (byte)((addr >> 8) & 3); + newpos = (byte)((addr >> 8) & 3); if (chr_pos != newpos) { chr_pos = newpos; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI_74_161_161_32.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI_74_161_161_32.cs index 9c77697faa..c58537ec62 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI_74_161_161_32.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI_74_161_161_32.cs @@ -2,15 +2,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - // Mapper 70 - // Example Games: - // -------------------------- - // Family Trainer - Manhattan Police - // Family Trainer - Meiro Daisakusen - // Kamen Rider Club - // Space Shadow internal sealed class BANDAI_74_161_161_32 : NesBoardBase { + //Mapper 70 + //Example Games: + //-------------------------- + //Family Trainer - Manhattan Police + //Family Trainer - Meiro Daisakusen + //Kamen Rider Club + //Space Shadow + private int chr; private int prg_bank_mask_16k; private byte prg_bank_16k; @@ -68,7 +69,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x2000) return Vrom[(addr & 0x1FFF) + (chr * 0x2000)]; - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Bonza.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Bonza.cs index 7a8c777cfb..deaa1e5580 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Bonza.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Bonza.cs @@ -5,6 +5,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // Bonza (R) // Bonza is some kind of gambling game requiring an outside interface of some kind // this is not implemented + + // Magic Jewelry 2 (Unl) internal sealed class Bonza : NesBoardBase { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BxROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BxROM.cs index 878fba9e93..d5f354fbb8 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BxROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BxROM.cs @@ -49,7 +49,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override byte ReadPrg(int addr) { - addr |= prg_bank_32k << 15; + addr |= (prg_bank_32k << 15); return Rom[addr]; } @@ -68,11 +68,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Vram[addr]; } - - return Vrom[addr | (chr_bank_8k << 13)]; + else + { + return Vrom[addr | (chr_bank_8k << 13)]; + } + } + else + { + return base.ReadPpu(addr); } - - return base.ReadPpu(addr); } + } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CNROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CNROM.cs index 98aaee12de..a196fb246e 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CNROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CNROM.cs @@ -10,6 +10,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //Arkista's Ring //Bump 'n' Jump //Cybernoid + [NesBoardImplPriority] internal sealed class CNROM : NesBoardBase { @@ -140,13 +141,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return 0x12; } - if (addr < 0x2000) { return Vrom[addr + (chr << 13)]; } - - return base.ReadPpu(addr); + else + { + return base.ReadPpu(addr); + } } public override void SyncState(Serializer ser) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CPROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CPROM.cs index 833e9a2f98..974f910870 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CPROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CPROM.cs @@ -20,15 +20,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES Cart.VramSize = 16; Cart.WramSize = 0; break; + case "NES-CPROM": //videomation AssertPrg(32); AssertChr(0); AssertVram(16); AssertWram(0); break; + default: return false; } //TODO - assert that mirror type is vertical? //set it in the cart? + SetMirrorType(EMirrorType.Vertical); return true; @@ -44,9 +47,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x1000) return Vram[addr]; - if(addr < 0x2000) + else if(addr<0x2000) return Vram[addr - 0x1000 + (chr << 12)]; - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Camerica.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Camerica.cs index 5180577185..2ee64a4d0d 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Camerica.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Camerica.cs @@ -75,6 +75,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } + public override byte ReadPrg(int addr) { int bank_16k = addr >> 14; @@ -85,7 +86,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } - // AKA mapper 232 + //AKA mapper 232 internal class Camerica_Mapper232 : NesBoardBase { //configuration @@ -123,6 +124,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES SetMirrorType(Cart.PadH, Cart.PadV); SyncPRG(); + return true; } @@ -159,4 +161,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return Rom[addr]; } } + } \ No newline at end of file diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CamericaGoldenFive.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CamericaGoldenFive.cs index 7a7b9e2f6f..1fb80d68bc 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CamericaGoldenFive.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CamericaGoldenFive.cs @@ -53,8 +53,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[((regs[0]) << 14) + (addr & 0x3FFF)]; } - - return Rom[((regs[1]) << 14) + (addr & 0x3FFF)]; + else + { + return Rom[((regs[1]) << 14) + (addr & 0x3FFF)]; + } } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Cony.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Cony.cs index c642675fb1..2d1abb76c1 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Cony.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Cony.cs @@ -134,6 +134,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES bank &= 0xFF; return Vrom[(bank << 10) + (addr & 0x3FF)]; } + } return base.ReadPpu(addr); @@ -187,9 +188,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr == 0x1000) return (byte)((NES.DB & 0xFC) | 0); - if (addr >= 0x1100 && addr <= 0x1103) + else if (addr >= 0x1100 && addr <= 0x1103) return _low[addr & 0x3]; - return base.ReadExp(addr); + else + return base.ReadExp(addr); } } @@ -216,6 +218,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES prg_bank_mask_16k = Cart.PrgSize / 16 - 1; prg_bank_mask_8k = Cart.PrgSize / 8 - 1; chr_bank_mask_2k = Cart.PrgSize / 2 - 1; + + //prg_regs[1] = (byte)prg_bank_mask_16k; + //is_2k_bank = true; return true; } return false; @@ -308,14 +313,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES bank = chr_regs[7]; return Vrom[(bank << 11) + (addr & 0x7FF)]; - } - else + } else { int index = (addr >> 10) & 0x7; int bank = chr_regs[index]; bank |= ((bank & 0x30) << 4); return Vrom[(bank << 10) + (addr & 0x3FF)]; } + } return base.ReadPpu(addr); @@ -331,8 +336,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } return Rom[(((bank & 0x30) | 0xF) << 14) + (addr & 0x3FFF)]; - } - else + } else { int index = (addr >> 13) & 0x3; int bank = prg_regs[index]; @@ -342,7 +346,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES bank = prg_bank_mask_8k; return Rom[(bank << 13) + (addr & 0x1FFF)]; + + } + } public override void ClockCpu() @@ -371,9 +378,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr == 0x1000) return (byte)((NES.DB & 0xFC) | 0); - if (addr >= 0x1100 && addr <= 0x1103) + else if (addr >= 0x1100 && addr <= 0x1103) return _low[addr & 0x3]; - return base.ReadExp(addr); + else + return base.ReadExp(addr); + } } @@ -400,6 +409,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (Cart.PrgSize == 1024) { prg_bank_mask_16k = Cart.PrgSize / 16 - 1; + prg_regs[1] = (byte)prg_bank_mask_16k; return true; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CoolBoy.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CoolBoy.cs index d08ceb1bad..9009b742d4 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CoolBoy.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CoolBoy.cs @@ -4,11 +4,13 @@ using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES { - // eldritch horror pirate multicart - // 32MB prg rom, no prg ram, no chr rom, 128KB chr ram - // behavior directly from fceu-mm internal sealed class CoolBoy : MMC3Board_Base { + // eldritch horror pirate multicart + // 32MB prg rom, no prg ram, no chr rom, 128KB chr ram + + // behavior directly from fceu-mm + // this could be broken down into more sensibly named variables private byte[] exp = new byte[4]; @@ -43,6 +45,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (!exp[3].Bit(7)) { exp[addr & 3] = value; + /* + if (exp[3].Bit(7)) + { + Console.WriteLine("EXP Write Protect Activated"); + } + if (exp[3].Bit(4)) + { + Console.WriteLine("Funky Mode Active"); + } + */ } } } @@ -50,17 +62,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES protected override int Get_PRGBank_8K(int addr) { int mask = 0, shift = 0; - int baseAddr = exp[0] & 0x07 | (exp[1] & 0x10) >> 1 | (exp[1] & 0x0c) << 2 | (exp[0] & 0x30) << 2; + int baseaddr = exp[0] & 0x07 | (exp[1] & 0x10) >> 1 | (exp[1] & 0x0c) << 2 | (exp[0] & 0x30) << 2; switch (exp[0] & 0xc0) { case 0x00: - baseAddr >>= 2; + baseaddr >>= 2; mask = 0x3f; shift = 6; break; case 0x80: - baseAddr >>= 1; + baseaddr >>= 1; mask = 0x1f; shift = 5; break; @@ -82,7 +94,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int v = base.Get_PRGBank_8K(addr); - int ret = baseAddr << shift | v & mask; + int ret = baseaddr << shift | v & mask; if (exp[3].Bit(4)) { ret |= exp[3] & (0x0e ^ exp[1] & 2); @@ -96,8 +108,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return (exp[2] & 15) << 3 | addr >> 10 & 7; } - - return base.Get_CHRBank_1K(addr); + else + { + return base.Get_CHRBank_1K(addr); + } } public override void SyncState(Serializer ser) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/DatachBarcode.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/DatachBarcode.cs index 4775d786a3..8e2d9f12e2 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/DatachBarcode.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/DatachBarcode.cs @@ -7,6 +7,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { // mostly jacked from nestopia's NstBoardBandaiDatach.cpp // very dirty, needs cleanup and such + public class DatachBarcode : IEmulatorService { private static readonly byte[,] prefixParityType = new byte[10, 6] @@ -66,6 +67,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ser.EndSection(); } + public void Reset() { cycles = 0; @@ -77,6 +79,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return stream_idx < data.Length; } + private static bool IsDigtsSupported(int count) + { + return count.In(MIN_DIGITS, MAX_DIGITS); + } public static bool ValidString(string s, out string why) { @@ -172,6 +178,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES for (int j = 0; j < 7; j++) result.WriteByte(dataRight[code[i], j]); + for (int i = 0; i < 7; i++) sum += code[i] * ((i & 1) != 0 ? 3 : 1); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/ExROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/ExROM.cs index 1b45631fe8..07fec3d7e7 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/ExROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/ExROM.cs @@ -123,7 +123,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES else chr_bank_mask_1k = Cart.VramSize - 1; - PowerOnState(); + PoweronState(); if (NES.apu != null) audio = new MMC5Audio(NES.apu.ExternalQueue, e => { irq_audio = e; SyncIRQ(); }); @@ -131,9 +131,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } - private void PowerOnState() + private void PoweronState() { - // set all prg regs to use ROM + //set all prg regs to use ROM regs_prg[0] = 0x80; regs_prg[1] = 0x80; regs_prg[2] = 0x80; @@ -265,7 +265,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } bank_1k &= chr_bank_mask_1k; - addr = (bank_1k << 10) | ofs; + addr = (bank_1k<<10)|ofs; return addr; } @@ -517,6 +517,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES nt_fill_attrib |= (byte)(nt_fill_attrib << 2); nt_fill_attrib |= (byte)(nt_fill_attrib << 4); break; + case 0x1113: //$5113: [.... .PPP] (simplified, but technically inaccurate -- see below) wram_bank = value & 7; @@ -700,6 +701,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES SyncIRQ(); } } + } public override void ClockCpu() diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FFE/Mapper006.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FFE/Mapper006.cs index 845db97d70..085ef54ab5 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FFE/Mapper006.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FFE/Mapper006.cs @@ -80,6 +80,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES _irqCount |= value << 8; _irqEnable = true; break; + } SyncIRQ(); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FS304.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FS304.cs index 128a52553b..33569dc6f2 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FS304.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FS304.cs @@ -3,6 +3,7 @@ internal sealed class FS304 : NesBoardBase { // waixing? + private int prg; private int prg_mask_32k; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Farid-UNROM-8-in-1.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Farid-UNROM-8-in-1.cs index 2d6605d07c..3567cf29f5 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Farid-UNROM-8-in-1.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Farid-UNROM-8-in-1.cs @@ -1,8 +1,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - // http://forums.nesdev.com/viewtopic.php?f=9&t=11099 internal sealed class Farid_UNROM_8_in_1 : NesBoardBase { + // http://forums.nesdev.com/viewtopic.php?f=9&t=11099 + // state private int c; // clock bit for the second 74'161 private int e; // /load for second 74'161. guaranteed to be 0 on powerup diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/GameGenie.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/GameGenie.cs index a2eaa35c6e..8c21eb78bc 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/GameGenie.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/GameGenie.cs @@ -3,6 +3,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { // this is an internal testing thing, not really for using + internal sealed class GameGenie : NesBoardBase { private static readonly byte[] PatternTables = new byte[256]; @@ -52,14 +53,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x4000) return NES.DB; - return Rom[addr & 0xfff]; + else + return Rom[addr & 0xfff]; } public override byte ReadPpu(int addr) { if (addr >= 0x2000) return base.ReadPpu(addr); - return PatternTables[addr & 0xff]; + else + return PatternTables[addr & 0xff]; } public override void WritePrg(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/GxROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/GxROM.cs index 100f670cfe..337ff4955b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/GxROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/GxROM.cs @@ -52,6 +52,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if(origin == EDetectionOrigin.INES) Console.WriteLine("Caution! This board (inferred from iNES) might have wrong mirr.type"); + return true; } public override byte ReadPrg(int addr) @@ -65,14 +66,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Vrom[addr + (chr << 13)]; } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } public override void WritePrg(int addr, byte value) { - chr = (value & 7) & chr_mask; - prg = ((value>>4) & 3) & prg_mask; + chr = ((value & 7) & chr_mask); + prg = (((value>>4) & 3) & prg_mask); } public override void SyncState(Serializer ser) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IC_74x377.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IC_74x377.cs index 18664a480b..143b2802dc 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IC_74x377.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IC_74x377.cs @@ -3,9 +3,11 @@ using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES { - // Mapper 011 - // Crystal Mines - // Metal Fighter + //mapper 011 + + //Crystal Mines + //Metal Fighter + [NesBoardImplPriority] internal sealed class IC_74x377 : NesBoardBase { @@ -62,8 +64,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Vrom[addr + (chr_bank_8k << 13)]; } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } public override void WritePrg(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IREM-74_161_161_21_138.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IREM-74_161_161_21_138.cs index 349b19edf8..88f56bd004 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IREM-74_161_161_21_138.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IREM-74_161_161_21_138.cs @@ -2,15 +2,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - // https://wiki.nesdev.com/w/index.php/INES_Mapper_077 - // Napoleon Senki - // the 4screen implementation is a bit of a guess, but it seems to work + //Mapper 77 + //Napoleon Senki + + //the 4screen implementation is a bit of a guess, but it seems to work + internal sealed class IREM_74_161_161_21_138 : NesBoardBase { private int chr, prg; public override bool Configure(EDetectionOrigin origin) { - // configure + //configure switch (Cart.BoardType) { case "MAPPER077": @@ -44,18 +46,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x0800) return Vrom[addr + (chr * 0x0800)]; - if (addr < 0x2000) + else if (addr < 0x2000) return Vram[addr]; - if (addr < 0x2800) + else if (addr < 0x2800) return Vram[addr & 0x7ff]; - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) { if (addr < 0x0800) return; - if (addr < 0x2000) + else if (addr < 0x2000) Vram[addr] = value; else if (addr < 0x2800) Vram[addr & 0x7ff] = value; @@ -66,7 +68,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x8000) return Rom[addr + (prg * 0x8000)]; - return base.ReadPrg(addr); + else + return base.ReadPrg(addr); } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IREM_TAM_S1.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IREM_TAM_S1.cs index 37aa07e111..306ef7189a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IREM_TAM_S1.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IREM_TAM_S1.cs @@ -2,8 +2,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - // https://wiki.nesdev.com/w/index.php/INES_Mapper_097 - // Kaiketsu Yanchamaru (Kid Niki 1) + //iNES Mapper 97 + //Kaiketsu Yanchamaru (Kid Niki 1) + internal sealed class IREM_TAM_S1 : NesBoardBase { private int prg_bank_mask_16k; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Irem_G101.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Irem_G101.cs index 9dca3503b9..563c2a0e7b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Irem_G101.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Irem_G101.cs @@ -2,10 +2,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - //AKA Mapper 032 - // Image Fight - // Major League - // Kaiketsu Yanchamaru 2 + //AKA mapper 032 + + //Image Fight + //Major League + //Kaiketsu Yanchamaru 2 + internal sealed class Irem_G101 : NesBoardBase { //configuration @@ -66,9 +68,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (oneScreenHack) SetMirrorType(EMirrorType.OneScreenA); - else if (mirror_mode == 0) - SetMirrorType(EMirrorType.Vertical); - else SetMirrorType(EMirrorType.Horizontal); + else + if (mirror_mode == 0) + SetMirrorType(EMirrorType.Vertical); + else SetMirrorType(EMirrorType.Horizontal); } public override void WritePrg(int addr, byte value) @@ -120,8 +123,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = (bank_1k << 10) | ofs; return Vrom[addr]; } - - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override byte ReadPrg(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Irem_H3001.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Irem_H3001.cs index a0afdca0cc..929a0b2515 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Irem_H3001.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Irem_H3001.cs @@ -2,10 +2,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - //AKA Mapper 65 - // Daiku no Gen San 2 - // Spartan X 2 - // NOTE - fceux support for this mapper has some kind of -4 cpu cycle delay built into the timer. not sure yet whether we need that + //AKA mapper 65 + + //Daiku no Gen San 2 + //Spartan X 2 + + //NOTE - fceux support for this mapper has some kind of -4 cpu cycle delay built into the timer. not sure yet whether we need that + internal sealed class Irem_H3001 : NesBoardBase { //configuration @@ -55,6 +58,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + /* + public override void ClockPPU() + { + clock_counter++; + if (clock_counter == 3) + { + ClockCPU(); + clock_counter = 0; + } + }*/ + public override void ClockCpu() { if (irq_counter == 0) return; @@ -91,8 +105,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = (bank_1k << 10) | ofs; return Vrom[addr]; } - - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override void WritePrg(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_05_06_07.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_05_06_07.cs index 5da05a06f4..2488793a33 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_05_06_07.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_05_06_07.cs @@ -67,7 +67,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x2000) return Vrom[addr | chr << 13]; - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override byte ReadPrg(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_13.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_13.cs index 1dc1021fc5..e13cd18688 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_13.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_13.cs @@ -2,11 +2,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - // Mapper 86 - // Example Games: - // -------------------------- - // Moero!! Pro Yakyuu (Black) - // Moero!! Pro Yakyuu (Red) + //Mapper 86 + + //Example Games: + //-------------------------- + //Moero!! Pro Yakyuu (Black) + //Moero!! Pro Yakyuu (Red) + internal sealed class JALECO_JF_13 : NesBoardBase { //configuration @@ -41,14 +43,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x8000) return Rom[addr + (prg * 0x8000)]; - return base.ReadPrg(addr); + else + return base.ReadPrg(addr); } public override byte ReadPpu(int addr) { if (addr < 0x2000) return Vrom[(addr & 0x1FFF) + (chr * 0x2000)]; - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override void WriteWram(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_17.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_17.cs index 87d5491bfc..bbc58613a4 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_17.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_17.cs @@ -2,18 +2,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - // iNES Mapper 72 - // Example Games: - // -------------------------- - // Pinball Quest (J) - // Moero!! Pro Tennis - // Moero!! Juudou Warriors + //iNES Mapper 72 + //Example Games: + //-------------------------- + //Pinball Quest (J) + //Moero!! Pro Tennis + //Moero!! Juudou Warriors + + //based on the chips on the pcb (3x 4bit registers and some OR gates) i'm gonna speculate something a little different about how this works. + //there isnt enough memory for 2 bank registers, a latched bank, and a latched command. so i think the bank isnt latched--the command is latched. + //when the top 2 bits are 0, then the low 4 bits are written to the register specified by the latch + //when the top 2 bits arent 0, theyre written to the latch + //interestingly, this works (for pinball quest) only when bus conflicts are applied, otherwise the game cant get past the title - // based on the chips on the pcb (3x 4bit registers and some OR gates) i'm gonna speculate something a little different about how this works. - // there isnt enough memory for 2 bank registers, a latched bank, and a latched command. so i think the bank isnt latched--the command is latched. - // when the top 2 bits are 0, then the low 4 bits are written to the register specified by the latch - // when the top 2 bits arent 0, theyre written to the latch - // interestingly, this works (for pinball quest) only when bus conflicts are applied, otherwise the game cant get past the title internal sealed class JALECO_JF_17 : NesBoardBase { //configuration @@ -65,6 +66,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WritePrg(int addr, byte value) { + //Console.WriteLine("MAP {0:X4} = {1:X2}", addr, value); + value = HandleNormalPRGConflict(addr, value); int command = value >> 6; @@ -94,10 +97,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (addr < 0x2000) { addr = ApplyMemoryMap(13, chr_banks_8k, addr); - return ReadPPUChr(addr); + return base.ReadPPUChr(addr); } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_19.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_19.cs index 87d0cff7b3..90d7bbd05d 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_19.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_JF_19.cs @@ -3,13 +3,15 @@ using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES { - // iNES Mapper 92 - // Example Games: - // Example Games: - // -------------------------- - // Moero!! Pro Soccer - // Moero!! Pro Yakyuu '88 - Ketteiban - // Near Identical to Jaleco JF 17, except for a slight PRG setup + //iNES Mapper 92 + //Example Games: + //Example Games: + //-------------------------- + //Moero!! Pro Soccer + //Moero!! Pro Yakyuu '88 - Ketteiban + + //Near Identical to Jaleco JF 17, except for a slight PRG setup + internal sealed class JALECO_JF_19 : NesBoardBase { //configuration @@ -61,7 +63,25 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WritePrg(int addr, byte value) { + //Console.WriteLine("MAP {0:X4} = {1:X2}", addr, value); + value = HandleNormalPRGConflict(addr, value); + /* + int command = value >> 6; + switch (command) + { + case 0: + if (latch == 1) + chr_banks_8k[0] = (byte)(value & 0xF); + else if (latch == 2) + prg_banks_16k[1] = (byte)(value & 0xF); + SyncMap(); + break; + default: + latch = command; + break; + } + */ // the important change here is that the chr and prg bank latches get filled on the rising edge, not falling if (value.Bit(6) && !latch.Bit(6)) @@ -83,10 +103,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (addr < 0x2000) { addr = ApplyMemoryMap(13, chr_banks_8k, addr); - return ReadPPUChr(addr); + return base.ReadPPUChr(addr); } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_SS8806.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_SS8806.cs index 0306c6f431..cf12a0956f 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_SS8806.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/JALECO_SS8806.cs @@ -2,9 +2,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - // http://wiki.nesdev.com/w/index.php/INES_Mapper_018 internal sealed class JALECO_SS8806 : NesBoardBase { + //http://wiki.nesdev.com/w/index.php/INES_Mapper_018 + private byte[] prg_banks_8k = new byte[4]; private byte[] chr_banks_1k = new byte[8]; private int chr_bank_mask_1k, prg_bank_mask_8k; @@ -14,6 +15,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private int irqcountwidth; private bool irqcountpaused; + public override bool Configure(EDetectionOrigin origin) { //analyze board type @@ -205,10 +207,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES else irqcountwidth = 16; break; + case 0xF003: // sound chip µPD7756C break; } + + } public override void ClockCpu() @@ -216,7 +221,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (!irqcountpaused) { int newclock = irqclock - 1; - if (Squeeze(newclock) > Squeeze(irqclock)) + if (squeeze(newclock) > squeeze(irqclock)) { IrqSignal = true; irqclock = irqreload; @@ -229,7 +234,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES /// /// emulate underflow for the appropriate number of bits /// - private uint Squeeze(int input) + private uint squeeze(int input) { unchecked { @@ -264,10 +269,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = MapCHR(addr); if (Vrom != null) return Vrom[addr]; - return Vram[addr]; + else return Vram[addr]; } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Jaleco-JF_11_14.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Jaleco-JF_11_14.cs index 9d635310e3..7ba05b63fe 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Jaleco-JF_11_14.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Jaleco-JF_11_14.cs @@ -3,22 +3,24 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { /* - Life Span: October 1986 - April 1987 - PCB Class: Jaleco-JF-11 - Jaleco-JF-14 - iNES Mapper 140 + * Life Span: October 1986 - April 1987 +PCB Class: Jaleco-JF-11 + Jaleco-JF-14 +iNES Mapper 140 + +JF-11 +PRG-ROM: 128kb +CHR-ROM: 32kb +Battery is not available +Uses vertical mirroring +No CIC present +Other chips used: Sunsoft-1 + * + * Games: + * Mississippi Satsujin Jiken (J) + * Bio Senshi Dan - Increaser Tono Tatakai [allegedly; but it does not work] + */ - JF-11 - PRG-ROM: 128kb - CHR-ROM: 32kb - Battery is not available - Uses vertical mirroring - No CIC present - Other chips used: Sunsoft-1 - Games: - Mississippi Satsujin Jiken (J) - Bio Senshi Dan - Increaser Tono Tatakai [allegedly; but it does not work] - */ internal sealed class Jaleco_JF_11_14 : NesBoardBase { private int chr, prg; @@ -45,14 +47,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x8000) return Rom[addr + (prg * 0x8000)]; - return base.ReadPrg(addr); + else + return base.ReadPrg(addr); } public override byte ReadPpu(int addr) { if (addr < 0x2000) return Vrom[(addr & 0x1FFF) + (chr * 0x2000)]; - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override void WriteWram(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-ACTION52.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-ACTION52.cs index f1d4399522..4ba32c55b6 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-ACTION52.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-ACTION52.cs @@ -72,17 +72,27 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return eRAM[(addr & 0x07)]; } - - return base.ReadExp(addr); + else + { + return base.ReadExp(addr); + } } public override void WritePrg(int addr, byte value) { - // $8000-FFFF: [.... ..CC] Low 2 bits of CHR - // A~[..MH HPPP PPO. CCCC] + //$8000-FFFF: [.... ..CC] Low 2 bits of CHR + //A~[..MH HPPP PPO. CCCC] + addr += 0x8000; - SetMirrorType(addr.Bit(13) ? EMirrorType.Horizontal : EMirrorType.Vertical); + if (addr.Bit(13)) + { + SetMirrorType(EMirrorType.Horizontal); + } + else + { + SetMirrorType(EMirrorType.Vertical); + } prg_mode = addr.Bit(5); prg_reg = (addr >> 6) & 0x1F; @@ -123,8 +133,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int bank = (prg_reg >> 1) & prg_bank_mask_32k; return Rom[(bank * 0x8000) + addr + chip_offset]; } - - return Rom[((prg_reg & prg_bank_mask_16k) * 0x4000) + (addr & 0x3FFF) + chip_offset]; + else + { + return Rom[((prg_reg & prg_bank_mask_16k) * 0x4000) + (addr & 0x3FFF) + chip_offset]; + } } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-MAX15.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-MAX15.cs index 68bb21eef6..1b3d41c7eb 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-MAX15.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-MAX15.cs @@ -3,9 +3,10 @@ using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES { - // http://wiki.nesdev.com/w/index.php/INES_Mapper_234 internal sealed class MLT_MAX15 : NesBoardBase { + //http://wiki.nesdev.com/w/index.php/INES_Mapper_234 + private bool mode = false; private int block_high = 0; private int block_low = 0; @@ -125,6 +126,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } return value; + } public override byte ReadPpu(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/HKROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/HKROM.cs index ceb8ef895b..5483024b00 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/HKROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/HKROM.cs @@ -7,6 +7,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //for simplicity's sake, the behaviour of mmc6 is wrapped up into this board since it isnt used anywhere else internal sealed class HKROM : MMC3Board_Base { + //configuration + //state private bool wram_enabled; private bool wram_h_enabled, wram_l_enabled; @@ -111,5 +113,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return base.ReadWram(addr); return 0; } + } } \ No newline at end of file diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3.cs index 9e66b06e76..4254c7d055 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3.cs @@ -300,6 +300,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES a12_old = a12; } + } } @@ -309,6 +310,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public MMC3 mmc3; public int extra_vrom; + public override void AddressPpu(int addr) { mmc3.AddressPPU(addr); @@ -353,7 +355,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (addr < 0x2000) { addr = MapCHR(addr); - return Vrom?[addr + extra_vrom] ?? Vram[addr]; + if (Vrom != null) + return Vrom[addr + extra_vrom]; + else return Vram[addr]; } return base.ReadPpu(addr); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper012.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper012.cs index 7cb8d4b590..d308f53515 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper012.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper012.cs @@ -45,5 +45,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES else bank_1k += (block1 << 8); return bank_1k; } + } } \ No newline at end of file diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper049.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper049.cs index 6da584763c..0490302fc7 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper049.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper049.cs @@ -44,6 +44,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES base.WriteWram(addr, value); } + protected override int Get_PRGBank_8K(int addr) { if (mode) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper074.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper074.cs index 47787b32d9..f28adc32af 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper074.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper074.cs @@ -2,11 +2,13 @@ //27 //TODO - could merge functionality with 192 somehow -//http://wiki.nesdev.com/w/index.php/INES_Mapper_074 + namespace BizHawk.Emulation.Cores.Nintendo.NES { internal sealed class Mapper074 : MMC3Board_Base { + //http://wiki.nesdev.com/w/index.php/INES_Mapper_074 + public override bool Configure(EDetectionOrigin origin) { //analyze board type diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper115.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper115.cs index 90959063c4..d97f26cab2 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper115.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper115.cs @@ -55,22 +55,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { int bank_8k = mmc3.Get_PRGBank_8K(addr); if (prg_mode_mapper == false) return bank_8k; - if (addr < 0x2000) + else if (addr < 0x2000) { return prg_page*4; } - - if (addr < 0x4000) + else if (addr < 0x4000) { return prg_page*4 + 1; } - - if (addr < 0x6000) + else if (addr < 0x6000) { return prg_page*4 + 2; } - - return prg_page*4 + 3; + else + { + return prg_page*4 + 3; + } + } protected override int Get_CHRBank_1K(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper121.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper121.cs index e6acdd94d8..f9b6e4bcb3 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper121.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper121.cs @@ -35,8 +35,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return exRegs[2]; } - - return base.ReadExp(addr); + else + { + return base.ReadExp(addr); + } } public override void WriteExp(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper123.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper123.cs index 82cd7e36dc..0d2b8f49ec 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper123.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper123.cs @@ -77,12 +77,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[((bank >> 1) << 15) + (addr & 0x7FFF)]; } - - return Rom[(bank << 14) + (addr & 0x3FFF)]; + else + { + return Rom[(bank << 14) + (addr & 0x3FFF)]; + } + } + else + { + //return (byte)(base.ReadPRG(addr) & 0x3F); + return base.ReadPrg(addr); } - - //return (byte)(base.ReadPRG(addr) & 0x3F); - return base.ReadPrg(addr); } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper182.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper182.cs index 291685ecf4..b6df8d8f1b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper182.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper182.cs @@ -26,7 +26,7 @@ case 0x8000: break; //? case 0x8001: base.WritePrg(0xA000,value); break; case 0xA000: - value = (byte)ScrambleA000(value); + value = (byte)scramble_A000(value); base.WritePrg(0x8000,value); break; case 0xA001: break; //? @@ -43,7 +43,7 @@ private static readonly byte[] scramble_table = { 0, 3, 1, 5, 6, 7, 2, 4 }; - private static int ScrambleA000(byte val) + private static int scramble_A000(byte val) { return (val & ~0x7) | scramble_table[val & 0x7]; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper189.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper189.cs index a6e0940b06..d2985e69a8 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper189.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper189.cs @@ -48,5 +48,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { WriteWram(addr, value); } + } } \ No newline at end of file diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper191.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper191.cs index 852926db88..87f7a1aaac 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper191.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper191.cs @@ -38,8 +38,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //this is referencing chr ram return Vram[addr & 0x7FF]; } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) @@ -58,5 +57,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } else base.WritePpu(addr, value); } + } } \ No newline at end of file diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper192.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper192.cs index a873fd7661..53463eac8a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper192.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper192.cs @@ -1,8 +1,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - // http://wiki.nesdev.com/w/index.php/INES_Mapper_192 internal sealed class Mapper192 : MMC3Board_Base { + //http://wiki.nesdev.com/w/index.php/INES_Mapper_192 + public override bool Configure(EDetectionOrigin origin) { //analyze board type @@ -46,6 +47,7 @@ } } + public override byte ReadPpu(int addr) { if (addr < 0x2000) @@ -56,28 +58,26 @@ byte value = Vram[addr & 0x03FF]; return value; } - - if (bank == 0x09) + else if (bank == 0x09) { return Vram[(addr & 0x03FF) + 0x400]; } - - if (bank == 0x0A) + else if (bank == 0x0A) { return Vram[(addr & 0x03FF) + 0x800]; } - - if (bank == 0x0B) + else if (bank == 0x0B) { return Vram[(addr & 0x03FF) + 0xC00]; } - - addr = MapCHR(addr); - return Vrom[addr + extra_vrom]; + else + { + addr = MapCHR(addr); + return Vrom[addr + extra_vrom]; + } } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper194.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper194.cs index ece5c92e0d..ecf869cb19 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper194.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper194.cs @@ -1,8 +1,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - // http://wiki.nesdev.com/w/index.php/INES_Mapper_194 internal sealed class Mapper194 : MMC3Board_Base { + //http://wiki.nesdev.com/w/index.php/INES_Mapper_194 + public override bool Configure(EDetectionOrigin origin) { //analyze board type @@ -46,18 +47,18 @@ { return Vram[addr & 0x03FF]; } - - if (bank == 0x01) + else if (bank == 0x01) { return Vram[(addr & 0x03FF) + 0x400]; } - - addr = MapCHR(addr); - return Vrom[addr + extra_vrom]; + else + { + addr = MapCHR(addr); + return Vrom[addr + extra_vrom]; + } } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195.cs index a6df45ae5d..f11c2caff0 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195.cs @@ -62,12 +62,14 @@ { return Vram[(bank_1k << 10) + (addr & 0x3FF)]; } - - addr = MapCHR(addr); - return Vrom[addr + extra_vrom]; + else + { + addr = MapCHR(addr); + return Vrom[addr + extra_vrom]; + } } - - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195_CW.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195_CW.cs index 51ea87b943..e3231e9aa6 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195_CW.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195_CW.cs @@ -41,12 +41,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Vram[(bank_1k << 10) + (addr & 0x3FF)]; } - - addr = MapCHR(addr); - return Vrom[addr + extra_vrom]; + else + { + addr = MapCHR(addr); + return Vrom[addr + extra_vrom]; + } } - - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper196.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper196.cs index 44370ca6d9..b46dd6d6e5 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper196.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper196.cs @@ -74,8 +74,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[addr | prgreg << 15]; } - - return base.ReadPrg(addr); + else + { + return base.ReadPrg(addr); + } } + } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper197.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper197.cs index 50bc45dc37..d8a7f6210b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper197.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper197.cs @@ -53,6 +53,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES chr_regs_1k_512[4 | i] = chr_right_upper | i; chr_regs_1k_512[6 | i] = chr_right_lower | i; } + } public override void SyncState(Serializer ser) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper199.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper199.cs index 075dcb3cec..7322c61100 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper199.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper199.cs @@ -43,49 +43,60 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (mmc3.regs[0]<8) { return Vram[(mmc3.regs[0] << 10) + (addr & 0x3FF)]; + } else + { + return Vrom[(mmc3.regs[0] << 10) + (addr & 0x3FF)]; } - - return Vrom[(mmc3.regs[0] << 10) + (addr & 0x3FF)]; } - - if (addr<0x800) + else if (addr<0x800) { if (exRegs[2] < 8) { return Vram[(exRegs[2] << 10) + (addr & 0x3FF)]; } - - return Vrom[(exRegs[2] << 10) + (addr & 0x3FF)]; + else + { + return Vrom[(exRegs[2] << 10) + (addr & 0x3FF)]; + } } - - if (addr < 0xC00) + else if (addr < 0xC00) { if (mmc3.regs[1] < 8) { return Vram[(mmc3.regs[1] << 10) + (addr & 0x3FF)]; } - - return Vrom[(mmc3.regs[1] << 10) + (addr & 0x3FF)]; + else + { + return Vrom[(mmc3.regs[1] << 10) + (addr & 0x3FF)]; + } } - - if (exRegs[3] < 8) + else { - return Vram[(exRegs[3] << 10) + (addr & 0x3FF)]; + if (exRegs[3] < 8) + { + return Vram[(exRegs[3] << 10) + (addr & 0x3FF)]; + } + else + { + return Vrom[(exRegs[3] << 10) + (addr & 0x3FF)]; + } } - - return Vrom[(exRegs[3] << 10) + (addr & 0x3FF)]; } - - int bank_1k = Get_CHRBank_1K(addr); - if (bank_1k < 8) + else { - return Vram[(bank_1k << 10) + (addr & 0x3FF)]; + int bank_1k = Get_CHRBank_1K(addr); + if (bank_1k < 8) + { + return Vram[(bank_1k << 10) + (addr & 0x3FF)]; + } + else + { + return Vrom[(bank_1k << 10) + (addr & 0x3FF)]; + } } - - return Vrom[(bank_1k << 10) + (addr & 0x3FF)]; } - - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) @@ -162,8 +173,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return exRegs[0]; } - - if (addr >= 0x6000) + else if (addr >= 0x6000) { return exRegs[1]; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper205.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper205.cs index d4ad6b9560..26ffbeb0f7 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper205.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper205.cs @@ -2,9 +2,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - // Mapper 205 info: http://wiki.nesdev.com/w/index.php/INES_Mapper_205 internal sealed class Mapper205 : MMC3Board_Base { + //Mapper 205 info: http://wiki.nesdev.com/w/index.php/INES_Mapper_205 + private int block; public override bool Configure(EDetectionOrigin origin) @@ -96,10 +97,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (addr < 0x2000) { addr = MapCHR2(addr); - return Vrom?[addr + extra_vrom] ?? Vram[addr]; + if (Vrom != null) + return Vrom[addr + extra_vrom]; + else return Vram[addr]; } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } public override void NesSoftReset() diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper208.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper208.cs index 475ddf681a..c88421f272 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper208.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper208.cs @@ -79,6 +79,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES exRegs[addr & 3] = (byte)(value ^ lut[exRegs[4]]); } } + else { base.WriteExp(addr, value); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper215.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper215.cs index b372cb2b2b..280afb72e7 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper215.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper215.cs @@ -5,13 +5,43 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES internal sealed class Mapper215 : MMC3Board_Base { private byte[] exRegs = new byte[4]; + public byte[] prg_regs_8k = new byte[4]; private bool is_mk3; + private int prg_mask_8k, chr_mask_1k; private readonly byte[] regs_sec = { 0, 2, 5, 3, 6, 1, 7, 4 }; + /* + * I'm not sure where these matrices originated from, but they don't seem to be needed + * so let's leave them as commented out in case a need arises + private readonly byte[,] regperm = new byte[,] + { + { 0, 1, 2, 3, 4, 5, 6, 7 }, + { 0, 2, 6, 1, 7, 3, 4, 5 }, + { 0, 5, 4, 1, 7, 2, 6, 3 }, // unused + { 0, 6, 3, 7, 5, 2, 4, 1 }, + { 0, 2, 5, 3, 6, 1, 7, 4 }, // only one actually used? + { 0, 1, 2, 3, 4, 5, 6, 7 }, // empty + { 0, 1, 2, 3, 4, 5, 6, 7 }, // empty + { 0, 1, 2, 3, 4, 5, 6, 7 }, // empty + }; + + private readonly byte[,] adrperm = new byte[,] + { + { 0, 1, 2, 3, 4, 5, 6, 7 }, + { 3, 2, 0, 4, 1, 5, 6, 7 }, + { 0, 1, 2, 3, 4, 5, 6, 7 }, // unused + { 5, 0, 1, 2, 3, 7, 6, 4 }, + { 3, 1, 0, 5, 2, 4, 6, 7 }, // only one actully used? + { 0, 1, 2, 3, 4, 5, 6, 7 }, // empty + { 0, 1, 2, 3, 4, 5, 6, 7 }, // empty + { 0, 1, 2, 3, 4, 5, 6, 7 }, // empty + }; + */ + public override bool Configure(EDetectionOrigin origin) { switch (Cart.BoardType) @@ -39,6 +69,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES prg_regs_8k[2] = (byte)(0xFE & prg_mask_8k); prg_regs_8k[3] = (byte)(0xFF & prg_mask_8k); + return true; } @@ -56,14 +87,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if ((exRegs[0] & 0x80) == 0) { - int temp = mmc3.prg_regs_8k[i]; + int temp = 0; + //for (int i=0;i<4;i++) + //{ + temp = mmc3.prg_regs_8k[i]; - if ((exRegs[1] & 0x8) > 0) - temp = (temp & 0x1F) | 0x20; - else - temp = ((temp & 0x0F) | (exRegs[1] & 0x10)); + if ((exRegs[1] & 0x8) > 0) + temp = (temp & 0x1F) | 0x20; + else + temp = ((temp & 0x0F) | (exRegs[1] & 0x10)); - prg_regs_8k[i] = (byte)(temp & prg_mask_8k); + prg_regs_8k[i] = (byte)(temp & prg_mask_8k); + //} } } @@ -161,7 +196,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } else { - SetMirrorType(value == 0 ? EMirrorType.Vertical : EMirrorType.Horizontal); + if (value==0) + { + SetMirrorType(EMirrorType.Vertical); + } + else + { + SetMirrorType(EMirrorType.Horizontal); + } } break; case 0xA001: @@ -169,7 +211,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES break; case 0xC000: if (exRegs[2]>0) - SetMirrorType((value >> 7 | value) == 0 ? EMirrorType.Vertical : EMirrorType.Horizontal); + if ((value >> 7 | value) == 0) + { + SetMirrorType(EMirrorType.Vertical); + } + else + { + SetMirrorType(EMirrorType.Horizontal); + } else base.WritePrg(0x4000, value); break; @@ -211,8 +260,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = (bank_1k << 10) | (addr & 0x3FF); return Vrom[addr]; } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } public override byte ReadPrg(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs index 0ec583a992..2b8f5385d1 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs @@ -10,6 +10,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private int prg_mask_8k, chr_mask_1k; private readonly byte[] regs_sec = { 0, 6, 3, 7, 5, 2, 4, 1 }; + public override bool Configure(EDetectionOrigin origin) { switch (Cart.BoardType) @@ -49,16 +50,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public void sync_prg() { + int temp = 0; for (int i=0;i<4;i++) { - int temp = mmc3.prg_regs_8k[i]; + temp = mmc3.prg_regs_8k[i]; if ((exRegs[1] & 0x8) > 0) temp = temp & 0x1F; else temp = ((temp & 0x0F) | (exRegs[1] & 0x10)); - temp |= (exRegs[1] << 5 & 0x60); + temp |= (exRegs[1] << 5 & 0x60); prg_regs_8k[i] = (byte)(temp & prg_mask_8k); } } @@ -142,15 +144,28 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } else { - SetMirrorType(value == 0 ? EMirrorType.Vertical : EMirrorType.Horizontal); + if (value == 0) + { + SetMirrorType(EMirrorType.Vertical); + } + else + { + SetMirrorType(EMirrorType.Horizontal); + } } break; case 0xA001: if (exRegs[2] > 0) { - SetMirrorType(value == 0 ? EMirrorType.Vertical : EMirrorType.Horizontal); - } - else + if (value == 0) + { + SetMirrorType(EMirrorType.Vertical); + } + else + { + SetMirrorType(EMirrorType.Horizontal); + } + } else { base.WritePrg(0x2001, value); } @@ -175,10 +190,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = (bank_1k << 10) | (addr & 0x3FF); return Vrom[addr]; } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } + public override byte ReadPrg(int addr) { int bank = addr >> 13; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper219.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper219.cs index 3873e2fb98..04690ba427 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper219.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper219.cs @@ -103,7 +103,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } break; } - } + } else base.WritePrg(addr, value); } @@ -128,8 +128,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } return Vram[((bank_chr << 10) + (addr & 0x3FF))]; } - - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper223.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper223.cs index 9372c492a6..9e9745c4b6 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper223.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper223.cs @@ -22,7 +22,7 @@ public override void WriteExp(int addr, byte value) { - if (addr > 0x1000) + if (addr>0x1000) { Wram[addr + 0x4000 - (0x5000 - 0x2000)] = value; } @@ -36,8 +36,8 @@ { return Wram[addr + 0x4000 - (0x5000 - 0x2000)]; } - - return base.ReadExp(addr); + else + return base.ReadExp(addr); } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper245.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper245.cs index 88448630fa..e42e201bcb 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper245.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper245.cs @@ -3,9 +3,9 @@ using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES { - // http://wiki.nesdev.com/w/index.php/INES_Mapper_245 internal sealed class Mapper245 : MMC3Board_Base { + //http://wiki.nesdev.com/w/index.php/INES_Mapper_245 private bool chr_mode; public override bool Configure(EDetectionOrigin origin) @@ -68,14 +68,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Vram[addr + 0x1000]; } - - return Vram[addr - 0x1000]; + else + { + return Vram[addr - 0x1000]; + } + } + else + { + return Vram[addr]; } - - return Vram[addr]; } - - return base.ReadPpu(addr); + else + { + return base.ReadPpu(addr); + } } public override void WritePpu(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper254.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper254.cs index ad3cf5cd57..c676040e03 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper254.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper254.cs @@ -33,8 +33,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Wram[addr]; } - - return (byte)(Wram[addr] ^ regs[1]); + else + { + return (byte)(Wram[addr] ^ regs[1]); + } } public override void WritePrg(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/NES-QJ.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/NES-QJ.cs index a2ead3b659..0fa3e03db5 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/NES-QJ.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/NES-QJ.cs @@ -55,7 +55,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return (byte)block; } - public override void WriteWram(int addr, byte value) { if (mmc3.wram_enable && !mmc3.wram_write_protect) @@ -63,5 +62,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES block = value & 1; } } + } } \ No newline at end of file diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Pocahontas.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Pocahontas.cs index 88de321aba..2024d02cae 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Pocahontas.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Pocahontas.cs @@ -5,6 +5,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES internal sealed class MapperPocahontas : MMC3Board_Base { private byte[] exRegs = new byte[3]; + public byte[] prg_regs_8k = new byte[4]; private int prg_mask_8k, chr_mask_1k; @@ -34,6 +35,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES prg_regs_8k[2] = (byte)(0xFE & prg_mask_8k); prg_regs_8k[3] = (byte)(0xFF & prg_mask_8k); + return true; } @@ -60,7 +62,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (addr < 0xA000) { - SetMirrorType(((value >> 7) | value) == 0 ? EMirrorType.Vertical : EMirrorType.Horizontal); + if (((value >> 7) | value)==0) + { + SetMirrorType(EMirrorType.Vertical); + } + else + { + SetMirrorType(EMirrorType.Horizontal); + } } else if (addr < 0xC000) { @@ -101,8 +110,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = (bank_1k << 10) | (addr & 0x3FF); return Vrom[addr]; } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } public override byte ReadPrg(int addr) @@ -114,13 +122,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[((bank >> 1) << 15) + (addr & 0x7FFF)]; } - - return Rom[((bank) << 14) + (addr & 0x3FFF)]; + else + { + return Rom[((bank) << 14) + (addr & 0x3FFF)]; + } } - bank = mmc3.Get_PRGBank_8K(addr); - bank &= prg_mask_8k; - return Rom[(bank << 13) + (addr & 0x1FFF)]; + else + { + bank = mmc3.Get_PRGBank_8K(addr); + bank &= prg_mask_8k; + return Rom[(bank << 13) + (addr & 0x1FFF)]; + } + } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/RexSoftSL1632.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/RexSoftSL1632.cs index 31543f23ff..d086dd97cd 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/RexSoftSL1632.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/RexSoftSL1632.cs @@ -42,11 +42,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return base.ReadPrg(addr); } - - int b = addr >> 13; - b = exprg[b]; - b &= prg_mask; - return Rom[addr & 0x1fff | b << 13]; + else + { + int b = addr >> 13; + b = exprg[b]; + b &= prg_mask; + return Rom[addr & 0x1fff | b << 13]; + } } private void SinkMirror(bool flip) @@ -76,14 +78,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES bank &= chr_mask; return Vrom[addr & 0x3ff | bank << 10]; } - - return base.ReadPpu(addr); + else + { + return base.ReadPpu(addr); + } } // this is stupid as hell public override void WritePrg(int addr, byte value) { + //Console.WriteLine("{0:x4}:{1:x2}", addr, value); + if ((addr & 0x2131) == 0x2131 && (exmode != value)) { exmode = value; @@ -125,5 +131,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } } + + + } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TLSROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TLSROM.cs index 1a85c39fbf..d0cf57e941 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TLSROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TLSROM.cs @@ -97,16 +97,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override byte ReadPpu(int addr) { - if (addr < 0x2000) + if (addr < 0x2000) return base.ReadPpu(addr); + else { + int nt = ((addr - 0x2000) >> 10) & 0x3; + addr = 0x2000 + (addr & 0x3FF) + (nametables[nt] << 10); return base.ReadPpu(addr); - } - - int nt = ((addr - 0x2000) >> 10) & 0x3; - addr = 0x2000 + (addr & 0x3FF) + (nametables[nt] << 10); - return base.ReadPpu(addr); - } + } + } public override void WritePpu(int addr, byte value) { if (addr < 0x2000) base.WritePpu(addr, value); @@ -116,6 +115,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = 0x2000 + (addr & 0x3FF) + (nametables[nt] << 10); base.WritePpu(addr, value); } + } public override void SyncState(Serializer ser) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TQROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TQROM.cs index cc0007f5f9..ce3c5a09be 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TQROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TQROM.cs @@ -36,11 +36,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr &= 0x1FFF; return Vram[addr]; } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } - - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) @@ -55,9 +54,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr &= 0x1FFF; Vram[addr] = value; } + //else + // if this address is mapped to chrrom and not chrram, the write just does nothing + //base.WritePPU(addr, value); } else base.WritePpu(addr, value); } + } + + } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TVROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TVROM.cs index 9f708698be..ba957a5a77 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TVROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TVROM.cs @@ -29,9 +29,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } - // nesdev wiki says that the nes CIRAM doesnt get used at all. - // and that even though 8KB is really here, only 4KB gets used. - // still, purists could validate it. + //nesdev wiki says that the nes CIRAM doesnt get used at all. + //and that even though 8KB is really here, only 4KB gets used. + //still, purists could validate it. + public override byte ReadPpu(int addr) { if (addr < 0x2000) @@ -54,5 +55,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES Vram[addr & 0xFFF] = value; } } + } } \ No newline at end of file diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TxROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TxROM.cs index 9cd1e8a9ef..38ac62d03f 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TxROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TxROM.cs @@ -30,6 +30,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { case "MAPPER116_HACKY": break; + case "TXROM-HOMEBREW": // should this even exist? break; case "MAPPER004": @@ -67,6 +68,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES case "KONAMI-TLROM": //Super C case "HVC-TLROM": //8 eyes (J) case "ACCLAIM-TLROM": + AssertPrg(128, 256, 512); AssertChr(64, 128, 256); AssertVram(0); AssertWram(0); AssertBattery(false); break; @@ -105,11 +107,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES AssertPrg(128); AssertChr(128); AssertVram(0); AssertWram(0); AssertBattery(false); break; + + default: return false; } BaseSetup(); + return true; } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper028.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper028.cs index 2e57be36ab..e29b8a5343 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper028.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper028.cs @@ -166,7 +166,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x2000) return Vram[addr | chr << 13]; - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper029.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper029.cs index 2de30c3e3f..71bfdfd4ee 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper029.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper029.cs @@ -42,7 +42,8 @@ { if (addr < 0x2000) return Vram[addr | chr << 13]; - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper036.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper036.cs index 1c33eb96c5..03f3280b0b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper036.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper036.cs @@ -77,6 +77,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES R++; R &= 0x30; } + break; case 0x102: diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper038.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper038.cs index 4e85f817b0..59282777fe 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper038.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper038.cs @@ -40,11 +40,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Vrom[addr + (chr << 13)]; } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } - private void WriteReg(byte value) + private void writereg(byte value) { prg = value & 3 & prg_mask; chr = (value >> 2) & 3 & chr_mask; @@ -55,13 +54,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WritePrg(int addr, byte value) { //if ((addr & 0x7000) == 0x7000) - // WriteReg(value); + // writereg(value); } public override void WriteWram(int addr, byte value) { if ((addr & 0x1000) == 0x1000) - WriteReg(value); + writereg(value); } public override void SyncState(Serializer ser) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper043.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper043.cs index f2ad34e7b4..c4dd86cd25 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper043.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper043.cs @@ -78,8 +78,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[addr]; } - - return Rom[addr + 0x4000]; + else + { + return Rom[addr + 0x4000]; + } } public override byte ReadPrg(int addr) @@ -88,23 +90,25 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[addr + 0x2000]; } - - if (addr < 0x4000) + else if (addr < 0x4000) { return Rom[addr - 0x2000]; } - - if (addr < 0x6000) + else if (addr < 0x6000) { return Rom[(addr - 0x4000) + prg * 0x2000]; } - - if (swap) + else { - return Rom[(addr - 0x6000) + 8 * 0x2000]; + if (swap) + { + return Rom[(addr - 0x6000) + 8 * 0x2000]; + } + else + { + return Rom[(addr - 0x6000) + 9 * 0x2000]; + } } - - return Rom[(addr - 0x6000) + 9 * 0x2000]; } public override void ClockCpu() @@ -117,7 +121,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { irqenable = false; IrqSignal = true; - } + } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper045.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper045.cs index de60ebbfe3..2829c21cbd 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper045.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper045.cs @@ -92,7 +92,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (regs[2]==0) { return 0xFF; - } + } return (0xFF >> ~((regs[2] & 0x0F)|0xF0)); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper046.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper046.cs index 8035916dbf..d08c7c2a87 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper046.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper046.cs @@ -2,9 +2,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - // https://wiki.nesdev.com/w/index.php/INES_Mapper_046 internal sealed class Mapper046 : NesBoardBase { + //Rumblestation 15-in-1 (Unl).nes + + /* + Regs at $6000-7FFF means no PRG-RAM. + + $6000-7FFF: [CCCC PPPP] High CHR, PRG bits + $8000-FFFF: [.CCC ...P] Low CHR, PRG bits + + 'C' selects 8k CHR @ $0000 + 'P' select 32k PRG @ $8000 + */ + //configuration private int prg_bank_mask_32k, chr_bank_mask_8k; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper051.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper051.cs index 5e4fc8f315..3a1fc6c0ab 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper051.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper051.cs @@ -106,7 +106,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private void SyncMirroring() { - SetMirrorType(_mode == 0x12 ? EMirrorType.Horizontal : EMirrorType.Vertical); + if (_mode == 0x12) + { + SetMirrorType(EMirrorType.Horizontal); + } + else + { + SetMirrorType(EMirrorType.Vertical); + } } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper057.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper057.cs index 9a257dfcb6..3bcb874959 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper057.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper057.cs @@ -54,13 +54,22 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { prg_reg = (value >> 5) & 0x07; prg_mode = value.Bit(4); - chr_reg_low_1 = value & 0x07; + chr_reg_low_1 = (value & 0x07); - SetMirrorType(value.Bit(3) ? EMirrorType.Horizontal : EMirrorType.Vertical); + if (value.Bit(3)) + { + SetMirrorType(EMirrorType.Horizontal); + } + else + { + SetMirrorType(EMirrorType.Vertical); + } } chr_reg &= ~0x07; chr_reg |= (chr_reg_low_0 | chr_reg_low_1); + + //Console.WriteLine("chr page = {0}", chr_reg); } public override byte ReadPrg(int addr) @@ -69,8 +78,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[((prg_reg >> 1) * 0x8000) + addr]; } - - return Rom[(prg_reg * 0x4000) + (addr & 0x3FFF)]; + else + { + return Rom[(prg_reg * 0x4000) + (addr & 0x3FFF)]; + } } public override byte ReadPpu(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper058.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper058.cs index 0b531f0be9..8725b3bb64 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper058.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper058.cs @@ -38,7 +38,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WritePrg(int addr, byte value) { prg_mode = addr.Bit(6); - SetMirrorType(addr.Bit(7) ? EMirrorType.Horizontal : EMirrorType.Vertical); + if (addr.Bit(7)) + { + SetMirrorType(EMirrorType.Horizontal); + } + else + { + SetMirrorType(EMirrorType.Vertical); + } prg_reg = addr & 0x07; chr_reg = (addr >> 3) & 0x07; @@ -50,8 +57,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[((prg_reg >> 1) * 0x8000) + addr]; } - - return Rom[(prg_reg * 0x4000) + (addr & 0x3FFF)]; + else + { + return Rom[(prg_reg * 0x4000) + (addr & 0x3FFF)]; + } } public override byte ReadPpu(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper063.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper063.cs index 60ea26397f..e722f589cc 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper063.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper063.cs @@ -43,28 +43,32 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (open_bus) { - return NES.DB; + return this.NES.DB; } - - return Rom[addr + prg0 * 0x2000]; + else + { + return Rom[addr + prg0 * 0x2000]; + } } - - if (addr < 0x4000) + else if (addr < 0x4000) { if (open_bus) { - return NES.DB; + return this.NES.DB; + } + else + { + return Rom[(addr - 0x2000) + prg1 * 0x2000]; } - - return Rom[(addr - 0x2000) + prg1 * 0x2000]; } - - if (addr < 0x6000) + else if (addr < 0x6000) { return Rom[(addr - 0x4000) + prg2 * 0x2000]; } - - return Rom[(addr - 0x6000) + prg3 * 0x2000]; + else + { + return Rom[(addr - 0x6000) + prg3 * 0x2000]; + } } public override void SyncState(Serializer ser) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper069.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper069.cs index 009b28dcf2..ad45e98e6d 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper069.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper069.cs @@ -270,12 +270,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = CalcWRAMAddress(addr, prg_bank_mask_8k); return Rom[addr]; } - - if (!wram_ram_enabled) + else if (!wram_ram_enabled) return 0xFF; //empty bus - - addr = CalcWRAMAddress(addr, wram_bank_mask_8k); - return Wram[addr]; + else + { + addr = CalcWRAMAddress(addr, wram_bank_mask_8k); + return Wram[addr]; + } } public override void WriteWram(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper078.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper078.cs index 04c9eff5b2..a6cb9cce09 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper078.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper078.cs @@ -56,14 +56,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (value.Bit(3) == false) { - SetMirrorType(holydiver ? EMirrorType.Horizontal : EMirrorType.OneScreenA); + if (holydiver) + SetMirrorType(EMirrorType.Horizontal); + else + SetMirrorType(EMirrorType.OneScreenA); } else { - SetMirrorType(holydiver ? EMirrorType.Vertical : EMirrorType.OneScreenB); + if (holydiver) + SetMirrorType(EMirrorType.Vertical); + else + SetMirrorType(EMirrorType.OneScreenB); } - chr = value >> 4; + chr = (value >> 4); } public override byte ReadPrg(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper090.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper090.cs index 3202dfef67..b80ba9e7b0 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper090.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper090.cs @@ -396,7 +396,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } else { - goto case 0x4002; + goto case 0x4002; } case 0x4001: //IRQ control irq_count_down = value.Bit(7); @@ -457,10 +457,24 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES SetMirrorType(EMirrorType.Horizontal); break; case 2: - SetMirrorType(mapper_035 ? EMirrorType.OneScreenB : EMirrorType.OneScreenA); + if (mapper_035) + { + SetMirrorType(EMirrorType.OneScreenB); + } + else + { + SetMirrorType(EMirrorType.OneScreenA); + } break; case 3: - SetMirrorType(mapper_035 ? EMirrorType.OneScreenA : EMirrorType.OneScreenB); + if (mapper_035) + { + SetMirrorType(EMirrorType.OneScreenA); + } + else + { + SetMirrorType(EMirrorType.OneScreenB); + } break; } break; @@ -625,8 +639,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return Vrom[nt << 10 | offset]; } - - return base.PeekPPU(addr); + else + { + return base.PeekPPU(addr); + } } public override byte ReadPpu(int addr) @@ -674,8 +690,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return Vrom[nt << 10 | offset]; } - - return base.ReadPpu(addr); + else + { + return base.ReadPpu(addr); + } } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper103.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper103.cs index afb85332f5..a777d2da95 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper103.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper103.cs @@ -76,5 +76,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ser.Sync(nameof(romenable), ref romenable); ser.Sync(nameof(prg), ref prg); } + } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper107.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper107.cs index 337b384ffb..fa2427630a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper107.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper107.cs @@ -62,5 +62,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES chr_bank_8k &= chr_bank_mask_8k; prg_bank_32k &= prg_bank_mask_32k; } + } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper132.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper132.cs index 3baa2f4ac9..b07cbcac74 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper132.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper132.cs @@ -65,13 +65,24 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr <= 0x103 && addr >= 0x100) reg[addr & 0x03] = value; + //reg[addr&0x03] = (byte)(value & 0x0f); + } public override byte ReadExp(int addr) { - if (addr == 0x100) + + /*if ((addr & 0x100) != 0) + return (byte)((NES.DB & (is173 ? 0x01 : 0xf0)) | reg[2]); + else if ((addr & 0x1000) == 0) + return NES.DB; + else + return 0xff; + */ + if (addr==0x100) return (byte)((reg[1] ^ reg[2]) | (0x40 | (is173 ? 0x01 : 0x00))); - return NES.DB; + else + return NES.DB; } public override byte ReadPrg(int addr) @@ -81,8 +92,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[addr & 0x3FFF]; } - - return Rom[addr + ((prg & prg_mask) << 15)]; + else + { + return Rom[addr + ((prg & prg_mask) << 15)]; + } } public override byte ReadPpu(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper136.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper136.cs index 9101bad36e..cdcbb5c752 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper136.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper136.cs @@ -49,8 +49,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return (byte)((_chrRegister & 0x3F) | (NES.DB & 0xC0)); } - - return base.ReadExp(addr); + else + { + return base.ReadExp(addr); + } } public override byte ReadPpu(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper143.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper143.cs index 76f57ba2c2..1f2fbf6e08 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper143.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper143.cs @@ -26,8 +26,8 @@ { if ((addr & 0x100) != 0) return (byte)(NES.DB & 0xc0 | ~addr & 0x3f); - - return NES.DB; + else + return NES.DB; } /* if this awful hack is uncommented, dancing blocks runs diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper156.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper156.cs index 3b6f4515a8..3b1141ac41 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper156.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper156.cs @@ -96,8 +96,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES break; case 0x4014: // is this right?? - SetMirrorType((value & 1) != 0 ? EMirrorType.Vertical : EMirrorType.Horizontal); - break; + if ((value & 1) != 0) + SetMirrorType(EMirrorType.Vertical); + else + SetMirrorType(EMirrorType.Horizontal); + break; } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper170.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper170.cs index c89f52c99b..87e21ee818 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper170.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper170.cs @@ -43,6 +43,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES reg = (byte)(value << 1 & 0x80); } + base.WriteWram(addr, value); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper175.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper175.cs index 3d8a1abf43..9abd9a152b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper175.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper175.cs @@ -41,6 +41,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ser.Sync(nameof(prgRegC), ref prgRegC); ser.Sync(nameof(prgRegE), ref prgRegE); + base.SyncState(ser); } @@ -94,13 +95,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[(prgReg8 << 14) + (addr & 0x3FFF)]; } - - if (addr < 0x6000) + else if (addr < 0x6000) { return Rom[(prgRegC << 13) + (addr & 0x1FFF)]; } - - return Rom[(prgRegE << 13) + (addr & 0x1FFF)]; + else + { + return Rom[(prgRegE << 13) + (addr & 0x1FFF)]; + } } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper190.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper190.cs index f835918785..2f35671312 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper190.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper190.cs @@ -40,8 +40,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[(prg_reg * 0x4000) + addr]; } - - return Rom[addr - 0x4000]; + else + { + return Rom[addr - 0x4000]; + } } public override byte ReadPpu(int addr) @@ -54,8 +56,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = (bank << 11) | ofs; return Vrom[addr]; } - - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override void WritePrg(int addr, byte value) @@ -68,5 +70,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES case 0x4000: prg_reg = 8 | (value & 0x7); break; } } + + } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper200.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper200.cs index 5d574b5ca1..a596eab978 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper200.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper200.cs @@ -36,7 +36,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WritePrg(int addr, byte value) { - SetMirrorType(addr.Bit(3) ? EMirrorType.Horizontal : EMirrorType.Vertical); + if (addr.Bit(3)) + { + SetMirrorType(EMirrorType.Horizontal); + } + else + { + SetMirrorType(EMirrorType.Vertical); + } int reg = addr & 0x07; prg_reg_16k = reg & prg_bank_mask_16k; chr_reg_8k = reg & chr_bank_mask_8k; @@ -48,8 +55,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[(prg_reg_16k * 0x4000) + addr]; } - - return Rom[(prg_reg_16k * 0x4000) + addr - 0x4000]; + else + { + return Rom[(prg_reg_16k * 0x4000) + addr - 0x4000]; + } } public override byte ReadPpu(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper220.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper220.cs index 5743411212..f83ad51d2e 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper220.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper220.cs @@ -79,13 +79,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int bank = reg[i] & prg_mask_2k; return Rom[(bank << 11) + (addr & 0x7FF)]; } - - if (addr < 0x4000) + else if (addr < 0x4000) { return Rom[0x1A000 /* bank 0xd*/ + (addr & 0x1FFF)]; } - - return Rom[0x1C000 /* bank 7*/ + (addr & 0x3FFF)]; + else + { + return Rom[0x1C000 /* bank 7*/ + (addr & 0x3FFF)]; + } } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper225.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper225.cs index 49b4908046..bcdcc613e7 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper225.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper225.cs @@ -17,7 +17,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES switch (Cart.BoardType) { case "MAPPER225": - case "MAPPER255": // Duplicate of 225 according to: http://problemkaputt.de/everynes.htm + case "MAPPER255": // Duplicate of 225 accoring to: http://problemkaputt.de/everynes.htm break; default: return false; @@ -44,7 +44,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { addr += 0x8000; prg_mode = addr.Bit(12); - SetMirrorType(addr.Bit(13) ? EMirrorType.Horizontal : EMirrorType.Vertical); + if (addr.Bit(13)) + { + SetMirrorType(EMirrorType.Horizontal); + } + else + { + SetMirrorType(EMirrorType.Vertical); + } int high = (addr & 0x4000) >> 8; prg_reg = (addr >> 6) & 0x3F | high; @@ -58,8 +65,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int bank = (prg_reg >> 1) & prg_bank_mask_32k; return Rom[(bank * 0x8000) + addr]; } - - return Rom[((prg_reg & prg_bank_mask_16k) * 0x4000) + (addr & 0x3FFF)]; + else + { + return Rom[((prg_reg & prg_bank_mask_16k) * 0x4000) + (addr & 0x3FFF)]; + } } public override byte ReadPpu(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper226.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper226.cs index 3922921678..19f8c8bd20 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper226.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper226.cs @@ -64,7 +64,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES prg_page |= ((value & 0x1F) + ((value & 0x80) >> 2)); prg_mode = value.Bit(5); - SetMirrorType(value.Bit(6) ? EMirrorType.Vertical : EMirrorType.Horizontal); + if (value.Bit(6)) + { + SetMirrorType(EMirrorType.Vertical); + } + else + { + SetMirrorType(EMirrorType.Horizontal); + } } else if (addr == 1) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper227.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper227.cs index 473ec695b3..f167e84583 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper227.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper227.cs @@ -98,7 +98,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES _prgBanks16K[0] = (byte)(_prgBanks16K[0]&_prgBankMask16K); _prgBanks16K[1] = (byte)(_prgBanks16K[1]&_prgBankMask16K); - SetMirrorType(M_horz ? EMirrorType.Horizontal : EMirrorType.Vertical); + if (M_horz) SetMirrorType(EMirrorType.Horizontal); + else SetMirrorType(EMirrorType.Vertical); } public override void WritePpu(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper230.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper230.cs index dc5ff4f8ae..c87c00cee1 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper230.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper230.cs @@ -48,7 +48,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES prg_page = value & 0x1F; prg_mode = value.Bit(5); - SetMirrorType(value.Bit(6) ? EMirrorType.Vertical : EMirrorType.Horizontal); + if (value.Bit(6)) + { + SetMirrorType(EMirrorType.Vertical); + } + else + { + SetMirrorType(EMirrorType.Horizontal); + } } } @@ -60,17 +67,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[((prg_page & chip0_prg_bank_mask_16k) * 0x4000) + addr]; } - - return Rom[(7 * 0x4000) + (addr & 0x3FFF)]; + else + { + return Rom[(7 * 0x4000) + (addr & 0x3FFF)]; + } } - - if (prg_mode == false) + else { - return Rom[((prg_page >> 1) * 0x8000) + addr + chip1_offset]; + if (prg_mode == false) + { + return Rom[((prg_page >> 1) * 0x8000) + addr + chip1_offset]; + } + else + { + int page = prg_page + 8; + return Rom[(page * 0x4000) + (addr & 0x03FFF)]; + } } - - int page = prg_page + 8; - return Rom[(page * 0x4000) + (addr & 0x03FFF)]; } public override void NesSoftReset() diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper231.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper231.cs index 29a200eb3e..4993ee2388 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper231.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper231.cs @@ -31,7 +31,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WritePrg(int addr, byte value) { - SetMirrorType(addr.Bit(7) ? EMirrorType.Horizontal : EMirrorType.Vertical); + if (addr.Bit(7)) + { + SetMirrorType(EMirrorType.Horizontal); + } + else + { + SetMirrorType(EMirrorType.Vertical); + } int prg_reg_P = (addr >> 1) & 0xF; int prg_reg_L = (addr >> 5) & 1; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper235.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper235.cs index 62f0b5ea81..b298ecd3b4 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper235.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper235.cs @@ -73,7 +73,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { int type = ((_reg >> 13) & 1) ^ 1; - SetMirrorType(type == 0 ? EMirrorType.Horizontal : EMirrorType.Vertical); + if (type == 0) + { + SetMirrorType(EMirrorType.Horizontal); + } + else + { + SetMirrorType(EMirrorType.Vertical); + } } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper240.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper240.cs index 236f52e777..fa69a78a46 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper240.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper240.cs @@ -34,6 +34,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + public override void SyncState(Serializer ser) { base.SyncState(ser); @@ -64,5 +65,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES prg_bank_32k &= prg_bank_mask_32k; chr_bank_mask_8k &= chr_bank_mask_8k; } + } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper243.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper243.cs index 9e2a686bdd..5e75811306 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper243.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper243.cs @@ -133,17 +133,24 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return Vrom[((chr_bank & chr_bank_mask_8k) * 0x2000) + addr]; } - - return base.ReadPpu(addr); + else + { + return base.ReadPpu(addr); + } } - - if (addr < 0x2000) + else { - int chr_bank = (regs[4] << 2) | (regs[6]) | (regs[2] << 3); - return Vrom[((chr_bank & chr_bank_mask_8k) * 0x2000) + addr]; - } + if (addr < 0x2000) + { + int chr_bank = (regs[4] << 2) | (regs[6]) | (regs[2] << 3); - return base.ReadPpu(addr); + return Vrom[((chr_bank & chr_bank_mask_8k) * 0x2000) + addr]; + } + else + { + return base.ReadPpu(addr); + } + } } public override byte ReadPrg(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper244.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper244.cs index bb48d3b800..146f87e441 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper244.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper244.cs @@ -23,7 +23,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES new List { 0, 1, 2, 3, }, new List { 3, 2, 1, 0, }, new List { 0, 2, 1, 3, }, - new List { 3, 1, 2, 0, } + new List { 3, 1, 2, 0, }, }; private readonly List> chr_perm = new List> diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper252.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper252.cs index e7b160c704..845fc9ae34 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper252.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper252.cs @@ -122,6 +122,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES bank = _prgBankMask8K; } + return Rom[(bank << 13) + (addr & 0x1FFF)]; } @@ -137,9 +138,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES bank = creg[x] & 1; return Vram[(bank << 10) + (addr & 0x3FF)]; } + else + { + bank = (creg[x] & _chrBankMask1K) << 10; + return Vrom[bank + (addr & 0x3FF)]; + } - bank = (creg[x] & _chrBankMask1K) << 10; - return Vrom[bank + (addr & 0x3FF)]; } return base.ReadPpu(addr); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper253.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper253.cs index 31aeae3136..68d9af674f 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper253.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper253.cs @@ -123,6 +123,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES bank = _prgBankMask8K; } + return Rom[(bank << 13) + (addr & 0x1FFF)]; } @@ -140,8 +141,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES bank = chr & 1; return Vram[(bank << 10) + (addr & 0x3FF)]; } + else + { + return Vrom[bank + (addr & 0x3FF)]; + } - return Vrom[bank + (addr & 0x3FF)]; } return base.ReadPpu(addr); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper50.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper50.cs index 9ffd015b25..167bd74b97 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper50.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper50.cs @@ -3,9 +3,10 @@ using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES { - // http://wiki.nesdev.com/w/index.php/INES_Mapper_050 internal sealed class Mapper50 : NesBoardBase { + //http://wiki.nesdev.com/w/index.php/INES_Mapper_050 + private byte prg_bank; private int prg_bank_mask_8k; private bool irq_enable; @@ -62,19 +63,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[(0x08 * 0x2000) + (addr & 0x1FFF)]; } - - if (addr < 0x4000) + else if (addr < 0x4000) { return Rom[(0x09 * 0x2000) + (addr & 0x1FFF)]; } - - if (addr < 0x6000) + else if (addr < 0x6000) { int bank = (prg_bank & prg_bank_mask_8k); return Rom[(bank * 0x2000) + (addr & 0x1FFF)]; } - - return Rom[(0x0B * 0x2000) + (addr & 0x1FFF)]; + else + { + return Rom[(0x0B * 0x2000) + (addr & 0x1FFF)]; + } } public override byte ReadWram(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper60.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper60.cs index f0d4fbee02..66fb941156 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper60.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper60.cs @@ -47,7 +47,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WritePrg(int addr, byte value) { _reg = addr; + int mirr = ((_reg & 8) >> 3) ^ 1; + SetMirrorType(mirr > 0 ? EMirrorType.Vertical : EMirrorType.Horizontal); } @@ -74,6 +76,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x2000) { + return Vrom[((_reg & 7) * 0x2000) + (addr & 0x1FFF)]; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper61.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper61.cs index 2b136075d0..fd6a985da7 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper61.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper61.cs @@ -35,7 +35,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WritePrg(int addr, byte value) { - SetMirrorType(addr.Bit(7) ? EMirrorType.Horizontal : EMirrorType.Vertical); + if (addr.Bit(7)) + { + SetMirrorType(EMirrorType.Horizontal); + } + else + { + SetMirrorType(EMirrorType.Vertical); + } prg_mode = addr.Bit(4); prg_page = ((addr & 0x0F) << 1) | ((addr & 0x20) >> 5); @@ -47,8 +54,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[(((prg_page >> 1) * 0x8000) + addr) & prg_byte_mask]; } - - return Rom[((prg_page * 0x4000) + (addr & 0x03FFF)) & prg_byte_mask]; + else + { + return Rom[((prg_page * 0x4000) + (addr & 0x03FFF)) & prg_byte_mask]; + } } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper62.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper62.cs index ff316a9750..e5e5df2a0e 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper62.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper62.cs @@ -36,7 +36,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WritePrg(int addr, byte value) { prg_mode = addr.Bit(5); - SetMirrorType(addr.Bit(7) ? EMirrorType.Horizontal : EMirrorType.Vertical); + if (addr.Bit(7)) + { + SetMirrorType(EMirrorType.Horizontal); + } + else + { + SetMirrorType(EMirrorType.Vertical); + } prg_reg = (addr & 0x40) | ((addr >> 8) & 0x3F); chr_reg = ((addr & 0x1F) << 2) | (value & 0x03); @@ -48,8 +55,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[((prg_reg >> 1) * 0x8000) + addr]; } - - return Rom[(prg_reg * 0x4000) + (addr & 0x3FFF)]; + else + { + return Rom[(prg_reg * 0x4000) + (addr & 0x3FFF)]; + } } public override byte ReadPpu(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NES-EVENT.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NES-EVENT.cs index f3f0610c6d..f3a5fb2578 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NES-EVENT.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NES-EVENT.cs @@ -42,10 +42,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private List Switches => new List { - Dipswitch1, - Dipswitch2, - Dipswitch3, - Dipswitch4 + { Dipswitch1 }, + { Dipswitch2 }, + { Dipswitch3 }, + { Dipswitch4 } }; public int IrqDestination @@ -266,6 +266,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES scnt.Write(addr, value); } + public override byte ReadPrg(int addr) { int bank_16k = addr >> 14; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NROM.cs index a404a4aab9..5f5ec24ded 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NROM.cs @@ -6,6 +6,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //configuration private int prg_byte_mask; + //state + //(none) + public override bool Configure(EDetectionOrigin origin) { //configure. diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NSFBoard.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NSFBoard.cs index e3788b4a92..fb731b3876 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NSFBoard.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NSFBoard.cs @@ -169,51 +169,51 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x3800) return base.ReadReg2xxx(addr); - if (addr >= 0x3FF0) + else if (addr >= 0x3FF0) { switch (addr) { case 0x3FF0: - { - byte ret = 0; - if (InitPending) ret = 1; - InitPending = false; - return ret; - } + { + byte ret = 0; + if (InitPending) ret = 1; + InitPending = false; + return ret; + } case 0x3FF1: - { - //kevtris's reset process seems not to work. dunno what all is going on in there + { + //kevtris's reset process seems not to work. dunno what all is going on in there - //our own innovation, should work OK.. - NES.apu.NESSoftReset(); + //our own innovation, should work OK.. + NES.apu.NESSoftReset(); - //mostly fceux's guidance - NES.WriteMemory(0x4015, 0); - for (int i = 0; i < 14; i++) - NES.WriteMemory((ushort)(0x4000 + i), 0); - NES.WriteMemory(0x4015, 0x0F); + //mostly fceux's guidance + NES.WriteMemory(0x4015, 0); + for (int i = 0; i < 14; i++) + NES.WriteMemory((ushort)(0x4000 + i), 0); + NES.WriteMemory(0x4015, 0x0F); - //clearing APU misc stuff, maybe not needed with soft reset above - //NES.WriteMemory(0x4017, 0xC0); - //NES.WriteMemory(0x4017, 0xC0); - //NES.WriteMemory(0x4017, 0x40); + //clearing APU misc stuff, maybe not needed with soft reset above + //NES.WriteMemory(0x4017, 0xC0); + //NES.WriteMemory(0x4017, 0xC0); + //NES.WriteMemory(0x4017, 0x40); - //important to NSF standard for ram to be cleared, otherwise replayers are confused on account of not initializing memory themselves - var ram = NES.ram; - var wram = this.Wram; - int wram_size = wram.Length; - for (int i = 0; i < 0x800; i++) - ram[i] = 0; - for (int i = 0; i < wram_size; i++) - wram[i] = 0; + //important to NSF standard for ram to be cleared, otherwise replayers are confused on account of not initializing memory themselves + var ram = NES.ram; + var wram = this.Wram; + int wram_size = wram.Length; + for (int i = 0; i < 0x800; i++) + ram[i] = 0; + for (int i = 0; i < wram_size; i++) + wram[i] = 0; - //store specified initial bank state - if (BankSwitched) - for (int i = 0; i < 8; i++) - WriteExp(0x5FF8 + i - 0x4000, InitBankSwitches[i]); + //store specified initial bank state + if (BankSwitched) + for (int i = 0; i < 8; i++) + WriteExp(0x5FF8 + i - 0x4000, InitBankSwitches[i]); - return (byte)(CurrentSong - 1); - } + return (byte)(CurrentSong - 1); + } case 0x3FF2: return 0; //always return NTSC for now case 0x3FF3: @@ -226,9 +226,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return base.ReadReg2xxx(addr); } } - - if (addr - 0x3800 < NSFROM.Length) return NSFROM[addr - 0x3800]; - return base.ReadReg2xxx(addr); + else if (addr - 0x3800 < NSFROM.Length) return NSFROM[addr - 0x3800]; + else return base.ReadReg2xxx(addr); } private const ushort NMI_VECTOR = 0x3800; @@ -366,21 +365,25 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES else if (addr == 0x7FFD) { return (byte)((RESET_VECTOR >> 8) & 0xFF); } return NES.DB; } - - if (BankSwitched) + else { - int bank_4k = addr >> 12; - int ofs = addr & ((1 << 12) - 1); - bank_4k = prg_banks_4k[bank_4k]; - addr = (bank_4k << 12) | ofs; + if (BankSwitched) + { + int bank_4k = addr >> 12; + int ofs = addr & ((1 << 12) - 1); + bank_4k = prg_banks_4k[bank_4k]; + addr = (bank_4k << 12) | ofs; - //rom data began at 0x80 of the NSF file - addr += 0x80; + //rom data began at 0x80 of the NSF file + addr += 0x80; - return Rom[addr]; + return Rom[addr]; + } + else + { + return FakePRG[addr]; + } } - - return FakePRG[addr]; } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot129_163.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot129_163.cs index 7a8e74c03b..c1fab834e0 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot129_163.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot129_163.cs @@ -177,6 +177,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return Rom[addr]; } + public override void WritePpu(int addr, byte value) { int bank_1k = addr >> 10; @@ -210,9 +211,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES bank_1k &= 1; return NES.CIRAM[bank_1k << 10 | ofs]; } - - bank_1k &= chr_bank_mask_1k; - return Vrom[bank_1k << 10 | ofs]; + else + { + bank_1k &= chr_bank_mask_1k; + return Vrom[bank_1k << 10 | ofs]; + } } private void SyncIRQ() @@ -266,8 +269,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES else return audio.GetSaveRam(); } - - return null; + else + { + return null; + } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs index 8b0fcfff63..02646b1b3f 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs @@ -121,8 +121,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Vrom[addr & 0x3ff | chr[addr >> 10] << 10]; } - - return base.ReadPpu(addr); + else + { + return base.ReadPpu(addr); + } } public override byte ReadPrg(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/DRROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/DRROM.cs index 73623aa894..df3a57672c 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/DRROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/DRROM.cs @@ -22,31 +22,30 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } - // the addressing logic for nametables is a bit speculative here - // how it is wired back to the NES and locally mirrored is unknown, - // but it probably doesnt matter in practice. - // still, purists could validate it. + //the addressing logic for nametables is a bit speculative here + //how it is wired back to the NES and locally mirrored is unknown, + //but it probably doesnt matter in practice. + //still, purists could validate it. + public override byte ReadPpu(int addr) { if (addr < 0x2000) { - // read patterns from mapper controlled area + //read patterns from mapper controlled area return base.ReadPpu(addr); } - - if (addr < 0x2800) + else if (addr < 0x2800) { return Vram[addr - 0x2000]; } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) { if (addr < 0x2000) { - // nothing wired here + //nothing wired here } else if (addr < 0x2800) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper088.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper088.cs index 3c890da528..ea7e0a2f40 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper088.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper088.cs @@ -12,6 +12,7 @@ For example, mask the CHR ROM 1K bank output from the mapper by $3F, and then OR it with $40 if the PPU address was >= $1000. Consequently, CHR is split into two halves. $0xxx can only have CHR from the first 64K, $1xxx can only have CHR from the second 64K. */ + internal sealed class Mapper088 : Namcot108Board_Base { //configuration @@ -53,7 +54,7 @@ public override byte ReadPpu(int addr) { if (addr < 0x2000) return Vrom[RewireCHR(addr)]; - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper095.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper095.cs index 26ad7a93b5..dfe3f91da6 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper095.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper095.cs @@ -39,7 +39,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override byte ReadPpu(int addr) { if (addr < 0x2000) return base.ReadPpu(addr); - return base.ReadPpu(RewireNametable(addr, 5)); + else return base.ReadPpu(RewireNametable(addr, 5)); } public override void WritePpu(int addr, byte value) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper112.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper112.cs index 62e0aba72f..c3f4670047 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper112.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper112.cs @@ -49,6 +49,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WritePrg(int addr, byte value) { + switch (addr & 0x6001) { case 0x0000: //$8000 @@ -59,11 +60,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES Sync(); break; case 0x4000: + Console.WriteLine("{0:X4} = {1:X2}", addr, value); chr_outer_reg = value; Sync(); break; case 0x6000: - SetMirrorType((value & 1) == 0 ? EMirrorType.Vertical : EMirrorType.Horizontal); + if ((value & 1) == 0) + { + SetMirrorType(EMirrorType.Vertical); + } + else + { + SetMirrorType(EMirrorType.Horizontal); + } break; } } @@ -121,7 +130,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override byte ReadPpu(int addr) { if (addr < 0x2000) return Vrom[RewireCHR(addr)]; - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper154.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper154.cs index aaebb148ac..0a2d30cb6a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper154.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper154.cs @@ -43,9 +43,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override byte ReadPpu(int addr) { if (addr < 0x2000) return Vrom[RewireCHR(addr)]; - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } - public override void WritePpu(int addr, byte value) { if (addr < 0x2000) { } @@ -54,7 +53,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WritePrg(int addr, byte value) { - SetMirrorType(value.Bit(6) ? EMirrorType.OneScreenB : EMirrorType.OneScreenA); + if (value.Bit(6)) + { + SetMirrorType(EMirrorType.OneScreenB); + } + else + { + SetMirrorType(EMirrorType.OneScreenA); + } + base.WritePrg(addr, value); } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs index 3ebdb79f16..f741d5e5a1 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs @@ -210,46 +210,48 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { addr += 0x4000; if (addr == 0x54FF) - { return 0x05; - } - - if (addr == 0x5678) + else if (addr == 0x5678) { - return NES.cpu.X == 0x0C ? (byte)0 : (byte)1; + if (NES.cpu.X == 0x0C) + return 0; + else + return 1; } - if (addr == 0x578F) + else if (addr == 0x578F) { - return NES.cpu.X == 0x0C ? (byte)0xD1 : (byte)0x89; + if (NES.cpu.X == 0x0C) + return 0xD1; + else + return 0x89; } - - if (addr == 0x5567) + else if (addr == 0x5567) { - return NES.cpu.X == 0x0C ? (byte)0x3E : (byte)0x37; + if (NES.cpu.X == 0x0C) + return 0x3E; + else + return 0x37; } - return base.ReadExp(addr - 0x4000); + else + return base.ReadExp(addr - 0x4000); } - - if (Cart.VsSecurity==32) + else if (Cart.VsSecurity==32) { if (addr==0x1E00) { tko_security = 0; return 0xAA; //not used?? } - if (addr == 0x1E01) { tko_security++; return TKO[tko_security - 1]; } - return NES.DB; } - - if (Cart.VsSecurity == 48) + else if (Cart.VsSecurity == 48) { if (addr == 0x1E00) { @@ -271,8 +273,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } return NES.DB; } - - return NES.DB; + else + { + return NES.DB; + } } protected virtual void BaseSetup() @@ -287,5 +291,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (!NES._isVS) SetMirrorType(EMirrorType.Vertical); } + } } \ No newline at end of file diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NanJing.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NanJing.cs index ebfe61bc33..a76db41c51 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NanJing.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NanJing.cs @@ -27,6 +27,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private bool trigger = false; private bool strobe = true; + public override bool Configure(EDetectionOrigin origin) { switch (Cart.BoardType) @@ -47,6 +48,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[(prg << 15) | addr]; } + + /* + public override void WritePRG(int addr, byte value) + { + }*/ public override byte ReadExp(int addr) { @@ -65,8 +71,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return 4; } } - - return 0; + else + return 0; } public override void WriteExp(int addr, byte value) @@ -101,6 +107,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } + /* + public override byte ReadWRAM(int addr) + { + return base.ReadWRAM(addr); + } + + public override void WriteWRAM(int addr, byte value) + { + base.WriteWRAM(addr, value); + }*/ + public override byte ReadPpu(int addr) { if (addr < 0x2000) @@ -112,11 +129,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES else return Vram[(addr & 0xfff) + 0x1000]; } - - return Vram[addr]; + else + return Vram[addr]; } - - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NesBoardBase.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NesBoardBase.cs index e8acf76110..b432621f7f 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NesBoardBase.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NesBoardBase.cs @@ -39,9 +39,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public bool SyncStateFlag; public virtual NES.CDLog_MapResults MapMemory(ushort addr, bool write) - { - var ret = new NES.CDLog_MapResults { Type = NES.CDLog_AddrType.None }; - + { + NES.CDLog_MapResults ret = new NES.CDLog_MapResults(); + ret.Type = NES.CDLog_AddrType.None; + if (addr < 0x2000) { ret.Type = NES.CDLog_AddrType.MainRAM; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/PxROM_FxROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/PxROM_FxROM.cs index ffaaab05fc..2db19a8527 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/PxROM_FxROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/PxROM_FxROM.cs @@ -57,6 +57,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return false; } + prg_bank_mask_8k = Cart.PrgSize / 8 - 1; chr_bank_mask_4k = Cart.ChrSize / 4 - 1; @@ -122,8 +123,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = (bank_4k << 12) | ofs; return Vrom[addr]; } - - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override byte ReadPpu(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SEEPROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SEEPROM.cs index efd75ead0d..90c412b6be 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SEEPROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SEEPROM.cs @@ -28,6 +28,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES /// true if the SEEPROM is trying to pull down the SDA line private bool PullDown = false; + /// number of bits left to send\recv of current byte private int BitsLeft; /// current data byte in progress @@ -185,6 +186,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES PullDown = false; } + public void WriteByte(byte val) { OutEnable = val.Bit(7); @@ -231,7 +233,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return !PullDown; } - public byte[] GetSaveRAM() => rom; + public byte[] GetSaveRAM() { return rom; } /// 256 byte instead of 128 byte public SEEPROM(bool Big) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sachen8259.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sachen8259.cs index 92a51eb0f6..e034a97cfa 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sachen8259.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sachen8259.cs @@ -145,8 +145,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES bank &= chr_bank_mask_2k; return Vrom[addr & 0x7ff | bank << 11]; } - - return base.ReadPpu(addr); + else + { + return base.ReadPpu(addr); + } } public override void SyncState(Serializer ser) @@ -159,6 +161,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } + + + + // similar in some ways to 8259ABC, but different // fceumm combines the code to implement them; i think that's too messy @@ -286,8 +292,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int bank = chr[addr >> 10] & chr_bank_mask_1k; return Vrom[addr & 0x3ff | bank << 10]; } - - return base.ReadPpu(addr); + else + { + return base.ReadPpu(addr); + } } public override void SyncState(Serializer ser) @@ -297,5 +305,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ser.Sync(nameof(prg), ref prg); ser.Sync(nameof(chr), ref chr, false); } + } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SachenSimple.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SachenSimple.cs index e3a9ed5962..ff2d18b318 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SachenSimple.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SachenSimple.cs @@ -103,7 +103,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x2000) return Vrom[addr + (chr << 13)]; - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override void SyncState(Serializer ser) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Subor.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Subor.cs index 844311f3c9..523cb8c670 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Subor.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Subor.cs @@ -50,39 +50,55 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[((basea + bank + 1) * 0x4000) + (addr & 0x3FFF)]; } - - return Rom[((basea + bank + 0) * 0x4000) + (addr & 0x3FFF)]; + else + { + return Rom[((basea + bank + 0) * 0x4000) + (addr & 0x3FFF)]; + } } - - if (addr < 0x4000) + else { - return Rom[((basea + bank + 0) * 0x4000) + (addr & 0x3FFF)]; + if (addr < 0x4000) + { + return Rom[((basea + bank + 0) * 0x4000) + (addr & 0x3FFF)]; + } + else + { + return Rom[((basea + bank + 1) * 0x4000) + (addr & 0x3FFF)]; + } } - - return Rom[((basea + bank + 1) * 0x4000) + (addr & 0x3FFF)]; } - - if ((regs[1] & 0x04) > 0) + else { - if (addr < 0x4000) + if ((regs[1] & 0x04) > 0) { - return Rom[(0x1F * 0x4000) + (addr & 0x3FFF)]; + if (addr < 0x4000) + { + return Rom[(0x1F * 0x4000) + (addr & 0x3FFF)]; + } + else + { + return Rom[((basea + bank) * 0x4000) + (addr & 0x3FFF)]; + } + } + else + { + if (addr < 0x4000) + { + return Rom[((basea + bank) * 0x4000) + (addr & 0x3FFF)]; + } + else + { + if (is167) + { + return Rom[(0x20 * 0x4000) + (addr & 0x3FFF)]; + } + else + { + return Rom[(0x07 * 0x4000) + (addr & 0x3FFF)]; + } + } } - - return Rom[((basea + bank) * 0x4000) + (addr & 0x3FFF)]; } - - if (addr < 0x4000) - { - return Rom[((basea + bank) * 0x4000) + (addr & 0x3FFF)]; - } - - if (is167) - { - return Rom[(0x20 * 0x4000) + (addr & 0x3FFF)]; - } - - return Rom[(0x07 * 0x4000) + (addr & 0x3FFF)]; } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1.cs index 117b5cfc99..e5ede7606d 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1.cs @@ -18,6 +18,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { case "MAPPER184": break; + case "SUNSOFT-1": //this will catch fantasy zone, which isn't emulated the same as the other SUNSOFT-1 boards if (Cart.Pcb == "SUNSOFT-4") @@ -31,14 +32,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } + + public override byte ReadPpu(int addr) { + if (addr < 0x1000) { return Vrom[(addr & 0xFFF) + (left_piece * 0x1000)]; } - - if (addr < 0x2000) + else if (addr < 0x2000) { return Vrom[(addr & 0xFFF) + (right_piece * 0x1000)]; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1_Alt.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1_Alt.cs index fd17dde30d..9094750f55 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1_Alt.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1_Alt.cs @@ -43,5 +43,6 @@ base.SyncState(ser); ser.Sync(nameof(prg), ref prg); } + } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft2_m89.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft2_m89.cs index d6db1ceb50..fc03420811 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft2_m89.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft2_m89.cs @@ -51,7 +51,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES prg_bank_16k = (byte)((value >> 4) & 7); SyncPRG(); - SetMirrorType(value.Bit(3) == false ? EMirrorType.OneScreenA : EMirrorType.OneScreenB); + if (value.Bit(3) == false) + SetMirrorType(EMirrorType.OneScreenA); + else + SetMirrorType(EMirrorType.OneScreenB); chr = ((value & 0x07) + ((value >> 7) * 0x08)); } @@ -70,7 +73,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x2000) return Vrom[(addr & 0x1FFF) + (chr * 0x2000)]; - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft3.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft3.cs index 672279653e..2be163861f 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft3.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft3.cs @@ -23,6 +23,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //let's make the extra space here, instead of in the main NES to avoid confusion private byte[] CIRAM_VS = new byte[0x800]; + public override void SyncState(Serializer ser) { base.SyncState(ser); @@ -134,6 +135,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } + public override void ClockCpu() { if (!irq_enable) return; @@ -159,21 +161,25 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (addr < 0x2000) { addr = ApplyMemoryMap(11, chr_banks_2k, addr); - return ReadPPUChr(addr); + return base.ReadPPUChr(addr); } - - if (NES._isVS) + else { - addr = addr - 0x2000; - if (addr < 0x800) + if (NES._isVS) { - return NES.CIRAM[addr]; + addr = addr - 0x2000; + if (addr < 0x800) + { + return NES.CIRAM[addr]; + } + else + { + return CIRAM_VS[addr - 0x800]; + } } - - return CIRAM_VS[addr - 0x800]; + else + return base.ReadPpu(addr); } - - return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft4.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft4.cs index f00d4cbfdf..c2bd7c0396 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft4.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft4.cs @@ -3,8 +3,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { //AKA mapper 068 (and TENGEN-800042) + //After Burner & After Burner 2 //Maharaja + internal sealed class Sunsoft4 : NesBoardBase { //configuration @@ -82,21 +84,22 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = (bank_2k << 11) | ofs; return Vrom[addr]; } - - //nametable may come from "NT-ROM" - //which means from extra CHR data starting at bank 0x80 - if (flag_r) + else { - addr = ApplyMirroring(addr); - int bank_1k = (addr >> 10) & 3; - int ofs = addr & ((1 << 10) - 1); - bank_1k = nt_regs[bank_1k] + 0x80; - bank_1k &= nt_bank_mask; - addr = (bank_1k << 10) | ofs; - return Vrom[addr]; + //nametable may come from "NT-ROM" + //which means from extra CHR data starting at bank 0x80 + if (flag_r) + { + addr = ApplyMirroring(addr); + int bank_1k = (addr >> 10) & 3; + int ofs = addr & ((1 << 10) - 1); + bank_1k = nt_regs[bank_1k] + 0x80; + bank_1k &= nt_bank_mask; + addr = (bank_1k << 10) | ofs; + return Vrom[addr]; + } + else return base.ReadPpu(addr); } - - return base.ReadPpu(addr); } public override void WritePrg(int addr, byte value) @@ -125,7 +128,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES case 0x6000: //$E000 flag_m = (value & 1) != 0; flag_r = ((value >> 4) & 1) != 0; - SetMirrorType(flag_m ? EMirrorType.Horizontal : EMirrorType.Vertical); + if (flag_m) SetMirrorType(EMirrorType.Horizontal); + else SetMirrorType(EMirrorType.Vertical); break; case 0x7000: //$F000 prg_regs_16k[0] = value; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs index d94e95c0b5..7f0d16c10a 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs @@ -26,6 +26,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // TODO -- different MMC1 revisions handle wram_disable differently; on some it doesn't work at all; on others, // it works, but with different initial states possible. we only emulate the first case + internal sealed class MMC1 { public MMC1_SerialController scnt = new MMC1_SerialController(); @@ -244,6 +245,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private const int pputimeout = 4; // i don't know if this is right, but anything lower will not boot Bill & Ted private bool disablemirror = false; // mapper 171: mmc1 without mirroring control + //the VS actually does have 2 KB of nametable address space //let's make the extra space here, instead of in the main NES to avoid confusion private byte[] CIRAM_VS = new byte[0x800]; @@ -280,11 +282,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (_is_snrom) { if (!mmc1.wram_disable && chr_wram_enable) - return base.ReadWram(addr); - return NES.DB; + return base.ReadWram(addr); + else + return NES.DB; } - - return base.ReadWram(addr); + else + { + return base.ReadWram(addr); + } } public override byte ReadPrg(int addr) @@ -316,23 +321,28 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = Gen_CHR_Address(addr); - return Cart.VramSize != 0 - ? Vram[addr & vram_mask] - : Vrom[addr]; + if (Cart.VramSize != 0) + return Vram[addr & vram_mask]; + else return Vrom[addr]; } - - if (NES._isVS) + else { - addr -= 0x2000; - if (addr < 0x800) + if (NES._isVS) { - return NES.CIRAM[addr]; + addr = addr - 0x2000; + if (addr < 0x800) + { + return NES.CIRAM[addr]; + } + else + { + return CIRAM_VS[addr - 0x800]; + } } - - return CIRAM_VS[addr - 0x800]; + else + return base.ReadPpu(addr); + } - - return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) @@ -362,7 +372,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (_is_snrom) { // WRAM enable is tied to ppu a12 - chr_wram_enable = !Gen_CHR_Address(addr).Bit(16); + if (Gen_CHR_Address(addr).Bit(16)) + chr_wram_enable = false; + else + chr_wram_enable = true; } if (Cart.VramSize != 0) @@ -502,6 +515,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } BaseConfigure(); + return true; } @@ -518,6 +532,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES chr_mask = (128 / 8 * 2) - 1; } + if (!disablemirror) SetMirrorType(mmc1.mirror); ppuclock = pputimeout; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TAITO_74_161_161_32.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TAITO_74_161_161_32.cs index 72451f663d..69ceee2e4e 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TAITO_74_161_161_32.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TAITO_74_161_161_32.cs @@ -51,7 +51,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES prg_bank_16k = (byte)((value >> 4) & 7); SyncPRG(); - SetMirrorType(value.Bit(7) ? EMirrorType.OneScreenB : EMirrorType.OneScreenA); + if (value.Bit(7)) + SetMirrorType(EMirrorType.OneScreenB); + else + SetMirrorType(EMirrorType.OneScreenA); } public override byte ReadPrg(int addr) @@ -68,7 +71,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x2000) return Vrom[(addr & 0x1FFF) + (chr * 0x2000)]; - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN-800032.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN-800032.cs index 54693d22e7..5f7f5adb4d 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN-800032.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN-800032.cs @@ -150,21 +150,27 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES chr_mode = value.Bit(7); Sync(); break; + case 0x0001: //data port regs[address] = value; Sync(); break; + case 0x2000: - SetMirrorType(value.Bit(0) ? EMirrorType.Horizontal : EMirrorType.Vertical); + if (value.Bit(0)) SetMirrorType(EMirrorType.Horizontal); + else SetMirrorType(EMirrorType.Vertical); break; + case 0x4000: irq_reload = value; break; + case 0x4001: irq_mode = value.Bit(0); if (irq_mode) irq_countdown = 4; irq_reload_pending = true; break; + case 0x6000: irq_enable = false; irq_pending = false; @@ -197,8 +203,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = (bank_1k << 10) | ofs; return Vrom[addr]; } - - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } private void SyncIRQ() @@ -266,7 +272,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void ClockCpu() { - if (irq_mode) + + if (irq_mode == true) { irq_countdown--; if (irq_countdown == 0) @@ -275,11 +282,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES irq_countdown = 4; } } - else if (clock_scanline_irq) + else { - clock_scanline_irq = false; - ClockIRQ(); + if (clock_scanline_irq) + { + clock_scanline_irq = false; + ClockIRQ(); + } } + } public override void ClockPpu() @@ -301,7 +312,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void AddressPpu(int addr) { int a12 = (addr >> 12) & 1; - bool rising_edge = a12 == 1 && a12_old == 0; + bool rising_edge = (a12 == 1 && a12_old == 0); if (rising_edge) { if (separator_counter > 0) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN_800008.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN_800008.cs index 9066200d19..1e0b28e0be 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN_800008.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN_800008.cs @@ -43,13 +43,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[addr | prg << 15]; } - public override byte ReadPpu(int addr) { if (addr < 0x2000) return Vrom[addr | chr << 13]; - - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override void SyncState(Serializer ser) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs index 446a002b07..a2e818b25b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs @@ -13,6 +13,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //Insector X //also mapper 048 (same as 33 but with an extra chip) + internal sealed class TAITO_TC0190FMC : NesBoardBase { //configuration @@ -56,13 +57,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (delay > 0) { + delay--; if(delay==0 && irq_pending) board.IrqSignal = true; + } } } + //state private byte[] prg_regs_8k = new byte[4]; private byte[] chr_regs_1k = new byte[8]; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_X1_005.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_X1_005.cs index 912af7a7d0..c0fb15f540 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_X1_005.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_X1_005.cs @@ -36,7 +36,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES * 8k prg @ cpu $e000 is fixed to last 8k of rom. * in TLSROM-like mode (mapper 207), mirroring reg is ignored, * and top bit of CHR regs (normally CHRROM A17) is used as CIRAM A10 + * */ + internal sealed class TAITO_X1_005 : NesBoardBase { // config @@ -106,7 +108,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { case 0x1E76: case 0x1E77: - SetMirrorType(value.Bit(0) ? EMirrorType.Vertical : EMirrorType.Horizontal); + if (value.Bit(0)) + SetMirrorType(EMirrorType.Vertical); + else + SetMirrorType(EMirrorType.Horizontal); break; case 0x1E70: @@ -155,7 +160,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr >= 0x1f00 && wramenable) return Wram[addr & 0x7f]; - return NES.DB; + else + return NES.DB; } public override byte ReadPrg(int addr) @@ -179,8 +185,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = (bank_1k << 10) | ofs; return Vrom[addr]; } - - if (tlsrewire) + else if (tlsrewire) { int bank_1k = addr >> 10; int ofs = addr & ((1 << 10) - 1); @@ -189,8 +194,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = (bank_1k << 10) | ofs; return NES.CIRAM[addr]; } - - return base.ReadPpu(addr); + else + { + return base.ReadPpu(addr); + } } public override void WritePpu(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-12-IN-1.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-12-IN-1.cs index 3b417d46ae..b23efb8e08 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-12-IN-1.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-12-IN-1.cs @@ -57,15 +57,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x2000) { - int baseBank = (ctrl & 3) << 3; - int bank; + int basebank = (ctrl & 3) << 3; + int bank = 0; if (addr < 0x1000) { - bank = regs[0] >> 3 | (baseBank << 2); + bank = regs[0] >> 3 | (basebank << 2); } else { - bank = regs[1] >> 3 | (baseBank << 2); + bank = regs[1] >> 3 | (basebank << 2); } return Vrom[(bank << 12) + (addr & 0xFFF)]; @@ -76,29 +76,30 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override byte ReadPrg(int addr) { - var baseBank = (ctrl & 3) << 3; - int bank; + var basebank = (ctrl & 3) << 3; + int bank = 0; + if (ctrl.Bit(3)) { if (addr < 0x4000) { - bank = baseBank | (regs[0] & 6) | 0; + bank = basebank | (regs[0] & 6) | 0; } else { - bank = baseBank | (regs[0] & 6) | 1; + bank = basebank | (regs[0] & 6) | 1; } } else { if (addr < 0x4000) { - bank = baseBank | (regs[0] & 7); + bank = basebank | (regs[0] & 7); } else { - bank = baseBank | 7; + bank = basebank | 7; } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-64in1-NR.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-64in1-NR.cs index f6fbeafcbb..feba7a5152 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-64in1-NR.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-64in1-NR.cs @@ -43,25 +43,30 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override byte ReadPrg(int addr) { - int bank; if ((regs[0] & 0x80) > 0) { if ((regs[1] & 0x80) > 0) { return Rom[((regs[1] & 0x1F) * 0x8000) + (addr & 0x7FFF)]; } - - bank = ((regs[1] & 0x1f) << 1) | ((regs[1] >> 6) & 1); - return Rom[(bank * 0x4000) + (addr & 0x3FFF)]; + else + { + int bank = ((regs[1] & 0x1f) << 1) | ((regs[1] >> 6) & 1); + return Rom[(bank * 0x4000) + (addr & 0x3FFF)]; + } } - - if (addr < 0x4000) + else { - return Rom[(addr & 0x3FFF)]; + if (addr < 0x4000) + { + return Rom[(addr & 0x3FFF)]; + } + else + { + int bank = ((regs[1] & 0x1f) << 1) | ((regs[1] >> 6) & 1); + return Rom[(bank * 0x4000) + (addr & 0x3FFF)]; + } } - - bank = ((regs[1] & 0x1f) << 1) | ((regs[1] >> 6) & 1); - return Rom[(bank * 0x4000) + (addr & 0x3FFF)]; } public override byte ReadPpu(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-8157.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-8157.cs index 86ecb03f49..54efd26b18 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-8157.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-8157.cs @@ -9,6 +9,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public bool _4in1Mode; private int _cmdreg; + private int _prgMask16k; public override bool Configure(EDetectionOrigin origin) @@ -22,6 +23,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } _prgMask16k = Cart.PrgSize / 16 - 1; + AutoMapperProps.Apply(this); return true; @@ -47,7 +49,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (((_cmdreg & 0x100) > 0) && Cart.PrgSize < 1024) { - addr = (addr & 0xFFF0) + 1; + addr = (addr & 0xFFF0) + (1); } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-A65AS.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-A65AS.cs index bde826b1f3..e3faf71399 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-A65AS.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-A65AS.cs @@ -62,18 +62,21 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES bank &= prgMask32k; return Rom[(bank * 0x8000) + (addr & 0x7FFF)]; } - - if (addr < 0x4000) - { - int bank = (_prgReg & 0x30) >> 1 | _prgReg & 7; - bank &= prgMask16k; - return Rom[(bank * 0x4000) + (addr & 0x3FFF)]; - } else { - int bank = (_prgReg & 0x30) >> 1 | 7; - bank &= prgMask16k; - return Rom[(bank * 0x4000) + (addr & 0x3FFF)]; + + if (addr < 0x4000) + { + int bank = (_prgReg & 0x30) >> 1 | _prgReg & 7; + bank &= prgMask16k; + return Rom[(bank * 0x4000) + (addr & 0x3FFF)]; + } + else + { + int bank = (_prgReg & 0x30) >> 1 | 7; + bank &= prgMask16k; + return Rom[(bank * 0x4000) + (addr & 0x3FFF)]; + } } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-BS-5.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-BS-5.cs index d2159057df..abf2de9e3e 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-BS-5.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-BS-5.cs @@ -83,13 +83,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[((reg_prg[0] & _prgMask8k) * 0x2000) + (addr & 0x1FFF)]; } - - if (addr < 0x4000) + else if (addr < 0x4000) { return Rom[((reg_prg[1] & _prgMask8k) * 0x2000) + (addr & 0x1FFF)]; } - - if (addr < 0x6000) + else if (addr < 0x6000) { return Rom[((reg_prg[2] & _prgMask8k) * 0x2000) + (addr & 0x1FFF)]; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-D1038.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-D1038.cs index 4b727cd48b..d31239852f 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-D1038.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-D1038.cs @@ -43,6 +43,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WritePrg(int addr, byte value) { _reg = addr; + SetMirrorType(_reg.Bit(3) ? EMirrorType.Horizontal : EMirrorType.Vertical); } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-GS-2004.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-GS-2004.cs index 87cec979df..561dabed23 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-GS-2004.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-GS-2004.cs @@ -25,6 +25,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // Last 8k of Prg goes into 6000-7FFF _wramOffset = ((Cart.PrgSize - 8) / 32) * 0x8000; + SetMirrorType(EMirrorType.Vertical); return true; @@ -40,6 +41,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { base.SyncState(ser); ser.Sync("reg", ref _reg); + } public override void WritePrg(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-Ghostbusters63in1.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-Ghostbusters63in1.cs index aa6e771876..d5b3ab3f71 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-Ghostbusters63in1.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-Ghostbusters63in1.cs @@ -1,5 +1,6 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; +using System; namespace BizHawk.Emulation.Cores.Nintendo.NES { @@ -11,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private int bank; [MapperProp] - public bool Ghostbusters63in1_63set = true; + public bool Ghostbusters63in1_63set=true; [MapperProp] public int Ghostbusters63in1_chip_22_select; @@ -42,28 +43,41 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WritePrg(int addr, byte value) { reg[addr & 1] = value; + bank = ((reg[0] & 0x80) >> 7) | ((reg[1] & 1) << 1); + SetMirrorType(reg[0].Bit(6) ? EMirrorType.Vertical : EMirrorType.Horizontal); + Console.WriteLine(reg[0]); + Console.WriteLine(reg[1]); } public override byte ReadPrg(int addr) { + //if (bank == 1) + //{ + // return NES.DB; + //} + if (reg[0].Bit(5)) { - var offset = Ghostbusters63in1_63set - ? banks[bank] - : banks[Ghostbusters63in1_chip_22_select]; + var offset=0; + if (Ghostbusters63in1_63set) + offset = banks[bank]; + else + offset = banks[Ghostbusters63in1_chip_22_select]; - int b = reg[0] & 0x1F; + int b = (reg[0] & 0x1F); return Rom[offset + (b << 14) + (addr & 0x3FFF)]; } else { - var offset = Ghostbusters63in1_63set - ? banks[bank] - : banks[Ghostbusters63in1_chip_22_select]; + var offset = 0; + if (Ghostbusters63in1_63set) + offset = banks[bank]; + else + offset = banks[Ghostbusters63in1_chip_22_select]; - int b = (reg[0] >> 1) & 0x0F; + int b = ((reg[0] >> 1) & 0x0F); return Rom[offset + (b << 15) + addr]; } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-NTD-03.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-NTD-03.cs index 7766defe80..eb4d9ed4b7 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-NTD-03.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-NTD-03.cs @@ -17,6 +17,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return false; } + return true; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-WS.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-WS.cs index 88a47bcae1..da2ed4569b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-WS.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-WS.cs @@ -45,7 +45,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES break; } - SetMirrorType((_reg0 & 0x10) > 0 ? EMirrorType.Horizontal : EMirrorType.Vertical); + if ((_reg0 & 0x10) > 0) + { + SetMirrorType(EMirrorType.Horizontal); + } + else + { + SetMirrorType(EMirrorType.Vertical); + } } public override byte ReadPrg(int addr) @@ -54,8 +61,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[((_reg0 & 0x07) * 0x4000) + (addr & 0x3FFF)]; } + else + { + return Rom[(((_reg0 & 0x6) >> 1) * 0x8000) + (addr & 0x7FFF)]; + } - return Rom[(((_reg0 & 0x6) >> 1) * 0x8000) + (addr & 0x7FFF)]; } public override byte ReadPpu(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs index dfda9c1064..ba4bfe53dc 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs @@ -247,8 +247,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return Vrom[addr]; } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } public override byte ReadPrg(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC_Super24in1SC03.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC_Super24in1SC03.cs index 439cbd12bd..038763d1d7 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC_Super24in1SC03.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC_Super24in1SC03.cs @@ -67,12 +67,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Vram[(bank_1k << 10) + (addr & 0x3FF)]; } - - bank_1k = bank_1k | (exRegs[2] << 3); - return Vrom[(bank_1k << 10) + (addr & 0x3FF)]; + else + { + bank_1k = bank_1k | (exRegs[2] << 3); + return Vrom[(bank_1k << 10) + (addr & 0x3FF)]; + } } - - return base.ReadPpu(addr); + else + return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-AX5705.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-AX5705.cs index 79c607d6d8..5ca6e5f6a0 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-AX5705.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-AX5705.cs @@ -88,18 +88,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[(prg_reg[0] * 0x2000) + (addr & 0x1FFF)]; } - - if (addr < 0xC000) + else if (addr < 0xC000) { return Rom[(prg_reg[1] * 0x2000) + (addr & 0x1FFF)]; } - - if (addr < 0xE000) + else if (addr < 0xE000) { return Rom[((0xFE & _prgMask8k) * 0x2000) + (addr & 0x1FFF)]; } - - return Rom[((0xFF & _prgMask8k) * 0x2000) + (addr & 0x1FFF)]; + else + { + return Rom[((0xFF & _prgMask8k) * 0x2000) + (addr & 0x1FFF)]; + } } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-CC-21.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-CC-21.cs index cbe432a9b9..b6d7cb4329 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-CC-21.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-CC-21.cs @@ -21,8 +21,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WritePrg(int addr, byte value) { - // FCEUX says: another one many-in-1 mapper, there is a lot of similar carts with little different wirings - _reg = addr == 0 ? value : addr; + if (addr == 0) // FCEUX says: another one many-in-1 mapper, there is a lot of similar carts with little different wirings + { + _reg = value; + } + else + { + _reg = addr; + } SetMirrorType(addr.Bit(0) ? EMirrorType.OneScreenB : EMirrorType.OneScreenA); } @@ -41,9 +47,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Vrom[((_reg & 1) * 0xFFF) + (addr & 0xFFF)]; } - - // Some bad, overdumped roms made by cah4e3 - return Vrom[((_reg & 1) * 0x2000) + (addr & 0x1FFF)]; + else // Some bad, overdumped roms made by cah4e3 + { + return Vrom[((_reg & 1) * 0x2000) + (addr & 0x1FFF)]; + } } return base.ReadPpu(addr); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-EDU2000.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-EDU2000.cs index 8741b2ef33..a2e408a527 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-EDU2000.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-EDU2000.cs @@ -4,6 +4,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES internal sealed class UNIF_UNL_EDU2000 : NesBoardBase { private int _reg; + private int _prgMask32; public override bool Configure(EDetectionOrigin origin) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-KS7012.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-KS7012.cs index d4d6e33370..3165f9a1f0 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-KS7012.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-KS7012.cs @@ -32,12 +32,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WritePrg(int addr, byte value) { addr += 0x8000; - reg = addr switch + switch (addr) { - 0xE0A0 => 0, - 0xEE36 => 1, - _ => reg - }; + case 0xE0A0: + reg = 0; break; + case 0xEE36: + reg = 1; break; + } } public override byte ReadPrg(int addr) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs index fe34e45226..ba43d4b394 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs @@ -23,6 +23,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES prg_bank_mask_8 = Cart.PrgSize / 8 - 1; + //SetMirrorType(Cart.pad_h, Cart.pad_v); SetMirrorType(EMirrorType.Vertical); return true; } @@ -42,12 +43,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return; } + addr += 0x8000; switch (addr & 0xE001) { case 0x8000: cmd = value & 7; break; case 0x8001: reg[cmd] = value; break; } + + } public override byte ReadWram(int addr) @@ -57,7 +61,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override byte ReadPrg(int addr) { - int bank; + int bank = 0; if (addr < 0x2000) { bank = reg[6]; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-SHERO.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-SHERO.cs index a8c4efd63e..7d909b8482 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-SHERO.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-SHERO.cs @@ -60,14 +60,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Vram[addr]; } + else + { + int bank_1k = Get_CHRBank_1K(addr); + addr = (bank_1k << 10) | (addr & 0x3FF); - int bank_1k = Get_CHRBank_1K(addr); - addr = (bank_1k << 10) | (addr & 0x3FF); + return Vrom[addr]; + } - return Vrom[addr]; } - - return Vram[addr]; + else + return Vram[addr]; } public override void WritePpu(int addr, byte value) @@ -85,7 +88,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } else - Vram[addr] = value; + Vram[addr] = value; } protected override int Get_CHRBank_1K(int addr) @@ -94,18 +97,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return base.Get_CHRBank_1K(addr) | ((reg & 8) << 5); } - - if (addr < 0x1000) + else if (addr < 0x1000) { return base.Get_CHRBank_1K(addr) | ((reg & 4) << 6); } - - if (addr < 0x1800) + else if (addr < 0x1800) { return base.Get_CHRBank_1K(addr) | ((reg & 1) << 8); } - - return base.Get_CHRBank_1K(addr) | ((reg & 2) << 7); + else + { + return base.Get_CHRBank_1K(addr) | ((reg & 2) << 7); + } } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-TF1201.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-TF1201.cs index 6dc998e645..10fe87bedf 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-TF1201.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-TF1201.cs @@ -82,10 +82,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void ClockPpu() { - if (NES.ppu.ppuphase != PPU.PPU_PHASE_VBL) + if ((NES.ppu.ppuphase != PPU.PPU_PHASE_VBL))// && IRQa) { IRQpre--; - if (IRQpre == 0) + if (IRQpre==0) { IRQCount++; IRQpre = 341; @@ -93,11 +93,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { IrqSignal = IRQa; } - if (IRQCount == 256) - { IRQCount = 0; - } } } } @@ -105,6 +102,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override byte ReadPrg(int addr) { int bank; + if (addr < 0x2000) { if ((swap & 3) > 0) @@ -136,6 +134,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES bank = prg_mask_8k; } + return Rom[(bank << 13) + (addr & 0x1FFF)]; } @@ -144,6 +143,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (addr < 0x2000) { int x = (addr >> 10) & 7; + return Vrom[(chr[x] << 10) + (addr & 0x3FF)]; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_DripGame.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_DripGame.cs index 165d2e5a9b..99105137d3 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_DripGame.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_DripGame.cs @@ -366,6 +366,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (Empty) { active = false; + //Console.WriteLine("Exhaust"); } else { @@ -376,7 +377,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } } - if (volumeChangePending) { volumeChangePending = false; diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_SMB2J.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_SMB2J.cs index ddff0b1de1..d29a792746 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_SMB2J.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_SMB2J.cs @@ -31,11 +31,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WriteExp(int addr, byte value) { addr += 0x4000; + switch (addr) { case 0x4022: - if (Rom.Length > 0x10000) { prg = (value & 0x01) << 2; } + if (Rom.Length > 0x10000) { prg = (value & 0x01) << 2; } break; + case 0x4122: irqenable = (value & 3) > 0; IrqSignal = false; @@ -50,8 +52,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Rom[(addr - 0x1000) + (prg_count - 3) * 0x1000]; } - - return base.ReadExp(addr); + else return base.ReadExp(addr); } public override byte ReadWram(int addr) @@ -74,7 +75,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { irqenable = false; IrqSignal = true; - } + } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UxROM.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UxROM.cs index d27940d773..5b7d0d23d6 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UxROM.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UxROM.cs @@ -4,6 +4,7 @@ using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES { //generally mapper2 + //Mega Man //Castlevania //Contra @@ -13,6 +14,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //TODO - look for a mirror=H UNROM--maybe there are none? this may be fixed to the board type. // why are there no bus conflicts in here??????? + [NesBoardImplPriority] internal sealed class UxROM : NesBoardBase { @@ -111,19 +113,23 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Vram[addr & vram_byte_mask]; } - - if (NES._isVS) + else { - addr -= 0x2000; - if (addr < 0x800) + if (NES._isVS) { - return NES.CIRAM[addr]; + addr = addr - 0x2000; + if (addr < 0x800) + { + return NES.CIRAM[addr]; + } + else + { + return CIRAM_VS[addr - 0x800]; + } } - - return CIRAM_VS[addr - 0x800]; + else + return base.ReadPpu(addr); } - - return base.ReadPpu(addr); } public override void WritePpu(int addr, byte value) @@ -137,7 +143,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // The game VS Castlevania apparently scans for more CIRAM then actually exists, so we have to mask out nonsensical values addr &= 0x2FFF; - addr -= 0x2000; + + addr = addr - 0x2000; if (addr < 0x800) { NES.CIRAM[addr] = value; @@ -159,7 +166,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (NES.IsVS) { ser.Sync("VS_CIRAM", ref CIRAM_VS, false); - } + } } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC1.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC1.cs index bbab163b97..fb390159eb 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC1.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC1.cs @@ -94,19 +94,24 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = (bank_4k << 12) | ofs; return Vrom[addr]; } - - if (NES._isVS) + else { - addr -= 0x2000; - if (addr < 0x800) + if (NES._isVS) { - return NES.CIRAM[addr]; - } - - return CIRAM_VS[addr - 0x800]; + addr = addr - 0x2000; + if (addr < 0x800) + { + return NES.CIRAM[addr]; + } + else + { + return CIRAM_VS[addr - 0x800]; + } + } + else + return base.ReadPpu(addr); } - - return base.ReadPpu(addr); + } public override void WritePpu(int addr, byte value) @@ -153,13 +158,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES case 0x4000: prg_banks_8k[2] = (value & 0xF) & prg_bank_mask_8k; break; case 0x1000: //[.... .BAM] Mirroring, CHR reg high bits - SetMirrorType(value.Bit(0) ? EMirrorType.Horizontal : EMirrorType.Vertical); + if(value.Bit(0)) + SetMirrorType(EMirrorType.Horizontal); + else + SetMirrorType(EMirrorType.Vertical); chr_regs_4k[0] &= 0x0F; chr_regs_4k[1] &= 0x0F; if (value.Bit(1)) chr_regs_4k[0] |= 0x10; if (value.Bit(2)) chr_regs_4k[1] |= 0x10; SyncCHR(); break; + case 0x6000: chr_regs_4k[0] = (chr_regs_4k[0] & 0xF0) | (value & 0x0F); SyncCHR(); @@ -168,7 +177,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES chr_regs_4k[1] = (chr_regs_4k[1] & 0xF0) | (value & 0x0F); SyncCHR(); break; + } } + + } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC2_4.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC2_4.cs index 6765ee5ae0..7ce93f8570 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC2_4.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC2_4.cs @@ -296,12 +296,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return Vrom[addr + extra_vrom]; } - - return base.ReadPpu(addr); + else return base.ReadPpu(addr); } public override void WritePrg(int addr, byte value) { + //Console.WriteLine("mapping {0:X4} = {1:X2}", addr + 0x8000, value); addr = remap(addr); int chr_value = value & 0xF; @@ -316,14 +316,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES prg_banks_8k[_prgMode?1:0] = (byte)((prg_banks_8k[0] & 0x20) | (value & 0x1F)); return; } - - if (addr >= 0x2000 && addr < 0x3000) + else if (addr >= 0x2000 && addr < 0x3000) { prg_banks_8k[1] = (byte)((prg_banks_8k[0] & 0x20) | (value & 0x1F)); return; } - - if (addr >= 0x3000 && addr < 0x7000) + else if (addr >= 0x3000 && addr < 0x7000) { value = (byte)(value << 2 & 0x20); @@ -506,9 +504,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (!latch6k_exists) return base.ReadWram(addr); - if (addr >= 0x1000) + else if (addr >= 0x1000) return NES.DB; - return (byte)(NES.DB & 0xfe | latch6k_value); + else + return (byte)(NES.DB & 0xfe | latch6k_value); } public override void WriteWram(int addr, byte value) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC3.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC3.cs index cd199c718f..0e03e9e12b 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC3.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC3.cs @@ -51,7 +51,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } prg_bank_mask_16k = Cart.PrgSize / 16 - 1; + SetMirrorType(EMirrorType.Vertical); + prg_banks_16k[1] = (byte)(0xFF & prg_bank_mask_16k); return true; @@ -70,7 +72,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int mask = 0xF << bit; irq_reload = (ushort)((irq_reload & ~mask) | (value << bit)); } - public override void WritePrg(int addr, byte value) { switch (addr) @@ -108,17 +109,22 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //acknowledge irq_pending = false; + SyncIRQ(); + break; + case 0x5000: irq_pending = false; irq_enabled = irq_autoen; SyncIRQ(); break; + case 0x7000: prg_banks_16k[0] = value & 0xF; prg_banks_16k[0] &= prg_bank_mask_16k; break; + } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC6.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC6.cs index 693c72fd82..969de22ec7 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC6.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC6.cs @@ -223,7 +223,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr >= 0x2000 && !NTROM) return NES.CIRAM[MapPPU(addr) & 0x7ff]; - return Vrom[MapPPU(addr) & chr_byte_mask]; + else + return Vrom[MapPPU(addr) & chr_byte_mask]; } public override void WritePpu(int addr, byte value) @@ -376,5 +377,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } } + } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC7.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC7.cs index 9fbf356e94..a95c9101b3 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC7.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC7.cs @@ -45,6 +45,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES IrqSignal = (irq_pending && irq_enabled); } + private static int RemapM117(int addr) { //addr &= 0x7007; // i don't know all of which bits are decoded, but this breaks stuff @@ -186,7 +187,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WritePrg(int addr, byte value) { + //Console.WriteLine(" mapping {0:X4} = {1:X2}", addr, value); addr = remap(addr); + //Console.WriteLine("- remapping {0:X4} = {1:X2}", addr, value); switch (addr) { case 0x0000: prg_banks_8k[0] = (byte)(value & prg_bank_mask_8k); break; @@ -300,6 +303,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (irq_mode) { ClockIRQ(); + //throw new InvalidOperationException("needed a test case for this; you found one!"); } else { diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VS_M99.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VS_M99.cs index 45a8159482..56dbb05c14 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VS_M99.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VS_M99.cs @@ -64,14 +64,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return Vrom[(addr & 0x1FFF) + ((NES.VS_chr_reg & chr_mask) << 13)]; } - - addr -= 0x2000; - if (addr<0x800) + else { - return NES.CIRAM[addr]; + addr = addr - 0x2000; + if (addr<0x800) + { + return NES.CIRAM[addr]; + } + else + { + return CIRAM_VS[addr-0x800]; + } + } - - return CIRAM_VS[addr-0x800]; } public override void WritePpu(int addr, byte value) @@ -83,7 +88,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } else { - addr -= 0x2000; + addr = addr - 0x2000; if (addr < 0x800) { NES.CIRAM[addr] = value; @@ -109,12 +114,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (addr<0x2000) { return Rom[(addr & 0x1FFF) + ((NES.VS_prg_reg*4) << 13)]; - } - + } else + return Rom[addr]; + } + else + { return Rom[addr]; } - - return Rom[addr]; + } } } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/inlnsf.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/inlnsf.cs index 457cfa9401..50fbae5cb4 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/inlnsf.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/inlnsf.cs @@ -4,6 +4,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { internal sealed class INLNSF : NesBoardBase { + // config private int prg_bank_mask_4k;