lua: add emu.on_snoop()
This commit is contained in:
parent
e7112a9a5d
commit
b545d79fb6
|
@ -183,6 +183,7 @@ namespace BizHawk
|
||||||
|
|
||||||
public byte ReadControls1()
|
public byte ReadControls1()
|
||||||
{
|
{
|
||||||
|
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
|
||||||
byte value = 0xFF;
|
byte value = 0xFF;
|
||||||
|
|
||||||
if (Controller["P1 Up"]) value &= 0xEF;
|
if (Controller["P1 Up"]) value &= 0xEF;
|
||||||
|
@ -196,6 +197,7 @@ namespace BizHawk
|
||||||
|
|
||||||
public byte ReadControls2()
|
public byte ReadControls2()
|
||||||
{
|
{
|
||||||
|
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
|
||||||
byte value = 0xFF;
|
byte value = 0xFF;
|
||||||
|
|
||||||
if (Controller["P2 Up"]) value &= 0xEF;
|
if (Controller["P2 Up"]) value &= 0xEF;
|
||||||
|
|
|
@ -126,6 +126,7 @@ namespace BizHawk.Emulation.Consoles.Calculator
|
||||||
|
|
||||||
byte ReadKeyboard()
|
byte ReadKeyboard()
|
||||||
{
|
{
|
||||||
|
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
|
||||||
//ref TI-9X
|
//ref TI-9X
|
||||||
|
|
||||||
int ret = 0xFF;
|
int ret = 0xFF;
|
||||||
|
|
|
@ -72,6 +72,7 @@ namespace BizHawk.Emulation.Consoles.Coleco
|
||||||
|
|
||||||
public byte ReadControls()
|
public byte ReadControls()
|
||||||
{
|
{
|
||||||
|
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
|
||||||
byte value = 0xFF;
|
byte value = 0xFF;
|
||||||
|
|
||||||
if (Controller["P1 Up"]) value &= 0xFF; //TODO;
|
if (Controller["P1 Up"]) value &= 0xFF; //TODO;
|
||||||
|
|
|
@ -86,9 +86,9 @@ namespace BizHawk.Emulation.Consoles.GB
|
||||||
|
|
||||||
public IController Controller { get; set; }
|
public IController Controller { get; set; }
|
||||||
|
|
||||||
// can when this is called (or not called) be used to give information about lagged frames?
|
|
||||||
LibGambatte.Buttons ControllerCallback()
|
LibGambatte.Buttons ControllerCallback()
|
||||||
{
|
{
|
||||||
|
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
|
||||||
IsLagFrame = false;
|
IsLagFrame = false;
|
||||||
return CurrentButtons;
|
return CurrentButtons;
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,6 +251,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
||||||
|
|
||||||
byte read_joyport(int addr)
|
byte read_joyport(int addr)
|
||||||
{
|
{
|
||||||
|
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
|
||||||
//read joystick port
|
//read joystick port
|
||||||
//many todos here
|
//many todos here
|
||||||
lagged = false;
|
lagged = false;
|
||||||
|
|
|
@ -453,6 +453,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
||||||
|
|
||||||
ushort snes_input_state(int port, int device, int index, int id)
|
ushort snes_input_state(int port, int device, int index, int id)
|
||||||
{
|
{
|
||||||
|
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
|
||||||
//Console.WriteLine("{0} {1} {2} {3}", port, device, index, id);
|
//Console.WriteLine("{0} {1} {2} {3}", port, device, index, id);
|
||||||
|
|
||||||
string key = "P" + (1 + port) + " ";
|
string key = "P" + (1 + port) + " ";
|
||||||
|
@ -483,8 +484,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
|
||||||
|
|
||||||
void snes_input_poll()
|
void snes_input_poll()
|
||||||
{
|
{
|
||||||
// libsnes.cpp calls this on every video refresh regardless of any underlying anything, so...
|
// this doesn't actually correspond to anything in the underlying bsnes;
|
||||||
//IsLagFrame = false;
|
// it gets called once per frame with video_refresh() and has nothing to do with anything
|
||||||
}
|
}
|
||||||
|
|
||||||
void snes_input_notify(int index)
|
void snes_input_notify(int index)
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
|
|
||||||
byte ReadInput()
|
byte ReadInput()
|
||||||
{
|
{
|
||||||
|
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
|
||||||
byte value = 0x3F;
|
byte value = 0x3F;
|
||||||
|
|
||||||
int player = SelectedController + 1;
|
int player = SelectedController + 1;
|
||||||
|
|
|
@ -106,7 +106,8 @@
|
||||||
|
|
||||||
void ReadController(ref byte data)
|
void ReadController(ref byte data)
|
||||||
{
|
{
|
||||||
data &= 0xC0;
|
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
|
||||||
|
data &= 0xC0;
|
||||||
if ((data & 0x40) != 0) // TH high
|
if ((data & 0x40) != 0) // TH high
|
||||||
{
|
{
|
||||||
if (Controller["P1 Up"] == false) data |= 0x01;
|
if (Controller["P1 Up"] == false) data |= 0x01;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
byte ReadControls1()
|
byte ReadControls1()
|
||||||
{
|
{
|
||||||
|
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
|
||||||
lagged = false;
|
lagged = false;
|
||||||
byte value = 0xFF;
|
byte value = 0xFF;
|
||||||
|
|
||||||
|
@ -36,6 +37,7 @@
|
||||||
|
|
||||||
byte ReadControls2()
|
byte ReadControls2()
|
||||||
{
|
{
|
||||||
|
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
|
||||||
lagged = false;
|
lagged = false;
|
||||||
byte value = 0xFF;
|
byte value = 0xFF;
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,11 @@ namespace BizHawk
|
||||||
/// if this is set, then the cpu should dump trace info to CpuTraceStream
|
/// if this is set, then the cpu should dump trace info to CpuTraceStream
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TraceBuffer Tracer = new TraceBuffer();
|
public TraceBuffer Tracer = new TraceBuffer();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// for emu.on_snoop()
|
||||||
|
/// </summary>
|
||||||
|
public System.Action InputCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CoreOutputComm
|
public class CoreOutputComm
|
||||||
|
|
|
@ -378,6 +378,7 @@ namespace BizHawk.MultiClient
|
||||||
"enablerewind",
|
"enablerewind",
|
||||||
"registerbefore",
|
"registerbefore",
|
||||||
"registerafter",
|
"registerafter",
|
||||||
|
"on_snoop",
|
||||||
};
|
};
|
||||||
|
|
||||||
public static string[] MemoryFunctions = new string[]
|
public static string[] MemoryFunctions = new string[]
|
||||||
|
@ -1171,6 +1172,27 @@ namespace BizHawk.MultiClient
|
||||||
frame_registerafterfunc = luaf;
|
frame_registerafterfunc = luaf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void emu_on_snoop(LuaFunction luaf)
|
||||||
|
{
|
||||||
|
if (luaf != null)
|
||||||
|
{
|
||||||
|
Global.Emulator.CoreInputComm.InputCallback = delegate()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
luaf.Call();
|
||||||
|
}
|
||||||
|
catch (SystemException e)
|
||||||
|
{
|
||||||
|
Global.MainForm.LuaConsole1.WriteToOutputWindow(
|
||||||
|
"error running function attached by lua function emu.on_snoop" +
|
||||||
|
"\nError message: " + e.Message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
//Memory library
|
//Memory library
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue