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
|
public partial class SMS
|
||||||
{
|
{
|
||||||
|
@ -41,7 +43,7 @@
|
||||||
{
|
{
|
||||||
case 0: ret = RomData[(RomBank2 * BankSize) + (address & BankSizeMask)]; break;
|
case 0: ret = RomData[(RomBank2 * BankSize) + (address & BankSizeMask)]; break;
|
||||||
case 1: if (SaveRAM != null) ret = SaveRAM[(address & BankSizeMask) % SaveRAM.Length]; 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:
|
default:
|
||||||
ret = SystemRam[address & RamSizeMask];
|
ret = SystemRam[address & RamSizeMask];
|
||||||
break;
|
break;
|
||||||
|
@ -105,7 +107,7 @@
|
||||||
switch (SaveRamBank)
|
switch (SaveRamBank)
|
||||||
{
|
{
|
||||||
case 1: SaveRAM[(address & BankSizeMask) % SaveRAM.Length] = value; return;
|
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");
|
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
|
SaveRamBank = (byte)((value & 4) == 0 ? 1 : 2); // SaveRAM selected
|
||||||
else
|
else
|
||||||
SaveRamBank = 0; // ROM bank selected
|
SaveRamBank = 0; // ROM bank selected
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (address == 0xFFFD) RomBank0 = (byte)(value % RomBanks);
|
else if (address == 0xFFFD) RomBank0 = (byte)(value % RomBanks);
|
||||||
else if (address == 0xFFFE) RomBank1 = (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)
|
void WriteRegister(int reg, byte data)
|
||||||
{
|
{
|
||||||
Registers[reg] = data;
|
Registers[reg] = data;
|
||||||
|
|
||||||
switch (reg)
|
switch (reg)
|
||||||
{
|
{
|
||||||
case 0: // Mode Control Register 1
|
case 0: // Mode Control Register 1
|
||||||
CheckVideoMode();
|
CheckVideoMode();
|
||||||
Cpu.Interrupt = (EnableLineInterrupts && HIntPending);
|
Cpu.Interrupt = (EnableLineInterrupts && HIntPending);
|
||||||
|
Cpu.Interrupt |= (EnableFrameInterrupts && VIntPending);
|
||||||
break;
|
break;
|
||||||
case 1: // Mode Control Register 2
|
case 1: // Mode Control Register 2
|
||||||
CheckVideoMode();
|
CheckVideoMode();
|
||||||
Cpu.Interrupt = (EnableFrameInterrupts && VIntPending);
|
Cpu.Interrupt = (EnableFrameInterrupts && VIntPending);
|
||||||
|
Cpu.Interrupt |= (EnableLineInterrupts && HIntPending);
|
||||||
break;
|
break;
|
||||||
case 2: // Name Table Base Address
|
case 2: // Name Table Base Address
|
||||||
NameTableBase = CalcNameTableBase();
|
NameTableBase = CalcNameTableBase();
|
||||||
|
@ -308,6 +311,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
||||||
SpritePatternGeneratorBase = (Registers[6] << 11) & 0x3800;
|
SpritePatternGeneratorBase = (Registers[6] << 11) & 0x3800;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static readonly byte[] pow2 = { 1, 2, 4, 8, 16, 32, 64, 128 };
|
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)
|
if (VIntPending && EnableFrameInterrupts)
|
||||||
|
{
|
||||||
Cpu.Interrupt = true;
|
Cpu.Interrupt = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessLineInterrupt()
|
void ProcessLineInterrupt()
|
||||||
|
@ -347,7 +354,9 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
|
||||||
{
|
{
|
||||||
HIntPending = true;
|
HIntPending = true;
|
||||||
if (EnableLineInterrupts)
|
if (EnableLineInterrupts)
|
||||||
|
{;
|
||||||
Cpu.Interrupt = true;
|
Cpu.Interrupt = true;
|
||||||
|
}
|
||||||
lineIntLinesRemaining = Registers[0x0A];
|
lineIntLinesRemaining = Registers[0x0A];
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue