diff --git a/recomp/patches-v111.txt b/recomp/patches-v111.txt index 89c37e9b..36c48190 100644 --- a/recomp/patches-v111.txt +++ b/recomp/patches-v111.txt @@ -30,6 +30,14 @@ set freecam NX2NAVI_PATCH_FREECAM 0 # (runtime/frame_rate.c). x10 is rewritten before it is read again, and the tst's flags feed only the fcsel. site ostep main 6e6cc0 1e220c21 @page:x10 # fcsel s1, s1, s2, eq -> adrp x10, page site ostep main 6e6cc4 1e201828 bd410148 # fdiv s8, s1, s0 -> ldr s8, [x10, #256] +# The engine's second step: the graphics system's update (main+0x3b4ea90) also divides 60.0 by the same nominal rate +# (its +0x2c8) and stores the result as a global, main+0x4d41fc8, the 60 Hz frames of the last update. Its reader is the +# hold-to-repeat timer of the buttons (main+0x3483680), which adds it to each held button's time and repeats the button +# once that passes the button's delay and period in 60 Hz frames; above 60 fps it added 1.0 a rendered frame, so a held +# button repeated fps / 60 times too often. The global takes frames per update from the patch page too, so the two steps +# never differ. x9 is not read in the function and is free across the call that follows; the store keeps x8. +site ostep main 3b4eaf4 5e21d800 @page:x9 # scvtf s0, s0 -> adrp x9, page +site ostep main 3b4eaf8 1e201820 bd410120 # fdiv s0, s1, s0 -> ldr s0, [x9, #256] # Physics solver steps: the physics system's step setup (main+0x38aeb80, and the same code in main+0x38afc10) gives the # rigid body world its solver step count for the frame, trunc(frames per update * count + 0.001) with the count at diff --git a/runtime/frame_rate.c b/runtime/frame_rate.c index b3010554..6b8e7bf5 100644 --- a/runtime/frame_rate.c +++ b/runtime/frame_rate.c @@ -556,6 +556,11 @@ static void speed_report(uint64_t now, double step, int interval) { memcpy(last_pos, p, sizeof p); last_pos_ns = now; } + float global_step; // Ocarina 1.1.1: the engine's global step (patches-v111.txt, the set ostep's second site) + if (probe && ostep_page && read_guest(MOD_MAIN_BASE + 0x4d41fc8, &global_step, 4)) { + size_t o = strlen(pos); + snprintf(pos + o, sizeof pos - o, "; global step %.3f frames", (double)global_step); + } if (os_step_hi > 0) { // Ocarina: the shortest and longest step given in these frames, and the time still owed size_t o = strlen(pos); snprintf(pos + o, sizeof pos - o, "; step %.3f..%.3f frames, %.1f ms owed", os_step_lo * 60, os_step_hi * 60,