From b3a7f8f1fceddcd45ec62bcbf75ba128e4f84f5a Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Sun, 3 Feb 2013 19:26:34 -0500 Subject: Synchronise the controller status more spread out inside a rendered frame: * before rendering a background; * before rendering sprites; * while rendering more than 128 samples of audio at once ("Prefer fluid video"); * after every 16 scanlines of CPU execution instead of every 1; * while waiting for an audio buffer to become available; * while killing time between frames with fast-forward disabled. Controller presses and releases are now combined in a DS button bitfield using a shorter 32-bit algorithm. See entry.cpp:NDSSFCAccumulateJoypad and #define ACCUMULATE_JOYPAD in the source. This is still not suitable for playing platformers frame-perfectly, but it's much better than half a second of latency to press or release a button, and one still needs to press buttons a bit more than just light taps. I'd say 50 milliseconds is the latency now. Platformers requiring more precision can be played with frameskip 0. DMA does not require double-buffered displaying, so synchronise the controller more often by disabling double-buffered displaying again. --- source/cpuexec.cpp | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'source/cpuexec.cpp') diff --git a/source/cpuexec.cpp b/source/cpuexec.cpp index a0c7ebc..30dff21 100644 --- a/source/cpuexec.cpp +++ b/source/cpuexec.cpp @@ -105,7 +105,7 @@ #include "sa1.h" #include "spc7110.h" -#ifdef SYNC_JOYPAD_AT_HBLANK +#ifdef ACCUMULATE_JOYPAD #include "display.h" #endif @@ -473,15 +473,14 @@ void S9xDoHBlankProcessing_SFX () 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); - } +#ifdef ACCUMULATE_JOYPAD +/* + * This call allows NDSSFC to synchronise the DS controller more often. + * If porting a later version of Snes9x into NDSSFC, it is essential to + * preserve it. + */ + if ((CPU.V_Counter & 0xF) == 0) + NDSSFCAccumulateJoypad (); #endif if (IPPU.HDMA && CPU.V_Counter <= PPU.ScreenHeight) IPPU.HDMA = S9xDoHDMA (IPPU.HDMA); @@ -663,15 +662,13 @@ void S9xDoHBlankProcessing_NoSFX () 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); - } +#ifdef ACCUMULATE_JOYPAD +/* + * This call allows NDSSFC to synchronise the DS controller more often. + * If porting a later version of Snes9x into NDSSFC, it is essential to + * preserve it. + */ + NDSSFCAccumulateJoypad (); #endif if (IPPU.HDMA && CPU.V_Counter <= PPU.ScreenHeight) IPPU.HDMA = S9xDoHDMA (IPPU.HDMA); -- cgit v1.2.3