Fixes SRAM selection and Interrupt control
This commit is contained in:
parent
16723b12db
commit
b2920834b1
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue