one thing i've wanted to do and never bothered with is to document the user input system. so let's get started:
0x21418C4 - g_pUserInput(global pointer to 0x21FF960)
0x21FF960 - user input heap/struct - first 2 members are 0x21FF9D0 and 0x21FFA48
0x21FF9D0 - user keypress input(sizeof = 0x44)
0x21FFA48 - user touchpad input(sizeof = 0x78)
keypress input:
0x0-0x38 - a variety of keypress recordings that capture that actual keys pressed, not the inverted presses that the hardware captures(i.e. if you press A+B, it will reflect that as 0x3 instead of 0x3FC)- about half are for previous keys pressed and to catch keypress combos and keys being held.
0x3C - frame counter that counts down from either 0x8 -> 0x0 or 0xF -> 0x0 depending on whether keys have changed between video frames or not
0x40 - const, never changes - copied into 0x3C at the end of the countdown when keys don't change between vframes.
0x44 - const, never changes - copied into 0x3C when keys change between vframes.
so what will happen is:
-player presses A from nothing- keycount will reset to 0xF and so long as the player continues to press only A, it will count down to 0x0, reset to 0x8 and continue counting from 8 to 0.
-player either lets go of A or presses another button at the same time - keycount will reset to 0xF and start to count down again. this will go back up to 8 and count down if the combo is held for all 0xF frames.
then inside the block from 0x8 - 0x38, about 4 of the entries capture the currently pressed keys, another 4 or so capture the keys from the last frame, a few more capture the delta between frames, and a couple capture the combined keys between frames(pressed or not) looking for key combos.
touchpad input:
really simple actually, even though the heap is bigger for touchpad input.
2 u16s @ 0x5C are the coordinates of the last touch press
u16 @ 0x62 indicates that the touchpad is being pressed(goes with the above, isn't constantly updating)
2 u16s @ 0x64 + u16 @ 0x6A, same as the above for a different purpose
2 u16s @ 0x6C + u16 @ 0x72, constantly updating between 0 and the last pressed position- this is where the rest update from.
i'll make changes as i go through and figure out exactly what each of the keypress members and touch press members do.
user input heap:
a heap with a struct allocated inside of it.
0x3B(0x21FF99B) - backlight switch(this won't change anything on an emulator)
0x3D(0x21FF99D) - keypress type - this switches between 0x1E and 0x3C(30 and 60) and tells the game which keypress type to use because each keypress fetch function can choose between 2 different keypress struct members(the values between 0x8 and 0x38 above). i thought it changed every other frame at first, but it seems to only happen for certain reasons. it basically tells each fetch function to choose between the previous keypress and the current frame's keypress.(or the keypress delta, etc)