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