Post Reply 
 
Thread Rating:
  • 1 Votes - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Patapon 1 input lag (I want errrradicate it)
08-13-2016, 08:51 AM (This post was last modified: 08-13-2016 09:21 AM by LamerDrv.)
Post: #28
RE: Patapon 1 input lag (I want errrradicate it)
It seems this is a dead end.
Can someone of the gurus tell what's next?

Here's what I managed to dig up so far:
LunaMoo found the point in code where drum strike is checked on ideality. Based on this I found the point in code where execution branches depending on whether the drum key is pressed.
Here's a rough pseudocode segment of the game that caught my attention:
Code:
get_drum_key();
get_current_timing();
...

if (key_is_pushed)
{
    huge chunk of code; //includes estimate using timing
}
else
    return;
This code is called with high frequency. Function get_current_timing() returns 15 different values in a circle:
0
0,133333
0,266667
0,400000
0,533333
0,666667
0,800000
0,933333
0,933333
0,800000
0,666667
0,533333
0,400000
0,266667
0,133333


Phone music tact in the game is 2 seconds - this is 4 background "boom" - once in 0.5 sec. That is the game divides the interval duration of 0.5 seconds to 15 segments. And for each segment the game checks if right key was pushed. If key was pushed and current timing is 0 - this is ideal strike.
If set loging point before "if" branching here is log:
22452 06:02:620 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f6eeeef
22640 06:02:636 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f6eeeef
22823 06:02:648 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f4ccccd
23001 06:02:662 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f2aaaaa
23188 06:02:677 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f088888
23376 06:02:716 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3ecccccc
23560 06:02:745 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3e888888
23743 06:02:781 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3e088888
23933 06:02:814 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=00000000 - moment for ideal strike
24161 06:02:846 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3e088889
24355 06:02:878 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3e888889
24538 06:02:912 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3ecccccd
24724 06:02:945 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f088889
24910 06:02:980 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f2aaaab
25092 06:03:011 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f4ccccd
25268 06:03:046 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f6eeeef
25489 06:03:078 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f6eeeef
25679 06:03:115 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f4ccccd
25866 06:03:145 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f2aaaaa
26054 06:03:178 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f088888
26240 06:03:213 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3ecccccc
26421 06:03:245 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3e888888
26598 06:03:279 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3e088888
26786 06:03:312 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=00000000 - moment for ideal strike
27085 06:03:348 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3e088889
27314 06:03:380 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3e888889
27505 06:03:415 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3ecccccd
27692 06:03:448 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f088889
27882 06:03:480 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f2aaaab
28072 06:03:513 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f4ccccd
28253 06:03:548 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f6eeeef
28478 06:03:579 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f6eeeef
28672 06:03:614 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f4ccccd
28867 06:03:646 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f2aaaaa
29049 06:03:680 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f088888
29274 06:03:712 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3ecccccc
29501 06:03:747 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3e888888
29703 06:03:781 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3e088888
29890 06:03:815 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=00000000 - moment for ideal strike
30227 06:03:849 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3e088889
30440 06:03:881 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3e888889
30646 06:03:916 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3ecccccd
30868 06:03:947 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f088889
31099 06:03:981 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f2aaaab
31305 06:04:017 user_main N[JIT]: Debugger\Breakpoints.cpp:320 BKP PC=08951214: s0=ffffffff; f0=3f4ccccd

s0=ffffffff=-1 means there is no pushed key - I didn't push any key.

Next, i set one more log point - inside ProcessKeyboard (in emluator code) and try to get the rhythm. I've attach the excerpt from log (with interpretation). In that log I can see that from my 32 drum strikes:
12 - ideal;
12 - too late;
8 - too early
It's stange. It's not like the problem with keyboard lag


One more experiment. Log point in game and grabbing sound by SoundForge (just phone sound, I didn't try to beat the drums).
See the jpg attachment.
   

This picture shows that there is little difference between execution speed of main thread and music the player hear. For example, time of background "boom" of 5th tact is 00:07,980. But time of call of get_current_timing() whit f0=0 in game is 00:08,012

I think that implementation of timing algorithm put strong requirement on speed of execution. And tiny speed deviations of main game thread and sound thread lead to the problem.

Maybe easier to patch the game than to improve emulator? For example get_current_timing() (z_un_0887b024) can be rewritten to return:
patched value | original value
0,933333 0,933333
0,800000 0,800000
0,666667 0,666667
0,533333 0,533333
0,400000 0,400000
0,266667 0,266667
0,000000 0,133333
0,000000 0,000000 --- expand time window for ideal moment
0,000000 0,133333
0,266667 0,266667
0,400000 0,400000
0,533333 0,533333
0,666667 0,666667
0,800000 0,800000
0,933333 0,933333


Attached File(s)
.txt  interpretation_log_z_un_089511e8+RAWINPUT.txt (Size: 15.62 KB / Downloads: 462)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Patapon 1 input lag (I want errrradicate it) - LamerDrv - 08-13-2016 08:51 AM

Forum Jump: