From a0d0c5e7a5bdc396b4c370a750273b6e3b963bb0 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Fri, 21 Dec 2012 03:50:10 -0500 Subject: Eliminate the latency of button press recognition, which was bad enough to lose keys entirely sometimes, and could otherwise delay a button press or release by 200 ms. This was the entire reason I created the fork, and I finally did it! It syncs the controls every scanline of a frame, which costs about 60,000 MIPS instructions per frame to deal with. Luckily, the processor runs at 396 MHz, which means the cost of checking the controls is 1% of the CPU's power. --- source/cpuexec.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/cpuexec.cpp') diff --git a/source/cpuexec.cpp b/source/cpuexec.cpp index 21b1574..5fb79e5 100644 --- a/source/cpuexec.cpp +++ b/source/cpuexec.cpp @@ -105,6 +105,10 @@ #include "sa1.h" #include "spc7110.h" +#ifdef SYNC_JOYPAD_AT_HBLANK +#include "display.h" +#endif + extern void S9xProcessSound (unsigned int); void S9xMainLoop (void) @@ -226,6 +230,16 @@ void S9xDoHBlankProcessing () switch (CPU.WhichEvent) { case HBLANK_START_EVENT: +#ifdef SYNC_JOYPAD_AT_HBLANK + // Re-get the controls every hblank. A resolution algorithm in + // ppu.cpp will determine with greater accuracy whether a key was + // pressed or released during the frame. + uint32 i; + for (i = 0; i < 5; i++) + { + IPPU.JoypadsAtHBlanks [i][CPU.V_Counter] = S9xReadJoypad (i); + } +#endif if (IPPU.HDMA && CPU.V_Counter <= PPU.ScreenHeight) IPPU.HDMA = S9xDoHDMA (IPPU.HDMA); -- cgit v1.2.3