Lua - Implement emu.getregister() and emu.getregisters(). Only implemented in NESHawk right now

This commit is contained in:
adelikat 2013-11-11 03:20:33 +00:00
parent b52ec7e647
commit fb78215590
25 changed files with 390 additions and 248 deletions

View File

@ -1,4 +1,5 @@
using System;
using System.Linq;
using LuaInterface;
using BizHawk.Emulation.Consoles.Nintendo;
@ -7,9 +8,10 @@ namespace BizHawk.Client.Common
{
public partial class EmulatorLuaLibrary : LuaLibraryBase
{
public EmulatorLuaLibrary(Action frameAdvanceCallback, Action yieldCallback)
public EmulatorLuaLibrary(Lua lua, Action frameAdvanceCallback, Action yieldCallback)
: base()
{
_lua = lua;
_frameAdvanceCallback = frameAdvanceCallback;
_yieldCallback = yieldCallback;
}
@ -24,6 +26,8 @@ namespace BizHawk.Client.Common
"displayvsync",
"frameadvance",
"framecount",
"getregister",
"getregisters",
"getsystemid",
"islagged",
"lagcount",
@ -35,6 +39,7 @@ namespace BizHawk.Client.Common
}
}
private Lua _lua;
private Action _frameAdvanceCallback;
private Action _yieldCallback;
@ -88,6 +93,21 @@ namespace BizHawk.Client.Common
return Global.Emulator.Frame;
}
public static int emu_getregister(string name)
{
return Global.Emulator.GetCpuFlagsAndRegisters().FirstOrDefault(x => x.Key == name).Value;
}
public LuaTable emu_getregisters()
{
LuaTable table = _lua.NewTable();
foreach (var kvp in Global.Emulator.GetCpuFlagsAndRegisters())
{
table[kvp.Key] = kvp.Value;
}
return table;
}
public static string emu_getsystemid()
{
return Global.Emulator.SystemId;

View File

@ -78,6 +78,7 @@ namespace BizHawk.Client.EmuHawk
new ConsoleLuaLibrary().LuaRegister(lua, Docs);
new EmulatorLuaLibrary(
_lua,
new Action(Frameadvance),
new Action(EmuYield)
).LuaRegister(lua, Docs);

View File

@ -74,6 +74,11 @@ namespace BizHawk.Emulation.Common
private readonly MemoryDomainList memoryDomains;
public MemoryDomainList MemoryDomains { get { return memoryDomains; } }
public void Dispose() { }
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
return new List<KeyValuePair<string, int>>();
}
}
public class NullSound : ISoundProvider

View File

@ -136,6 +136,14 @@ namespace BizHawk.Emulation.Common
/// Subdomains of another domain are also welcome.
/// The MainMemory identifier will be 0 if not set
MemoryDomainList MemoryDomains { get; }
//Debugging
/// <summary>
/// Returns a list of Cpu registers and their current state
/// </summary>
/// <returns></returns>
List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters();
}
public enum DisplayType { NTSC, PAL, DENDY }

View File

@ -118,17 +118,17 @@ namespace BizHawk.Emulation.CPUs.M6502
// ==== End State ====
/// <summary>Carry Flag</summary>
private bool FlagC
public bool FlagC
{
get { return (P & 0x01) != 0; }
set { P = (byte)((P & ~0x01) | (value ? 0x01 : 0x00)); }
private set { P = (byte)((P & ~0x01) | (value ? 0x01 : 0x00)); }
}
/// <summary>Zero Flag</summary>
private bool FlagZ
public bool FlagZ
{
get { return (P & 0x02) != 0; }
set { P = (byte)((P & ~0x02) | (value ? 0x02 : 0x00)); }
private set { P = (byte)((P & ~0x02) | (value ? 0x02 : 0x00)); }
}
/// <summary>Interrupt Disable Flag</summary>
@ -139,38 +139,38 @@ namespace BizHawk.Emulation.CPUs.M6502
}
/// <summary>Decimal Mode Flag</summary>
private bool FlagD
public bool FlagD
{
get { return (P & 0x08) != 0; }
set { P = (byte)((P & ~0x08) | (value ? 0x08 : 0x00)); }
private set { P = (byte)((P & ~0x08) | (value ? 0x08 : 0x00)); }
}
/// <summary>Break Flag</summary>
private bool FlagB
public bool FlagB
{
get { return (P & 0x10) != 0; }
set { P = (byte)((P & ~0x10) | (value ? 0x10 : 0x00)); }
private set { P = (byte)((P & ~0x10) | (value ? 0x10 : 0x00)); }
}
/// <summary>T... Flag</summary>
private bool FlagT
public bool FlagT
{
get { return (P & 0x20) != 0; }
set { P = (byte)((P & ~0x20) | (value ? 0x20 : 0x00)); }
private set { P = (byte)((P & ~0x20) | (value ? 0x20 : 0x00)); }
}
/// <summary>Overflow Flag</summary>
private bool FlagV
public bool FlagV
{
get { return (P & 0x40) != 0; }
set { P = (byte)((P & ~0x40) | (value ? 0x40 : 0x00)); }
private set { P = (byte)((P & ~0x40) | (value ? 0x40 : 0x00)); }
}
/// <summary>Negative Flag</summary>
private bool FlagN
public bool FlagN
{
get { return (P & 0x80) != 0; }
set { P = (byte)((P & ~0x80) | (value ? 0x80 : 0x00)); }
private set { P = (byte)((P & ~0x80) | (value ? 0x80 : 0x00)); }
}
public int TotalExecutedCycles;

View File

@ -1,5 +1,6 @@
using System.IO;
using System;
using System.Collections.Generic;
using System.IO;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Computers.Commodore64.Cartridge;
using BizHawk.Emulation.Computers.Commodore64.Disk;
@ -86,6 +87,11 @@ namespace BizHawk.Emulation.Computers.Commodore64
board.HardReset();
//disk.HardReset();
}
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
}
}
static public class C64Util

View File

@ -40,6 +40,12 @@ namespace BizHawk
Console.WriteLine("Game uses mapper " + game.GetOptionsDict()["m"]);
HardReset();
}
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
}
public void ResetCounters()
{
_frame = 0;

View File

@ -1,4 +1,6 @@
using EMU7800.Core;
using System;
using System.Collections.Generic;
using EMU7800.Core;
namespace BizHawk.Emulation
{
@ -13,5 +15,10 @@ namespace BizHawk.Emulation
MachineBase theMachine;
EMU7800.Win.GameProgram GameInfo;
public byte[] hsram = new byte[2048];
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
}
}
}

View File

@ -41,6 +41,11 @@ namespace BizHawk.Emulation.Consoles.Calculator
//-------
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
}
public byte ReadMemory(ushort addr)
{
byte ret;

View File

@ -80,6 +80,11 @@ namespace BizHawk.Emulation.Consoles.Coleco
LagCount++;
}
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
}
void LoadRom(byte[] rom, bool skipbios)
{
RomData = new byte[0x8000];

View File

@ -17,6 +17,11 @@ namespace BizHawk.Emulation.Consoles.Intellivision
STIC Stic;
PSG Psg;
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
}
public void Connect()
{
Cpu.SetIntRM(Stic.GetSr1());

View File

@ -10,6 +10,11 @@ namespace BizHawk.Emulation.Consoles.Nintendo.GBA
{
public class GBA : IEmulator, IVideoProvider, ISyncSoundProvider
{
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
}
public static readonly ControllerDefinition GBAController =
new ControllerDefinition
{

View File

@ -124,6 +124,11 @@ namespace BizHawk.Emulation.Consoles.GB
return CurrentButtons;
}
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
}
/// <summary>
/// true if the emulator is currently emulating CGB
/// </summary>

View File

@ -11,6 +11,11 @@ namespace BizHawk.Emulation.Consoles.GB
{
bool disposed = false;
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
}
Gameboy L;
Gameboy R;
// counter to ensure we do 35112 samples per frame

View File

@ -10,7 +10,12 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Consoles.Nintendo.N64
{
public class N64 : IEmulator, IVideoProvider
{
{
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
}
public string SystemId { get { return "N64"; } }
public string BoardName { get { return null; } }

View File

@ -881,6 +881,26 @@ namespace BizHawk.Emulation.Consoles.Nintendo
}
public bool BinarySaveStatesPreferred { get { return false; } }
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
return new List<KeyValuePair<string, int>>
{
new KeyValuePair<string, int>("A", cpu.A),
new KeyValuePair<string, int>("X", cpu.X),
new KeyValuePair<string, int>("Y", cpu.Y),
new KeyValuePair<string, int>("S", cpu.S),
new KeyValuePair<string, int>("Flag C", cpu.FlagC ? 1 : 0),
new KeyValuePair<string, int>("Flag Z", cpu.FlagZ ? 1 : 0),
new KeyValuePair<string, int>("Flag I", cpu.FlagI ? 1 : 0),
new KeyValuePair<string, int>("Flag D", cpu.FlagD ? 1 : 0),
new KeyValuePair<string, int>("Flag B", cpu.FlagB ? 1 : 0),
new KeyValuePair<string, int>("Flag V", cpu.FlagV ? 1 : 0),
new KeyValuePair<string, int>("Flag N", cpu.FlagN ? 1 : 0),
new KeyValuePair<string, int>("Flag T", cpu.FlagT ? 1 : 0)
};
}
}
}

View File

@ -78,6 +78,11 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
api.Dispose();
}
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
}
public class MyScanlineHookManager : ScanlineHookManager
{
public MyScanlineHookManager(LibsnesCore core)

View File

@ -6,211 +6,211 @@ using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.TurboGrafx
{
partial class PCEngine
{
bool ArcadeCard, ArcadeCardRewindHack;
int ShiftRegister;
byte ShiftAmount;
byte RotateAmount;
ArcadeCardPage[] ArcadePage = new ArcadeCardPage[4];
partial class PCEngine
{
bool ArcadeCard, ArcadeCardRewindHack;
int ShiftRegister;
byte ShiftAmount;
byte RotateAmount;
ArcadeCardPage[] ArcadePage = new ArcadeCardPage[4];
class ArcadeCardPage
{
public byte Control;
public int Base;
public ushort Offset;
public ushort IncrementValue;
class ArcadeCardPage
{
public byte Control;
public int Base;
public ushort Offset;
public ushort IncrementValue;
public void Increment()
{
if ((Control & 1) == 0)
return;
public void Increment()
{
if ((Control & 1) == 0)
return;
if ((Control & 0x10) != 0)
{
Base += IncrementValue;
Base &= 0xFFFFFF;
}
else
Offset += IncrementValue;
}
if ((Control & 0x10) != 0)
{
Base += IncrementValue;
Base &= 0xFFFFFF;
}
else
Offset += IncrementValue;
}
public int EffectiveAddress
{
get
{
int address = Base;
if ((Control & 2) != 0)
address += Offset;
if ((Control & 8) != 0)
address += 0xFF0000;
return address & 0x1FFFFF;
}
}
}
public int EffectiveAddress
{
get
{
int address = Base;
if ((Control & 2) != 0)
address += Offset;
if ((Control & 8) != 0)
address += 0xFF0000;
return address & 0x1FFFFF;
}
}
}
void WriteArcadeCard(int addr, byte value)
{
if (ArcadeCard == false) return;
var page = ArcadePage[(addr >> 4) & 3];
switch (addr & 0x0F)
{
case 0:
case 1:
ArcadeRam[page.EffectiveAddress] = value;
page.Increment();
break;
case 2:
page.Base &= ~0xFF;
page.Base |= value;
break;
case 3:
page.Base &= ~0xFF00;
page.Base |= (value << 8);
break;
case 4:
page.Base &= ~0xFF0000;
page.Base |= (value << 16);
break;
case 5:
page.Offset &= 0xFF00;
page.Offset |= value;
break;
case 6:
page.Offset &= 0x00FF;
page.Offset |= (ushort) (value << 8);
if ((page.Control & 0x60) == 0x40)
{
page.Base += page.Offset + (((page.Control & 0x08)==0) ? 0 : 0xFF00000);
page.Base &= 0xFFFFFF;
}
break;
case 7:
page.IncrementValue &= 0xFF00;
page.IncrementValue |= value;
break;
case 8:
page.IncrementValue &= 0x00FF;
page.IncrementValue |= (ushort)(value << 8);
break;
case 9:
page.Control = (byte) (value & 0x7F);
break;
case 10:
if ((page.Control & 0x60) == 0x60)
{
page.Base += page.Offset;
page.Base &= 0xFFFFFF;
if ((page.Control & 8) != 0)
{
page.Base += 0xFF0000;
page.Base &= 0xFFFFFF;
}
}
break;
}
}
void WriteArcadeCard(int addr, byte value)
{
if (ArcadeCard == false) return;
var page = ArcadePage[(addr >> 4) & 3];
switch (addr & 0x0F)
{
case 0:
case 1:
ArcadeRam[page.EffectiveAddress] = value;
page.Increment();
break;
case 2:
page.Base &= ~0xFF;
page.Base |= value;
break;
case 3:
page.Base &= ~0xFF00;
page.Base |= (value << 8);
break;
case 4:
page.Base &= ~0xFF0000;
page.Base |= (value << 16);
break;
case 5:
page.Offset &= 0xFF00;
page.Offset |= value;
break;
case 6:
page.Offset &= 0x00FF;
page.Offset |= (ushort)(value << 8);
if ((page.Control & 0x60) == 0x40)
{
page.Base += page.Offset + (((page.Control & 0x08) == 0) ? 0 : 0xFF00000);
page.Base &= 0xFFFFFF;
}
break;
case 7:
page.IncrementValue &= 0xFF00;
page.IncrementValue |= value;
break;
case 8:
page.IncrementValue &= 0x00FF;
page.IncrementValue |= (ushort)(value << 8);
break;
case 9:
page.Control = (byte)(value & 0x7F);
break;
case 10:
if ((page.Control & 0x60) == 0x60)
{
page.Base += page.Offset;
page.Base &= 0xFFFFFF;
if ((page.Control & 8) != 0)
{
page.Base += 0xFF0000;
page.Base &= 0xFFFFFF;
}
}
break;
}
}
byte ReadArcadeCard(int addr)
{
if (ArcadeCard == false) return 0xFF;
var page = ArcadePage[(addr >> 4) & 3];
switch (addr & 0x0F)
{
case 0:
case 1:
byte value = ArcadeRam[page.EffectiveAddress];
page.Increment();
return value;
case 2: return (byte) (page.Base >> 0);
case 3: return (byte) (page.Base >> 8);
case 4: return (byte) (page.Base >> 16);
case 5: return (byte) (page.Offset >> 0);
case 6: return (byte) (page.Offset >> 8);
case 7: return (byte) (page.IncrementValue >> 0);
case 8: return (byte) (page.IncrementValue >> 8);
case 9: return (byte) (page.Control >> 0);
case 10: return 0;
}
return 0xFF;
}
byte ReadArcadeCard(int addr)
{
if (ArcadeCard == false) return 0xFF;
var page = ArcadePage[(addr >> 4) & 3];
switch (addr & 0x0F)
{
case 0:
case 1:
byte value = ArcadeRam[page.EffectiveAddress];
page.Increment();
return value;
case 2: return (byte)(page.Base >> 0);
case 3: return (byte)(page.Base >> 8);
case 4: return (byte)(page.Base >> 16);
case 5: return (byte)(page.Offset >> 0);
case 6: return (byte)(page.Offset >> 8);
case 7: return (byte)(page.IncrementValue >> 0);
case 8: return (byte)(page.IncrementValue >> 8);
case 9: return (byte)(page.Control >> 0);
case 10: return 0;
}
return 0xFF;
}
void SaveArcadeCardBinary(BinaryWriter writer)
{
writer.Write(ShiftRegister);
writer.Write(ShiftAmount);
writer.Write(RotateAmount);
for (int i = 0; i < 4; i++)
{
writer.Write(ArcadePage[i].Control);
writer.Write(ArcadePage[i].Base);
writer.Write(ArcadePage[i].Offset);
writer.Write(ArcadePage[i].IncrementValue);
}
if (ArcadeCardRewindHack == false)
writer.Write(ArcadeRam);
}
void SaveArcadeCardBinary(BinaryWriter writer)
{
writer.Write(ShiftRegister);
writer.Write(ShiftAmount);
writer.Write(RotateAmount);
for (int i = 0; i < 4; i++)
{
writer.Write(ArcadePage[i].Control);
writer.Write(ArcadePage[i].Base);
writer.Write(ArcadePage[i].Offset);
writer.Write(ArcadePage[i].IncrementValue);
}
if (ArcadeCardRewindHack == false)
writer.Write(ArcadeRam);
}
void LoadArcadeCardBinary(BinaryReader reader)
{
ShiftRegister = reader.ReadInt32();
ShiftAmount = reader.ReadByte();
RotateAmount = reader.ReadByte();
for (int i = 0; i < 4; i++)
{
ArcadePage[i].Control = reader.ReadByte();
ArcadePage[i].Base = reader.ReadInt32();
ArcadePage[i].Offset = reader.ReadUInt16();
ArcadePage[i].IncrementValue = reader.ReadUInt16();
}
if (ArcadeCardRewindHack == false)
ArcadeRam = reader.ReadBytes(0x200000);
}
void LoadArcadeCardBinary(BinaryReader reader)
{
ShiftRegister = reader.ReadInt32();
ShiftAmount = reader.ReadByte();
RotateAmount = reader.ReadByte();
for (int i = 0; i < 4; i++)
{
ArcadePage[i].Control = reader.ReadByte();
ArcadePage[i].Base = reader.ReadInt32();
ArcadePage[i].Offset = reader.ReadUInt16();
ArcadePage[i].IncrementValue = reader.ReadUInt16();
}
if (ArcadeCardRewindHack == false)
ArcadeRam = reader.ReadBytes(0x200000);
}
void SaveArcadeCardText(TextWriter writer)
{
writer.WriteLine("[ArcadeCard]");
writer.WriteLine("ShiftRegister {0} ", ShiftRegister);
writer.WriteLine("RotateAmount {0} ", ShiftAmount);
writer.WriteLine("RotateAmount {0} ", RotateAmount);
for (int i = 0; i < 4; i++)
{
writer.WriteLine("Control {0} {1:X2}", i, ArcadePage[i].Control);
writer.WriteLine("Base {0} {1:X6}", i, ArcadePage[i].Base);
writer.WriteLine("Offset {0} {1:X4}", i, ArcadePage[i].Offset);
writer.WriteLine("Increment {0} {1:X4}", i, ArcadePage[i].IncrementValue);
}
writer.Write("RAM "); ArcadeRam.SaveAsHex(writer);
writer.WriteLine("[/ArcadeCard]");
writer.WriteLine();
}
void SaveArcadeCardText(TextWriter writer)
{
writer.WriteLine("[ArcadeCard]");
writer.WriteLine("ShiftRegister {0} ", ShiftRegister);
writer.WriteLine("RotateAmount {0} ", ShiftAmount);
writer.WriteLine("RotateAmount {0} ", RotateAmount);
for (int i = 0; i < 4; i++)
{
writer.WriteLine("Control {0} {1:X2}", i, ArcadePage[i].Control);
writer.WriteLine("Base {0} {1:X6}", i, ArcadePage[i].Base);
writer.WriteLine("Offset {0} {1:X4}", i, ArcadePage[i].Offset);
writer.WriteLine("Increment {0} {1:X4}", i, ArcadePage[i].IncrementValue);
}
writer.Write("RAM "); ArcadeRam.SaveAsHex(writer);
writer.WriteLine("[/ArcadeCard]");
writer.WriteLine();
}
public void LoadArcadeCardText(TextReader reader)
{
while (true)
{
string[] args = reader.ReadLine().Split(' ');
if (args[0].Trim() == "") continue;
if (args[0] == "[/ArcadeCard]") break;
if (args[0] == "ShiftRegister")
ShiftRegister = int.Parse(args[1]);
else if (args[0] == "ShiftAmount")
ShiftAmount = byte.Parse(args[1]);
else if (args[0] == "RotateAmount")
RotateAmount = byte.Parse(args[1]);
else if (args[0] == "RAM")
ArcadeRam.ReadFromHex(args[1]);
else if (args[0] == "Control")
ArcadePage[int.Parse(args[1])].Control = byte.Parse(args[2], NumberStyles.HexNumber);
else if (args[0] == "Base")
ArcadePage[int.Parse(args[1])].Base = int.Parse(args[2], NumberStyles.HexNumber);
else if (args[0] == "Offset")
ArcadePage[int.Parse(args[1])].Offset = ushort.Parse(args[2], NumberStyles.HexNumber);
else if (args[0] == "Increment")
ArcadePage[int.Parse(args[1])].IncrementValue = ushort.Parse(args[2], NumberStyles.HexNumber);
else
Console.WriteLine("Skipping unrecognized identifier " + args[0]);
}
}
}
public void LoadArcadeCardText(TextReader reader)
{
while (true)
{
string[] args = reader.ReadLine().Split(' ');
if (args[0].Trim() == "") continue;
if (args[0] == "[/ArcadeCard]") break;
if (args[0] == "ShiftRegister")
ShiftRegister = int.Parse(args[1]);
else if (args[0] == "ShiftAmount")
ShiftAmount = byte.Parse(args[1]);
else if (args[0] == "RotateAmount")
RotateAmount = byte.Parse(args[1]);
else if (args[0] == "RAM")
ArcadeRam.ReadFromHex(args[1]);
else if (args[0] == "Control")
ArcadePage[int.Parse(args[1])].Control = byte.Parse(args[2], NumberStyles.HexNumber);
else if (args[0] == "Base")
ArcadePage[int.Parse(args[1])].Base = int.Parse(args[2], NumberStyles.HexNumber);
else if (args[0] == "Offset")
ArcadePage[int.Parse(args[1])].Offset = ushort.Parse(args[2], NumberStyles.HexNumber);
else if (args[0] == "Increment")
ArcadePage[int.Parse(args[1])].IncrementValue = ushort.Parse(args[2], NumberStyles.HexNumber);
else
Console.WriteLine("Skipping unrecognized identifier " + args[0]);
}
}
}
}

View File

@ -598,6 +598,11 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
MemoryDomainList memoryDomains;
public MemoryDomainList MemoryDomains { get { return memoryDomains; } }
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
}
public void Dispose()
{
if (disc != null)

View File

@ -25,6 +25,11 @@ namespace BizHawk.Emulation.Consoles.PSX
public bool StartAsyncSound() { return true; }
public void EndAsyncSound() { }
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
}
public static bool CheckIsPSX(DiscSystem.Disc disc)
{
bool ret = false;

View File

@ -243,6 +243,11 @@ namespace BizHawk.Emulation.Consoles.Sega
#endif
}
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
}
int vdpcallback(int level) // Musashi handler
{
InterruptCallback(level);

View File

@ -1,40 +1,40 @@
namespace BizHawk.Emulation.Consoles.Sega
{
public partial class SMS
{
// The CodeMasters mapper has 3 banks of 16kb, like the Sega mapper.
// The differences are that the paging control addresses are different, and the first 1K of ROM is not protected.
// Bank 0: Control Address $0000 - Maps $0000 - $3FFF
// Bank 1: Control Address $4000 - Maps $4000 - $7FFF
// Bank 2: Control Address $8000 - Maps $8000 - $BFFF
// System RAM is at $C000+ as in the Sega mapper.
public partial class SMS
{
// The CodeMasters mapper has 3 banks of 16kb, like the Sega mapper.
// The differences are that the paging control addresses are different, and the first 1K of ROM is not protected.
// Bank 0: Control Address $0000 - Maps $0000 - $3FFF
// Bank 1: Control Address $4000 - Maps $4000 - $7FFF
// Bank 2: Control Address $8000 - Maps $8000 - $BFFF
// System RAM is at $C000+ as in the Sega mapper.
byte ReadMemoryCM(ushort address)
{
if (address < BankSize * 1) return RomData[(RomBank0 * BankSize) + address];
if (address < BankSize * 2) return RomData[(RomBank1 * BankSize) + (address & BankSizeMask)];
if (address < BankSize * 3) return RomData[(RomBank2 * BankSize) + (address & BankSizeMask)];
byte ReadMemoryCM(ushort address)
{
if (address < BankSize * 1) return RomData[(RomBank0 * BankSize) + address];
if (address < BankSize * 2) return RomData[(RomBank1 * BankSize) + (address & BankSizeMask)];
if (address < BankSize * 3) return RomData[(RomBank2 * BankSize) + (address & BankSizeMask)];
return SystemRam[address & RamSizeMask];
}
return SystemRam[address & RamSizeMask];
}
void WriteMemoryCM(ushort address, byte value)
{
if (address >= 0xC000)
SystemRam[address & RamSizeMask] = value;
void WriteMemoryCM(ushort address, byte value)
{
if (address >= 0xC000)
SystemRam[address & RamSizeMask] = value;
else if (address == 0x0000) RomBank0 = (byte)(value % RomBanks);
else if (address == 0x4000) RomBank1 = (byte)(value % RomBanks);
else if (address == 0x8000) RomBank2 = (byte)(value % RomBanks);
}
else if (address == 0x0000) RomBank0 = (byte)(value % RomBanks);
else if (address == 0x4000) RomBank1 = (byte)(value % RomBanks);
else if (address == 0x8000) RomBank2 = (byte)(value % RomBanks);
}
void InitCodeMastersMapper()
{
Cpu.ReadMemory = ReadMemoryCM;
Cpu.WriteMemory = WriteMemoryCM;
WriteMemoryCM(0x0000, 0);
WriteMemoryCM(0x4000, 1);
WriteMemoryCM(0x8000, 2);
}
}
void InitCodeMastersMapper()
{
Cpu.ReadMemory = ReadMemoryCM;
Cpu.WriteMemory = WriteMemoryCM;
WriteMemoryCM(0x0000, 0);
WriteMemoryCM(0x4000, 1);
WriteMemoryCM(0x8000, 2);
}
}
}

View File

@ -77,6 +77,11 @@ namespace BizHawk.Emulation.Consoles.Sega
_lagcount = 0;
islag = false;
}
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
}
public int LagCount { get { return _lagcount; } set { _lagcount = value; } }
public bool IsLagFrame { get { return islag; } }

View File

@ -97,6 +97,11 @@ namespace BizHawk.Emulation.Consoles.Sega.Saturn
public IController Controller { get; set; }
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
}
public bool GLMode { get; private set; }
public void SetGLRes(int factor, int width, int height)

View File

@ -56,6 +56,10 @@ namespace BizHawk.Emulation.Consoles.Sony.PSP
}
}
public List<KeyValuePair<string, int>> GetCpuFlagsAndRegisters()
{
throw new NotImplementedException();
}
bool disposed = false;
static PSP attachedcore = null;