Lua - catch NotImplementedException on emu.getregister(s) and warn the user that this particular core doesn't implement this feature yet. Also, put IEmulator extensions in their own namespace
This commit is contained in:
parent
5cf192394b
commit
9a24539c10
|
@ -4,6 +4,7 @@ using System.IO;
|
|||
using System.Reflection;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||
using BizHawk.Emulation.Cores.Nintendo.SNES;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||
using BizHawk.Emulation.Cores.Nintendo.NES;
|
||||
using BizHawk.Emulation.Cores.PCEngine;
|
||||
using BizHawk.Emulation.Cores.Sega.MasterSystem;
|
||||
|
@ -57,9 +58,20 @@ namespace BizHawk.Client.Common
|
|||
"getregister",
|
||||
"returns the value of a cpu register or flag specified by name. For a complete list of possible registers or flags for a given core, use getregisters"
|
||||
)]
|
||||
public static int GetRegister(string name)
|
||||
public int GetRegister(string name)
|
||||
{
|
||||
return Global.Emulator.GetCpuFlagsAndRegisters().FirstOrDefault(x => x.Key == name).Value;
|
||||
try
|
||||
{
|
||||
return Global.Emulator.GetCpuFlagsAndRegisters().FirstOrDefault(x => x.Key == name).Value;
|
||||
}
|
||||
catch (NotImplementedException)
|
||||
{
|
||||
|
||||
Log(string.Format(
|
||||
"Error: {0} does not yet implement getregister()",
|
||||
Global.Emulator.Attributes().CoreName));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
|
@ -69,9 +81,19 @@ namespace BizHawk.Client.Common
|
|||
public LuaTable GetRegisters()
|
||||
{
|
||||
var table = Lua.NewTable();
|
||||
foreach (var kvp in Global.Emulator.GetCpuFlagsAndRegisters())
|
||||
|
||||
try
|
||||
{
|
||||
table[kvp.Key] = kvp.Value;
|
||||
foreach (var kvp in Global.Emulator.GetCpuFlagsAndRegisters())
|
||||
{
|
||||
table[kvp.Key] = kvp.Value;
|
||||
}
|
||||
}
|
||||
catch (NotImplementedException)
|
||||
{
|
||||
Log(string.Format(
|
||||
"Error: {0} does not yet implement getregisters()",
|
||||
Global.Emulator.Attributes().CoreName));
|
||||
}
|
||||
|
||||
return table;
|
||||
|
|
|
@ -7,9 +7,11 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||
using BizHawk.Emulation.Cores.Atari.Atari2600;
|
||||
using BizHawk.Emulation.Cores.Atari.Atari7800;
|
||||
using BizHawk.Emulation.Cores.Calculators;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace BizHawk.Emulation.Common
|
||||
namespace BizHawk.Emulation.Common.IEmulatorExtensions
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue