diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/MemoryMap.Sega.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/MemoryMap.Sega.cs index 9ea94543e0..91075b9b8a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/MemoryMap.Sega.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/MemoryMap.Sega.cs @@ -1,4 +1,6 @@ -namespace BizHawk.Emulation.Cores.Sega.MasterSystem +using System; + +namespace BizHawk.Emulation.Cores.Sega.MasterSystem { public partial class SMS { @@ -41,7 +43,7 @@ { case 0: ret = RomData[(RomBank2 * BankSize) + (address & BankSizeMask)]; break; case 1: if (SaveRAM != null) ret = SaveRAM[(address & BankSizeMask) % SaveRAM.Length]; break; - case 2: if (SaveRAM != null) ret = SaveRAM[(BankSize + (address & BankSizeMask)) & BankSizeMask]; break; + case 2: if (SaveRAM != null) ret = SaveRAM[(BankSize + (address & BankSizeMask)) % SaveRAM.Length]; break; default: ret = SystemRam[address & RamSizeMask]; break; @@ -105,7 +107,7 @@ switch (SaveRamBank) { case 1: SaveRAM[(address & BankSizeMask) % SaveRAM.Length] = value; return; - case 2: SaveRAM[(BankSize + (address & BankSizeMask)) & BankSizeMask] = value; return; + case 2: SaveRAM[(BankSize + (address & BankSizeMask)) % SaveRAM.Length] = value; return; } } else System.Console.WriteLine("Game attempt to use SRAM but SRAM not present"); @@ -119,6 +121,7 @@ SaveRamBank = (byte)((value & 4) == 0 ? 1 : 2); // SaveRAM selected else SaveRamBank = 0; // ROM bank selected + } else if (address == 0xFFFD) RomBank0 = (byte)(value % RomBanks); else if (address == 0xFFFE) RomBank1 = (byte)(value % RomBanks); diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.cs index 1df9eca772..34234f1591 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.cs @@ -280,15 +280,18 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem void WriteRegister(int reg, byte data) { Registers[reg] = data; + switch (reg) { case 0: // Mode Control Register 1 CheckVideoMode(); Cpu.Interrupt = (EnableLineInterrupts && HIntPending); + Cpu.Interrupt |= (EnableFrameInterrupts && VIntPending); break; case 1: // Mode Control Register 2 CheckVideoMode(); Cpu.Interrupt = (EnableFrameInterrupts && VIntPending); + Cpu.Interrupt |= (EnableLineInterrupts && HIntPending); break; case 2: // Name Table Base Address NameTableBase = CalcNameTableBase(); @@ -308,6 +311,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem SpritePatternGeneratorBase = (Registers[6] << 11) & 0x3800; break; } + } static readonly byte[] pow2 = { 1, 2, 4, 8, 16, 32, 64, 128 }; @@ -336,7 +340,10 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem } if (VIntPending && EnableFrameInterrupts) + { Cpu.Interrupt = true; + } + } void ProcessLineInterrupt() @@ -347,7 +354,9 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem { HIntPending = true; if (EnableLineInterrupts) + {; Cpu.Interrupt = true; + } lineIntLinesRemaining = Registers[0x0A]; } return;