diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs index 2f2837c733..737d49735d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -284,7 +284,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES private readonly InputCallbackSystem _inputCallbacks = new InputCallbackSystem(); // TODO: optimize managed to unmanaged using the ActiveChanged event - public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented]get { return _inputCallbacks; } } + public IInputCallbackSystem InputCallbacks { get { return _inputCallbacks; } } public ITraceable Tracer { get; private set; } public IMemoryCallbackSystem MemoryCallbacks { get; private set; } @@ -501,7 +501,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES { // as this is implemented right now, only P1 and P2 normal controllers work - InputCallbacks.Call(); + // port = 0, oninputpoll = 2: left port was strobed + // port = 1, oninputpoll = 3: right port was strobed + Console.WriteLine("ONINPUTPOLL: {0}", port + 2); + + // InputCallbacks.Call(); //Console.WriteLine("{0} {1} {2} {3}", port, device, index, id); string key = "P" + (1 + port) + " "; @@ -539,7 +543,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES void snes_input_notify(int index) { - IsLagFrame = false; + // gets called with the following numbers: + // 4xxx : lag frame related + // 0: signifies latch bit going to 0. should be reported as oninputpoll + // 1: signifies latch bit going to 1. should be reported as oninputpoll + if (index >= 0x4000) + IsLagFrame = false; + else + Console.WriteLine("ONINPUTPOLL: {0}", index); } void snes_video_refresh(int* data, int width, int height) diff --git a/libsnes/bsnes/snes/alt/cpu/mmio.cpp b/libsnes/bsnes/snes/alt/cpu/mmio.cpp index 47dffe381b..16f6e84353 100644 --- a/libsnes/bsnes/snes/alt/cpu/mmio.cpp +++ b/libsnes/bsnes/snes/alt/cpu/mmio.cpp @@ -132,6 +132,7 @@ void CPU::mmio_write(unsigned addr, uint8 data) { case 0x4016: { input.port1->latch(data & 1); input.port2->latch(data & 1); + interface()->inputNotify(data & 1); // latch notify if (!status.auto_joypad_poll_enabled) { interface()->inputNotify(0x4016); } return; } diff --git a/libsnes/bsnes/snes/alt/cpu/timing.cpp b/libsnes/bsnes/snes/alt/cpu/timing.cpp index 88577db267..13027e8bf6 100644 --- a/libsnes/bsnes/snes/alt/cpu/timing.cpp +++ b/libsnes/bsnes/snes/alt/cpu/timing.cpp @@ -87,10 +87,14 @@ void CPU::scanline() { } void CPU::run_auto_joypad_poll() { + input.port1->latch(1); input.port2->latch(1); input.port1->latch(0); input.port2->latch(0); + interface()->inputNotify(1); + interface()->inputNotify(0); + uint16 joy1 = 0, joy2 = 0, joy3 = 0, joy4 = 0; for(unsigned i = 0; i < 16; i++) { diff --git a/libsnes/bsnes/snes/cpu/mmio/mmio.cpp b/libsnes/bsnes/snes/cpu/mmio/mmio.cpp index 858e590e2c..554c2b27cf 100644 --- a/libsnes/bsnes/snes/cpu/mmio/mmio.cpp +++ b/libsnes/bsnes/snes/cpu/mmio/mmio.cpp @@ -35,6 +35,7 @@ void CPU::mmio_w2183(uint8 data) { void CPU::mmio_w4016(uint8 data) { input.port1->latch(data & 1); input.port2->latch(data & 1); + interface()->inputNotify(data & 1); } //JOYSER0 diff --git a/libsnes/bsnes/snes/cpu/timing/joypad.cpp b/libsnes/bsnes/snes/cpu/timing/joypad.cpp index 179df27d0d..9df4a0d2e2 100644 --- a/libsnes/bsnes/snes/cpu/timing/joypad.cpp +++ b/libsnes/bsnes/snes/cpu/timing/joypad.cpp @@ -13,6 +13,8 @@ void CPU::step_auto_joypad_poll() { input.port2->latch(1); input.port1->latch(0); input.port2->latch(0); + interface()->inputNotify(1); + interface()->inputNotify(0); } uint2 port0 = input.port1->data(); diff --git a/output/dll/libsneshawk-32-compatibility.dll b/output/dll/libsneshawk-32-compatibility.dll index 36389c49c8..4af8fe7be1 100644 Binary files a/output/dll/libsneshawk-32-compatibility.dll and b/output/dll/libsneshawk-32-compatibility.dll differ diff --git a/output/dll/libsneshawk-32-performance.dll b/output/dll/libsneshawk-32-performance.dll index 21f1c9a1a5..ce372af6b8 100644 Binary files a/output/dll/libsneshawk-32-performance.dll and b/output/dll/libsneshawk-32-performance.dll differ