Post Reply 
 
Thread Rating:
  • 1 Votes - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Patapon 1 input lag (I want errrradicate it)
07-16-2016, 10:09 AM
Post: #1
Patapon 1 input lag (I want errrradicate it)
Hi, all.

I am very saddened by the known "input lag" problem in Patapon game. While "Patapon 1" is playable, I can't keep "Fever" for long. Unfortunately, now I haven't a psp. But as far as remember keeping "fever" wasn't a problem on real psp.
I read posts about emulator settings and "patapon 1". But I was not able adjust ppsspp that "Patapon 1" works fine on PC.

I am trying to understand the reason of this lag and what emulator's particularities impact on timing in "Patapon 1". Is this "input lag", or may be "sound lag" or may be something other? And I am asking for help.

First, I was trying to analyse the logs of emulator while playing the "Patapon 1". I was trying to understand how long does it take from the passing key event to handling key inside game. I compare the times of calling EmuScreen::pspKey, sceCtrlReadBufferPositive, CtrlUpdateLatch. I see about 10-50 milliseconds between EmuScreen::pspKey and CtrlUpdateLatch. But I don't know: is it normal or is it too long.


Second. I looked inside the game code (in disassembler) and found sceCtrlReadBufferPositive call (there is only one place in "Patapon 1" game where sceCtrlReadBufferPositive is called).
Then I found the addresses for data which relating keys.    

Now I want to find the fragments of game code that refer to these data. (Ideally, a want to find the game code fragment that assesses the timings)
I need something similar to "breakpoint on memory access".
As far as I understand the emulator has modules for read/write memory in psp address space.

My questions:
Can I trace accessing the data in specific addresses?
Where should I set a conditional breakpoints in code of emulator (in Visual Studio) to trace the accessing data in specific address of PSP memory space?

P.S: Many thanks to authors for the ppsspp emulator.
P.P.S: pata-pata-pon
Find all posts by this user
Quote this message in a reply
07-16-2016, 01:51 PM
Post: #2
RE: Patapon 1 input lag (I want errrradicate it)
Sorry. I didn't notice that disassembeler have "memory access breakpoint" and "conditional breakpoint" functionality. Now I will continue to search.
Find all posts by this user
Quote this message in a reply
07-16-2016, 03:29 PM (This post was last modified: 07-16-2016 03:30 PM by [Unknown].)
Post: #3
RE: Patapon 1 input lag (I want errrradicate it)
From memory, Patapon samples input every vblank, or in other words once per frame. An input lag of up to 16.8ms should be unavoidable on a real PSP.

There's lots of things that can cause input lag or perceived input lag though:

* Many gamepads, keyboards, and mice (or their drivers) have lag.
* PPSSPP buffers audio a bit, but tries to output with low latency. Your drivers or device may be buffering as well.
* Your display driver may be vsyncing or otherwise graphics (buffering), which may cause a perceived lag as well.

The PSP had specialized hardware for each of these things. Your PC probably doesn't.

For example, a gamepad I have seems to give me ~100ms of latency between button press and PPSSPP being told about it. Possibly the author of my gamepad's driver figured 10Hz was "good enough." Keyboards typically also have lag and also rollover problems.

-[Unknown]
Find all posts by this user
Quote this message in a reply
07-16-2016, 07:46 PM
Post: #4
RE: Patapon 1 input lag (I want errrradicate it)
Thanks for the info.
16.8 ms - is it because FPS differs in psp and PC ? And is it critical for this game?

I am understanding that there are many components. That's why I trying to look for answers in game code.
I want to find: when this game evaluates "getting into the rhythm" what parameters it measures - milliseconds, samples, cycles or other things. May be I will be able to understand what can be done to improve (for this specific game).

Maybe someone already analysed the code of "Patapon 1"?
Find all posts by this user
Quote this message in a reply
07-16-2016, 11:08 PM
Post: #5
RE: Patapon 1 input lag (I want errrradicate it)
I mean that from when you depress the button to when the game even checks, an input lag of 16.8ms can occur on the real PSP. It's just how the game is written. I'm sure there's other delay when sensing the press, but it's probably a lot better than PCs on average.

I'm not sure - it's definitely possible. Could ask over at romhacking.org.

-[Unknown]
Find all posts by this user
Quote this message in a reply
07-17-2016, 06:46 AM
Post: #6
Sad RE: Patapon 1 input lag (I want errrradicate it)
(07-16-2016 11:08 PM)[Unknown] Wrote:  I'm not sure - it's definitely possible. Could ask over at romhacking.org.

-[Unknown]
It's seems romhacking.org goes away Sad

Just thinking

1) It says here (_uofw.github.io/uofw/group__Controller.html#ga6ac060595213e8f55054f80ddfad5391)
"Default update interval is the VBlank interrupt (approximately 60 times per second)"

2) Emulator log shows all calls to system function -> We know that "Patapon 1" doesn't manupulate with update frequency of the internal controller buffer -> This means that "Patapon 1" on real PSP uses default VBlank frequency to reading input data
...
If we assume that game logic of Patapon 1 counts something based on VBlank frequency...

Is it possible to make an experiment with incrementing the VBlank frequency to 60 and observe game's behavior?
Find all posts by this user
Quote this message in a reply
07-17-2016, 11:20 AM
Post: #7
RE: Patapon 1 input lag (I want errrradicate it)
Hi.
Please tell me, can I change a code in psp address space with emulator?

For example, game have code:
lw v0,0x4(a0)
and v0,v0,a1
jr ra
sltu v0,zero,v0

I want to change it to:
li v0,0 (or xor vo, vo, vo)
and v0,v0,a1
jr ra
sltu v0,zero,v0
Find all posts by this user
Quote this message in a reply
07-17-2016, 02:20 PM
Post: #8
RE: Patapon 1 input lag (I want errrradicate it)
Oops, I meant romhacking.net.

Increasing the vblank frequency, aside from screwing up rendering and game speed, would probably only require you to press buttons faster.

You can edit the code in the disassembler. Just start typing.

-[Unknown]
Find all posts by this user
Quote this message in a reply
07-17-2016, 07:39 PM (This post was last modified: 07-17-2016 07:55 PM by LamerDrv.)
Post: #9
RE: Patapon 1 input lag (I want errrradicate it)
(07-17-2016 02:20 PM)[Unknown] Wrote:  You can edit the code in the disassembler. Just start typing.
Unbelievable... Smile)))) I love ppsspp.
By the way that code fragment reads the key data for drums. When I block data reading by changing lw v0,0x4(a0) to zero reading, drum buttons (tringle, cross, square, circle) stop to work while playing level. But other buttons (left, right, select) still work.
I hopes that I've found the place where game logic reads the drum buttons after key state data is prepared by "key reading engine".


(07-17-2016 02:20 PM)[Unknown] Wrote:  Increasing the vblank frequency, aside from screwing up rendering and game speed, would probably only require you to press buttons faster.

I understand that some parts of game code will run more often. But not all parts (I hopes).
For example:
While I searching how Potapon 1 reads keys, first I found some kind of "key reading engine" (it calls sceCtrlReadBufferPositive function).
Probably "key reading engine" binds with vblank or runs inside vblank (judging by the frequency of sceCtrlReadBufferPositive calls in emulator log).

But may be part of game logic (which judge "getting to the rhythm") doesn't bind to vblank directly.

I hopes that the increasing of the vblank frequency will makes "key reading engine" runs often, but will no affect the work of game logic.
That's what I would like to verify.
Find all posts by this user
Quote this message in a reply
07-18-2016, 08:01 AM
Post: #10
RE: Patapon 1 input lag (I want errrradicate it)
Just like [Unknown] said, unlocking it in Patapon 1 it will require you to press keys twice as fast and give you half of the detection "range" as well making even basic things very hard to do. It's as easy as nopping one jump or forcing a branch that skips it:
   
You pretty much want to do same thing 60fps patches do and the reason there aren't all that many of them is exactly because in most games it will double the speed and you will have to patch everything which is ~ if not very hard, at least awfuly time consuming as in most games will require playing through the whole game and changing many things separately.

There's definitely a difference between patapon 1 where after reaching "fever" you have to press keys faster to keep it and Patapon 2/3 where it keeps the original rhytm. This problem might just as well be a game design(no idea how first game of this series works on psp) or a timing bug maybe caused by something possibly unrelated which many japanese suffer from since ppsspp isn't exactly as slow as real psp.
I personally don't understand how "input lag" would matter here through, to me it's just an easy thing to blame, however since it would still be a constant thing, pretty much ensured by "force real clock sync" in ppsspp system settings - it would still never get you "out of rhytm" unless you play on real hardware every single day and you're soo used to it that you can't live with a minimal difference, but then you couldn't even get to "fever" and the problem I understand is keeping, not getting it which means reaching 10 successful combos already.

Either way if you found some timer waiting for keys to be pressed for combos during fever you could simulate different behaviour by basically cheating and extending it's limit, slowing it down or make it work same way as normal combos.

I don't recall having problems keeping fever, but I think I just wanted to test it quickly and made myself a cheat to force fever instantly after a single successful combo so it was probably removing the problem as a side effect.

http://forums.ppsspp.org/showthread.php?tid=6594 - Custom PPSSPP Shaders!
http://forums.ppsspp.org/showthread.php?tid=3590&pid=117172#pid117172 - simple CE scripts to help creating CWCheats,
https://github.com/LunaMoo/PPSSPP_workarounds - CWCheat workarounds.
Find all posts by this user
Quote this message in a reply
07-18-2016, 03:28 PM
Post: #11
Tongue RE: Patapon 1 input lag (I want errrradicate it)
(07-18-2016 08:01 AM)LunaMoo Wrote:  (no idea how first game of this series works on psp)
I played first patapon on real psp many times. It's one from my favorite games. Probably, that's why I'm so suffer Tongue
In patapon 1 on real psp I had nearly perfect timing. I remember that getting to "fever" wasn't problem (got it on 4-5th combo). And keeping "fever" wasn't problem too - I rarely lost it. (Even If I lost "fever", I could to get it again after 4-5th combo. It's very important while fighting with against a boss.)
But on ppsspp I have to make 10 combos to get "fever". And then I am losing it - almost immediately.
Personally, I feel a significant difference between Patapon 1 on psp and Patapon 1 on ppsspp

(07-18-2016 08:01 AM)LunaMoo Wrote:  I don't recall having problems keeping fever, but I think I just wanted to test it quickly and made myself a cheat to force fever instantly after a single successful combo so it was probably removing the problem as a side effect.
You know the game code!!! Can you give me details about your cheat, please?
I start searching from key handling and my search will require a lot of time - assembler is hard for me (I can't recognize the patterns corresponding to a simple construction of high level language. And I don't know MIPS assembler.)
But the place where you've patched the game (so game can no longer distinguish normal combo from perfect combo) must be close to code handling the timing.
Find all posts by this user
Quote this message in a reply
07-18-2016, 06:29 PM
Post: #12
RE: Patapon 1 input lag (I want errrradicate it)
My instant fever cheat wouldn't really do much here since I was just forcing variable to always say "fever" and it wasn't even caring about combos, however I made a new cheat now which would make fever easier to keep even with default(10) number of combos required:
Code:
_S UCUS-98711
_G Patapon
_C0 Casual Fever
_L 0xE0030002 0x0014B9F0
_L 0x2014B9DC 0x28640005
//0x5 on the end of above line is number of combos required for fever, can be decreased to as low as to 0x2, default was 0xA
_L 0x2014B9E0 0x54040007
_L 0x2014B9F0 0xAE030014
_C0 Casual Fever [Disable]
_L 0x2014B9DC 0x2404000A
_L 0x2014B9E0 0x54640007
_L 0x2014B9F0 0x10830002
~ after I read your post, I edited it to set fever on 5 combos, hopefully that reflects expected behaviour.


I didn't saw your post while working on it/trying to figure it out, but if it should activate on 5th combo that's already pointing to a totally different kind of problem than input delays and probably is some messed up timing issue since unfortunately japanese games are often depending on exact hardware timings and emulators always have problems with those:|.

On ppsspp I can see a variable which is set to 0 for 0-4 combos, then goes to 1 for 5-9 combos and to 2 for 10 combos and fever activates in the last case, trying to go further, but setting 0 on 11th combo which sometimes can be avoided by pressing the combo slightly faster before it can set 0, but it's hard.
This cheat sets fever back after every check of number of combos above selected number, so until you actually fail entering another combo it should never drop from it, so kind of works around the issue.

http://forums.ppsspp.org/showthread.php?tid=6594 - Custom PPSSPP Shaders!
http://forums.ppsspp.org/showthread.php?tid=3590&pid=117172#pid117172 - simple CE scripts to help creating CWCheats,
https://github.com/LunaMoo/PPSSPP_workarounds - CWCheat workarounds.
Find all posts by this user
Quote this message in a reply
07-18-2016, 06:46 PM
Post: #13
RE: Patapon 1 input lag (I want errrradicate it)
Hmm, if it's 10 and should be 5, that's definitely interesting. Could it be related to a game update or DLC or anything? I don't remember now whether it was 5 or 10, but 10 sounds high...

-[Unknown]
Find all posts by this user
Quote this message in a reply
07-19-2016, 05:35 AM (This post was last modified: 07-19-2016 06:02 AM by LamerDrv.)
Post: #14
RE: Patapon 1 input lag (I want errrradicate it)
(07-18-2016 06:29 PM)LunaMoo Wrote:  My instant fever cheat wouldn't really do much here since I was just forcing variable to always say "fever" and it wasn't even caring about combos, however I made a new cheat now which would make fever easier to keep even with default(10) number of combos required:
Code:
_S UCUS-98711
_G Patapon
_C0 Casual Fever
_L 0xE0030002 0x0014B9F0
_L 0x2014B9DC 0x28640005
//0x5 on the end of above line is number of combos required for fever, can be decreased to as low as to 0x2, default was 0xA
_L 0x2014B9E0 0x54040007
_L 0x2014B9F0 0xAE030014
_C0 Casual Fever [Disable]
_L 0x2014B9DC 0x2404000A
_L 0x2014B9E0 0x54640007
_L 0x2014B9F0 0x10830002
~ after I read your post, I edited it to set fever on 5 combos, hopefully that reflects expected behaviour.

Thank you very much.

(07-18-2016 06:29 PM)LunaMoo Wrote:  On ppsspp I can see a variable which is set to 0 for 0-4 combos, then goes to 1 for 5-9 combos and to 2 for 10 combos and fever activates in the last case, trying to go further, but setting 0 on 11th combo which sometimes can be avoided by pressing the combo slightly faster before it can set 0, but it's hard.
This cheat sets fever back after every check of number of combos above selected number, so until you actually fail entering another combo it should never drop from it, so kind of works around the issue.

I found this variable, yesterday. I was watching this value in memory tab while playing level (don't interrupting play). I tried to understand when it changes value from 0 to 1 and from 1 to 2.
It seems to me that:
- while combo number from 0 to 4 - fever=0;
- if 'combo number' > 4 AND fever<2 AND you make 3 (from 4) ideal drum strikes then fever=fever+1;
- if 'combo number' >4 AND fever<2 AND you make 4 ideal strikes then fever=2
- if 'combo number' == 10 AND fever<2 then fever=2

That is after 4 combos you can:
- get fever mode making two almost perfect tacts (3 ideal drum strikes from 4)
Or
- get fever mode immediately making 1 ideal tact (4 ideal drum strikes)
Or
- get fever mode on 10th combo

But this is inaccurate information.
I think the game takes decision about writing a value to this variable after evaluation last tact. I am going search the places in code that write this variable (once I get back from work). And somewhere nearby I'll find it Big Grin timing handling.
Find all posts by this user
Quote this message in a reply
07-19-2016, 08:01 AM (This post was last modified: 07-19-2016 09:05 AM by LunaMoo.)
Post: #15
RE: Patapon 1 input lag (I want errrradicate it)
I can see this like that in Patapon third where it's very easy, but it doesn't really work in first one.

Perfect timing gives best drum sounds, so by hearing those means you have no problems pressing the buttons with perfect timing, I definitely heard those when making the cheat yesterday so I don't think messing with input timing is the right way to correct it, neither is my cheat which only works around the issue.

Each drum rewards certain amounts of points based on timing accuracy where max during fever is 1000 and starts from like 20% without any drum. Based on that I think our observed problem would happen when the function that checks the score runs before fourth drum score get's added, so you kind of making perfect input and can hear the results of it in-game, but it's not reflected in your score so you can never reach "early fever" and also once you get to the fever, it drops instantly, because score from just 3 drums most of the time doesn't pass requirements to keep the fever.

So most accurate approach would be finding a function which slowing down fixes the game, I'm thinking this could actually be similar to this issue, maybe it's even same thing which there potentially is caused by sceGeDrawSync running too fast. In Patapon 1 is called twice once every frame, so I think I'll experiment with slowing that a bit or anything else that happens before checking the score.


Edit: I think I was right on that:
Code:
_C0 Delay sceGeDrawSync
_L 0xE0085E3C 0x0001491C
//delay script
_L 0x20001F00 0x3C1B0880
_L 0x20001F04 0x3C090018
_L 0x20001F08 0x34080000
_L 0x20001F0C 0x1509FFFF
_L 0x20001F10 0x25080001
_L 0x20001F14 0x0A275E3C
_L 0x20001F18 0x00000000
//replace
_L 0x2001491C 0x0E2007C0
_C0 Delay sceGeDrawSync [Disable]
_L 0x2001491C 0x0E275E3C
with this, I can reach fever faster on clear game without using any other fever cheats I made earlier, it also allows me to keep it easier, althrough I think it also changes the timing for combos as well(no suprise if it breaks those since I delay it by loop with very high number of repeats choosen randomly without any research;p).

Note this due to being very wasteful isn't really good workaround;p, ppsspp itself should just eat some cycles during that syscall. Edit: also would correct myself about reaching fever quicker without problems ~ the timing change messes me up now and have harder time to get perfect drums;p, but once I get them between 3-10 combos the fever kicks in early ~ that would actually reflect what I see normally in Patapon 3. Going to try changing ppsspp this time.

Edit:
And so adding
Code:
hleEatCycles(200000);
to sceGeDrawSync seems to be fixing this issue, but I literally took that value from what the other function which is delayed as a hack for Crash Tag Team Racing apparently does now ~ quoting [Unknown] :
Quote:Most likely it's the gpu thing, a brief test seemed to indicate that sceKernelVolatileMemLock takes maybe around ~1200 cycles, not like ~200000.

-[Unknown]

~ build for testing if you're interested ~ https://www.mediafire.com/?5eu7uyalr3tay79 pretty much v1.2.2-766-g4a1d3c3 + the change from above ~ this is just the exe for windows version.

http://forums.ppsspp.org/showthread.php?tid=6594 - Custom PPSSPP Shaders!
http://forums.ppsspp.org/showthread.php?tid=3590&pid=117172#pid117172 - simple CE scripts to help creating CWCheats,
https://github.com/LunaMoo/PPSSPP_workarounds - CWCheat workarounds.
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: