From a36c7376a56a761316624b050aee8e6beec54b86 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:07:13 +0000 Subject: [PATCH 001/135] decomp: clarify names in wait_for_graphics_pipeline_idle arg0 -> unused_arg0: The SHA-256-bound C snapshot explicitly discards s32 arg0 with (void)arg0. Retail incoming a0 is first written at 0x0012059c by ori a0,v0,0x2, before any read of a0, then overwritten by cfc2 at 0x001205b0. The original Ghidra signature is int FUN_00120558(void); no incoming argument value feeds the polling loop or zero return. arg1 -> unused_arg1: The SHA-256-bound C snapshot explicitly discards s32 arg1 with (void)arg1. Retail incoming a1 is first overwritten at 0x00120588 by lw a1,0x0(t1), reading GIF DMA CHCR at 0x1000a000, before andi a1,a1,0x100 at 0x00120598. Ghidra decompiles the routine with no parameters; its polling and return consume no incoming a1 value. --- src/rendering/wait_for_graphics_pipeline_idle.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rendering/wait_for_graphics_pipeline_idle.c b/src/rendering/wait_for_graphics_pipeline_idle.c index c38dcb403a..e15adc9708 100644 --- a/src/rendering/wait_for_graphics_pipeline_idle.c +++ b/src/rendering/wait_for_graphics_pipeline_idle.c @@ -10,7 +10,7 @@ */ s32 wait_for_graphics_pipeline_idle(s32 arg0, s32 arg1) __asm__("FUN_00120558"); -s32 wait_for_graphics_pipeline_idle(s32 arg0, s32 arg1) { +s32 wait_for_graphics_pipeline_idle(s32 unused_arg0, s32 unused_arg1) { u32 busy; u32 initial_busy; u32 vif1_dma; @@ -19,8 +19,8 @@ s32 wait_for_graphics_pipeline_idle(s32 arg0, s32 arg1) { u32 vpu_status; u32 gif_status; - (void)arg0; - (void)arg1; + (void)unused_arg0; + (void)unused_arg1; do { vif1_dma = *(vu32 *)0x10009000; initial_busy = 1; From c24a7c2ff9aed19af6d019c15133d1718b94bb92 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:18:48 +0000 Subject: [PATCH 002/135] decomp: clarify names in register_moby_class arg1 -> indexed_textures: In the bound source, arg1 is the second s32 parameter and is forwarded unchanged as argument 2 of prepare_resident_class_render_data(moby, arg1, arg2, oclass). Retail 0x002036a4 saves incoming a1 in s2; 0x002036f8 restores s2 to a1 before jal 0x00203338 at 0x00203708. The supplied original Ghidra signature identifies that parameter as ResidentRenderTextureDefinition *pIndexedTextures and documents optional indexed texture definitions. arg2 -> material_map: In the bound source, arg2 is the third s32 parameter and is forwarded unchanged as argument 3 of prepare_resident_class_render_data(moby, arg1, arg2, oclass). Retail 0x002036a8 saves incoming a2 in s3; 0x002036fc restores s3 to a2 before jal 0x00203338 at 0x00203708. The supplied original Ghidra signature identifies it as ResidentClassMaterialMap *pMaterialMap and documents the resource's 16-byte material map. --- src/world/loaders/register_moby_class.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/world/loaders/register_moby_class.c b/src/world/loaders/register_moby_class.c index acc36671cd..35ec63e9d3 100644 --- a/src/world/loaders/register_moby_class.c +++ b/src/world/loaders/register_moby_class.c @@ -13,7 +13,7 @@ extern void prepare_resident_class_render_data(MobyClassData *, s32, s32, s32) __asm__("FUN_00203338"); void register_moby_class(MobyClassData *moby, s32 arg1, s32 arg2, s32 oclass) __asm__("FUN_00203640"); -void register_moby_class(MobyClassData *moby, s32 arg1, s32 arg2, s32 oclass) { +void register_moby_class(MobyClassData *moby, s32 indexed_textures, s32 material_map, s32 oclass) { s32 n; n = D_0015FF00; @@ -27,7 +27,7 @@ void register_moby_class(MobyClassData *moby, s32 arg1, s32 arg2, s32 oclass) { D_001B6180[n] = moby->unk2C; assign_moby_class_data(oclass); D_0015FF00++; - prepare_resident_class_render_data(moby, arg1, arg2, oclass); + prepare_resident_class_render_data(moby, indexed_textures, material_map, oclass); } } From 8f59adbfa20a95ff3a3f7777feddf1f6600e13d6 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:21:10 +0000 Subject: [PATCH 003/135] decomp: clarify names in draw_stretchable_ui_frame arg3 -> height: Authoritative source src/ui/frames/draw_stretchable_ui_frame.c (SHA-256 ee40cbd02c5169f84a9c3f8ee165900d2662e0dc848d83237d4112518d90bf02) forwards s32 arg3 as sprite argument five. Retail 0x00201150 saves a3 in s2, and 0x0020118c/0x002011ac forward s2 in t0 to 0x001ffc30. Helper 0x001ffcac saves t0 in s7; 0x001ffd90 adds s7 to the y value in s3, and 0x001ffd98 shifts the sum by four before packing the second vertex. This proves the pixel-space height. arg4 -> alpha: The source forwards s32 arg4 as sprite argument six. Retail 0x0020114c saves incoming t0 in s3; 0x00201190 and 0x002011b4 forward that value in t1 to 0x001ffc30. Helper 0x001ffcb4 saves t1 in s0, 0x001ffd24 shifts s0 left by 24, 0x001ffd2c ORs it with fixed RGB 0x7f7f7f, and 0x001ffd34 stores the color packet value. The supplied helper decompilation identifies this RGBAQ component as alpha, independently supported by the bit placement. --- src/ui/frames/draw_stretchable_ui_frame.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ui/frames/draw_stretchable_ui_frame.c b/src/ui/frames/draw_stretchable_ui_frame.c index d4cec0734e..db6726f23f 100644 --- a/src/ui/frames/draw_stretchable_ui_frame.c +++ b/src/ui/frames/draw_stretchable_ui_frame.c @@ -5,15 +5,15 @@ extern s32 draw_hud_sprite_flipped() __asm__("FUN_001ffe18"); void draw_stretchable_ui_frame(s32 x, s32 y, s32 width, s32 arg3, s32 arg4) __asm__("FUN_00201128"); -void draw_stretchable_ui_frame(s32 x, s32 y, s32 width, s32 arg3, s32 arg4) { +void draw_stretchable_ui_frame(s32 x, s32 y, s32 width, s32 height, s32 alpha) { s32 middle_frame; s32 edge_frame; middle_frame = get_icon_frame(0x7580, 0); edge_frame = get_icon_frame(0x7580, 1); - draw_hud_sprite(edge_frame, x, y, 0x20, arg3, arg4); - draw_hud_sprite(middle_frame, x + 0x20, y, width - 0x40, arg3, arg4); - draw_hud_sprite_flipped(edge_frame, (x + width) - 0x20, y, 0x20, arg3, arg4); + draw_hud_sprite(edge_frame, x, y, 0x20, height, alpha); + draw_hud_sprite(middle_frame, x + 0x20, y, width - 0x40, height, alpha); + draw_hud_sprite_flipped(edge_frame, (x + width) - 0x20, y, 0x20, height, alpha); } extern void func_00201128(s32 x, s32 y, s32 width, s32 arg3, s32 arg4) From a9abc783c11a0a3850b6607c3422e16975a3898a Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:21:10 +0000 Subject: [PATCH 004/135] decomp: clarify names in load_display_text_resource_entry arg0 -> destination: The source void *arg0 is used only as the destination of fast_vec_scale(arg0, &loc, scale). Retail 0x00214be0 saves incoming a0 in s0; 0x00214c20 restores it to a0 before the scale_vector_xyz call at 0x00214c28, with the stack vector in a1. The original Ghidra decompilation likewise passes float *param_1 as the scale output. arg1 -> packed_chars_source: The source s32 *arg1 is dereferenced once as fast_vector_from_packed_chars(&loc, *arg1). Retail 0x00214bf8 loads a1 from 0(a1) in the delay slot of the conversion call at 0x00214bf4, while a0 points to the stack vector. Original Ghidra shows FUN_001f9d50(afStack_50,*param_2), proving this parameter points to the packed input word. --- src/ui/text/load_display_text_resource_entry.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/text/load_display_text_resource_entry.c b/src/ui/text/load_display_text_resource_entry.c index f955a41ada..a164612595 100644 --- a/src/ui/text/load_display_text_resource_entry.c +++ b/src/ui/text/load_display_text_resource_entry.c @@ -21,7 +21,7 @@ extern void fast_vec_scale(void *dst, void *a, f32 scale) __asm__("FUN_001f9a68" void load_display_text_resource_entry(void *arg0, s32 *arg1) __asm__("FUN_00214bc0"); -void load_display_text_resource_entry(void *arg0, s32 *arg1) { +void load_display_text_resource_entry(void *destination, s32 *packed_chars_source) { struct Loc loc; f32 scale; @@ -30,10 +30,10 @@ void load_display_text_resource_entry(void *arg0, s32 *arg1) { loc.v.f[1] = 127.0f; loc.v.f[2] = 127.0f; - fast_vector_from_packed_chars(&loc, *arg1); + fast_vector_from_packed_chars(&loc, *packed_chars_source); scale = loc.d * 0.0001f; subtract_vector_xyz(&loc, &loc, &loc.v); - fast_vec_scale(arg0, &loc, scale); + fast_vec_scale(destination, &loc, scale); } extern __typeof__(load_display_text_resource_entry) func_00214BC0 From d22aaf96b6db8ae7d2fb8f50f217c9a07ea15adb Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:21:10 +0000 Subject: [PATCH 005/135] decomp: clarify names in set_up_vis_gif_viewer a3 -> material_control_base: Source src/rendering/set_up_vis_gif_viewer.c (SHA-256 d759fae7076bab1eebde0cd9daa5ef255bede82fdbb4d06f1cb16976a991e86f) declares a3 as s32 and ORs it unshifted with ((u64)t0 << 2) and ((u64)mode << 24). Retail 0x0020304c ORs incoming a3 into v0; 0x00203058 adds the shifted material index and 0x0020305c stores the result at original packet offset 0x10. Original Ghidra identifies this word as qwMaterialControl and the argument as dwMaterialBase, proving the base contribution. t0 -> material_control_shift2: The authoritative source declares t0 as s32 and uses ((u64)t0 << 2) in the material-control expression only for mode >= 0. Retail 0x00203038 moves incoming t0 to v0, 0x00203040 shifts v0 left by 2, 0x0020304c ORs it with a3, and 0x00203058/0x0020305c combine the mode shifted by 24 and store the material-control word at packet offset 0x10. Original Ghidra likewise names this input lMaterialShift2; the precise bit meaning remains unresolved. --- src/rendering/set_up_vis_gif_viewer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rendering/set_up_vis_gif_viewer.c b/src/rendering/set_up_vis_gif_viewer.c index 09e0bf2a1a..af23ab037e 100644 --- a/src/rendering/set_up_vis_gif_viewer.c +++ b/src/rendering/set_up_vis_gif_viewer.c @@ -5,7 +5,7 @@ void set_up_vis_gif_viewer(u64 *q, s32 n, s32 prim, s32 a3, s32 t0, s32 mode) __asm__("FUN_00202fd0"); -void set_up_vis_gif_viewer(u64 *q, s32 n, s32 prim, s32 a3, s32 t0, s32 mode) { +void set_up_vis_gif_viewer(u64 *q, s32 n, s32 prim, s32 material_control_base, s32 material_control_shift2, s32 mode) { u64 w0; s64 w1; u64 w2; @@ -17,7 +17,7 @@ void set_up_vis_gif_viewer(u64 *q, s32 n, s32 prim, s32 a3, s32 t0, s32 mode) { if (mode >= 0) { q[0] = (0x20 | (w1 & 0x1C)) | ((u64)prim << 6) | ((u64)(u32)n << 32); q += 2; - q[0] = (a3 | ((u64)t0 << 2)) | ((u64)mode << 24); + q[0] = (material_control_base | ((u64)material_control_shift2 << 2)) | ((u64)mode << 24); q += 2; q[0] = w0; q[2] = w2; From bc169776877e558f3eb8978418b4bd2eb4fa3c3a Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:21:10 +0000 Subject: [PATCH 006/135] decomp: clarify names in spawn_spark t0 -> first_vector_scratch: Source declares t0 as f32[4] and passes it with &s->a after packing first_vector there. Retail 0x00218994 sets s0=object+0x20; 0x002189d8-0x002189e0 packs first_vector into s0, then 0x002189f0-0x002189f8 passes sp as the first argument and s0 as the second to FUN_00214bc0. Ghidra identifies the corresponding 16-byte local as auStack_e0; no subsequent use occurs. t1 -> second_vector_scratch: Source declares t1 as f32[4] and passes it with &s->b after packing second_vector there. Retail 0x002189a4 sets s1=object+0x24; 0x002189e4-0x002189ec packs second_vector into s1, then 0x002189fc-0x00218a04 passes sp+0x10 as the first argument and s1 as the second to FUN_00214bc0. Ghidra identifies this distinct 16-byte local as auStack_d0; no subsequent use occurs. --- src/rendering/effects/spawn_spark.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rendering/effects/spawn_spark.c b/src/rendering/effects/spawn_spark.c index 443aab90d6..fc4bb84a9d 100644 --- a/src/rendering/effects/spawn_spark.c +++ b/src/rendering/effects/spawn_spark.c @@ -45,8 +45,8 @@ struct Obj *spawn_spark(u128 *source_quadword, f32 *first_vector, f32 *second_ve s32 arg7, s32 lookup_index_and_flags) { struct Obj *o; struct Sub *s; - f32 t0[4]; - f32 t1[4]; + f32 first_vector_scratch[4]; + f32 second_vector_scratch[4]; o = create_part(2); if (o != 0) { @@ -71,8 +71,8 @@ struct Obj *spawn_spark(u128 *source_quadword, f32 *first_vector, f32 *second_ve s->h18 = truncate_float_to_s32(second_vector[3] * 210000.0f / 1000.0f); pack_vector_xyz_with_shared_scale(first_vector, &s->a); pack_vector_xyz_with_shared_scale(second_vector, &s->b); - load_display_text_resource_entry(t0, &s->a); - load_display_text_resource_entry(t1, &s->b); + load_display_text_resource_entry(first_vector_scratch, &s->a); + load_display_text_resource_entry(second_vector_scratch, &s->b); s->c = arg3; s->d = arg4; s->h10 = arg5; From 442ea726f1d6916cbb6917a8fe4c32d0219ba4de Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:31:27 +0000 Subject: [PATCH 007/135] decomp: clarify names in draw_moby_list arg0 -> source_address: Retail 0x0020d33c saves incoming a0 in s1; 0x0020d374 restores it unchanged to a0 for moby_proc at 0x0020d378, separate from moby_anim_head in a1. The supplied original Ghidra signature identifies this uint input as source_address. Checked caller 0x00225a7c forms an array at its input + 0x44, loads each 32-bit entry into a0 at 0x00225a80, skips null entries at 0x00225a84 and passes each nonzero source address to draw_moby_list at 0x00225a8c. This supports source_address without claiming the source layout or changing the existing s32 type. --- src/gameplay/entities/draw_moby_list.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gameplay/entities/draw_moby_list.c b/src/gameplay/entities/draw_moby_list.c index bcf709f602..2893ace5ea 100644 --- a/src/gameplay/entities/draw_moby_list.c +++ b/src/gameplay/entities/draw_moby_list.c @@ -9,11 +9,11 @@ extern s32 vu1_add_g_sregister() __asm__("func_00233980"); void draw_moby_list(s32 arg0, s32 arg1) __asm__("FUN_0020d330"); -void draw_moby_list(s32 arg0, s32 arg1) { +void draw_moby_list(s32 source_address, s32 arg1) { vu1_add_g_sregister(0x47, (long)0x5360B); flush_cache(0); restore_moby_class_dists(); - moby_anim_head = moby_proc(arg0, moby_anim_head, arg1, 0); + moby_anim_head = moby_proc(source_address, moby_anim_head, arg1, 0); stash_moby_class_dists(); moby_anim_head -= 0x10; } From 36f22e45bec321d370455a4a3f534a7e14a44ed3 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:31:27 +0000 Subject: [PATCH 008/135] decomp: clarify names in snd_set_sound_params_cb a6 -> callback_address: In the SHA-256-bound source src/audio/voices/snd_set_sound_params_cb.c (dbbb1ceefea2bf7de84c4880c01feba809647c94ccf889d7251b2d71a73036cb), s32 a6 is the fourth argument to snd_send_iop_command_no_wait(0x21, 0x18, buf, a6, a7). Retail 0x0012e4cc moves incoming t2 (seventh parameter) into a3 before jal 0x0012e6e0 at 0x0012e4f4. The prepared original Ghidra decompilation calls this parameter dwCallbackAddress and forwards it in that same position, establishing callback_address without changing its type. a7 -> callback_context_address: The bound source forwards s32 a7 as the fifth argument to snd_send_iop_command_no_wait after a6. Retail 0x0012e4dc moves incoming t3 (eighth parameter) to t0, the fifth call argument, before jal 0x0012e6e0 at 0x0012e4f4. The original Ghidra decompilation identifies it as dwContextAddress, describes a guest callback context address, and passes (long)(int)dwContextAddress in the same slot. This proves the callback context address role while preserving s32. --- src/audio/voices/snd_set_sound_params_cb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/voices/snd_set_sound_params_cb.c b/src/audio/voices/snd_set_sound_params_cb.c index f33f0d34fa..b150614172 100644 --- a/src/audio/voices/snd_set_sound_params_cb.c +++ b/src/audio/voices/snd_set_sound_params_cb.c @@ -3,7 +3,7 @@ extern s32 snd_send_iop_command_no_wait() __asm__("func_0012E6E0"); void snd_set_sound_params_cb(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7) __asm__("FUN_0012e4c0"); -void snd_set_sound_params_cb(s32 request_word_0, s32 request_word_1, s32 request_word_2, s32 request_word_3, s32 request_word_4, s32 request_word_5, s32 a6, s32 a7) { +void snd_set_sound_params_cb(s32 request_word_0, s32 request_word_1, s32 request_word_2, s32 request_word_3, s32 request_word_4, s32 request_word_5, s32 callback_address, s32 callback_context_address) { s32 buf[6]; buf[0] = request_word_0; @@ -12,7 +12,7 @@ void snd_set_sound_params_cb(s32 request_word_0, s32 request_word_1, s32 request buf[3] = request_word_3; buf[4] = request_word_4; buf[5] = request_word_5; - snd_send_iop_command_no_wait(0x21, 0x18, buf, a6, a7); + snd_send_iop_command_no_wait(0x21, 0x18, buf, callback_address, callback_context_address); } extern __typeof__(snd_set_sound_params_cb) func_0012E4C0 __attribute__((alias("FUN_0012e4c0"))); From ce5d3fd4d0c5f0bb11422d987d4f1148f0afcdae Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:31:27 +0000 Subject: [PATCH 009/135] decomp: clarify names in snd_play_sound_vol_pan_pmpb a0 -> request_word_0: Retail 0x0012e310 stores incoming a0 at sp+0x00; the bound source assigns it to buf[0]. At 0x0012e334 the stack payload becomes the third argument, submitted at 0x0012e33c with command 0x11 and size 0x18. The original decompilation calls this dwWord0. a1 -> request_word_1: Retail 0x0012e320 stores incoming a1 at sp+0x04 before a1 is replaced by size 0x18 at 0x0012e32c. The bound source assigns it to buf[1], proving the second 32-bit request word, matching original dwWord1. a2 -> request_word_2: Retail 0x0012e328 stores incoming a2 at sp+0x08 before a2 becomes the payload pointer at 0x0012e334. The bound source assigns it to buf[2], proving the third 32-bit request word, matching original dwWord2. a3 -> request_word_3: Retail 0x0012e30c preserves incoming a3 in v0, then 0x0012e338 stores v0 at sp+0x0c. The bound source assigns a3 to buf[3], proving the fourth 32-bit request word, matching original dwWord3. a4 -> request_word_4: Retail 0x0012e318 stores incoming t0 (the fifth argument, source a4) at sp+0x10 before t0 receives callback context at 0x0012e324. Source buf[4] and original dwWord4 establish the fifth 32-bit request word. a5 -> request_word_5: Retail 0x0012e340 stores incoming t1 (the sixth argument, source a5) at sp+0x14 in the call delay slot. Source buf[5] and original dwWord5 establish the sixth 32-bit word of the 0x18-byte payload sent at 0x0012e33c. --- src/audio/voices/snd_play_sound_vol_pan_pmpb.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/audio/voices/snd_play_sound_vol_pan_pmpb.c b/src/audio/voices/snd_play_sound_vol_pan_pmpb.c index 8518901b3d..9608312209 100644 --- a/src/audio/voices/snd_play_sound_vol_pan_pmpb.c +++ b/src/audio/voices/snd_play_sound_vol_pan_pmpb.c @@ -3,15 +3,15 @@ extern s32 snd_send_iop_command_no_wait() __asm__("func_0012E6E0"); void snd_play_sound_vol_pan_pmpb(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7) __asm__("FUN_0012e308"); -void snd_play_sound_vol_pan_pmpb(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 callback_address, s32 callback_context_address) { +void snd_play_sound_vol_pan_pmpb(s32 request_word_0, s32 request_word_1, s32 request_word_2, s32 request_word_3, s32 request_word_4, s32 request_word_5, s32 callback_address, s32 callback_context_address) { s32 buf[6]; - buf[0] = a0; - buf[1] = a1; - buf[2] = a2; - buf[3] = a3; - buf[4] = a4; - buf[5] = a5; + buf[0] = request_word_0; + buf[1] = request_word_1; + buf[2] = request_word_2; + buf[3] = request_word_3; + buf[4] = request_word_4; + buf[5] = request_word_5; snd_send_iop_command_no_wait(0x11, 0x18, buf, callback_address, callback_context_address); } From 0798a5e1f9a8708881f56af17ad9c74d5db9b2df Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:31:27 +0000 Subject: [PATCH 010/135] decomp: clarify names in draw_pause_ring v1 -> viewport_dimension: In the SHA-256 fa223ffceaf9d3a833d2d3db0eebb57ff65f2e80b67acf0402e5046419f2b832 source, s32 v1 loads pause_state->w and supplies cx before conditional replacement by viewport_height. Retail 0x00220b6c loads v1 from +0x20; 0x00220b88-0x00220b90 preserves its original width as float for the half-width center at 0x00220bb4. The slt/movz at 0x00220b94-0x00220b98 replaces v1 with height when width >= height. At 0x00220ba4-0x00220bc4 the selected dimension is converted, halved, and reduced by 40 for radius. Prepared Ghidra independently expresses this as iVar1=width and iVar6=min(width,height). Thus viewport_dimension describes both phases without falsely asserting v1 always holds width or always the minimum. --- src/ui/menus/pause/draw_pause_ring.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ui/menus/pause/draw_pause_ring.c b/src/ui/menus/pause/draw_pause_ring.c index ba7abb0793..8fae267d0e 100644 --- a/src/ui/menus/pause/draw_pause_ring.c +++ b/src/ui/menus/pause/draw_pause_ring.c @@ -47,23 +47,23 @@ s32 draw_pause_ring(struct PauseState *pause_state) { s32 flag; f32 cx, cy, radius; struct IconEnt *iconTab; - s32 v1, viewport_height; + s32 viewport_dimension, viewport_height; setup_gif_paging(0); - v1 = pause_state->w; + viewport_dimension = pause_state->w; iconTab = D_001863D0; viewport_height = pause_state->h; - flag = v1 < viewport_height; + flag = viewport_dimension < viewport_height; /* v1 doubles as `selected`: retail's movz reuses the same register that already holds v1 (loaded straight into it), so the C must overwrite v1 itself rather than assign a fresh local -- that fresh local costs an extra `move` before the conditional one. */ - cx = (f32)v1 * 0.5f; + cx = (f32)viewport_dimension * 0.5f; cy = (f32)viewport_height * 0.5f; if (flag == 0) { - v1 = viewport_height; + viewport_dimension = viewport_height; } - radius = (f32)v1 * 0.5f - 40.0f; + radius = (f32)viewport_dimension * 0.5f - 40.0f; i = 0; do { f32 t, x, y; From cdabf13b82004551114710dc1d43b6395d32535a Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:32:44 +0000 Subject: [PATCH 011/135] decomp: clarify names in video_dec_create arg1 -> mpeg_work_area: At 0x0023cafc video_dec_create calls 0x0012b7d8 without modifying incoming a1 (original Ghidra param_2 is void *). Helper 0x0012b7f0 saves a1 in s0; 0x0012b7f8-0x0012b804 passes it as fill_bytes destination with zero fill. Instructions 0x0012b808-0x0012b810 align that address to four bytes; 0x0012b840 stores the aligned decoder state in context+0x40. This proves MPEG decoder work-area storage. arg2 -> mpeg_work_area_size: At 0x0023cafc incoming a2 (original Ghidra uint param_3) reaches initialize_mpeg_video_decoder unchanged. Helper 0x0012b7ec saves a2 in s1 while the same a2 supplies fill_bytes length at 0x0012b800. Instructions 0x0012b814-0x0012b81c subtract the work-area alignment padding from s1 and compare remaining bytes against 0x10c0; 0x0012b844-0x0012b850 passes the remaining capacity minus 0x10c0 to initialize_mpeg_work_area. This proves the supplied work-area size in bytes. --- src/video/decoder/video_dec_create.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/decoder/video_dec_create.c b/src/video/decoder/video_dec_create.c index 659356d86a..38d48ee50c 100644 --- a/src/video/decoder/video_dec_create.c +++ b/src/video/decoder/video_dec_create.c @@ -11,7 +11,7 @@ extern s32 video_dec_reset() __asm__("func_0023CC30"); s32 video_dec_create(s32 video_dec, s32 arg1, s32 arg2, s32 data, s32 tag, s32 size, s32 ts, s32 ts_count) __asm__("FUN_0023cac8"); -s32 video_dec_create(s32 video_dec, s32 arg1, s32 arg2, s32 data, s32 tag, s32 size, s32 ts, +s32 video_dec_create(s32 video_dec, s32 mpeg_work_area, s32 mpeg_work_area_size, s32 data, s32 tag, s32 size, s32 ts, s32 ts_count) { sceMpegCreate(video_dec); AddMpegCallback(video_dec, 0, D_0023D080, 0); From 73e6486b7452e7aa97e3e5ca5cde96c28c461006 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:32:44 +0000 Subject: [PATCH 012/135] decomp: clarify names in play_mpeg_movie arg0 -> movie_source: In the SHA-256 a7e7456d26ba60de5d21ded34dad3a7450ddb7e2b5d995d6f04e4f50912f8fe0 source snapshot, s32 arg0 is the first init_all input. Retail 0x0023a3d8 saves incoming a0 in s0 and 0x0023a3f4 restores it as a0 for init_all at 0x0023a3fc. Checked helper 0x0023a7ec saves that input in s2; 0x0023a9b4 passes it as a1 to 0x0023ba48 with the decoder_state+0xd9040 object as a0. Failure of that operation triggers the 'Can't Open movie' diagnostic at 0x0023a9cc-0x0023a9d8. The supplied original retail decompilation identifies the input as source_start and describes an explicit source descriptor. This supports movie_source without claiming its address/offset units. --- src/video/decoder/play_mpeg_movie.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/decoder/play_mpeg_movie.c b/src/video/decoder/play_mpeg_movie.c index 4c63aeff56..8dda3d628b 100644 --- a/src/video/decoder/play_mpeg_movie.c +++ b/src/video/decoder/play_mpeg_movie.c @@ -10,11 +10,11 @@ extern s32 term_all() __asm__("func_0023AA68"); s32 play_mpeg_movie(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) __asm__("FUN_0023a3b8"); -s32 play_mpeg_movie(s32 arg0, s32 arg1, s32 decoder_buffer_base, s32 decoder_state_base, s32 arg4) { +s32 play_mpeg_movie(s32 movie_source, s32 arg1, s32 decoder_buffer_base, s32 decoder_state_base, s32 arg4) { decoder_buffer_address = decoder_buffer_base; decoder_state = decoder_state_base; ChangeThreadPriority(GetThreadId(), 1); - if (init_all(arg0, arg1, arg4) != 0) { + if (init_all(movie_source, arg1, arg4) != 0) { read_mpeg(decoder_state + 0xD9048, decoder_state, decoder_state + 0xD9040); } term_all(); From 22adc94f694217911b081ce3479da0f36c68252f Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:32:44 +0000 Subject: [PATCH 013/135] decomp: clarify names in draw_hud_sprite_rect v0 -> texture_v0: In the bound source src/ui/hud/draw_hud_sprite_rect.c (SHA-256 e82909f4ccf5ab14677f2d235d6cb9c57fecfd77cd4731a355d6942b7479ee28), s32 v0 is packed as q[5] = u0 | ((u64)v0 << 16), immediately before the x0/y0 vertex in q[6]. Retail 0x002009cc preserves argument 7 (t2) in s0; 0x00200a28 shifts it by 16, 0x00200a2c combines it with u0 in s8, and 0x00200a3c stores the packed coordinate. Original Ghidra likewise packs param_6 | param_7 << 0x10. This proves the first endpoint's vertical texture coordinate. v1 -> texture_v1: In the bound source, s32 v1 is packed as q[7] = u1 | ((u64)v1 << 16), immediately before the x1/y1 vertex in q[8]. Retail 0x002009c0 loads argument 9 from 0xb0(sp) into s7; 0x00200a54 shifts it by 16, 0x00200a60 loads the saved u1, 0x00200a6c combines them, and 0x00200a90 stores the pair at 0x38(s1). Original Ghidra expresses the same pair as param_8 | param_9 << 0x10. This proves the second endpoint's vertical texture coordinate. --- src/ui/hud/draw_hud_sprite_rect.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/hud/draw_hud_sprite_rect.c b/src/ui/hud/draw_hud_sprite_rect.c index f41d1dd1e6..3fa7d3c2ab 100644 --- a/src/ui/hud/draw_hud_sprite_rect.c +++ b/src/ui/hud/draw_hud_sprite_rect.c @@ -7,7 +7,7 @@ extern u64 get_frame_texture(s32) __asm__("func_001FFA10"); void draw_hud_sprite_rect(s32 tex, s32 x0, s32 y0, s32 x1, s32 y1, s32 u0, s32 v0, s32 u1, s32 v1, s32 alpha) __asm__("FUN_00200958"); -void draw_hud_sprite_rect(s32 tex, s32 x0, s32 y0, s32 x1, s32 y1, s32 u0, s32 v0, s32 u1, s32 v1, +void draw_hud_sprite_rect(s32 tex, s32 x0, s32 y0, s32 x1, s32 y1, s32 u0, s32 texture_v0, s32 u1, s32 texture_v1, s32 alpha) { u64 *q; @@ -21,10 +21,10 @@ void draw_hud_sprite_rect(s32 tex, s32 x0, s32 y0, s32 x1, s32 y1, s32 u0, s32 v q[2] = get_frame_texture(tex); q[3] = 0x156; q[4] = (u64)alpha << 24 | 0x7F7F7F; - q[5] = u0 | ((u64)v0 << 16); + q[5] = u0 | ((u64)texture_v0 << 16); q[6] = (x0 + screen_extent.left - 8) | ((u64)(y0 + screen_extent.top - 8) << 16) | ((u64)hud_state.z << 32); - q[7] = u1 | ((u64)v1 << 16); + q[7] = u1 | ((u64)texture_v1 << 16); q[8] = (x1 + screen_extent.left - 8) | ((u64)(y1 + screen_extent.top - 8) << 16) | ((u64)hud_state.z << 32); q[9] = 0; From d624f4b5e5c81fb4edd2d74dcff94e58cf4625b7 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:32:44 +0000 Subject: [PATCH 014/135] decomp: clarify names in decode_map_mask arg1 -> compressed_data_base: In decode_map_mask, incoming a1 is saved in s5 at 0x0020672c and forwarded as helper a2 at 0x00206760. In decode_map_rle_row, 0x00206880 forms a2+0x200 for the first row; 0x0020687c and 0x0020689c add signed table offsets to a2 for subsequent starts and row ends. The resulting start feeds byte loads at 0x002068d0/0x002068d8 and nibble/run expansion, proving this s32 is the compressed-data base address. arg2 -> row_end_offsets: Incoming s16 *arg2 is saved from a2 into s4 at 0x00206734 and passed as helper a3 in the 0x0020676c delay slot, with row index i in a1. Helper 0x0020686c-0x00206874 indexes a3 by row*2 and loads the previous signed halfword to obtain the row start relative to the compressed base. The current signed halfword at 0x00206890 is added to that base at 0x0020689c to form the row end; end minus start controls the run count at 0x002068a0-0x002068ac. Thus the pointer supplies per-row end offsets. --- src/ui/map/decode_map_mask.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/map/decode_map_mask.c b/src/ui/map/decode_map_mask.c index 1e19ef03f9..73a12a320e 100644 --- a/src/ui/map/decode_map_mask.c +++ b/src/ui/map/decode_map_mask.c @@ -4,7 +4,7 @@ extern void decode_map_rle_row(u8 *dst, s32 arg1, s32 arg2, s16 *arg3) __asm__(" void decode_map_mask(u8 *dst, s32 arg1, s16 *arg2) __asm__("FUN_00206710"); -void decode_map_mask(u8 *dst, s32 arg1, s16 *arg2) { +void decode_map_mask(u8 *dst, s32 compressed_data_base, s16 *row_end_offsets) { s32 s; s32 i; s32 col; @@ -16,7 +16,7 @@ void decode_map_mask(u8 *dst, s32 arg1, s16 *arg2) { src = (u8 *)0x70000000; for (i = 0; i < 0x100; i++) { - decode_map_rle_row((u8 *)0x70000000, i, arg1, arg2); + decode_map_rle_row((u8 *)0x70000000, i, compressed_data_base, row_end_offsets); s = i % 0x10; p = dst + ((s + ((i / 0x10) * 0x200)) * 4); for (col = 0; col < 0x20; col++) { From 9ba77ed4874c33065826fcfafa1707d836262206 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:34:22 +0000 Subject: [PATCH 015/135] decomp: clarify names in append_scrolling_textured_quad v0 -> texture_v_top: In the bound source, float v0 fills uv[0].f.v and uv[1].f.v; these pairs precede the (x0,y0) and (x1,y0) vertices. Retail 0x00231704 and 0x0023173c store f14 to sp+0xc and sp+4; loads/stores at 0x00231800/0x0023180c and 0x0023181c/0x0023182c emit those pairs with the y0 row. Original Ghidra names the same component v_min in CONCAT44(v_min,u_min/u_max). Thus this is the top row texture V coordinate. v1 -> texture_v_bottom: In the bound source, float v1 fills uv[2].f.v and uv[3].f.v; these pairs precede the (x0,y1) and (x1,y1) vertices. Retail 0x0023171c and 0x0023174c store f15 to sp+0x1c and sp+0x14; loads/stores at 0x00231838/0x00231844 and 0x00231848/0x00231850 emit these pairs with the y1 row formed from y+h. Original Ghidra identifies these components as v_max. Thus this is the bottom row texture V coordinate. --- src/ui/loading/append_scrolling_textured_quad.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ui/loading/append_scrolling_textured_quad.c b/src/ui/loading/append_scrolling_textured_quad.c index f9f69c574c..da215406fc 100644 --- a/src/ui/loading/append_scrolling_textured_quad.c +++ b/src/ui/loading/append_scrolling_textured_quad.c @@ -20,7 +20,7 @@ void append_scrolling_textured_quad(int x, int y, int w, int h, unsigned long rg float u1, float v0, float v1) __asm__("FUN_002316e8"); void append_scrolling_textured_quad(int x, int y, int w, int h, unsigned long rgba, unsigned long tex, float u0, - float u1, float v0, float v1) { + float u1, float texture_v_top, float texture_v_bottom) { int x0 = x * 16 + screen_extent.left - 8; int x1 = (x + w) * 16 + screen_extent.left - 8; int y0 = y * 16 + screen_extent.top - 8; @@ -30,13 +30,13 @@ void append_scrolling_textured_quad(int x, int y, int w, int h, unsigned long rg int *base; uv[0].f.u = u0; - uv[0].f.v = v0; + uv[0].f.v = texture_v_top; uv[1].f.u = u1; - uv[1].f.v = v0; + uv[1].f.v = texture_v_top; uv[2].f.u = u0; - uv[2].f.v = v1; + uv[2].f.v = texture_v_bottom; uv[3].f.u = u1; - uv[3].f.v = v1; + uv[3].f.v = texture_v_bottom; render_packet_cursor.words[0] = 0x10000007; render_packet_cursor.words[1] = 0; From 398599b18efb781ee802689cc80928403e139d54 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:34:22 +0000 Subject: [PATCH 016/135] decomp: clarify names in matrix_to_quaternion arg0 -> output_quaternion: In source snapshot src/math/rotations/matrix_to_quaternion.c (SHA-256 182b3f8118adcac2608b8ede9e0aba91448828e8c1a68922143ad0a2a1e94eed), arg0 initializes float *q and receives q[0..3]. Retail 0x00214270 saves a0 in s5; 0x002142fc stores half sqrt(trace+1) at s5+0xc, and 0x00214310/0x00214324/0x0021433c store the scaled antisymmetric matrix differences at s5+0/4/8. Original Ghidra param_1 has the same writes, proving the quaternion output buffer. arg1 -> rotation_matrix: The authoritative source initializes float (*m)[4] from arg1 and reads its upper-left 3x3 block to form the quaternion. Retail 0x00214278 saves a1 in s0; 0x00214298/0x0021429c/0x002142a0 load s0+0/0x14/0x28 and sum them as the trace. Reads at 0x00214300..0x00214330 form off-diagonal differences. Original Ghidra param_2[0], [5], [10] and [9]-[6] confirm four-float row stride and the rotation-matrix input role. --- src/math/rotations/matrix_to_quaternion.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/math/rotations/matrix_to_quaternion.c b/src/math/rotations/matrix_to_quaternion.c index 86d3ba8128..aad08fca57 100644 --- a/src/math/rotations/matrix_to_quaternion.c +++ b/src/math/rotations/matrix_to_quaternion.c @@ -8,9 +8,9 @@ extern QuatNext D_0015FFD8; largest diagonal element, working on a packed 3x3 copy. */ void matrix_to_quaternion(void *arg0, void *arg1) __asm__("FUN_00214260"); -void matrix_to_quaternion(void *arg0, void *arg1) { - float *q = arg0; - float(*m)[4] = arg1; +void matrix_to_quaternion(void *output_quaternion, void *rotation_matrix) { + float *q = output_quaternion; + float(*m)[4] = rotation_matrix; QuatNext n = D_0015FFD8; float mat[3][3]; float trace; From d9abfdf2367d684a9d949bff9a88d6802a130ae4 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:34:22 +0000 Subject: [PATCH 017/135] decomp: clarify names in pick_map_slot_to_evict arg0 -> unused_arg0: The authoritative src/ui/map/pick_map_slot_to_evict.c snapshot (SHA-256 22f8de2ad0591909b223dedad364c5a16f763623301b5391956eb9ea34a9bd0d) never references s32 arg0 in its body. Retail 0x002052c0 assigns a0=4 on the level-zero path before use; the other path loads a0 from level_map_selection.level at 0x00205308 before the helper call. No incoming a0 value is read or saved. The original Ghidra decompilation declares FUN_00205278(void), corroborating non-use. arg1 -> unused_arg1: The authoritative C body never references s32 arg1. Retail 0x002052bc overwrites a1 with the global-state base before using it on the level-zero path. The alternate path never consumes incoming a1; 0x00205398 assigns a1=-1 before the slot_id store at 0x002053a8. No incoming a1 value is read or saved anywhere in the supplied instruction table. Original Ghidra FUN_00205278(void) corroborates that no input parameter is consumed. --- src/ui/map/pick_map_slot_to_evict.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/map/pick_map_slot_to_evict.c b/src/ui/map/pick_map_slot_to_evict.c index 24497b24cb..2bc8158f05 100644 --- a/src/ui/map/pick_map_slot_to_evict.c +++ b/src/ui/map/pick_map_slot_to_evict.c @@ -6,7 +6,7 @@ extern s32 find_id_in_terminated_table(s32 id) __asm__("func_00205220"); s32 pick_map_slot_to_evict(s32 arg0, s32 arg1) __asm__("FUN_00205278"); -s32 pick_map_slot_to_evict(s32 arg0, s32 arg1) { +s32 pick_map_slot_to_evict(s32 unused_arg0, s32 unused_arg1) { s64 max; s32 base; s64 delta; From 8f14175e9e0075884bf769b5574fdfd239102a6d Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:34:22 +0000 Subject: [PATCH 018/135] decomp: clarify names in CheckStateRange arg0 -> resource: In src/runtime/state/check_state_range.c (SHA-256 554daa1f84149263fc8439897ee924c934fc4c50e08bbe4657bdaaf5a0363333), s32 arg0 is forwarded as the first argument to call_global_state_resource, whose existing declaration names that s32 parameter resource. Original Ghidra decompilation likewise calls FUN_00116c70(param_1,0,10). Retail 0x00112384 zeros a1 and 0x00112390 sets a2 to 10 for the jal at 0x0011238c, while a0 is untouched; thus the incoming argument supplies the resource operand unchanged. --- src/runtime/state/check_state_range.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/state/check_state_range.c b/src/runtime/state/check_state_range.c index e6058606a2..0ceb00a4f4 100644 --- a/src/runtime/state/check_state_range.c +++ b/src/runtime/state/check_state_range.c @@ -1,5 +1,5 @@ #include "types.h" extern s64 call_global_state_resource(s32 resource, s32 first, s32 second) __asm__("CallGlobalStateResource"); -s64 CheckStateRange(s32 arg0) { - return (s64)(s32)(call_global_state_resource(arg0, 0, 0xA) << 32 >> 32); +s64 CheckStateRange(s32 resource) { + return (s64)(s32)(call_global_state_resource(resource, 0, 0xA) << 32 >> 32); } From 81b54620b731afdcbc580806d5123370aac5e043 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:35:59 +0000 Subject: [PATCH 019/135] decomp: clarify names in snd_reset_state_and_flush_commands arg0 -> unused_arg: In the authoritative src/audio/rpc/snd_reset_state_and_flush_commands.c snapshot (SHA-256 37d624f251db1be2d5ea61c1ea12f70c91d06b9abfb61c686717342eae547ca7), s32 arg0 occurs in declarations but is never referenced by the function body: it stores zero to GlobalTableStatus and calls snd_flush_sound_commands() without arguments. The complete retail body at 0x0012eb00-0x0012eb1c contains no explicit read of a0; 0x0012eb04 stores zero and 0x0012eb0c calls 0x0012dc80. The supplied original Ghidra decompilation likewise declares continue_sound_rpc_submissions(void). These establish unused_arg as a bounded description of this wrapper parameter. --- src/audio/rpc/snd_reset_state_and_flush_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/rpc/snd_reset_state_and_flush_commands.c b/src/audio/rpc/snd_reset_state_and_flush_commands.c index 2acb1084b1..49afb72230 100644 --- a/src/audio/rpc/snd_reset_state_and_flush_commands.c +++ b/src/audio/rpc/snd_reset_state_and_flush_commands.c @@ -3,7 +3,7 @@ extern s32 snd_flush_sound_commands() __asm__("FUN_0012dc80"); void snd_reset_state_and_flush_commands(s32 arg0) __asm__("FUN_0012eb00"); extern s32 GlobalTableStatus __asm__("D_0015ECC4") __attribute__((sda)); -void snd_reset_state_and_flush_commands(s32 arg0) { +void snd_reset_state_and_flush_commands(s32 unused_arg) { GlobalTableStatus = 0; snd_flush_sound_commands(); } From b6ac28e750fb8040d7023c972deb7b3c678790d0 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:35:59 +0000 Subject: [PATCH 020/135] decomp: clarify names in audio_dec_delete arg0 -> unused_arg: In src/audio/decoder/audio_dec_delete.c (SHA-256 e861985c1a74277ad106be0f00655cb59023b00b23edb9aa270dee3a0483f4e9), s32 arg0 is never referenced: audio_dec_delete calls snd_close_movie_sound() then returns 1. Retail 0x0023ac90-0x0023acac only saves/restores ra and sp, calls 0x0012f0e0 at 0x0023ac98, and sets v0=1 at 0x0023aca4; no instruction explicitly reads a0. The original Ghidra decompilation likewise has a void argument list and only stop_mpeg_audio_rpc_driver(); return 1. This proves unused_arg within the assigned function. --- src/audio/decoder/audio_dec_delete.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/decoder/audio_dec_delete.c b/src/audio/decoder/audio_dec_delete.c index ec1a64134b..e20f0bbf29 100644 --- a/src/audio/decoder/audio_dec_delete.c +++ b/src/audio/decoder/audio_dec_delete.c @@ -2,7 +2,7 @@ extern s32 snd_close_movie_sound() __asm__("FUN_0012f0e0"); s32 audio_dec_delete(s32 arg0) __asm__("FUN_0023ac90"); -s32 audio_dec_delete(s32 arg0) { +s32 audio_dec_delete(s32 unused_arg) { snd_close_movie_sound(); return 1; } From e9deb65ce98c8b2c8f2848d7c66b44c0e307656f Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:35:59 +0000 Subject: [PATCH 021/135] decomp: clarify names in FUN_0021df30 arg0 -> destination: The current void *arg0 is cast to char *p solely to address stores. Retail a0 is the base for sw zero at 0x0021df40 (+0x48), swc1 f0 at 0x0021df44 (+0x38, bits 0x40490fdb), sw zero at 0x0021df48 (+0x34), and the delay-slot sw at 0x0021df50 (+0x44). The original Ghidra param_1 likewise supplies all four store addresses, proving it is the destination of initialization writes. --- src/ui/menus/fun_0021df30.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/menus/fun_0021df30.c b/src/ui/menus/fun_0021df30.c index 8d5b09adf3..02733de193 100644 --- a/src/ui/menus/fun_0021df30.c +++ b/src/ui/menus/fun_0021df30.c @@ -1,6 +1,6 @@ /* Ported from rac1-decomp (src/game/pause.c, func_0021EF38). */ -int FUN_0021df30(void *arg0) { - char *p = (char *)arg0; +int FUN_0021df30(void *destination) { + char *p = (char *)destination; *(float *)(p + 0x38) = 3.14159274f; *(int *)(p + 0x34) = 0; *(int *)(p + 0x44) = 0; From d317698570d8196530d71784f964204526c6c880 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:35:59 +0000 Subject: [PATCH 022/135] decomp: clarify names in snd_get_doppler_pitch_mod arg0 -> projected_velocity: In src/audio/snd_get_doppler_pitch_mod.c (SHA-256 51bb60a6e29e9c60038578bf8fb808e6ae7beb0b622701954c86db966a55f335), int arg0 is the only input to (arg0 * 0x5F4) / 0x2E5. Retail 0x0012f1a8 multiplies incoming a0 by 1524, 0x0012f1b4 divides the signed product by 741, and 0x0012f1b8 returns the quotient. The supplied original Ghidra decompilation names this input projected_velocity and records that sound_update (call at 0x0022d5b0) derives it from a source/listener velocity projection multiplied by 300, supporting the projected_velocity role. --- src/audio/snd_get_doppler_pitch_mod.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/snd_get_doppler_pitch_mod.c b/src/audio/snd_get_doppler_pitch_mod.c index f806e7664a..32efd060a8 100644 --- a/src/audio/snd_get_doppler_pitch_mod.c +++ b/src/audio/snd_get_doppler_pitch_mod.c @@ -1,3 +1,3 @@ -int snd_get_doppler_pitch_mod(int arg0) { - return (arg0 * 0x5F4) / 0x2E5; +int snd_get_doppler_pitch_mod(int projected_velocity) { + return (projected_velocity * 0x5F4) / 0x2E5; } From 1f8128c59fcfb105cf3db50978e7ce230b97b189 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:37:32 +0000 Subject: [PATCH 023/135] decomp: clarify names in mpeg_error arg0 -> unused_mpeg: In the supplied source snapshot (SHA-256 0b4b210e9d3e21833a79b02d42c01322b5ace133d26f6e6a26a53f9bd6440aeb), mpeg_error's s32 arg0 is never referenced. The recovered mpegError__FP7sceMpegP18sceMpegCbDataErrorPv alias identifies the first callback argument as the MPEG object. Retail 0x0023d084 overwrites incoming a0 with lui a0,0x16, and 0x0023d08c forms the diagnostic string address without any read of incoming a0. Only cb_data in a1 is read at 0x0023d094 (+4). Original Ghidra likewise leaves param_1 unused. Thus unused_mpeg documents its callback role and proven non-use without changing its s32 type. --- src/video/decoder/callbacks/mpeg_error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/decoder/callbacks/mpeg_error.c b/src/video/decoder/callbacks/mpeg_error.c index 304367399c..ff9d73ee8e 100644 --- a/src/video/decoder/callbacks/mpeg_error.c +++ b/src/video/decoder/callbacks/mpeg_error.c @@ -10,7 +10,7 @@ extern u8 video_error_message[] __asm__("D_00161220"); extern s32 DebugPrint(); s32 mpeg_error(s32 arg0, struct MpegErrorData *cb_data) __asm__("FUN_0023d080"); -s32 mpeg_error(s32 arg0, struct MpegErrorData *cb_data) { +s32 mpeg_error(s32 unused_mpeg, struct MpegErrorData *cb_data) { DebugPrint(video_error_message, cb_data->unk4); return 1; } From 761872a3003ace7b31414dd3dd68985fd71cf321 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:37:32 +0000 Subject: [PATCH 024/135] decomp: clarify names in snd_stream_safe_check_cd_idle arg0 -> payload_word: Authoritative src/audio/streaming/snd_stream_safe_check_cd_idle.c (SHA-256 647d5fbad72f46d827ad9cde1de31fcfd2fc2202b9ce4a85517e02267910dc5c) copies s32 arg0 unchanged into *(s32 *)sp_slot and passes sp_slot with byte length 4 to snd_send_iop_command_and_wait(0x36, 4, sp_slot). Retail 0x0012ed38 stores incoming a0 at 0(sp); 0x0012ed34 sets a1=4, 0x0012ed3c sets a2=sp, and 0x0012ed44/48 calls 0x0012e548 with a0=0x36. Original Ghidra likewise copies dwWord into auStack_20[0] before snd_SendIOPCommand(0x36,4,auStack_20), proving the sole 32-bit payload word role. --- src/audio/streaming/snd_stream_safe_check_cd_idle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/streaming/snd_stream_safe_check_cd_idle.c b/src/audio/streaming/snd_stream_safe_check_cd_idle.c index b15d8b3b00..24d5c17c99 100644 --- a/src/audio/streaming/snd_stream_safe_check_cd_idle.c +++ b/src/audio/streaming/snd_stream_safe_check_cd_idle.c @@ -2,9 +2,9 @@ extern s32 snd_send_iop_command_and_wait() __asm__("func_0012E548"); void snd_stream_safe_check_cd_idle(s32 arg0) __asm__("FUN_0012ed30"); -void snd_stream_safe_check_cd_idle(s32 arg0) { +void snd_stream_safe_check_cd_idle(s32 payload_word) { u8 sp_slot[0x10]; - *(s32 *)sp_slot = arg0; + *(s32 *)sp_slot = payload_word; snd_send_iop_command_and_wait(0x36, 4, sp_slot); } From 6141059ae2ef60b5cc949acd392da559098d8af0 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:37:32 +0000 Subject: [PATCH 025/135] decomp: clarify names in snd_set_playback_mode arg0 -> playback_mode: In src/audio/mixer/snd_set_playback_mode.c (SHA-256 a17801aeb6bb33d8d17a3c839bbc969792c4965c7b14faaa69be0e0583552d96), s32 arg0 is copied unchanged into *(s32 *)sp_slot. Retail 0x0012e248 stores incoming a0 at sp+0; 0x0012e244 sets payload size 4, 0x0012e24c passes sp as a2, and 0x0012e254/0x0012e25c send command 11 to 0x0012e6e0. The established snd_set_playback_mode name and original snd_SetPlaybackMode(int nMode) decompilation identify this word as the playback mode. --- src/audio/mixer/snd_set_playback_mode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/mixer/snd_set_playback_mode.c b/src/audio/mixer/snd_set_playback_mode.c index 2a6c553c07..71815b5117 100644 --- a/src/audio/mixer/snd_set_playback_mode.c +++ b/src/audio/mixer/snd_set_playback_mode.c @@ -3,8 +3,8 @@ extern s32 snd_send_iop_command_no_wait(s32 cmd, s32 size, void *buf, s32 a, s32 b) __asm__("func_0012E6E0"); void snd_set_playback_mode(s32 arg0) __asm__("FUN_0012e240"); -void snd_set_playback_mode(s32 arg0) { +void snd_set_playback_mode(s32 playback_mode) { u8 sp_slot[0x10]; - *(s32 *)sp_slot = arg0; + *(s32 *)sp_slot = playback_mode; snd_send_iop_command_no_wait(11, 4, sp_slot, 0, 0); } From 8e5015905ce5705ebaec338ed40e2d975b3728ea Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:37:32 +0000 Subject: [PATCH 026/135] decomp: clarify names in snd_stop_sound arg0 -> sound_handle: The authoritative src/audio/voices/snd_stop_sound.c snapshot (SHA-256 2f01065bc59ff43c4c67ffa15aaf57d0eb179f5414dc8e6035daed18b4ed09d5) assigns s32 arg0 directly to buf[0]. Retail 0x0012e370 stores incoming a0 at sp+0; 0x0012e374 passes that stack payload in a2, with four-byte length at 0x0012e36c and command 0x15 at 0x0012e37c to snd_SendIOPCommandNoWait at 0x0012e384. The supplied original Ghidra signature names this exact 32-bit input nSoundHandle and describes command 21 as continuing one sound handle, supporting sound_handle without changing the established C function name. --- src/audio/voices/snd_stop_sound.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/voices/snd_stop_sound.c b/src/audio/voices/snd_stop_sound.c index a6d883c3dd..d181e54996 100644 --- a/src/audio/voices/snd_stop_sound.c +++ b/src/audio/voices/snd_stop_sound.c @@ -2,10 +2,10 @@ extern s32 snd_send_iop_command_no_wait() __asm__("func_0012E6E0"); void snd_stop_sound(s32 arg0) __asm__("FUN_0012e368"); -void snd_stop_sound(s32 arg0) { +void snd_stop_sound(s32 sound_handle) { s32 buf[4]; - buf[0] = arg0; + buf[0] = sound_handle; snd_send_iop_command_no_wait(0x15, 4, buf, 0, 0); } From 4c0d902e89fd9f31cb812fc65e8925c967141946 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:39:04 +0000 Subject: [PATCH 027/135] decomp: clarify names in refresh_point_light arg0 -> point_light_index: At 0x00201f68 the retail wrapper saves incoming a0 in s0 across detach_point_light (jal 0x00201f88 at 0x00201f64), then restores it into a0 at 0x00201f70 for create_point_light (jal 0x00201ba8 at 0x00201f6c). Source and original Ghidra both show unchanged forwarding. In the checked helper, 0x00201bb8 saves that argument in s4; 0x00201bc0 multiplies it by 0x30 to select the record at 0x0019c3c0, while 0x00201bdc shifts it by 5 and 0x00201bec-0x00201c08 load the corresponding point-light position/radius at 0x0019c1c0 + index*0x20 + 0x10. Ghidra identifies this as g_abObjectRenderPointLights[param_1].vPosition_and_radius. Instructions 0x00201c50-0x00201ce8 shift the same index by 4/8/12 and insert it into packed point-light indices. These uses prove point_light_index rather than a pointer or count. --- src/rendering/refresh_point_light.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rendering/refresh_point_light.c b/src/rendering/refresh_point_light.c index 84f5de6aef..5524891fcc 100644 --- a/src/rendering/refresh_point_light.c +++ b/src/rendering/refresh_point_light.c @@ -3,7 +3,7 @@ extern s32 create_point_light() __asm__("FUN_00201ba8"); extern s32 detach_point_light() __asm__("FUN_00201f88"); void refresh_point_light(s32 arg0) __asm__("FUN_00201f58"); -void refresh_point_light(s32 arg0) { +void refresh_point_light(s32 point_light_index) { detach_point_light(); - create_point_light(arg0); + create_point_light(point_light_index); } From ee1764e7efab89131d552d075174cebeb44052dc Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:39:04 +0000 Subject: [PATCH 028/135] decomp: clarify names in FUN_0021ca98 arg0 -> destination: In src/ui/menus/fun_0021ca98.c (SHA-256 f4f46a25bf611698e17229cbc0c2bcf7640df59aa1c7cec8c0f062334b999d0e), void *arg0 is used only as the base of the pointer store at byte offset 0x34. Retail Ghidra shows *(undefined4 *)(param_1 + 0x34) = uVar1; retail instruction 0x0021cab8 is sw v0,0x34(a0). Instructions 0x0021ca9c through 0x0021cab4 select 0x001d06d0 or 0x001d0708 according to the byte at 0x0013d4c2, proving a0/arg0 is the destination base. --- src/ui/menus/fun_0021ca98.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/menus/fun_0021ca98.c b/src/ui/menus/fun_0021ca98.c index 0d3751de5f..9524eaa8b2 100644 --- a/src/ui/menus/fun_0021ca98.c +++ b/src/ui/menus/fun_0021ca98.c @@ -3,8 +3,8 @@ extern unsigned char D_0013D4C2 NOT_SDA; extern char D_001D06D0[]; extern char D_001D0708[]; -int FUN_0021ca98(void *arg0) { - *(char **)((char *)arg0 + 0x34) = (D_0013D4C2 != 0) ? D_001D06D0 : D_001D0708; +int FUN_0021ca98(void *destination) { + *(char **)((char *)destination + 0x34) = (D_0013D4C2 != 0) ? D_001D06D0 : D_001D0708; return 0; } From 9b4faebd4d8bcb6518928ca15457c99f9ee1fd88 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:39:04 +0000 Subject: [PATCH 029/135] decomp: clarify names in snd_unload_bank arg0 -> bank_handle: The original retail snd_UnloadBank decompilation identifies nBankHandle. At 0x0012e1e0 sw a0,0(sp) copies this incoming s32 unchanged into the stack payload; 0x0012e1dc sets its size to 4, 0x0012e1e4 passes sp as the buffer, and 0x0012e1ec/0x0012e1f4 submit command 6 to snd_SendIOPCommandNoWait. The bound C mirrors this as *(s32 *)sp_slot = arg0 and snd_send_iop_command_no_wait(6, 4, sp_slot, 0, 0), proving the bank handle parameter role. --- src/audio/banks/snd_unload_bank.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/banks/snd_unload_bank.c b/src/audio/banks/snd_unload_bank.c index 4092067589..55d947c7d7 100644 --- a/src/audio/banks/snd_unload_bank.c +++ b/src/audio/banks/snd_unload_bank.c @@ -3,9 +3,9 @@ extern s32 snd_send_iop_command_no_wait(s32 cmd, s32 size, void *buf, s32 a, s32 b) __asm__("func_0012E6E0"); void snd_unload_bank(s32 arg0) __asm__("FUN_0012e1d8"); -void snd_unload_bank(s32 arg0) { +void snd_unload_bank(s32 bank_handle) { u8 sp_slot[0x10]; - *(s32 *)sp_slot = arg0; + *(s32 *)sp_slot = bank_handle; snd_send_iop_command_no_wait(6, 4, sp_slot, 0, 0); } From 0d67c0644d3723990dce7aefe82668acc6bcab7e Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:39:04 +0000 Subject: [PATCH 030/135] decomp: clarify names in snd_pause_all_sounds_in_group arg0 -> payload_word: Retail 0x0012e3f0 stores incoming a0 unchanged as one 32-bit word at sp+0; 0x0012e3ec sets size a1=4 and 0x0012e3f4 passes sp as a2. At 0x0012e3fc command a0 becomes 0x16 before the 0x0012e404 call to 0x0012e6e0. The source likewise copies s32 arg0 into sp_slot and submits (22,4,sp_slot,0,0); original Ghidra copies dwWord to auStack_20[0]. Thus the parameter is the command payload word. --- src/audio/voices/snd_pause_all_sounds_in_group.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/voices/snd_pause_all_sounds_in_group.c b/src/audio/voices/snd_pause_all_sounds_in_group.c index 71a00c3e5a..0573453a91 100644 --- a/src/audio/voices/snd_pause_all_sounds_in_group.c +++ b/src/audio/voices/snd_pause_all_sounds_in_group.c @@ -3,9 +3,9 @@ extern s32 snd_send_iop_command_no_wait(s32 cmd, s32 size, void *buf, s32 a, s32 b) __asm__("func_0012E6E0"); void snd_pause_all_sounds_in_group(s32 arg0) __asm__("FUN_0012e3e8"); -void snd_pause_all_sounds_in_group(s32 arg0) { +void snd_pause_all_sounds_in_group(s32 payload_word) { u8 sp_slot[0x10]; - *(s32 *)(sp_slot + 0) = arg0; + *(s32 *)(sp_slot + 0) = payload_word; snd_send_iop_command_no_wait(22, 4, sp_slot, 0, 0); } From ebe0e1133fdb1194a001490491a1839ea8732b23 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:40:33 +0000 Subject: [PATCH 031/135] decomp: clarify names in snd_pause_vag_stream arg0 -> sound_handle: The authoritative s32 arg0 is stored unchanged into *(s32 *)(sp_slot + 0). Retail 0x0012ec78 stores incoming a0 at 0(sp); 0x0012ec74 sets payload size 4, 0x0012ec7c passes sp as a2, and 0x0012ec84/0x0012ec8c send command 0x2d through snd_send_iop_command_no_wait. The original Ghidra decompilation identifies this sole payload word as dwHandle, consistent with the established snd_pause_vag_stream function name, proving the sound_handle role. --- src/audio/streaming/snd_pause_vag_stream.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/streaming/snd_pause_vag_stream.c b/src/audio/streaming/snd_pause_vag_stream.c index 8db7f74abb..e36f697033 100644 --- a/src/audio/streaming/snd_pause_vag_stream.c +++ b/src/audio/streaming/snd_pause_vag_stream.c @@ -3,9 +3,9 @@ extern s32 snd_send_iop_command_no_wait(s32 cmd, s32 size, void *buf, s32 a, s32 b) __asm__("func_0012E6E0"); void snd_pause_vag_stream(s32 arg0) __asm__("FUN_0012ec70"); -void snd_pause_vag_stream(s32 arg0) { +void snd_pause_vag_stream(s32 sound_handle) { u8 sp_slot[0x10]; - *(s32 *)(sp_slot + 0) = arg0; + *(s32 *)(sp_slot + 0) = sound_handle; snd_send_iop_command_no_wait(45, 4, sp_slot, 0, 0); } From bb7478b1ed12ce1399f78d38daf477738f3a3f1b Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:40:33 +0000 Subject: [PATCH 032/135] decomp: clarify names in leave_menu_prompt arg0 -> menu_screen: In the authoritative src/ui/menus/leave_menu_prompt.c snapshot (SHA-256 f7a82906955b7543dc1ddb4892bd684fc20017f28b339d83ed111d03d6d3abfd), arg0 has type struct MenuScreen * and owns data.prompt.buffer. Retail 0x00221a94 preserves incoming a0 in s0; 0x00221a9c loads the buffer from 0x54(s0) for FUN_00225cd8, and 0x00221aa0 stores its result back to 0x54(s0). Original Ghidra likewise reads and writes param_1 + 0x54, proving this parameter is the owning menu screen. --- src/ui/menus/leave_menu_prompt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/menus/leave_menu_prompt.c b/src/ui/menus/leave_menu_prompt.c index f7ea194f86..c3615edd31 100644 --- a/src/ui/menus/leave_menu_prompt.c +++ b/src/ui/menus/leave_menu_prompt.c @@ -3,7 +3,7 @@ extern s32 complete_stream_buffer_transfer() __asm__("FUN_00225cd8"); s32 leave_menu_prompt(struct MenuScreen *arg0) __asm__("FUN_00221a88"); -s32 leave_menu_prompt(struct MenuScreen *arg0) { - arg0->data.prompt.buffer = complete_stream_buffer_transfer(arg0->data.prompt.buffer); +s32 leave_menu_prompt(struct MenuScreen *menu_screen) { + menu_screen->data.prompt.buffer = complete_stream_buffer_transfer(menu_screen->data.prompt.buffer); return 0; } From c75d7b74d0026e900e8d237940f65c273ad25aef Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:40:33 +0000 Subject: [PATCH 033/135] decomp: clarify names in enter_menu_prompt arg0 -> menu_screen: The SHA-256-bound source declares arg0 as struct MenuScreen * and writes select_next_stream_buffer(0) to arg0->data.prompt.buffer. Retail 0x00221a58 preserves incoming a0 in s0; 0x00221a60 sets the helper argument to zero, 0x00221a64 calls 0x00225c18, and 0x00221a6c stores its v0 result at 0x54(s0). Original Ghidra likewise writes the helper result to param_1 + 0x54, proving the parameter is the menu screen receiving the prompt buffer. --- src/ui/menus/enter_menu_prompt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/menus/enter_menu_prompt.c b/src/ui/menus/enter_menu_prompt.c index 38279140d1..941ecc713a 100644 --- a/src/ui/menus/enter_menu_prompt.c +++ b/src/ui/menus/enter_menu_prompt.c @@ -4,8 +4,8 @@ extern s32 select_next_stream_buffer() __asm__("func_00225C18"); s32 enter_menu_prompt(struct MenuScreen *arg0) __asm__("FUN_00221a48"); -s32 enter_menu_prompt(struct MenuScreen *arg0) { +s32 enter_menu_prompt(struct MenuScreen *menu_screen) { menu_system.current->confirmed = 0; - arg0->data.prompt.buffer = select_next_stream_buffer(0); + menu_screen->data.prompt.buffer = select_next_stream_buffer(0); return 0; } From f0b4619f248b2196d1fe5fc9bb02de479cf7140d Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:40:33 +0000 Subject: [PATCH 034/135] decomp: clarify names in set_scrolling_status_message arg0 -> message: In src/ui/text/set_scrolling_status_message.c (SHA-256 52bbe58f7f392eb605c040ef0f3a87197fe804d9e3517207136db6f9bc97936a), s32 arg0 is the third argument of sprintf. Retail 0x00237e94 moves incoming a0 to a2; 0x00237e9c/0x00237eac load format 0x001e8a70 into a1, and 0x00237eb4 loads the destination from 0x2c(s0) into a0 for the sprintf call at 0x00237eb0. The supplied original Ghidra decompilation identifies this format as eighteen spaces followed by %s and the argument as char *message, proving its message-text role while preserving the existing s32 source type. --- src/ui/text/set_scrolling_status_message.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/text/set_scrolling_status_message.c b/src/ui/text/set_scrolling_status_message.c index 747c65aea0..abdc16a282 100644 --- a/src/ui/text/set_scrolling_status_message.c +++ b/src/ui/text/set_scrolling_status_message.c @@ -11,8 +11,8 @@ extern u8 D_001E8A70[]; extern s32 sprintf(); void set_scrolling_status_message(s32 arg0) __asm__("FUN_00237e90"); -void set_scrolling_status_message(s32 arg0) { - sprintf(D_001E63C0.unk2C, D_001E8A70, arg0); +void set_scrolling_status_message(s32 message) { + sprintf(D_001E63C0.unk2C, D_001E8A70, message); D_001E63C0.unk44 = 0; } From 87c473d463f4f43a01572abb0092a09c64fa022d Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:42:05 +0000 Subject: [PATCH 035/135] decomp: clarify names in snd_continue_vag_stream arg0 -> sound_handle: At retail 0x0012eca8, sw a0,0(sp) copies the incoming parameter unchanged into the payload; 0x0012eca4 sets its size to 4, 0x0012ecac passes sp as the buffer, and 0x0012ecb4/0x0012ecbc queue command 0x2e through snd_SendIOPCommandNoWait. The supplied original Ghidra signature names this word dwHandle and documents it as one sound handle. The authoritative snd_continue_vag_stream(s32 arg0) source performs the identical single-word copy and send, supporting sound_handle without changing its s32 type. --- src/audio/streaming/snd_continue_vag_stream.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/streaming/snd_continue_vag_stream.c b/src/audio/streaming/snd_continue_vag_stream.c index 9f95271b19..938413c9e5 100644 --- a/src/audio/streaming/snd_continue_vag_stream.c +++ b/src/audio/streaming/snd_continue_vag_stream.c @@ -3,9 +3,9 @@ extern s32 snd_send_iop_command_no_wait(s32 cmd, s32 size, void *buf, s32 a, s32 b) __asm__("func_0012E6E0"); void snd_continue_vag_stream(s32 arg0) __asm__("FUN_0012eca0"); -void snd_continue_vag_stream(s32 arg0) { +void snd_continue_vag_stream(s32 sound_handle) { u8 sp_slot[0x10]; - *(s32 *)(sp_slot + 0) = arg0; + *(s32 *)(sp_slot + 0) = sound_handle; snd_send_iop_command_no_wait(46, 4, sp_slot, 0, 0); } From b589306ba698082cd3a2d5f76beecdf86033f869 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:42:05 +0000 Subject: [PATCH 036/135] decomp: clarify names in snd_continue_all_sounds_in_group arg0 -> payload_word: In the bound source src/audio/voices/snd_continue_all_sounds_in_group.c (SHA-256 59de5150a238923cf309ca60d044ce976904f385101249c9c5ddf9ee0815407c), s32 arg0 is stored at sp_slot + 0 and passed via sp_slot to snd_send_iop_command_no_wait(23, 4, sp_slot, 0, 0). Retail 0x0012e420 stores incoming a0 at 0(sp); 0x0012e41c sets size a1 to 4, 0x0012e424 sets a2 to sp, and 0x0012e42c/0x0012e434 select command 0x17 and call 0x0012e6e0. Original Ghidra likewise copies dwWord into auStack_20[0]. Thus payload_word describes the exact unchanged 32-bit payload. --- src/audio/voices/snd_continue_all_sounds_in_group.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/voices/snd_continue_all_sounds_in_group.c b/src/audio/voices/snd_continue_all_sounds_in_group.c index d5cefd5a2b..a6c05d410d 100644 --- a/src/audio/voices/snd_continue_all_sounds_in_group.c +++ b/src/audio/voices/snd_continue_all_sounds_in_group.c @@ -3,9 +3,9 @@ extern s32 snd_send_iop_command_no_wait(s32 cmd, s32 size, void *buf, s32 a, s32 b) __asm__("func_0012E6E0"); void snd_continue_all_sounds_in_group(s32 arg0) __asm__("FUN_0012e418"); -void snd_continue_all_sounds_in_group(s32 arg0) { +void snd_continue_all_sounds_in_group(s32 payload_word) { u8 sp_slot[0x10]; - *(s32 *)(sp_slot + 0) = arg0; + *(s32 *)(sp_slot + 0) = payload_word; snd_send_iop_command_no_wait(23, 4, sp_slot, 0, 0); } From a5c19511349f7483945dca8613e88c23a0e8d0be Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:42:05 +0000 Subject: [PATCH 037/135] decomp: clarify names in finish_audio_stream_read arg0 -> callback_value: The prepared retail decompilation identifies this function as the callback registered at 0x00215430. At 0x00216954 v0 is set to 1 and 0x0021695c compares incoming a0 against it, returning for other values. For value 1, 0x00216970 clears read_state before the error query at 0x0021696c, and 0x0021697c stores 2 on nonzero query result. The bound C uses s32 arg0 only in the corresponding arg0 == 1 test, proving it is the callback value rather than the queried error. --- src/audio/streaming/finish_audio_stream_read.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/streaming/finish_audio_stream_read.c b/src/audio/streaming/finish_audio_stream_read.c index a1067ef2fe..3ae4968495 100644 --- a/src/audio/streaming/finish_audio_stream_read.c +++ b/src/audio/streaming/finish_audio_stream_read.c @@ -6,8 +6,8 @@ extern s32 snd_stream_safe_cd_get_error() __asm__("func_0012EEF0"); void finish_audio_stream_read(s32 arg0) __asm__("FUN_00216950"); -void finish_audio_stream_read(s32 arg0) { - if (arg0 == 1) { +void finish_audio_stream_read(s32 callback_value) { + if (callback_value == 1) { music_stream_state.read_state = 0; if (snd_stream_safe_cd_get_error() != 0) { music_stream_state.read_state = 2; From 40b536f1405bbd6bac40fa4cbbe7c5661e2cfb39 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:42:05 +0000 Subject: [PATCH 038/135] decomp: clarify names in snd_stream_safe_cd_get_error arg0 -> unused_arg: In source src/audio/streaming/snd_stream_safe_cd_get_error.c (SHA-256 36115276284205eaa2c06dc873f60e055f5f578f558f878bf1b89c0d51f554bf), s32 arg0 appears only in the declarations, never in the body. Retail instructions 0x0012eef0-0x0012ef24 never read a0: 0x0012eef4 loads the backend flag, 0x0012ef08 loads the cached error into v0, and 0x0012ef14 calls the native error query without argument setup. Original Ghidra int query_cd_read_error(void) likewise has no parameter use. Thus unused_arg states the proven local role. --- src/audio/streaming/snd_stream_safe_cd_get_error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/streaming/snd_stream_safe_cd_get_error.c b/src/audio/streaming/snd_stream_safe_cd_get_error.c index e9810e7e7c..49c546e0ab 100644 --- a/src/audio/streaming/snd_stream_safe_cd_get_error.c +++ b/src/audio/streaming/snd_stream_safe_cd_get_error.c @@ -5,7 +5,7 @@ extern s32 sceCdGetError(); s32 snd_stream_safe_cd_get_error(s32 arg0) __asm__("FUN_0012eef0"); -s32 snd_stream_safe_cd_get_error(s32 arg0) { +s32 snd_stream_safe_cd_get_error(s32 unused_arg) { if (snd_cd_stream_active == 0) { return sceCdGetError(); } From af130881acb660fe4dd94087b206751ae9017d30 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:43:31 +0000 Subject: [PATCH 039/135] decomp: clarify names in leave_save_slot_screen arg0 -> screen: The bound source src/ui/menus/save_data/leave_save_slot_screen.c (SHA-256 b109c0b7d9efc21cc8dc9a6d398e271c9773143f5279e9d82024b02dc9ab7a5d) declares arg0 as struct MenuScreen *. Retail 0x00222f64 preserves incoming a0 in s0; 0x00222f6c loads its +0x48 save_data field into the argument of FUN_00225cd8, and 0x00222f70 stores the returned v0 back into the same field. Original Ghidra likewise reads and writes *(param_1 + 0x48). Thus the parameter is the screen object owning the updated save data. --- src/ui/menus/save_data/leave_save_slot_screen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/menus/save_data/leave_save_slot_screen.c b/src/ui/menus/save_data/leave_save_slot_screen.c index 6ffa386b9c..86f620a4d1 100644 --- a/src/ui/menus/save_data/leave_save_slot_screen.c +++ b/src/ui/menus/save_data/leave_save_slot_screen.c @@ -3,7 +3,7 @@ extern s32 complete_stream_buffer_transfer() __asm__("FUN_00225cd8"); s32 leave_save_slot_screen(struct MenuScreen *arg0) __asm__("FUN_00222f58"); -s32 leave_save_slot_screen(struct MenuScreen *arg0) { - arg0->data.save.save_data = complete_stream_buffer_transfer(arg0->data.save.save_data); +s32 leave_save_slot_screen(struct MenuScreen *screen) { + screen->data.save.save_data = complete_stream_buffer_transfer(screen->data.save.save_data); return 0; } From 96c317f0eb40db62628d7bec642a34e7dbdc30bd Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:43:31 +0000 Subject: [PATCH 040/135] decomp: clarify names in enter_save_slot_screen arg0 -> menu_screen: In src/ui/menus/save_data/enter_save_slot_screen.c (snapshot SHA-256 4ac5cc17789f66d3b82629dcea57692dcf5fed2285a05e37619af9c64dd6b3cd), arg0 has type struct MenuScreen * and receives data.save.save_data and data.save.step writes. Retail 0x00222f20 preserves incoming a0 in s0; 0x00222f38 stores the buffer-selection return v0 at 0x48(s0), and 0x00222f3c clears 0x4c(s0). Original Ghidra likewise writes param_1+0x48 and param_1+0x4c. Thus this argument is the menu screen initialized by enter_save_slot_screen. --- src/ui/menus/save_data/enter_save_slot_screen.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/menus/save_data/enter_save_slot_screen.c b/src/ui/menus/save_data/enter_save_slot_screen.c index 40fcaaaafb..3276dcfb40 100644 --- a/src/ui/menus/save_data/enter_save_slot_screen.c +++ b/src/ui/menus/save_data/enter_save_slot_screen.c @@ -4,9 +4,9 @@ extern s32 initialize_graphics_buffer_descriptors() __asm__("FUN_00225ac0"); extern s32 select_next_stream_buffer() __asm__("FUN_00225c18"); s32 enter_save_slot_screen(struct MenuScreen *arg0) __asm__("FUN_00222f18"); -s32 enter_save_slot_screen(struct MenuScreen *arg0) { +s32 enter_save_slot_screen(struct MenuScreen *menu_screen) { initialize_graphics_buffer_descriptors(1); - arg0->data.save.save_data = select_next_stream_buffer(0); - arg0->data.save.step = 0; + menu_screen->data.save.save_data = select_next_stream_buffer(0); + menu_screen->data.save.step = 0; return 0; } From 893455b308096f34a17b7b79ecd5e5395b35c2c4 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:43:31 +0000 Subject: [PATCH 041/135] decomp: clarify names in FUN_00221d28 arg0 -> destination: In src/ui/menus/fun_00221d28.c (SHA-256 9e11332fc7387221209e6905d3933453ae8b23f363a35a1ccf27956d00d0bbe6), char *arg0 is used only as the base of *(int *)(arg0 + 0x34). Original retail Ghidra likewise writes to param_1 + 0x34. Retail 0x00221d40 divides the current level index unsigned by 19, 0x00221d4c obtains the remainder, 0x00221d50 scales it by four, and 0x00221d54-0x00221d58 load the selected entry from 0x001d4528. The store at 0x00221d60 writes that value to 0x34(a0), proving the parameter is the destination base pointer. --- src/ui/menus/fun_00221d28.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/menus/fun_00221d28.c b/src/ui/menus/fun_00221d28.c index 73557da99b..30b2170dc9 100644 --- a/src/ui/menus/fun_00221d28.c +++ b/src/ui/menus/fun_00221d28.c @@ -5,8 +5,8 @@ extern int pause_level_sprite_lists[] __asm__("D_001D4528"); extern s32 current_level_index __asm__("D_0015ED84") MACRO_ADDR; /* `D_001D4528[(unsigned)D_0015ED84 % 19]`; the older near-miss predated MACRO_ADDR. */ -int FUN_00221d28(char *arg0) { - *(int *)(arg0 + 0x34) = pause_level_sprite_lists[(unsigned int)current_level_index % 19]; +int FUN_00221d28(char *destination) { + *(int *)(destination + 0x34) = pause_level_sprite_lists[(unsigned int)current_level_index % 19]; return 0; } From 14e61c0358a6164ec583929e71c986a9149c2b1f Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:43:31 +0000 Subject: [PATCH 042/135] decomp: clarify names in relocate_asset_entry_pointers a0 -> table_container: In the authoritative source src/runtime/relocation/relocate_asset_entry_pointers.c (SHA-256 d2628cdaabd005eb2b02c42726a64972ce1a05e7e89609cb8c65167e338e514e), u8 *a0 initializes base, base advances by idx * 4, and p is loaded from base + 72. Retail instructions 0x002032e0..0x002032e8 shift a1 by 2, add it to incoming a0, and load the nested pointer from offset 0x48. The original Ghidra expression pContainer->apTables[nTableIndex] independently describes this same data flow. Thus the incoming parameter is the table container, distinct from the selected nested base used by the subsequent relocations. --- src/runtime/relocation/relocate_asset_entry_pointers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/relocation/relocate_asset_entry_pointers.c b/src/runtime/relocation/relocate_asset_entry_pointers.c index f2b172f81a..6e252e3b25 100644 --- a/src/runtime/relocation/relocate_asset_entry_pointers.c +++ b/src/runtime/relocation/relocate_asset_entry_pointers.c @@ -2,8 +2,8 @@ void relocate_asset_entry_pointers(u8 *a0, s32 idx, s32 on) __asm__("FUN_002032e0"); -void relocate_asset_entry_pointers(u8 *a0, s32 idx, s32 on) { - u8 *base = a0; +void relocate_asset_entry_pointers(u8 *table_container, s32 idx, s32 on) { + u8 *base = table_container; u8 *p; u32 v; From d76063a00a84c4bcaa6a95740460118ca206d2b4 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:44:42 +0000 Subject: [PATCH 043/135] decomp: clarify names in music_pause arg0 -> pause_secondary: In the authoritative music_pause(s32 arg0) source, arg0 != 0 gates only secondary.fade_flags = -0x8000 and secondary.unkE = 0. Retail 0x00216050 branches on a0 == 0 to 0x00216068, skipping precisely the halfword stores at 0x00216060/0x00216064 to state offsets 0x5c/0x5e. Stores at offsets 0x78/0x7a and 0x40/0x42 remain unconditional. Original Ghidra param_1 has the same conditional pair, proving the argument selects whether to pause the secondary stream. --- src/audio/music/music_pause.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/music/music_pause.c b/src/audio/music/music_pause.c index 8abdea4c14..c0038ccfba 100644 --- a/src/audio/music/music_pause.c +++ b/src/audio/music/music_pause.c @@ -1,7 +1,7 @@ #include "types.h" #include "rnc/audio/music/music_stream_state.h" -void music_pause(s32 arg0) { - if (arg0 != 0) { +void music_pause(s32 pause_secondary) { + if (pause_secondary != 0) { music_stream_state.secondary.fade_flags = -0x8000; music_stream_state.secondary.unkE = 0; } From 7725753228c7e5b0763749ab8c5a9f53564dd2e5 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:44:42 +0000 Subject: [PATCH 044/135] decomp: clarify names in mark_stream_buffer_read_active arg0 -> buffer_address: Retail 0x00225de4 positions a1 at graphics_buffer_descriptors[0].flags; 0x00225de8 loads the preceding address word and 0x00225dec compares it with parameter a0. The original Ghidra decompilation explicitly compares GraphicsBufferDescriptor.address with param_1. Source entry[-1] != arg0 performs this same selection across five 8-byte descriptors; a match ORs 4 into the corresponding flags at 0x00225dfc/0x00225e04. Thus the parameter is the buffer address used to select the descriptor to mark read active. --- src/ui/menus/mark_stream_buffer_read_active.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/menus/mark_stream_buffer_read_active.c b/src/ui/menus/mark_stream_buffer_read_active.c index 6011b21bea..226f8de452 100644 --- a/src/ui/menus/mark_stream_buffer_read_active.c +++ b/src/ui/menus/mark_stream_buffer_read_active.c @@ -3,13 +3,13 @@ s32 mark_stream_buffer_read_active(s32 arg0) __asm__("FUN_00225dd8"); -s32 mark_stream_buffer_read_active(s32 arg0) { +s32 mark_stream_buffer_read_active(s32 buffer_address) { s32 count = 0; u8 *base = (u8 *)graphics_buffer_descriptors; s32 *entry = (s32 *)(base + 4); loop: count += 1; - if (entry[-1] != arg0) { + if (entry[-1] != buffer_address) { entry += 2; if (count >= 5) { return 1; From 44d7393fdeb6fdff7ca3d2d51a2cb9c5e03c7fcb Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:44:42 +0000 Subject: [PATCH 045/135] decomp: clarify names in vo_buf_get_data arg0 -> vo_buffer: The bound source src/video/decoder/vo_buf_get_data.c (SHA-256 888e3bcecbe1d355d301eb8008154b280dc80b56b76d9d9a725cbbe81414fd3d) declares arg0 as struct VoBuf * in established vo_buf_get_data. Retail 0x0023d298 preserves incoming a0 in s0; 0x0023d2a4 and 0x0023d2ac load offsets 8 and 0 from that same object, then 0x0023d2b0-0x0023d2b4 compute offset0 + offset8 * 0xd0000. Original Ghidra likewise reads *param_1 and param_1[2]. These establish arg0 as the VoBuf object whose data is retrieved, supporting vo_buffer. --- src/video/decoder/vo_buf_get_data.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/decoder/vo_buf_get_data.c b/src/video/decoder/vo_buf_get_data.c index 0ab76c9998..0809458475 100644 --- a/src/video/decoder/vo_buf_get_data.c +++ b/src/video/decoder/vo_buf_get_data.c @@ -8,11 +8,11 @@ struct VoBuf { extern s32 FUN_0023d1f8(); s32 vo_buf_get_data(struct VoBuf *arg0) __asm__("FUN_0023d288"); -s32 vo_buf_get_data(struct VoBuf *arg0) { +s32 vo_buf_get_data(struct VoBuf *vo_buffer) { if (FUN_0023d1f8() != 0) { return 0; } - return arg0->unk0 + (arg0->unk8 * 0xD0000); + return vo_buffer->unk0 + (vo_buffer->unk8 * 0xD0000); } /* Recovered original symbol name. */ From aa4fccaf51e2fa798f1d05cb53f1d5c2367dc408 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:44:42 +0000 Subject: [PATCH 046/135] decomp: clarify names in vu1_add_vif_code arg0 -> vif_code: In the authoritative src/rendering/vu1/vu1_add_vif_code.c snapshot (SHA-256 0644d5dc3cb357b4b8beec28fd0b89a3e848d2392f435dfd898db347d1212f71), the established function vu1_add_vif_code takes s32 arg0 and stores it unchanged at render_packet_cursor.words + 12 bytes. Retail Ghidra likewise writes param_1 to g_pDmaPacketCursor[3]; instruction 0x00233968 is sw a0,0xc(v1). The preceding stores at 0x00233944, 0x00233950 and 0x0023395c emit 0x10000000, zero and zero, then 0x00233974 advances the cursor by 0x10 bytes. Thus the argument is the VIF code word appended by this established function, supporting vif_code without changing its s32 type. --- src/rendering/vu1/vu1_add_vif_code.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rendering/vu1/vu1_add_vif_code.c b/src/rendering/vu1/vu1_add_vif_code.c index 08feae674c..b4c63ded20 100644 --- a/src/rendering/vu1/vu1_add_vif_code.c +++ b/src/rendering/vu1/vu1_add_vif_code.c @@ -5,11 +5,11 @@ void vu1_add_vif_code(s32 arg0) __asm__("FUN_00233938"); -void vu1_add_vif_code(s32 arg0) { +void vu1_add_vif_code(s32 vif_code) { *render_packet_cursor.words = 0x10000000; *(s32 *)((u32)render_packet_cursor.words + 4) = 0; *(s32 *)((u32)render_packet_cursor.words + 8) = 0; - *(s32 *)((u32)render_packet_cursor.words + 12) = arg0; + *(s32 *)((u32)render_packet_cursor.words + 12) = vif_code; render_packet_cursor.words += 4; } From 678ea4894d2f81a0a88a6bc7b18dea309706dd97 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:45:57 +0000 Subject: [PATCH 047/135] decomp: clarify names in find_map_entry_slot arg0 -> map_id: The authoritative src/ui/map/find_map_entry_slot.c snapshot (SHA-256 0ccd16f4efc4e11a8d6d29544724be23d448c1c31cab2a0601b6594e7381317d) sets id = map->slot_id and compares *id == arg0 only when id[-5] != 0, returning the slot count. Original retail Ghidra compares *piVar1 with param_1. Retail 0x002050bc loads the slot ID from 0(v1), and 0x002050c0 compares it with incoming a0; 0x002050c8-0x002050cc return the matching index. The five-slot scan returns -1 at 0x002050dc-0x002050e0 on failure. Thus this s32 argument is the map ID sought by find_map_entry_slot. --- src/ui/map/find_map_entry_slot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/map/find_map_entry_slot.c b/src/ui/map/find_map_entry_slot.c index 45acd28162..ef98efc12d 100644 --- a/src/ui/map/find_map_entry_slot.c +++ b/src/ui/map/find_map_entry_slot.c @@ -4,7 +4,7 @@ s32 find_map_entry_slot(s32 arg0) __asm__("FUN_002050a0"); /* Returns the cache slot holding map id arg0, or -1. */ -s32 find_map_entry_slot(s32 arg0) { +s32 find_map_entry_slot(s32 map_id) { register struct MapState *map; register s32 *id; register s32 count = 0; @@ -12,7 +12,7 @@ s32 find_map_entry_slot(s32 arg0) { map = &level_map_selection; id = map->slot_id; do { - if (id[-5] != 0 && *id == arg0) { /* slot[count], slot_id[count] */ + if (id[-5] != 0 && *id == map_id) { /* slot[count], slot_id[count] */ return count; } count += 1; From 6a220a5258d2cfc3f5371fb99958d8d1931a5ec2 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:45:57 +0000 Subject: [PATCH 048/135] decomp: clarify names in request_audio_stream_break arg0 -> unused_parameter: The authoritative src/audio/streaming/request_audio_stream_break.c snapshot (SHA-256 ce9aada006803f19591f455f85e914c876ab14ba0799edc2a4bc510705f54775) declares s32 arg0 but never references it in the body. All 16 original retail instructions at 0x002166e8-0x00216724 leave incoming a0 unread: 0x002166fc loads the shared read_state, 0x00216700 tests it, 0x00216708 calls func_0012EEA8, and 0x00216714 stores 1 to the shared break flag. Original Ghidra likewise shows cancel_cd_read(void). Thus only its unused status is proven. --- src/audio/streaming/request_audio_stream_break.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/streaming/request_audio_stream_break.c b/src/audio/streaming/request_audio_stream_break.c index 1241d4aa05..bd41b793f0 100644 --- a/src/audio/streaming/request_audio_stream_break.c +++ b/src/audio/streaming/request_audio_stream_break.c @@ -6,7 +6,7 @@ extern s32 snd_stream_safe_cd_break() __asm__("func_0012EEA8"); void request_audio_stream_break(s32 arg0) __asm__("FUN_002166e8"); -void request_audio_stream_break(s32 arg0) { +void request_audio_stream_break(s32 unused_parameter) { if (music_stream_state.read_state != 0) { snd_stream_safe_cd_break(); music_stream_state.break_requested = 1; From c5909fdb51cd4fec504ef90a8f85d2de8a5a426d Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:45:57 +0000 Subject: [PATCH 049/135] decomp: clarify names in enable_dmac arg0 -> channel_index: Retail 0x0011916c saves incoming a0 in s1; 0x00119190 calls _EnableDmac at 0x00118800 with a0 restored from s1 in the 0x00119194 delay slot. Source enable_dmac(s32 arg0) forwards arg0 unchanged to _EnableDmac; original Ghidra names this int nChannel and identifies it as the DMAC channel index. Interrupt preservation does not modify the argument. --- src/runtime/dma/enable_dmac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/dma/enable_dmac.c b/src/runtime/dma/enable_dmac.c index 19d84cec54..69a8dc74af 100644 --- a/src/runtime/dma/enable_dmac.c +++ b/src/runtime/dma/enable_dmac.c @@ -7,7 +7,7 @@ extern s32 EnableInterrupts(); s32 enable_dmac(s32 arg0) __asm__("FUN_00119160"); -s32 enable_dmac(s32 arg0) { +s32 enable_dmac(s32 channel_index) { u32 status; s32 result; @@ -16,7 +16,7 @@ s32 enable_dmac(s32 arg0) { if (status != 0) { DIntr(); } - result = _EnableDmac(arg0); + result = _EnableDmac(channel_index); CpuSync(); if (status != 0) { EnableInterrupts(); From 69c93c14f0fd7aabbd2331d8256b0208e9885684 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:45:57 +0000 Subject: [PATCH 050/135] decomp: clarify names in set_d4_chcr arg0 -> control_value: The bound source src/video/decoder/dma/set_d4_chcr.c (SHA-256 b939f3b5919052ac7112af50689499b598b587eb07d8a70df43f9fe3dfdd7fda) writes s32 arg0 directly to volatile s32 address 0x1000B400. Retail instruction 0x0023bbc0 saves incoming a0 into s0; 0x0023bbdc/0x0023bbe8 construct 0x1000B400 in v1, and 0x0023bbf4 stores s0 there unchanged. Original Ghidra names that destination REG_DMAC_4_IPU_TO_CHCR and the parameter control, consistent with established set_d4_chcr. --- src/video/decoder/dma/set_d4_chcr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/decoder/dma/set_d4_chcr.c b/src/video/decoder/dma/set_d4_chcr.c index 292d991e7c..9737d109c5 100644 --- a/src/video/decoder/dma/set_d4_chcr.c +++ b/src/video/decoder/dma/set_d4_chcr.c @@ -5,10 +5,10 @@ extern void EnableInterrupts(void); void set_d4_chcr(s32 arg0) __asm__("FUN_0023bbb0"); -void set_d4_chcr(s32 arg0) { +void set_d4_chcr(s32 control_value) { DIntr(); *(volatile s32 *)0x1000F590 = *(volatile s32 *)0x1000F520 | 0x10000; - *(volatile s32 *)0x1000B400 = arg0; + *(volatile s32 *)0x1000B400 = control_value; *(volatile s32 *)0x1000F590 = *(volatile s32 *)0x1000F520 & 0xFFFEFFFF; EnableInterrupts(); } From 881ebcf82ee3fdee45b0112898101cb1ce71aed0 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:47:09 +0000 Subject: [PATCH 051/135] decomp: clarify names in start_display arg0 -> vblank_field_to_skip: In src/video/display/start_display.c (SHA-256 86cc71a58caa0266beb9f32e98d25578636ea24826acb7fa50e99e853bc81838), s32 arg0 is used only in sceGsSyncV(0) == arg0. Retail 0x0023b59c preserves a0 in s0; 0x0023b5a0 calls the helper identified in original Ghidra as wait_for_gs_vblank_field with a0=0; 0x0023b5b4 branches back while v0 equals s0. Only after a different field result does execution set movie_display_active to 1 and clear D_001611E4. Thus the parameter specifies the vblank field value to skip before starting display. --- src/video/display/start_display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/display/start_display.c b/src/video/display/start_display.c index e7b0484da5..2d7f9dacae 100644 --- a/src/video/display/start_display.c +++ b/src/video/display/start_display.c @@ -7,10 +7,10 @@ extern s32 sceGsSyncV(); void start_display(s32 arg0) __asm__("FUN_0023b590"); -void start_display(s32 arg0) { +void start_display(s32 vblank_field_to_skip) { do { - } while (sceGsSyncV(0) == arg0); + } while (sceGsSyncV(0) == vblank_field_to_skip); movie_display_active = 1; D_001611E4 = 0; } From fab2897358190ccfcc96a289b4989dcdd6945157 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:47:09 +0000 Subject: [PATCH 052/135] decomp: clarify names in random_angle_radians arg0 -> unused_arg: In src/math/random/random_angle_radians.c (SHA-256 04214bc736ac1cb07d5607921f7d3d17a2937ac9d9e240611e1d4610ea31c08c), s32 arg0 occurs only in the declaration and definition signatures, never in the return expression. Retail 0x00213308-0x00213354 never reads incoming a0: jal 0x001160d8 at 0x00213310 supplies v0, which is shifted at 0x00213318, masked at 0x00213328, centered at 0x00213334, converted and scaled at 0x0021333c-0x0021334c into f0. Original Ghidra likewise decompiles FUN_00213308(void). Thus unused_arg describes the retained C parameter without inventing a semantic input. --- src/math/random/random_angle_radians.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/math/random/random_angle_radians.c b/src/math/random/random_angle_radians.c index 1b067a12ba..5a2a1df14b 100644 --- a/src/math/random/random_angle_radians.c +++ b/src/math/random/random_angle_radians.c @@ -4,7 +4,7 @@ extern s32 rand(); f32 random_angle_radians(s32 arg0) __asm__("FUN_00213308"); -f32 random_angle_radians(s32 arg0) { +f32 random_angle_radians(s32 unused_arg) { return (f32)(((rand() >> 0x10) & 0xFFF) - 0x800) * 3.1415927f * 0.00048828125f; } extern __typeof__(random_angle_radians) func_00213308 __attribute__((alias("FUN_00213308"))); From 8735a87de6f85dd7622bfda123169d02db5d9570 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:47:09 +0000 Subject: [PATCH 053/135] decomp: clarify names in vo_buf_create a1 -> initial_buffer_word: In authoritative src/video/decoder/vo_buf_create.c (SHA-256 12a7142a41622599306e30383aefae37bea7b2ca96f99f1017c8287edfb9c524), s32 a1 is assigned directly to p[0], where p is the buffer cast to volatile s32*. Original retail Ghidra param_2 flows directly into *param_1. Retail 0x0023d194 is sw a1,0x0(a0), proving this parameter supplies the initial first 32-bit buffer word. Its incoming value has no further use; 0x0023d1ac overwrites register a1 with zero for the separate loop offset. --- src/video/decoder/vo_buf_create.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/decoder/vo_buf_create.c b/src/video/decoder/vo_buf_create.c index 731e2173f2..a1afe78880 100644 --- a/src/video/decoder/vo_buf_create.c +++ b/src/video/decoder/vo_buf_create.c @@ -1,13 +1,13 @@ #include "types.h" void vo_buf_create(void *buffer, s32 a1, s32 a2, s32 count) __asm__("FUN_0023d190"); -void vo_buf_create(void *buffer, s32 a1, s32 entry_base_address, s32 count) { +void vo_buf_create(void *buffer, s32 initial_buffer_word, s32 entry_base_address, s32 count) { s32 offset; volatile s32 *p; p = (volatile s32 *)buffer; p[3] = 0; - p[0] = a1; + p[0] = initial_buffer_word; p[1] = entry_base_address; p[4] = count; p[2] = 0; From 6d576858cbfd116206a80ede13292bbb5ad09ed3 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:47:09 +0000 Subject: [PATCH 054/135] decomp: clarify names in get_mpeg_timestamp arg0 -> unused_parameter: In the authoritative src/video/decoder/callbacks/get_mpeg_timestamp.c snapshot (SHA-256 484fa1129964a7474742b8bcf1d81e5c0da13b16d33c2ae4ae6842d53b234438), s32 arg0 has no body references. The original Ghidra param_1 is likewise unused. Retail 0x0023d150 overwrites incoming a0 with lui a0,0xd before any read; 0x0023d158 and 0x0023d160 form decoder_state+0xd9090 for the helper at 0x0023d164. The output instead derives from incoming a1 saved into s0 at 0x0023d154 and receives stores at 0x0023d178/0x0023d17c. Thus the first parameter is unused. --- src/video/decoder/callbacks/get_mpeg_timestamp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/decoder/callbacks/get_mpeg_timestamp.c b/src/video/decoder/callbacks/get_mpeg_timestamp.c index 8595959d00..cd4b70d57a 100644 --- a/src/video/decoder/callbacks/get_mpeg_timestamp.c +++ b/src/video/decoder/callbacks/get_mpeg_timestamp.c @@ -9,7 +9,7 @@ struct Out { }; s32 get_mpeg_timestamp(s32 arg0, struct Out *out) __asm__("FUN_0023d140"); -s32 get_mpeg_timestamp(s32 arg0, struct Out *out) { +s32 get_mpeg_timestamp(s32 unused_parameter, struct Out *out) { u64 tmp[3]; vi_buf_get_ts(decoder_state + 0xD9090, tmp); From 962c5033a9b7906e1d2137db26f0b04e2b0fb104 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:48:20 +0000 Subject: [PATCH 055/135] decomp: clarify names in clear_record_flag_by_key arg0 -> record_key: The bound source (src/audio/streaming/clear_record_flag_by_key.c, SHA-256 42068eb7f1f2d275a3033aba06f5a8c323cbe0664e93b62e13fbfa6657915b07) compares s32 arg0 only against graphics_buffer_descriptors[i].address. Retail 0x00225e38 loads the record's first word via -4(a1), and 0x00225e3c compares it with input a0. On equality, 0x00225e44 through 0x00225e54 clear bit 0x4 in the adjacent flags word; otherwise 0x00225e60 advances eight bytes through five records. Original Ghidra likewise compares descriptor.address to param_1. Thus this argument is the record lookup key, consistent with clear_record_flag_by_key. --- src/audio/streaming/clear_record_flag_by_key.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/streaming/clear_record_flag_by_key.c b/src/audio/streaming/clear_record_flag_by_key.c index 101d58550a..27d184abc0 100644 --- a/src/audio/streaming/clear_record_flag_by_key.c +++ b/src/audio/streaming/clear_record_flag_by_key.c @@ -7,11 +7,11 @@ struct KeyedFlagRecord { s32 clear_record_flag_by_key(s32 arg0) __asm__("FUN_00225e20"); -s32 clear_record_flag_by_key(s32 arg0) { +s32 clear_record_flag_by_key(s32 record_key) { s32 i; for (i = 0; i < 5; i++) { - if (graphics_buffer_descriptors[i].address == arg0) { + if (graphics_buffer_descriptors[i].address == record_key) { graphics_buffer_descriptors[i].flags &= ~4; return 0; } From f17f75adf89ec881e9453954de17f7c36e79395f Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:48:20 +0000 Subject: [PATCH 056/135] decomp: clarify names in snd_play_vag_stream_by_loc_ex_cb a8 -> request_word_6: In src/audio/streaming/snd_play_vag_stream_by_loc_ex_cb.c (snapshot SHA-256 0b96a843879fe7f91d4eb814d7fd5dc7f841f0722cb5802ae5ae837808bb108e), buf[6] = a8 copies this s32 parameter unchanged to offset 0x18 in buf. Retail 0x0012ec18 loads the ninth argument from 0x30(sp) into t4 after the 0x30-byte stack allocation; 0x0012ec5c stores t4 to 0x18(sp) in the call delay slot. At 0x0012ec2c a2 receives sp, while 0x0012ec34 and 0x0012ec3c set command 0x2c and payload length 0x1c. The original Ghidra decompilation likewise copies dwWord6 to uStack_18 and sends the 28-byte request. Thus this is zero-based request word 6; its deeper IOP meaning remains unproven. --- src/audio/streaming/snd_play_vag_stream_by_loc_ex_cb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/streaming/snd_play_vag_stream_by_loc_ex_cb.c b/src/audio/streaming/snd_play_vag_stream_by_loc_ex_cb.c index 5215e505c2..32c14d229c 100644 --- a/src/audio/streaming/snd_play_vag_stream_by_loc_ex_cb.c +++ b/src/audio/streaming/snd_play_vag_stream_by_loc_ex_cb.c @@ -16,7 +16,7 @@ void snd_play_vag_stream_by_loc_ex_cb(s32 loc, s32 size, s32 vol_l, s32 vol_r, s u64 cb_data) __asm__("FUN_0012ec08"); void snd_play_vag_stream_by_loc_ex_cb(s32 loc, s32 size, s32 vol_l, s32 vol_r, s32 pitch, s32 flags, - s32 voice, s32 channel, s32 a8, s32 id, u64 cb_data) { + s32 voice, s32 channel, s32 request_word_6, s32 id, u64 cb_data) { int new_var; s32 buf[7]; new_var = (pitch << 16) | (vol_l & 0xFFFF); @@ -29,7 +29,7 @@ void snd_play_vag_stream_by_loc_ex_cb(s32 loc, s32 size, s32 vol_l, s32 vol_r, s buf[3] = (flags << 16) | (vol_r & 0xFFFF); buf[4] = voice; buf[5] = channel; - buf[6] = a8; + buf[6] = request_word_6; snd_send_iop_command_no_wait(0x2C, 0x1C, buf, id, cb_data); } From 30023b41178c241fdefdb43f472cd68e01dbd7f6 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:48:20 +0000 Subject: [PATCH 057/135] decomp: clarify names in transform_scaled_vertex_batch arg2 -> point_indices: The original retail Ghidra signature at 0x0020cd48 identifies third argument pnPoint_indices as int *, used by FUN_002106f8(pRender_context,nPoint_count,pnPoint_indices) to resolve selected local points. Retail instructions 0x0020cd48-0x0020cd7c never overwrite incoming a2 before jal 0x002106f8 at 0x0020cd78, proving the third argument is forwarded to that resolver. The resulting a3 point buffer is then scaled, basis-transformed and translated in 16-byte steps at 0x0020cd88-0x0020cdc8. Name point_indices expresses that supplied index role while retaining the authoritative C's s32 type and unused source representation. --- src/rendering/geometry/transform_scaled_vertex_batch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rendering/geometry/transform_scaled_vertex_batch.c b/src/rendering/geometry/transform_scaled_vertex_batch.c index 9eb6993c63..db42b281e0 100644 --- a/src/rendering/geometry/transform_scaled_vertex_batch.c +++ b/src/rendering/geometry/transform_scaled_vertex_batch.c @@ -13,7 +13,7 @@ extern void func_002106F8(void); void transform_scaled_vertex_batch(struct VertexBatch *object, s32 count, s32 arg2, u8 *cursor) __asm__("FUN_0020cd48"); -void transform_scaled_vertex_batch(struct VertexBatch *object, s32 count, s32 arg2, u8 *cursor) { +void transform_scaled_vertex_batch(struct VertexBatch *object, s32 count, s32 point_indices, u8 *cursor) { f32 scale; scale = *(f32 *)((u8 *)object + 0x2C) * 0.0009765625f; From a316a0d81f4071dafb5110ef98b3d27f12222b80 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:49:30 +0000 Subject: [PATCH 058/135] decomp: clarify names in disable_intc arg0 -> intc_cause: In the supplied source, s32 arg0 is passed unchanged to _DisableIntc(arg0). Retail 0x00119034 saves incoming a0 into s1; 0x00119058 calls _DisableIntc at 0x001187f0 with delay-slot 0x0011905c restoring a0 from s1. The prepared retail decompilation identifies this same parameter as nCause, the INTC cause index. The established disable_intc name corroborates this role. --- src/runtime/interrupts/disable_intc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/interrupts/disable_intc.c b/src/runtime/interrupts/disable_intc.c index 1772a06f32..c3b43add74 100644 --- a/src/runtime/interrupts/disable_intc.c +++ b/src/runtime/interrupts/disable_intc.c @@ -7,7 +7,7 @@ extern s32 EnableInterrupts(); s32 disable_intc(s32 arg0) __asm__("FUN_00119028"); -s32 disable_intc(s32 arg0) { +s32 disable_intc(s32 intc_cause) { u32 status; s32 result; @@ -16,7 +16,7 @@ s32 disable_intc(s32 arg0) { if (status != 0) { DIntr(); } - result = _DisableIntc(arg0); + result = _DisableIntc(intc_cause); CpuSync(); if (status != 0) { EnableInterrupts(); From fc692c20067db6a1ef1798261dbaca37576f2ab4 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:49:30 +0000 Subject: [PATCH 059/135] decomp: clarify names in unpack_spr_descriptor arg0 -> descriptor: In the authoritative src/runtime/memory/unpack_spr_descriptor.c snapshot (SHA-256 57d449ddddb891437a00e309a94efb74d9ef35a3154a057ccd1b0e4036b57f17), void *arg0 becomes p via (unsigned int)arg0 | 0x20000000. Original Ghidra likewise forms piVar1 from param_1 | 0x20000000. Retail 0x001238a0-0x001238a8 ORs incoming a0 into that window and loads its first count. Loads at 0x001238b4 and 0x001238f4 fetch destination pointers at +0x8/+0xc; 0x001238c0 and 0x00123900 derive inline source runs at +0x10/+0x50, bounded by counts at +0/+4. Thus the parameter supplies the descriptor base address. --- src/runtime/memory/unpack_spr_descriptor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/memory/unpack_spr_descriptor.c b/src/runtime/memory/unpack_spr_descriptor.c index a49bf43ea5..5930ced258 100644 --- a/src/runtime/memory/unpack_spr_descriptor.c +++ b/src/runtime/memory/unpack_spr_descriptor.c @@ -19,8 +19,8 @@ */ void unpack_spr_descriptor(void *arg0) __asm__("FUN_001238a0"); -void unpack_spr_descriptor(void *arg0) { - char *p = (char *)((unsigned int)arg0 | 0x20000000); +void unpack_spr_descriptor(void *descriptor) { + char *p = (char *)((unsigned int)descriptor | 0x20000000); unsigned char *src; char *d; int i; From 4dff231efa09cd73cdd138535fca3afefe19e233 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:49:30 +0000 Subject: [PATCH 060/135] decomp: clarify names in FUN_00227140 arg0 -> render_selector: The source forwards s32 arg0 unchanged as FUN_00228598's first argument. Retail FUN_00227140 never modifies a0 before jal at 0x002271bc. In checked helper evidence 2a497e8da4564fdeac0e11266b3e9455, 0x002285cc loads each signed byte from scratchpad 0x70003000 and 0x002285d4 compares it against a0; only matching records enter the packet-copy block 0x002285dc..0x00228608. The same a0 selects alternate rendering branches via comparisons with 2 at 0x002286b8 and 0x002287d4. Thus it is a render selector, with exact selector-value meanings unresolved. --- src/ui/menus/fun_00227140.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/menus/fun_00227140.c b/src/ui/menus/fun_00227140.c index df8cc708aa..61418844c7 100644 --- a/src/ui/menus/fun_00227140.c +++ b/src/ui/menus/fun_00227140.c @@ -7,13 +7,13 @@ extern struct Mat D_001D7D90[]; extern s32 D_00160360[2] __attribute__((sda)); extern void FUN_00228598(s32, s32); -void FUN_00227140(s32 arg0, s32 slot, s32 mat) { +void FUN_00227140(s32 render_selector, s32 slot, s32 mat) { render_packet_cursor.tag->tag = 0x30000003; render_packet_cursor.tag->addr = (u32)&D_001D7D90[mat]; render_packet_cursor.tag->vif0 = 0x13000000; render_packet_cursor.tag->vif1 = 0x50000003; render_packet_cursor.tag++; - FUN_00228598(arg0, D_00160360[slot]); + FUN_00228598(render_selector, D_00160360[slot]); } extern __typeof__(FUN_00227140) func_00227140 __attribute__((alias("FUN_00227140"))); From 5f62e7acf58be3cbe799775f1e4871e4d60b83b2 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:49:30 +0000 Subject: [PATCH 061/135] decomp: clarify names in load_irx_module arg1 -> size_bytes: In src/runtime/iop/load_irx_module.c (SHA-256 7648159708e4e0da917161a4c0581ad38ade047623a48f944861959c829af13f), s32 arg1 is passed to sceSifAllocIopHeap and assigned directly to transfer.size. Retail 0x00201530 saves incoming a1 in s0; 0x0020153c passes s0 as a0 to allocation at 0x00201544; 0x00201550 stores the same value at sp+8, the size word of the DMA descriptor passed to sceSifSetDma at 0x00201564. The original Ghidra decompilation names this incoming value size_bytes and uses it for allocation and uStack_58. Together these establish the IRX image size in bytes. --- src/runtime/iop/load_irx_module.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/iop/load_irx_module.c b/src/runtime/iop/load_irx_module.c index 6f41a678d7..965dea4c82 100644 --- a/src/runtime/iop/load_irx_module.c +++ b/src/runtime/iop/load_irx_module.c @@ -14,14 +14,14 @@ extern s32 InvokeIopStatus(s32 module_id, s32 a1, s32 a2); extern void invoke_state_initializer(s32 module_id) __asm__("InvokeStateInitializer"); s32 load_irx_module(s32 irx_image, s32 arg1) __asm__("FUN_00201520"); -s32 load_irx_module(s32 irx_image, s32 arg1) { +s32 load_irx_module(s32 irx_image, s32 size_bytes) { struct sceSifDmaData transfer; s32 module_id; s32 dma_id; s32 result; - module_id = sceSifAllocIopHeap(arg1); - transfer.size = arg1; + module_id = sceSifAllocIopHeap(size_bytes); + transfer.size = size_bytes; transfer.source = irx_image; transfer.destination = module_id; transfer.attr = 0; From 21590fe90f7ed2e31f5586c255e8fd052afc2519 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:50:46 +0000 Subject: [PATCH 062/135] decomp: clarify names in random_float_between MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit arg0 -> unused_parameter: In src/math/random/random_float_between.c (SHA-256 64a2901debc7aec42e55826c14508f64a5a2e610e1a65edf2747c37467d807b2), s32 arg0 appears only in the declaration and definition parameter lists; the return expression uses only fparg0, fparg1 and rand(). Retail 0x002132a8–0x00213300 never reads incoming a0: 0x002132b4 and 0x002132c0 preserve f12/f13, 0x002132bc obtains randomness, and 0x002132c4–0x002132f4 computes the scaled float result. Original Ghidra decompilation likewise exposes only two float inputs. Thus unused_parameter describes the proven lack of use without assigning an unproved subsystem role. --- src/math/random/random_float_between.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/math/random/random_float_between.c b/src/math/random/random_float_between.c index d6364b3028..27b087e53c 100644 --- a/src/math/random/random_float_between.c +++ b/src/math/random/random_float_between.c @@ -2,7 +2,7 @@ extern s32 rand(); f32 random_float_between(s32 arg0, f32 fparg0, f32 fparg1) __asm__("FUN_002132a8"); -f32 random_float_between(s32 arg0, f32 fparg0, f32 fparg1) { +f32 random_float_between(s32 unused_parameter, f32 fparg0, f32 fparg1) { return fparg0 + ((f32)((rand() >> 0x10) & 0x7FFF) * (fparg1 - fparg0) * 0.000030517578f); } From 0afbf5ce925cafe2524d41a20ae8b8e3b3f9b8c7 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:50:46 +0000 Subject: [PATCH 063/135] decomp: clarify names in reserve_aligned_buffer_space arg0 -> decoder_state: Source forwards arg0 only to _Error(arg0, D_00153A38) after the pool capacity check fails. Retail 0x0012bc24 saves incoming a0 in t0; 0x0012bc70 restores it to a0 before jal 0x0012c328 at 0x0012bc74, with the work-area-too-small string in a1. Original retail Ghidra identifies this same first argument as MpegVideoDecoderState *pState and forwards it to report_mpeg_decoder_error. Thus decoder_state describes its proven role without changing its existing s32 type. --- src/runtime/memory/reserve_aligned_buffer_space.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/memory/reserve_aligned_buffer_space.c b/src/runtime/memory/reserve_aligned_buffer_space.c index 2c63c8e02a..0c13e7470e 100644 --- a/src/runtime/memory/reserve_aligned_buffer_space.c +++ b/src/runtime/memory/reserve_aligned_buffer_space.c @@ -10,7 +10,7 @@ extern s32 _Error(); s32 reserve_aligned_buffer_space(s32 arg0, struct BufferPool *pool, s32 size, u32 alignment) __asm__("FUN_0012bc20"); -s32 reserve_aligned_buffer_space(s32 arg0, struct BufferPool *pool, s32 size, u32 alignment) { +s32 reserve_aligned_buffer_space(s32 decoder_state, struct BufferPool *pool, s32 size, u32 alignment) { s32 start; u32 new_end; @@ -20,6 +20,6 @@ s32 reserve_aligned_buffer_space(s32 arg0, struct BufferPool *pool, s32 size, u3 pool->unk8 = new_end; return start; } - _Error(arg0, D_00153A38); + _Error(decoder_state, D_00153A38); return 0; } \ No newline at end of file From 22dc6338e7f3166f028bd0090115b22107610d7d Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:50:46 +0000 Subject: [PATCH 064/135] decomp: clarify names in send_to_spu arg3 -> staging_byte_offset: Retail caller 0x0023b088 forms t1 = loop index << 12; 0x0023b148/0x0023b164 loads a3 from decoder+0x60, and call delay slot 0x0023b17c adds t1 to a3 while a2 is 0x400 (0x0023b168). At 0x0023b194-0x0023b1d4 that position advances by 0x400 and wraps modulo 0x1000. Assigned function preserves a3 in s3 at 0x0023af2c and forwards it in a1 at 0x0023afa0 to 0x0012f148 after DMA completion; helper 0x0012f154 stores it as the second 32-bit payload word for command 0x5a (0x0012f158-0x0012f164). This proves a staging byte offset, matching source snd_update_movie_adpcm(size,arg3), rather than the DMA source or byte count. --- src/audio/decoder/send_to_spu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/decoder/send_to_spu.c b/src/audio/decoder/send_to_spu.c index 2dc8a51dc6..016f18dcec 100644 --- a/src/audio/decoder/send_to_spu.c +++ b/src/audio/decoder/send_to_spu.c @@ -8,7 +8,7 @@ extern void snd_update_movie_adpcm(s32, s32) __asm__("FUN_0012f148"); void send_to_spu(struct AudioDec *dec, s32 src, s32 size, s32 arg3) __asm__("FUN_0023af18"); -void send_to_spu(struct AudioDec *dec, s32 src, s32 size, s32 arg3) { +void send_to_spu(struct AudioDec *dec, s32 src, s32 size, s32 staging_byte_offset) { u32 descriptor[4]; s32 dma_id; @@ -22,7 +22,7 @@ void send_to_spu(struct AudioDec *dec, s32 src, s32 size, s32 arg3) { } while (dma_id == 0); while (sceSifDmaStat(dma_id) >= 0) { } - snd_update_movie_adpcm(size, arg3); + snd_update_movie_adpcm(size, staging_byte_offset); } extern __typeof__(send_to_spu) func_0023AF18 __attribute__((alias("FUN_0023af18"))); From 0c3a00fbdcec8beb1f6be9abd072bb9086460f1d Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:50:46 +0000 Subject: [PATCH 065/135] decomp: clarify names in normalize_vector_triplet arg0 -> matrix: In the authoritative source src/math/vectors/normalize_vector_triplet.c (SHA-256 9f57e465591e359d005504eede31999e81ce7d6111359a46263a6c0650e34149), f32 *arg0 initializes base, used for both gather and writeback at byte offsets i*4 for i=0..2 with src/dst advancing four floats. Retail 0x00214138 preserves incoming a0 in s1; 0x00214154 adds the row offset, 0x00214160-0x00214178 gathers three floats at 0x10-byte strides, 0x00214188 normalizes the temporary in place with magnitude 1.0, and 0x00214190-0x002141b8 writes those floats back at the same strides. This matches the original Ghidra float *matrix parameter and proves that matrix names the mutable matrix base. --- src/math/vectors/normalize_vector_triplet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/math/vectors/normalize_vector_triplet.c b/src/math/vectors/normalize_vector_triplet.c index f5f7187f02..6270352717 100644 --- a/src/math/vectors/normalize_vector_triplet.c +++ b/src/math/vectors/normalize_vector_triplet.c @@ -9,7 +9,7 @@ extern void fast_vec_normalize(f32 *, f32 *, f32) __asm__("func_001F9BF8"); void normalize_vector_triplet(f32 *arg0) __asm__("FUN_00214128"); -void normalize_vector_triplet(f32 *arg0) { +void normalize_vector_triplet(f32 *matrix) { struct Vec3Padded scratch; f32 *base; f32 *src; @@ -20,7 +20,7 @@ void normalize_vector_triplet(f32 *arg0) { s32 next; s32 count; - base = arg0; + base = matrix; i = 0; do { next = i + 1; From b800190ae86410bd25db3315285a039060eab735 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:52:02 +0000 Subject: [PATCH 066/135] decomp: clarify names in set_d3_chcr arg0 -> chcr_value: In src/video/decoder/dma/set_d3_chcr.c (SHA-256 41ec1c10844981477fa39dcc9a71ff551701159a833734dda911c6903f6e8303), s32 arg0 is stored directly to volatile s32 address 0x1000B000. Retail 0x0023bb50 saves incoming a0 into s0; 0x0023bb6c/0x0023bb78 construct 0x1000B000 in v1; 0x0023bb84 stores s0 unchanged through v1. Original Ghidra identifies this destination as REG_DMAC_3_IPU_FROM_CHCR and assigns param_1 to it, corroborating established function name set_d3_chcr. --- src/video/decoder/dma/set_d3_chcr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/decoder/dma/set_d3_chcr.c b/src/video/decoder/dma/set_d3_chcr.c index 5a805089fe..92416b6fd6 100644 --- a/src/video/decoder/dma/set_d3_chcr.c +++ b/src/video/decoder/dma/set_d3_chcr.c @@ -5,10 +5,10 @@ extern void EnableInterrupts(void); void set_d3_chcr(s32 arg0) __asm__("FUN_0023bb40"); -void set_d3_chcr(s32 arg0) { +void set_d3_chcr(s32 chcr_value) { DIntr(); *(volatile s32 *)0x1000F590 = *(volatile s32 *)0x1000F520 | 0x10000; - *(volatile s32 *)0x1000B000 = arg0; + *(volatile s32 *)0x1000B000 = chcr_value; *(volatile s32 *)0x1000F590 = *(volatile s32 *)0x1000F520 & 0xFFFEFFFF; EnableInterrupts(); } From d7bcfe25d04f8b67437277ff2ab26e097b2dbc3d Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:52:02 +0000 Subject: [PATCH 067/135] decomp: clarify names in font_print_wrapped_small arg4 -> packed_render_attributes: The s32 fifth input is saved from t0 into s4 at 0x001f6ff4, restored to t0 at 0x001f7030 and forwarded unchanged to font_print_wrapped at 0x001f7040. Helper 0x001f6cc4 moves it into s1; 0x001f6e28-0x001f6e5c preserves bits 24-31 with 0xff000000 and replaces bits 0-23 from the control-byte-selected table using 0x00ffffff. Its packed value is stored as the ninth drawing argument by sd s1,0(sp) at 0x001f6e88, 0x001f6ed4 and 0x001f6f24 before calls to emit_fixed_textured_quad. This proves packed rendering attributes without requiring exact channel semantics. --- src/ui/text/font_print_wrapped_small.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/text/font_print_wrapped_small.c b/src/ui/text/font_print_wrapped_small.c index 76e8046d5a..63d441815e 100644 --- a/src/ui/text/font_print_wrapped_small.c +++ b/src/ui/text/font_print_wrapped_small.c @@ -5,9 +5,9 @@ extern s32 font_print_wrapped() __asm__("FUN_001f6cb8"); void font_print_wrapped_small(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6) __asm__("FUN_001f6fd0"); -void font_print_wrapped_small(s32 start_x, s32 start_y, s32 wrap_width, s32 max_height, s32 arg4, s32 text, +void font_print_wrapped_small(s32 start_x, s32 start_y, s32 wrap_width, s32 max_height, s32 packed_render_attributes, s32 text, s32 byte_limit) { - font_print_wrapped(start_x, start_y, wrap_width, max_height, arg4, text, byte_limit, get_effect_texture(2), small_font_metrics); + font_print_wrapped(start_x, start_y, wrap_width, max_height, packed_render_attributes, text, byte_limit, get_effect_texture(2), small_font_metrics); } extern void func_001F6FD0(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6) From 75200450104e9127b230887a23b5089be5ac9bb0 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:52:02 +0000 Subject: [PATCH 068/135] decomp: clarify names in build_moby_bone_transform arg1 -> bone_index: In the bound source, s32 arg1 is copied into sp40 and passed by address as the sole element to FUN_00210850(moby, 1, &sp40, output_transform). Retail 0x0020ccdc stores incoming a1 at sp+0x40; 0x0020ccd8 and 0x0020cce4-0x0020cce8 pass that address with count 1. Direct helper 0x00210850/0x0021085c obtains a table via moby+0x24 then +0x1c; 0x002108a8 loads this element, 0x002108b8 shifts it by 2, and 0x002108c0-0x002108c8 selects the pointer at table+4+index*4. The selected chain's last bone byte is saved at 0x002108f8, then 0x00210950-0x00210994 uses it to copy one 0x40-byte transform from scratchpad to output. Together with established build_moby_bone_transform and its rotation/translation operations, this proves a bone-table index rather than a count or pointer. --- src/gameplay/entities/build_moby_bone_transform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gameplay/entities/build_moby_bone_transform.c b/src/gameplay/entities/build_moby_bone_transform.c index 9752ec24cf..3ac64360b8 100644 --- a/src/gameplay/entities/build_moby_bone_transform.c +++ b/src/gameplay/entities/build_moby_bone_transform.c @@ -8,13 +8,13 @@ extern void multiply_matrix(s32, void *, s32) __asm__("FUN_001fa378"); extern void FUN_00210850(struct Moby *, s32, s32 *, s32); void build_moby_bone_transform(struct Moby *arg0, s32 arg1, s32 arg2) __asm__("FUN_0020cca8"); -void build_moby_bone_transform(struct Moby *moby, s32 arg1, s32 output_transform) { +void build_moby_bone_transform(struct Moby *moby, s32 bone_index, s32 output_transform) { u8 sp_slot[0x40]; s32 sp40; f32 scale; s32 temp_16_22; - sp40 = arg1; + sp40 = bone_index; scale = (*(f32 *)((u8 *)moby + 0x2C)) * 0.0009765625f; FUN_00210850(moby, 1, &sp40, output_transform); temp_16_22 = output_transform + 0x30; From 379594b819b23975ff3a7b38325d01474c91f66f Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:53:27 +0000 Subject: [PATCH 069/135] decomp: clarify names in disable_dmac arg0 -> channel_index: The source's s32 arg0 is used only as _DisableDmac(arg0). Retail 0x00119104 saves incoming a0 in s1, and 0x00119128/0x0011912c calls _DisableDmac at 0x00118810 with that unchanged value restored to a0. The supplied original Ghidra signature names this argument nChannel and describes it as the DMAC channel index; disable_dmac preserves interrupt state around the channel operation. --- src/runtime/dma/disable_dmac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/dma/disable_dmac.c b/src/runtime/dma/disable_dmac.c index ff8cf4d9df..5caf7f0337 100644 --- a/src/runtime/dma/disable_dmac.c +++ b/src/runtime/dma/disable_dmac.c @@ -7,7 +7,7 @@ extern s32 EnableInterrupts(); s32 disable_dmac(s32 arg0) __asm__("FUN_001190f8"); -s32 disable_dmac(s32 arg0) { +s32 disable_dmac(s32 channel_index) { u32 status; s32 result; @@ -16,7 +16,7 @@ s32 disable_dmac(s32 arg0) { if (status != 0) { DIntr(); } - result = _DisableDmac(arg0); + result = _DisableDmac(channel_index); CpuSync(); if (status != 0) { EnableInterrupts(); From 3eaab697482ee492755ba543eee1cdd13041f46f Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:53:27 +0000 Subject: [PATCH 070/135] decomp: clarify names in round_float_to_decimal_places arg0 -> decimal_places: The source copies signed s32 arg0 into count, initializes value=1, and multiplies value by 10 once per positive count. Retail 0x00214c54 tests a0<=0, 0x00214c60 decrements a0, and 0x00214c74/0x00214c78 repeats multiplication by ten. At 0x00214c7c-0x00214c94 the resulting power of ten becomes floating scale and half-step; 0x00214ca0 scales the input and 0x00214cb4 divides the converted result by that scale. Thus arg0 selects the number of decimal places, consistent with the original Ghidra decimal_places parameter. --- src/math/conversion/round_float_to_decimal_places.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/math/conversion/round_float_to_decimal_places.c b/src/math/conversion/round_float_to_decimal_places.c index ce7fd74f81..cc4777cd35 100644 --- a/src/math/conversion/round_float_to_decimal_places.c +++ b/src/math/conversion/round_float_to_decimal_places.c @@ -4,13 +4,13 @@ extern s32 truncate_float_to_s32(f32) __asm__("FUN_001fa6d0"); f32 round_float_to_decimal_places(s32 arg0, f32 fparg0) __asm__("FUN_00214c48"); -f32 round_float_to_decimal_places(s32 arg0, f32 fparg0) { +f32 round_float_to_decimal_places(s32 decimal_places, f32 fparg0) { s32 count; s32 value; f32 scale; f32 half; - count = arg0; + count = decimal_places; value = 1; if (count > 0) { do { From bb9fb65dd61b5f69fd5a848c5c220224b50867de Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:53:27 +0000 Subject: [PATCH 071/135] decomp: clarify names in set_video_timing arg0 -> pal_mode_enabled: In the SHA-256-bound src/runtime/time/set_video_timing.c snapshot, s32 arg0 is used only by if (arg0 == 0). Retail 0x00214970 branches on a0 != 0 to 0x002149f0. The zero path writes 0 to g_nPalVideoMode/pal_mode at 0x002149d4 and selects approximately 1/60-second timing (0x3c888889); the nonzero path writes 1 at 0x00214a4c and selects approximately 1/50-second timing (0x3ca3d70b and 0x3ca3d70a), with frame scale 1.2 and inverse 0.8333333. Original retail Ghidra decompilation confirms the same param_1 branch and g_nPalVideoMode assignments. Thus this parameter enables PAL timing when nonzero. --- src/runtime/time/set_video_timing.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/time/set_video_timing.c b/src/runtime/time/set_video_timing.c index 2912246841..22be6afdd3 100644 --- a/src/runtime/time/set_video_timing.c +++ b/src/runtime/time/set_video_timing.c @@ -13,8 +13,8 @@ extern f32 frame_scale_inv_macro __asm__("D_0015ED68") MACRO_ADDR; extern f32 frame_time_macro __asm__("D_0015ED6C") MACRO_ADDR; extern f32 frame_time_sq_macro __asm__("D_0015ED70") MACRO_ADDR; extern f32 frame_time_cube_macro __asm__("D_0015ED74") MACRO_ADDR; -void set_video_timing(s32 arg0) { - if (arg0 == 0) { +void set_video_timing(s32 pal_mode_enabled) { + if (pal_mode_enabled == 0) { pal_mode = 0; frame_scale_macro = 1.0f; frame_scale_sq_macro = 1.0f; From b66c2f5c5ea79760b5b58da3c5ba0173664f0505 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:53:27 +0000 Subject: [PATCH 072/135] decomp: clarify names in video_callback arg0 -> unused_callback_arg: In the authoritative src/video/decoder/callbacks/video_callback.c snapshot (SHA-256 34b378102d082b3db30274afc3bf101d49c782a15063ba18d268b987b5700dd6), s32 arg0 appears only in the declaration and definition, with no body reference. The retail decompilation likewise never references param_1. The complete retail instruction range 0x0023b5f0-0x0023b724 preserves incoming a1 in s5 at 0x0023b614 and a2 in s2 at 0x0023b604, but never reads incoming a0 before overwriting it with lui a0,0x16 at 0x0023b64c and lw a0,0x120c(a0) at 0x0023b650. Therefore the first callback parameter is unused. --- src/video/decoder/callbacks/video_callback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/decoder/callbacks/video_callback.c b/src/video/decoder/callbacks/video_callback.c index 25cbbd6726..fdeda1e80e 100644 --- a/src/video/decoder/callbacks/video_callback.c +++ b/src/video/decoder/callbacks/video_callback.c @@ -24,7 +24,7 @@ extern s32 video_dec_put_ts(u8 *, s64, s64, u32, s32) __asm__("func_0023CC98"); s32 video_callback(s32 arg0, struct VdecCb *cb, struct VdecBuf *ab) __asm__("FUN_0023b5f0"); -s32 video_callback(s32 arg0, struct VdecCb *cb, struct VdecBuf *ab) { +s32 video_callback(s32 unused_callback_arg, struct VdecCb *cb, struct VdecBuf *ab) { u32 ptr0; s32 len0; u32 ptr1; From 4f2ef69cf0272ada875a10e45fc5e20f77a49897 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:54:55 +0000 Subject: [PATCH 073/135] decomp: clarify names in cosine_interpolate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit arg0 -> unused_arg: In src/math/interpolation/cosine_interpolate.c (SHA-256 29ca19bd71ac3f1b2cfb57d63649fb98d96c048a8aefdd8650f7904060b8f6c0), s32 arg0 appears only in the declaration and definition and is never referenced by the body. The complete retail instructions at 0x002133d0–0x00213460 never read the incoming integer argument register a0: f12 and f13 are saved as endpoints at 0x002133e8 and 0x002133f4, f14 is tested at 0x002133dc/0x0021340c and multiplied by pi at 0x0021342c. The original Ghidra decompilation likewise uses only first, second, and amount. Thus unused_arg is proven within this function without assigning an unknown caller-side meaning. --- src/math/interpolation/cosine_interpolate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/math/interpolation/cosine_interpolate.c b/src/math/interpolation/cosine_interpolate.c index ffde38c30e..5cf37120c5 100644 --- a/src/math/interpolation/cosine_interpolate.c +++ b/src/math/interpolation/cosine_interpolate.c @@ -4,7 +4,7 @@ extern f32 fast_cos(f32) __asm__("func_001F9DC8"); f32 cosine_interpolate(s32 arg0, f32 from, f32 to, f32 t) __asm__("FUN_002133d0"); -f32 cosine_interpolate(s32 arg0, f32 from, f32 to, f32 t) { +f32 cosine_interpolate(s32 unused_arg, f32 from, f32 to, f32 t) { if (t == 0.0f) { return from; } From 818f67c0b6d6042b95adc1ff3e908caf4e603726 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:54:55 +0000 Subject: [PATCH 074/135] decomp: clarify names in find_next_pause_page arg0 -> page: In the authoritative src/ui/menus/pause/find_next_pause_page.c snapshot (SHA-256 ce65bf0e6b407775c08bc6fbd48a7d4a9ac8a116289314e8d0687697ec5c690d), char *arg0 is examined at +0x30, advanced through *(char **)(arg0 + 0x4C), and cast to struct MenuScreen * for current->pending_focus. Retail a0 follows exactly this flow: flag loads at 0x0021b7d0/0x0021b7e8 and 0x0021b810/0x0021b82c, link loads into a0 at 0x0021b804/0x0021b83c, and a0 stored to +0x80 of the current object at 0x0021b848-0x0021b84c. The original Ghidra param_1 decompilation confirms the same flag tests, link walk and final store, proving page is the mutable page traversal pointer. --- src/ui/menus/pause/find_next_pause_page.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ui/menus/pause/find_next_pause_page.c b/src/ui/menus/pause/find_next_pause_page.c index 87c90aa87c..70f7cd425c 100644 --- a/src/ui/menus/pause/find_next_pause_page.c +++ b/src/ui/menus/pause/find_next_pause_page.c @@ -12,7 +12,7 @@ copy is retail's kept %hi. */ int find_next_pause_page(char *arg0, int reverse) __asm__("FUN_0021b7a8"); -int find_next_pause_page(char *arg0, int reverse) { +int find_next_pause_page(char *page, int reverse) { int ok = 0; int found = 0; @@ -21,28 +21,28 @@ int find_next_pause_page(char *arg0, int reverse) { } { struct MenuSystem *g = &menu_system; - if (g->unk134 != 0 && (*(int *)(arg0 + 0x30) & 8)) { + if (g->unk134 != 0 && (*(int *)(page + 0x30) & 8)) { ok = 1; } - if (g->unk138 != 0 && (*(int *)(arg0 + 0x30) & 4)) { + if (g->unk138 != 0 && (*(int *)(page + 0x30) & 4)) { ok = 1; } } while (ok) { struct MenuSystem *g = &menu_system; found = 1; - arg0 = *(char **)(arg0 + 0x4C); + page = *(char **)(page + 0x4C); ok = 0; - if (g->unk134 != 0 && (*(int *)(arg0 + 0x30) & 8)) { + if (g->unk134 != 0 && (*(int *)(page + 0x30) & 8)) { ok = 1; } - if (g->unk138 != 0 && (*(int *)(arg0 + 0x30) & 4)) { + if (g->unk138 != 0 && (*(int *)(page + 0x30) & 4)) { ok = 1; } } if (found) { struct MenuSystem *g2 = &menu_system; - g2->current->pending_focus = (struct MenuScreen *)arg0; + g2->current->pending_focus = (struct MenuScreen *)page; } return 0; } From 82b7ff17d439c3d4ee16e6c7ba47e487763bfae5 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:54:55 +0000 Subject: [PATCH 075/135] decomp: clarify names in audio_dec_create arg3 -> globals_address: In src/audio/decoder/audio_dec_create.c (SHA-256 01740fba3d046defe51bf90bc425f64c6289c26f2a133894cc7f41410fad7196), the s32 arg3 is cast to struct Globals_001612BC * and assigned directly to D_001612BC. Retail 0x0023abec preserves incoming a3 in s3; 0x0023ac54 loads 0x00160000 and 0x0023ac58 stores s3 at offset 0x12bc, establishing the destination 0x001612bc. Original Ghidra likewise records DAT_001612bc = param_4. This proves a globals address role without asserting the opaque structure's contents. --- src/audio/decoder/audio_dec_create.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/decoder/audio_dec_create.c b/src/audio/decoder/audio_dec_create.c index ef2c8b8ade..430a313ce0 100644 --- a/src/audio/decoder/audio_dec_create.c +++ b/src/audio/decoder/audio_dec_create.c @@ -7,7 +7,7 @@ extern s32 snd_init_movie_sound() __asm__("FUN_0012f068"); extern void fast_mem_zero16() __asm__("func_001F9810"); s32 audio_dec_create(struct AudioDec *dec, s32 buffer, s32 buffer_size, s32 arg3) __asm__("FUN_0023abd0"); -s32 audio_dec_create(struct AudioDec *dec, s32 buffer, s32 buffer_size, s32 arg3) { +s32 audio_dec_create(struct AudioDec *dec, s32 buffer, s32 buffer_size, s32 globals_address) { s32 movie_handle; s32 three; s32 four; @@ -26,7 +26,7 @@ s32 audio_dec_create(struct AudioDec *dec, s32 buffer, s32 buffer_size, s32 arg3 dec->totalBytesSent = 0; dec->iopZero = 0; dec->spuPos = 0; - D_001612BC = (struct Globals_001612BC *)arg3; + D_001612BC = (struct Globals_001612BC *)globals_address; four = 0x400; dec->iopBuffSize = four; movie_handle = snd_init_movie_sound(0x400, 0x1000, 0x400, 0, 5, 3); From 4ff54f78df43fafb366ed7c2369f5a19a91e1325 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:54:55 +0000 Subject: [PATCH 076/135] decomp: clarify names in draw_menu_text_box arg0 -> menu_text_box: In source src/ui/menus/draw_menu_text_box.c (SHA-256 b914f136eda755a99ca0a23919600b391b20f67461fea93e44cbb7195fcf4dd1), char *arg0 supplies box geometry, text IDs and drawing state. Retail 0x00222774 retains incoming a0 in s1; 0x002227b0-0x002227b4 passes it to PackImageDescriptor. Loads at 0x002227b8-0x002227e8 form top/bottom and left/right/center from s1+0x18, +0x1c, +0x20 and +0x24. The switch reads +0x50 at 0x002227dc, text lookup reads +0x34 at 0x00222868-0x00222884 or 0x002228f4-0x002228fc, and 0x002228ec writes the completion/space flag at +0x54. Original Ghidra param_1/iVar4 shows the same object data flow, proving the menu_text_box role. --- src/ui/menus/draw_menu_text_box.c | 34 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/ui/menus/draw_menu_text_box.c b/src/ui/menus/draw_menu_text_box.c index d62e5ec991..b92d5a39e2 100644 --- a/src/ui/menus/draw_menu_text_box.c +++ b/src/ui/menus/draw_menu_text_box.c @@ -16,7 +16,7 @@ extern void vu1_add_g_sregister(int, long) __asm__("func_00233980"); the start subtracts its own variable, which keeps retail's order. */ int draw_menu_text_box(char *arg0) __asm__("FUN_00222768"); -int draw_menu_text_box(char *arg0) { +int draw_menu_text_box(char *menu_text_box) { short box[12]; int ypos; int n; @@ -25,16 +25,16 @@ int draw_menu_text_box(char *arg0) { vu1_add_g_sregister(0x47, 0x30000); vu1_add_g_sregister(0x42, 0x8000000044L); setup_gif_paging(0); - PackImageDescriptor(box, arg0); + PackImageDescriptor(box, menu_text_box); box[9] = 9; - box[3] = *(int *)(arg0 + 0x18) + *(int *)(arg0 + 0x20); - box[0] = *(int *)(arg0 + 0x1C) + 4; - box[1] = *(int *)(arg0 + 0x1C) + *(int *)(arg0 + 0x24) - 4; - box[2] = *(int *)(arg0 + 0x18); - box[4] = *(int *)(arg0 + 0x18) + (*(int *)(arg0 + 0x20) >> 1); + box[3] = *(int *)(menu_text_box + 0x18) + *(int *)(menu_text_box + 0x20); + box[0] = *(int *)(menu_text_box + 0x1C) + 4; + box[1] = *(int *)(menu_text_box + 0x1C) + *(int *)(menu_text_box + 0x24) - 4; + box[2] = *(int *)(menu_text_box + 0x18); + box[4] = *(int *)(menu_text_box + 0x18) + (*(int *)(menu_text_box + 0x20) >> 1); box[10] = 0; box[11] = 0; - switch (*(int *)(arg0 + 0x50)) { + switch (*(int *)(menu_text_box + 0x50)) { case 1: case 2: case 3: @@ -50,26 +50,26 @@ int draw_menu_text_box(char *arg0) { case 16: case 17: case 18: - n = (*(int *)(arg0 + 0x3C) >> 4) - 4; - ypos = *(int *)(arg0 + 0x1C) - n; - for (i = 0; (*(int **)(arg0 + 0x34))[i] != -1; i++) { + n = (*(int *)(menu_text_box + 0x3C) >> 4) - 4; + ypos = *(int *)(menu_text_box + 0x1C) - n; + for (i = 0; (*(int **)(menu_text_box + 0x34))[i] != -1; i++) { box[5] = ypos; - box[11] = (*(int *)(arg0 + 0x3C) >> 4) & 0xF; + box[11] = (*(int *)(menu_text_box + 0x3C) >> 4) & 0xF; font_print_window_regular(box, 0x80FFA888L, - get_help_message_text((*(int **)(arg0 + 0x34))[i]), -1); + get_help_message_text((*(int **)(menu_text_box + 0x34))[i]), -1); ypos += box[7]; ypos += 10; } - if (ypos + 0x18 < *(int *)(arg0 + 0x1C) + *(int *)(arg0 + 0x24)) { - *(int *)(arg0 + 0x54) = 1; + if (ypos + 0x18 < *(int *)(menu_text_box + 0x1C) + *(int *)(menu_text_box + 0x24)) { + *(int *)(menu_text_box + 0x54) = 1; } break; case 4: case 11: case 15: case 19: - box[5] = *(int *)(arg0 + 0x1C) + 0x20; - font_print_window_regular(box, 0x80FFA888L, get_help_message_text(*(int *)(arg0 + 0x34)), + box[5] = *(int *)(menu_text_box + 0x1C) + 0x20; + font_print_window_regular(box, 0x80FFA888L, get_help_message_text(*(int *)(menu_text_box + 0x34)), -1); break; case 0: From 11401a197521a049d48224694c8e45ded45723bc Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:56:26 +0000 Subject: [PATCH 077/135] decomp: clarify names in enable_intc arg0 -> cause_index: The s32 arg0 in the authoritative enable_intc source is used only as _EnableIntc(arg0). Retail 0x0011909c saves incoming a0 in s1; 0x001190c4 restores s1 to a0 in the delay slot of the 0x001190c0 call to _EnableIntc at 0x001187e0. The original Ghidra decompilation identifies this unchanged argument as nCause, the INTC cause index. Status masking and interrupt preservation do not alter it. --- src/runtime/interrupts/enable_intc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/interrupts/enable_intc.c b/src/runtime/interrupts/enable_intc.c index 489226d02b..280152e5bc 100644 --- a/src/runtime/interrupts/enable_intc.c +++ b/src/runtime/interrupts/enable_intc.c @@ -7,7 +7,7 @@ extern s32 EnableInterrupts(); s32 enable_intc(s32 arg0) __asm__("FUN_00119090"); -s32 enable_intc(s32 arg0) { +s32 enable_intc(s32 cause_index) { u32 status; s32 result; @@ -16,7 +16,7 @@ s32 enable_intc(s32 arg0) { if (status != 0) { DIntr(); } - result = _EnableIntc(arg0); + result = _EnableIntc(cause_index); CpuSync(); if (status != 0) { EnableInterrupts(); From eb16c26d6ffa6bd2961af22f3062467c68d506f5 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:56:26 +0000 Subject: [PATCH 078/135] decomp: clarify names in collect_mission_ids arg3 -> use_selected_ids: In the authoritative source src/gameplay/missions/collect_mission_ids.c (SHA-256 801054431b0c186aea727b7d8f7cb62fd1b848dd6110028f8c5cf3c343aa0225), int arg3 is tested only for nonzero after out[count] = p->id. Retail 0x0020bc8c tests a3 and its delay-slot store at 0x0020bc90 writes the node ID. Zero skips to 0x0020bcb4; nonzero executes 0x0020bc94-0x0020bcb0, replacing that output with 0x523E for status 2, otherwise loading signed sel at node+0x26 and the signed short at node+0x14+2*sel. Original Ghidra param_4 shows the same conditional replacement. Thus this integer acts as a flag selecting selected IDs in place of node IDs, with the explicit status-2 constant exception. --- src/gameplay/missions/collect_mission_ids.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gameplay/missions/collect_mission_ids.c b/src/gameplay/missions/collect_mission_ids.c index 9ff12ebbb3..7ed56af931 100644 --- a/src/gameplay/missions/collect_mission_ids.c +++ b/src/gameplay/missions/collect_mission_ids.c @@ -12,7 +12,7 @@ extern MissionNode *D_001A2C20[]; int collect_mission_ids(int *out, int *mask, int *nums, int arg3) __asm__("FUN_0020bc00"); -int collect_mission_ids(int *out, int *mask, int *nums, int arg3) { +int collect_mission_ids(int *out, int *mask, int *nums, int use_selected_ids) { MissionNode *p = D_001A2C20[0]; int count = 0; int all = 1; @@ -36,7 +36,7 @@ int collect_mission_ids(int *out, int *mask, int *nums, int arg3) { } if (!(f & 2) && t != 0 && !((f & 1) && t == 2)) { out[count] = p->id; - if (arg3 != 0) { + if (use_selected_ids != 0) { out[count] = (p->status == 2) ? 0x523E : p->ids[p->sel]; } if (mask != 0 && p->status == 2) { From fb2e1a3cd37cab819980ac7ccd36336c9e6546ec Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:56:26 +0000 Subject: [PATCH 079/135] decomp: clarify names in handle_sif_set_system_register a0 -> packet: At 0x0011a428 lw v0,0x10(a0) loads the index and at 0x0011a430 lw v1,0x14(a0) loads the stored value. The source reads these same offsets through s32 *a0; original Ghidra identifies this input as SifSetSystemRegisterPacket *pPacket. Its fields supply both operands of the system-register write, proving the packet role. a1 -> command_state: At 0x0011a42c lw a2,0x1c(a1) obtains the register-table base. Instructions 0x0011a434 and 0x0011a438 scale the packet index by four and add that base, then 0x0011a440 stores the packet value. Source loads dst from s32 *a1 at +0x1c; original Ghidra types this parameter as SifCommandState *pState and uses pState->pSystemRegisters, proving the command-state role. --- src/runtime/sio/handle_sif_set_system_register.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/runtime/sio/handle_sif_set_system_register.c b/src/runtime/sio/handle_sif_set_system_register.c index d4b680d10e..a0f11468f7 100644 --- a/src/runtime/sio/handle_sif_set_system_register.c +++ b/src/runtime/sio/handle_sif_set_system_register.c @@ -4,14 +4,14 @@ array a1+0x1C at slot a0+0x10. Returns nothing (SIO calls it void). */ void handle_sif_set_system_register(s32 *a0, s32 *a1) __asm__("FUN_0011a428"); -void handle_sif_set_system_register(s32 *a0, s32 *a1) { +void handle_sif_set_system_register(s32 *packet, s32 *command_state) { s32 *dst; s32 index; s32 value; - index = *(s32 *)((u8 *)a0 + 0x10); - dst = *(s32 **)((u8 *)a1 + 0x1C); - value = *(s32 *)((u8 *)a0 + 0x14); + index = *(s32 *)((u8 *)packet + 0x10); + dst = *(s32 **)((u8 *)command_state + 0x1C); + value = *(s32 *)((u8 *)packet + 0x14); dst[index] = value; } From c3fee37696cd1036683bf638a01c6155e88b3761 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:58:20 +0000 Subject: [PATCH 080/135] decomp: clarify names in draw_menu_selection_marker arg2 -> draw_icon: Retail 0x0021f910 copies third argument a2 into s0; 0x0021f948 branches to 0x0021f974 when s0 is zero, skipping only the icon path. For nonzero values, 0x0021f950 resolves icon 0xE99E variant 1 and 0x0021f96c draws that sprite at (x-13,y-18), size 30 by 30. Both rectangle calls precede this test unconditionally. This matches source if (arg2 != 0) around draw_hud_sprite(get_icon_frame(...)), proving draw_icon is a draw-enable flag. --- src/ui/menus/draw_menu_selection_marker.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/menus/draw_menu_selection_marker.c b/src/ui/menus/draw_menu_selection_marker.c index e32c5a4c2d..e21a5f8629 100644 --- a/src/ui/menus/draw_menu_selection_marker.c +++ b/src/ui/menus/draw_menu_selection_marker.c @@ -6,10 +6,10 @@ extern s32 draw_hud_sprite() __asm__("func_001FFC30"); extern s32 append_screen_rect_packet(s32, s32, s32, s32, u64, s32) __asm__("func_00200E08"); void draw_menu_selection_marker(s32 x, s32 y, s32 arg2) __asm__("FUN_0021f8e8"); -void draw_menu_selection_marker(s32 x, s32 y, s32 arg2) { +void draw_menu_selection_marker(s32 x, s32 y, s32 draw_icon) { append_screen_rect_packet(x - 5, y - 5, x + 5, y + 5, (u64)0x80FFA888, 0); append_screen_rect_packet(x - 4, y - 4, x + 4, y + 4, (u64)panel_clear_color, 0); - if (arg2 != 0) { + if (draw_icon != 0) { draw_hud_sprite(get_icon_frame(0xE99E, 1), x - 0xD, y - 0x12, 0x1E, 0x1E, 0x80); } From 033c7170d8a18b0fa1eb270d0e45a4af3008bd78 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:58:20 +0000 Subject: [PATCH 081/135] decomp: clarify names in FUN_00221968 arg0 -> menu_screen: The bound source src/ui/menus/fun_00221968.c (SHA-256 513b525ffc99701aabb14d5eb2f0959db84daf230f3e558baceffacdd25b6dac) declares arg0 as struct MenuScreen * and uses only arg0->moby. Retail 0x00221974 preserves incoming a0 in a3; 0x002219dc and 0x00221a30 load a2 from 0x14(a3) for allocate_voice_for_target_entry at 0x002219e0 and 0x00221a2c. Original Ghidra likewise passes *(void **)(param_1 + 0x14) in both branches, proving this is the supplied menu screen containing the voice target. --- src/ui/menus/fun_00221968.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/menus/fun_00221968.c b/src/ui/menus/fun_00221968.c index 002ded431b..bcee75b7b2 100644 --- a/src/ui/menus/fun_00221968.c +++ b/src/ui/menus/fun_00221968.c @@ -7,7 +7,7 @@ #include "rnc/ui/menus/menu_globals.h" extern s32 allocate_voice_for_target_entry() __asm__("func_0022DA68"); -s32 FUN_00221968(struct MenuScreen *arg0) { +s32 FUN_00221968(struct MenuScreen *menu_screen) { if (controller_state.pressed_unmasked & PAD_TRIANGLE) { if (menu_system.current->back != 0) { menu_system.next = menu_system.current->back; @@ -18,14 +18,14 @@ s32 FUN_00221968(struct MenuScreen *arg0) { selected_level_index[0] = current_level_index; return 1; } else if (controller_state.pressed_unmasked & PAD_CROSS) { - allocate_voice_for_target_entry(0, 0x11, arg0->moby); + allocate_voice_for_target_entry(0, 0x11, menu_screen->moby); return 1; } else if (controller_state.pressed_unmasked & PAD_CIRCLE) { menu_system.unkE4 = selected_level_index[0]; menu_system.unkF0 = menu_system.current; menu_system.close_request = 3; menu_system.unkF4 = 0xF; - allocate_voice_for_target_entry(0, 0x11, arg0->moby); + allocate_voice_for_target_entry(0, 0x11, menu_screen->moby); } return 0; } From 7be8617c848c9da56e9a351add37ce3f58b4e3e2 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:58:20 +0000 Subject: [PATCH 082/135] decomp: clarify names in update_world_object_animation arg0 -> unused_arg: In the authoritative src/world/animation/update_world_object_animation.c snapshot (SHA-256 8df76dd511ecbf5716548390eb708e5c975cffbdb8cfea5581f51e9fb0171f01), void *arg0 appears only in the declaration and definition, never in the body. Retail 0x00204794 overwrites a0 with zero before any read or save of its incoming value, then 0x002047c4 calls FlushCache. Workspace input instead comes from global state via lw a1,0x58(s1) at 0x002047cc and lw s2,0x58(s1) at 0x002047e0. The prepared original Ghidra decompilation likewise declares FUN_00204790(void). Thus unused_arg describes proven non-use without assigning an unsupported pointer purpose. --- src/world/animation/update_world_object_animation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/world/animation/update_world_object_animation.c b/src/world/animation/update_world_object_animation.c index a405fff450..2d4518ce82 100644 --- a/src/world/animation/update_world_object_animation.c +++ b/src/world/animation/update_world_object_animation.c @@ -81,7 +81,7 @@ extern struct Moby *func_0020D348_m(int) __asm__("FUN_0020c4f8"); void update_world_object_animation(void *arg0) __asm__("FUN_00204790"); extern s32 game_mode_macro __asm__("D_0015F604") MACRO_ADDR; -void update_world_object_animation(void *arg0) { +void update_world_object_animation(void *unused_arg) { struct ModelRec *rec; struct Moby *mob; int *cp; From 6a51c2b48b7dbb98ef432d83f6463122c71ecfcf Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:58:20 +0000 Subject: [PATCH 083/135] decomp: clarify names in _isOutSizeOK arg0 -> decoder: The snapshot types arg0 as struct MpegDecoder *. Retail 0x00129814 saves a0 in s0; 0x0012981c, 0x00129828 and 0x00129854 read its output limits at +0xe0, +0xdc and +0xe4. At 0x00129884 the same pointer is passed to _Error, agreeing with the original Ghidra decoder-state argument. arg1 -> reference_image: The snapshot types arg1 as struct MpegRefImage *. Retail 0x00129824 copies a1 to a2; 0x0012982c and 0x0012983c load its +4 width and +8 height for comparison with decoder limits. At 0x0012986c and 0x00129874 those same dimensions feed the 'Too small buffer size for %dx%d picture' diagnostic, matching the original Ghidra second argument. s1 -> out_size_ok: Retail 0x00129838 sets s1 to zero on width failure; 0x00129840-0x00129848 invert the height-exceeds-limit comparison, and 0x0012985c-0x00129860 invert the product-exceeds-size-limit comparison. At 0x00129864 nonzero skips the error path, while 0x00129868/0x00129890 return s1. This matches source return s1 and original Ghidra boolean bVar1. --- src/sdk/library/is_out_size_ok.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/sdk/library/is_out_size_ok.c b/src/sdk/library/is_out_size_ok.c index 607a376f6e..d845f7b57c 100644 --- a/src/sdk/library/is_out_size_ok.c +++ b/src/sdk/library/is_out_size_ok.c @@ -5,34 +5,34 @@ const u8 D_00153980[] = "Too small buffer size for %dx%d picture\n"; extern s32 _Error(void *a, void *b); extern s32 sprintf(char *d, char *f, ...); -s32 _isOutSizeOK(struct MpegDecoder *arg0, struct MpegRefImage *arg1) { +s32 _isOutSizeOK(struct MpegDecoder *decoder, struct MpegRefImage *reference_image) { char sp_slot[0x100]; s32 t; int new_var2; struct MpegRefImage *new_var; - s32 s1; - t = arg0->out_max_height; + s32 out_size_ok; + t = decoder->out_max_height; if (t != 0) { - s1 = 0; - new_var = arg1; - if (arg0->out_max_width < arg1->width) { + out_size_ok = 0; + new_var = reference_image; + if (decoder->out_max_width < reference_image->width) { goto tail; } - new_var2 = t < arg1->height; - if (arg1->unk10) { - s1 = (t < new_var->height) ^ 1; + new_var2 = t < reference_image->height; + if (reference_image->unk10) { + out_size_ok = (t < new_var->height) ^ 1; goto tail; } else { - s1 = new_var2 ^ 1; + out_size_ok = new_var2 ^ 1; goto tail; } } else { - s1 = (arg0->out_max_size < (arg1->unkC * arg1->unk10)) ^ 1; + out_size_ok = (decoder->out_max_size < (reference_image->unkC * reference_image->unk10)) ^ 1; } tail: - if (s1 == 0) { - sprintf(sp_slot, (char *)D_00153980, arg1->width, arg1->height); - _Error(arg0, sp_slot); + if (out_size_ok == 0) { + sprintf(sp_slot, (char *)D_00153980, reference_image->width, reference_image->height); + _Error(decoder, sp_slot); } - return s1; + return out_size_ok; } From 85a81a67c8b2963449d6288a7292765657f2cfb7 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:00:12 +0000 Subject: [PATCH 084/135] decomp: clarify names in update_audio_stream_until_idle arg0 -> wait_for_completion: In the bound source src/audio/streaming/update_audio_stream_until_idle.c (SHA-256 4df92f1e4f0a5f422b93c0786faa94d4ac212ad2c6ea0cbb292875d92f0d02a9), s32 arg0 is used only by if (arg0 != 0). Retail 0x002168b4 branches on incoming a0 == 0 to 0x00216914, which runs one service cycle and returns. Nonzero checks the signed read-state halfword at 0x001516d8 (0x002168c4), calls sceGsSyncV(0) at 0x002168d8, services the stream, and repeats at 0x00216904 while that halfword is nonzero. The original Ghidra nWait_for_completion parameter has the same control flow; this proves wait_for_completion is a mode flag, preserving its s32 type. --- src/audio/streaming/update_audio_stream_until_idle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/streaming/update_audio_stream_until_idle.c b/src/audio/streaming/update_audio_stream_until_idle.c index 7e0cf336b0..32c4873767 100644 --- a/src/audio/streaming/update_audio_stream_until_idle.c +++ b/src/audio/streaming/update_audio_stream_until_idle.c @@ -9,8 +9,8 @@ extern s32 music_update() __asm__("func_00216290"); extern s32 sceGsSyncV(); s16 update_audio_stream_until_idle(s32 arg0) __asm__("FUN_002168a8"); -s16 update_audio_stream_until_idle(s32 arg0) { - if (arg0 != 0) { +s16 update_audio_stream_until_idle(s32 wait_for_completion) { + if (wait_for_completion != 0) { if (music_stream_state.read_state != 0) { do { sceGsSyncV(0); From 934a91407ecaa9e6716edff790c70356a14cdef3 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:00:13 +0000 Subject: [PATCH 085/135] decomp: clarify names in draw_selected_item_ammo arg0 -> image_descriptor_input: In src/ui/menus/draw_selected_item_ammo.c (SHA-256 c26bb5aa1d9a695d73b7b4bb25391a0bbe67dcbb2322cec4ef6ddcd816324f88), s32 arg0 is used only as the second argument of PackImageDescriptor((s32 *)descriptor, arg0). Retail 0x0021f16c preserves incoming a0 in s3; 0x0021f2cc moves s3 to a1, and 0x0021f2d0 calls 0x00226778 with a0 = sp+0x50 (descriptor destination). The original Ghidra decompilation likewise passes param_1 to FUN_00226778(auStack_70,param_1). That destination is subsequently passed to font_print_window_regular at 0x0021f2fc, proving the argument supplies the image descriptor construction input for the ammo text window. --- src/ui/menus/draw_selected_item_ammo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/menus/draw_selected_item_ammo.c b/src/ui/menus/draw_selected_item_ammo.c index df7b9256ab..648e6fa9c8 100644 --- a/src/ui/menus/draw_selected_item_ammo.c +++ b/src/ui/menus/draw_selected_item_ammo.c @@ -24,7 +24,7 @@ extern void vu1_add_g_sregister(s32, s32) __asm__("func_00233980"); extern s32 sprintf(); s32 draw_selected_item_ammo(s32 arg0) __asm__("FUN_0021f158"); -s32 draw_selected_item_ammo(s32 arg0) { +s32 draw_selected_item_ammo(s32 image_descriptor_input) { u8 sp_slot[0x50]; u8 descriptor[0x20]; s16 temp_4_20; @@ -61,7 +61,7 @@ s32 draw_selected_item_ammo(s32 arg0) { } } setup_gif_paging(0); - PackImageDescriptor((s32 *)descriptor, arg0); + PackImageDescriptor((s32 *)descriptor, image_descriptor_input); *(s16 *)(descriptor + 0x10) = 0x10; *(s16 *)(descriptor + 0x12) = 3; font_print_window_regular((s32 *)descriptor, (((u64)0x80FF << 0x10) | 0xA888), sp_slot, -1); From 21376b03d53153e0bc69942e3bc1171da46c15ce Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:00:13 +0000 Subject: [PATCH 086/135] decomp: clarify names in decode_motion_vector arg0 -> motion_vector: In established decode_motion_vector, retail 0x001280a8 preserves a0 in t2, 0x001280b0 loads the existing signed vector through that pointer, and 0x0012812c stores the updated vector through the same pointer. The authoritative C likewise reads *arg0 and writes the reconstructed, range-wrapped result to *arg0. arg1 -> delta_shift: Retail a1 controls sllv at 0x001280b4 for the 0x10 range limit, at 0x001280cc for positive (motion_code - 1), and at 0x00128100 for negative ~motion_code. Source arg1 is exactly this shared shift count for the decoded delta magnitude and its wrap range. arg2 -> motion_code: Retail a2 selects positive, zero, and negative reconstruction at 0x001280bc and 0x001280f0. Positive codes contribute 1 + ((a2 - 1) << a1) + a3; negative codes subtract 1 + ((~a2) << a1) + a3 at 0x001280fc-0x0012810c. Zero leaves the vector unchanged apart from the optional unit conversion. This proves arg2 is the signed motion delta code in decode_motion_vector. arg3 -> motion_residual: Retail a3 is added to the shifted code magnitude at 0x001280d0 and 0x00128108, before that magnitude is respectively added to or subtracted from the vector. Source arg3 occurs only in (((arg2 - 1) << arg1) + arg3) and ((~arg2 << arg1) + arg3), proving its residual contribution to the decoded motion delta. --- src/sdk/library/decode_motion_vector.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/sdk/library/decode_motion_vector.c b/src/sdk/library/decode_motion_vector.c index c9ced751f3..588cc6a76a 100644 --- a/src/sdk/library/decode_motion_vector.c +++ b/src/sdk/library/decode_motion_vector.c @@ -3,7 +3,7 @@ void decode_motion_vector(s32 *arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) __asm__("FUN_001280a8"); -void decode_motion_vector(s32 *arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { +void decode_motion_vector(s32 *motion_vector, s32 delta_shift, s32 motion_code, s32 motion_residual, s32 arg4) { int new_var; s32 temp_4_5; int new_var3; @@ -11,13 +11,13 @@ void decode_motion_vector(s32 *arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { s32 temp_9_6; s32 var_2_17; s32 var_4_9; - temp_4_5 = *arg0; + temp_4_5 = *motion_vector; new_var = 1; - temp_9_6 = 0x10 << arg1; + temp_9_6 = 0x10 << delta_shift; var_4_9 = (arg4 != 0) ? (temp_4_5 >> new_var) : (temp_4_5); - new_var3 = arg2 > 0; + new_var3 = motion_code > 0; if (new_var3) { - var_4_9 = (var_4_9 + new_var) + (((arg2 - new_var) << arg1) + arg3); + var_4_9 = (var_4_9 + new_var) + (((motion_code - new_var) << delta_shift) + motion_residual); var_2_17 = var_4_9 * 2; if (var_4_9 >= temp_9_6) { var_4_9 -= temp_9_6 * 2; @@ -25,9 +25,9 @@ void decode_motion_vector(s32 *arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { } } else { var_2_17 = var_4_9 * 2; - if (arg2 < 0) { - new_var2 = (~arg2) << arg1; - var_4_9 = (var_4_9 - new_var) - (new_var2 + arg3); + if (motion_code < 0) { + new_var2 = (~motion_code) << delta_shift; + var_4_9 = (var_4_9 - new_var) - (new_var2 + motion_residual); if (var_4_9 < (-temp_9_6)) { temp_9_6 = temp_9_6 * 2; new_var3 = temp_9_6; @@ -41,13 +41,13 @@ void decode_motion_vector(s32 *arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { ; } } - if (arg2) { + if (motion_code) { { new_var3 = arg4 != 0; } - *arg0 = (new_var3) ? (var_4_9 * 2) : (var_4_9); + *motion_vector = (new_var3) ? (var_4_9 * 2) : (var_4_9); } else { - *arg0 = (arg4 != 0) ? (var_4_9 * 2) : (var_4_9); + *motion_vector = (arg4 != 0) ? (var_4_9 * 2) : (var_4_9); } } From 7b4b966ce06b0d8bd90d88e73e094b8c561eba57 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:01:41 +0000 Subject: [PATCH 087/135] decomp: clarify names in select_next_stream_buffer arg0 -> require_low_flag_bit: In the authoritative src/audio/streaming/select_next_stream_buffer.c snapshot (SHA-256 eded3c360fa32672f0f439fe47a46ef12422a773d202fe3865562ee409fb6bd6), s32 arg0 is used only to choose flags versus flags ^ 1 before testing !(f & 1). Original Ghidra param_1 has the same predicate. Retail 0x00225c40 branches on a0 == 0; 0x00225c48-0x00225c50 loads flags and XORs bit 0 only for nonzero a0, while 0x00225c54 loads flags unchanged for zero. The mask at 0x00225c58 and skip at 0x00225c5c therefore require original bit 0 set for nonzero input and clear for zero input. Subsequent checks require a nonzero address and flags bit 1 clear before selecting the buffer. --- src/audio/streaming/select_next_stream_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/streaming/select_next_stream_buffer.c b/src/audio/streaming/select_next_stream_buffer.c index 53c7b6aebc..0141a02c6d 100644 --- a/src/audio/streaming/select_next_stream_buffer.c +++ b/src/audio/streaming/select_next_stream_buffer.c @@ -5,12 +5,12 @@ extern s32 get_stream_buffer_size() __asm__("func_00225D88"); s32 select_next_stream_buffer(s32 arg0) __asm__("FUN_00225c18"); -s32 select_next_stream_buffer(s32 arg0) { +s32 select_next_stream_buffer(s32 require_low_flag_bit) { s32 i; s32 f; for (i = 0; i < 5; i++) { - if (arg0 != 0) { + if (require_low_flag_bit != 0) { f = graphics_buffer_descriptors[i].flags ^ 1; } else { f = graphics_buffer_descriptors[i].flags; From 0eaa09de94874169375b26f88bbec3f7cce87e0b Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:01:42 +0000 Subject: [PATCH 088/135] decomp: clarify names in draw_quit_game_menu arg0 -> quit_menu: The authoritative src/ui/menus/draw_quit_game_menu.c snapshot (SHA-256 40013ba783fa6b2ab971e92faf3ae974214bbf180c85d2aec69bf6cb865d543a) types arg0 as struct QuitMenu*. Retail 0x0021e8b4 preserves incoming a0 in s3; 0x0021e8c4 and 0x0021e8cc read its +0x20 and +0x24 values. The first is halved for font_print_center at 0x0021e97c and reloaded at 0x0021e9b4 to subtract maximum measured option text width before halving at 0x0021e9c8. The second supplies text positions minus 0x40, 0x28 and 0x14 at 0x0021e8fc, 0x0021e904 and 0x0021e90c. The original Ghidra decompilation shows the same param_1 reads and rendering flow. Together with the established draw_quit_game_menu name, this proves the parameter is the quit-menu object providing layout inputs. --- src/ui/menus/draw_quit_game_menu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ui/menus/draw_quit_game_menu.c b/src/ui/menus/draw_quit_game_menu.c index 6b4b61d5eb..e2b9233711 100644 --- a/src/ui/menus/draw_quit_game_menu.c +++ b/src/ui/menus/draw_quit_game_menu.c @@ -24,7 +24,7 @@ extern void vu1_add_g_sregister() __asm__("func_00233980"); extern void memset() __asm__("func_001153FC"); s32 draw_quit_game_menu(struct QuitMenu *arg0) __asm__("FUN_0021e890"); -s32 draw_quit_game_menu(struct QuitMenu *arg0) { +s32 draw_quit_game_menu(struct QuitMenu *quit_menu) { unsigned long new_var; s16 packet[0xC]; s32 temp_16_69; @@ -33,8 +33,8 @@ s32 draw_quit_game_menu(struct QuitMenu *arg0) { s32 temp_18_25; s32 temp_2_73; s32 temp_16_16; - temp_16_16 = arg0->unk20; - temp_17_18 = arg0->unk24; + temp_16_16 = quit_menu->unk20; + temp_17_18 = quit_menu->unk24; memset(packet, 0, 0x18); temp_18_25 = (s32)(temp_16_16 + (((u32)temp_16_16) >> 0x1F)); temp_18_25 = temp_18_25 >> 1; @@ -55,7 +55,7 @@ s32 draw_quit_game_menu(struct QuitMenu *arg0) { temp_16_69 = measure_text_width_regular(get_help_message_text(0x524B), -1); temp_2_73 = measure_text_width_regular(get_help_message_text(0x524F), -1); temp_17_81 = - ((s32)(arg0->unk20 - ((temp_2_73 >= temp_16_69) ? (temp_2_73) : (temp_16_69)))) >> 1; + ((s32)(quit_menu->unk20 - ((temp_2_73 >= temp_16_69) ? (temp_2_73) : (temp_16_69)))) >> 1; font_print_large(temp_17_81, temp_17_18 - 0x28, 0x80FFA888, get_help_message_text(0x524B), -1); font_print_large(temp_17_81, temp_17_18 - 0x14, 0x80FFA888, get_help_message_text(0x524F), -1); do_gif_paging(); From 245a10c6dba33767056ace6c3d24756f8124f90c Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:01:42 +0000 Subject: [PATCH 089/135] decomp: clarify names in _skipMB0 arg0 -> decoder: In src/sdk/library/skip_mb0.c (SHA-256 2c06ba0a9f4a6f0ee0f8f2c95b861fb2c86420dce231ec87b0125e3c8025f696), arg0 has type struct MpegDecoder *. Retail a0 loads mb_buf_index at 0x00127b5c (offset 0x810), sets dc_reset at 0x00127b6c (offset 0x1b0), reads picture_coding_type at 0x00127b70/0x00127bb8 and picture_structure at 0x00127b8c/0x00127ba4, and passes the same decoder to _Error at 0x00127bcc. These accesses prove decoder-state ownership. arg4 -> flags: The source declares arg4 as s32 * and uses it only in *arg4 &= ~1. Retail preserves the fifth argument t0 in s0 at 0x00127b54, loads its pointed word at 0x00127bc4 or 0x00127bd8, ANDs it with -2 at 0x00127be8, and stores it back at 0x00127bec. Original Ghidra likewise shows *param_5 = uVar2 & 0xfffffffe, proving an in-place flags word with bit 0 cleared while preserving every other bit. --- src/sdk/library/skip_mb0.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/sdk/library/skip_mb0.c b/src/sdk/library/skip_mb0.c index b0acb074b9..8d2909449a 100644 --- a/src/sdk/library/skip_mb0.c +++ b/src/sdk/library/skip_mb0.c @@ -15,34 +15,34 @@ struct MpegMotionRef { extern u8 D_00153868[]; extern s32 _Error(struct MpegDecoder *a0, u8 *a1); -s32 _skipMB0(struct MpegDecoder *arg0, struct MpegSkipState *arg1, s32 *arg2, struct MpegMotionRef *arg3, - s32 *arg4) { +s32 _skipMB0(struct MpegDecoder *decoder, struct MpegSkipState *arg1, s32 *arg2, struct MpegMotionRef *arg3, + s32 *flags) { s32 temp_10_11; s32 temp_2_32; s32 var_9_6; var_9_6 = 1; - temp_10_11 = arg0->mb_buf_index * 0x140; - *(s32 *)((u8 *)(((u8 *)arg0 + (temp_10_11))) + 0x6CC) = 1; - arg0->dc_reset = 1; - if (arg0->picture_coding_type == 2) { + temp_10_11 = decoder->mb_buf_index * 0x140; + *(s32 *)((u8 *)(((u8 *)decoder + (temp_10_11))) + 0x6CC) = 1; + decoder->dc_reset = 1; + if (decoder->picture_coding_type == 2) { arg1->unk14 = 0; arg1->unk10 = 0; arg1->unk4 = 0; arg1->unk0 = 0; } - if (arg0->picture_structure == 3) { + if (decoder->picture_structure == 3) { *arg2 = 2; } else { *arg2 = 1; - temp_2_32 = arg0->picture_structure == 2; + temp_2_32 = decoder->picture_structure == 2; arg3->unk4 = temp_2_32; arg3->unk0 = temp_2_32; } - if (arg0->picture_coding_type == 1) { - _Error(arg0, D_00153868); + if (decoder->picture_coding_type == 1) { + _Error(decoder, D_00153868); var_9_6 = 0; } - *arg4 &= ~1; + *flags &= ~1; return var_9_6; } From 19f10d86f254e3bd810631bbeba366f7be6cf8d5 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:01:42 +0000 Subject: [PATCH 090/135] decomp: clarify names in _lshift arg1 -> input_bigint: The source types arg1 as struct Bigint * and reads its _k, _maxwds, _wds and _x. Retail 0x00115b8c preserves a1 in s1; 0x00115ba0 reads its word count at +0x10, 0x00115bc0/0x00115bf0 forms its data pointer at +0x14, and 0x00115c50-0x00115c74 reads its words to construct the separately allocated shifted result. Original Ghidra param_2 follows the same input-word flow. arg2 -> shift_bits: Source computes n = arg2 >> 5, writes n low zero words, then masks arg2 with 0x1F and shifts input words left by that remainder while carrying high bits. Retail 0x00115b84 computes a2 >> 5; 0x00115bbc/0x00115bec masks a2 by 0x1f; 0x00115c10-0x00115c24 writes whole zero words; 0x00115c54 performs sllv by the remainder and 0x00115c48/0x00115c74 extracts carry using 32 minus that remainder. Original Ghidra param_3 has identical bit-count use. --- src/sdk/library/lshift.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/sdk/library/lshift.c b/src/sdk/library/lshift.c index 1c58929b61..4705ac0912 100644 --- a/src/sdk/library/lshift.c +++ b/src/sdk/library/lshift.c @@ -33,7 +33,7 @@ struct Bigint { extern struct Bigint *_Balloc(s32, s32); extern s32 InsertLinkObject(); -struct Bigint *_lshift(s32 arg0, struct Bigint *arg1, s32 arg2) { +struct Bigint *_lshift(s32 arg0, struct Bigint *input_bigint, s32 shift_bits) { s32 i; s32 k1; s32 n; @@ -44,10 +44,10 @@ struct Bigint *_lshift(s32 arg0, struct Bigint *arg1, s32 arg2) { u32 *xe; u32 z; - n = arg2 >> 5; - k1 = arg1->_k; - n1 = n + arg1->_wds + 1; - for (i = arg1->_maxwds; n1 > i; i <<= 1) { + n = shift_bits >> 5; + k1 = input_bigint->_k; + n1 = n + input_bigint->_wds + 1; + for (i = input_bigint->_maxwds; n1 > i; i <<= 1) { k1++; } b1 = _Balloc(arg0, k1); @@ -55,13 +55,13 @@ struct Bigint *_lshift(s32 arg0, struct Bigint *arg1, s32 arg2) { for (i = 0; i < n; i++) { *x1++ = 0; } - x = arg1->_x; - xe = x + arg1->_wds; - if (arg2 &= 0x1F) { - k1 = 32 - arg2; + x = input_bigint->_x; + xe = x + input_bigint->_wds; + if (shift_bits &= 0x1F) { + k1 = 32 - shift_bits; z = 0; do { - *x1++ = *x << arg2 | z; + *x1++ = *x << shift_bits | z; z = *x++ >> k1; } while (x < xe); if ((*x1 = z) != 0) { @@ -73,6 +73,6 @@ struct Bigint *_lshift(s32 arg0, struct Bigint *arg1, s32 arg2) { } while (x < xe); } b1->_wds = n1 - 1; - InsertLinkObject(arg0, arg1); + InsertLinkObject(arg0, input_bigint); return b1; } From c0398771a323b65266b226cdcdb8fa737d4100a8 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:03:39 +0000 Subject: [PATCH 091/135] decomp: clarify names in vu0_load_micro_program arg0 -> dma_tag_address: Retail 0x002334ec preserves incoming a0 in s1; 0x0023353c masks s1 with 0x0FFFFFFF and 0x00233544 stores the result at 0x10008030, identified in the original Ghidra decompilation as REG_DMAC_0_VIF0_TADR. The source snapshot performs the identical arg0 mask/store, after clearing QWC and before writing CHCR=0x145. Thus the parameter supplies the DMA tag address. --- src/rendering/vu0/vu0_load_micro_program.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rendering/vu0/vu0_load_micro_program.c b/src/rendering/vu0/vu0_load_micro_program.c index f111353c8b..1171a5d126 100644 --- a/src/rendering/vu0/vu0_load_micro_program.c +++ b/src/rendering/vu0/vu0_load_micro_program.c @@ -4,14 +4,14 @@ extern void SpinWait(s32); void vu0_load_micro_program(s32 arg0) __asm__("FUN_002334d8"); -void vu0_load_micro_program(s32 arg0) { +void vu0_load_micro_program(s32 dma_tag_address) { if ((*(volatile u32 *)0x10008000 & 0x100) != 0) { do { SpinWait(0x10); } while ((*(volatile u32 *)0x10008000 & 0x100) != 0); } *(volatile u32 *)0x10008020 = 0; - *(volatile u32 *)0x10008030 = arg0 & 0x0FFFFFFF; + *(volatile u32 *)0x10008030 = dma_tag_address & 0x0FFFFFFF; *(volatile u32 *)0x10008000 = 0x145; if ((*(volatile u32 *)0x10008000 & 0x100) != 0) { do { From 77ad8aa04670ce35f1abb9eb47040256da32f08a Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:03:39 +0000 Subject: [PATCH 092/135] decomp: clarify names in transition_default_draw arg0 -> unused_parameter: In authoritative src/gameplay/state/transition_default_draw.c (SHA-256 b1d3131b67d315d0b0027c29580f530e05b7f8a49094062ae2ecf509c3e2426d), s32 *arg0 occurs only in the declaration and definition parameter lists; the function body never reads, dereferences, writes or forwards it. The supplied original retail decompilation is void render_gameplay_frame(void), with no parameter-dependent expression. Retail 0x001eb410-0x001eb73c never saves or dereferences incoming a0; 0x001eb42c/0x001eb438 and 0x001eb440 establish 0x193fc0 for fill_transfer_words. This proves an unused source parameter, without identifying its intended pointee. --- src/gameplay/state/transition_default_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gameplay/state/transition_default_draw.c b/src/gameplay/state/transition_default_draw.c index e1a9119207..2db0e7222a 100644 --- a/src/gameplay/state/transition_default_draw.c +++ b/src/gameplay/state/transition_default_draw.c @@ -51,7 +51,7 @@ extern s32 draw_ties_1() __asm__("func_002358C8"); extern s32 light_ties() __asm__("func_00237370"); void transition_default_draw(s32 *arg0) __asm__("FUN_001eb410"); -void transition_default_draw(s32 *arg0) { +void transition_default_draw(s32 *unused_parameter) { s32 n; if (D_0016045C == 0 || D_0016045C->unk4 != 0) { From 6fc03f370e4a9410349d491eb210ff157e0ca84a Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:03:39 +0000 Subject: [PATCH 093/135] decomp: clarify names in sceMcSync arg0 -> poll_mode: In the bound source, s32 arg0 initializes wait_flag. Retail 0x00123c54 saves a0 in s2; 0x00123c7c skips the waiting loop when s2 is nonzero. When zero and RPC is pending, 0x00123ca0 repeatedly checks RPC and 0x00123c98 sleeps for 0x3c until complete. Thus zero blocks and nonzero polls. arg1 -> active_code_out: In the bound source, s32 *arg1 initializes code_out, which receives D_00132DA8[0]. Retail 0x00123c4c saves a1 in s4; 0x00123cb0 checks it for NULL, and 0x00123cb8-0x00123cbc load the active code from 0x00132da8 and store it through s4. This same code gates the initial -1 return and is cleared on completion at 0x00123ccc. arg2 -> completion_status_out: In the bound source, s32 *arg2 initializes status_out. Retail 0x00123c44 saves a2 in s5; after 0x00123cb4 converts RPC-not-pending into completion, 0x00123cc0 gates the completion path, 0x00123cc8 checks s5 for NULL, and 0x00123cd0-0x00123cd8 copy the word at 0x0015afc0 through s5 before SignalSema. It is therefore the optional completion status output. --- src/sdk/storage/memory_card/sce_mc_sync.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sdk/storage/memory_card/sce_mc_sync.c b/src/sdk/storage/memory_card/sce_mc_sync.c index 4999a6a899..aacb4105e9 100644 --- a/src/sdk/storage/memory_card/sce_mc_sync.c +++ b/src/sdk/storage/memory_card/sce_mc_sync.c @@ -6,11 +6,11 @@ extern u32 D_0015AFC0[]; extern s32 SceSifCheckStatRpc(); extern s32 SignalSema(); extern s32 mcDelayThread(); -s32 sceMcSync(s32 arg0, s32 *arg1, s32 *arg2) { +s32 sceMcSync(s32 poll_mode, s32 *active_code_out, s32 *completion_status_out) { s32 var_16_24; - register s32 wait_flag = arg0; - register s32 *code_out = arg1; - register s32 *status_out = arg2; + register s32 wait_flag = poll_mode; + register s32 *code_out = active_code_out; + register s32 *status_out = completion_status_out; if (D_00132DA8[0] == 0) { return -1; From b3930b3011fc50b159ac913831cf54d8194fd40e Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:05:43 +0000 Subject: [PATCH 094/135] decomp: clarify names in mode_freeze_init arg1 -> freeze_context: In the bound source src/textbin/runtime/memory/mode_freeze_init.c (SHA-256 c456a4d0fb72a8188f6331c2d56610bdc26c0c25a40e8f735290fa4250875d0c), the s32 second parameter is used only by freeze.unk18 = arg1. Retail 0x001fbad0 copies a1 to saved s2 before sound calls; 0x001fbb10 stores s2 at 0x18 of the freeze base 0x00193300, with no interpretation or transformation. Original Ghidra likewise assigns param_2 to DAT_00193318. Caller 0x00222f88 loads the dereferenced context at 0x001d5bf4 into a1 at 0x0022306c before calling at 0x00223074; its other accesses dereference that same value at +0x40 and +0x38. Caller 0x00208f28 instead supplies zero in a1 at 0x00208f64. Thus freeze_context denotes the opaque caller context retained by this initializer without claiming a concrete object type. --- src/textbin/runtime/memory/mode_freeze_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/textbin/runtime/memory/mode_freeze_init.c b/src/textbin/runtime/memory/mode_freeze_init.c index 91c9766f2c..dc0d202f6e 100644 --- a/src/textbin/runtime/memory/mode_freeze_init.c +++ b/src/textbin/runtime/memory/mode_freeze_init.c @@ -24,7 +24,7 @@ extern s32 push_help_history() __asm__("func_001FED30"); void mode_freeze_init(u32 mode, s32 arg1) __asm__("FUN_001fbab8"); -void mode_freeze_init(u32 mode, s32 arg1) { +void mode_freeze_init(u32 mode, s32 freeze_context) { struct FreezeModeState *st; if (game_mode != 3) { @@ -32,7 +32,7 @@ void mode_freeze_init(u32 mode, s32 arg1) { music_pause(0); } freeze.unk14 = game_mode; - freeze.unk18 = arg1; + freeze.unk18 = freeze_context; game_mode = 4; freeze.unk0 = mode; switch (mode) { From 5ea2b95e69ca24825d6a9ed7dfb8f410fb3251ad Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:05:43 +0000 Subject: [PATCH 095/135] decomp: clarify names in send_adpcm arg0 -> audio_decoder: In src/audio/decoder/send_adpcm.c (snapshot SHA-256 1e4314592419cbc2d60c4167e80535cd41068e5af982ebf0b38ffc56896e65c3), arg0 initializes struct AudioDec *ad. Retail 0x0023afd0 saves incoming a0 in s0; 0x0023afdc reads its state at +0, 0x0023b058 reads channel count at +0x18, 0x0023b084/0x0023b08c/0x0023b0ac read ring put/size/data at +0x38/+0x40/+0x34, and 0x0023b174 passes the same s0 as a0 to send_to_spu at 0x0023b178. Original Ghidra likewise casts param_1 to piVar10 and passes param_1 to FUN_0023af18; these uses establish an audio decoder context pointer. --- src/audio/decoder/send_adpcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/decoder/send_adpcm.c b/src/audio/decoder/send_adpcm.c index 46b1ab830c..2404b121d9 100644 --- a/src/audio/decoder/send_adpcm.c +++ b/src/audio/decoder/send_adpcm.c @@ -16,8 +16,8 @@ extern void send_to_spu(struct AudioDec *, unsigned char *, int, int) __asm__("f pointer (one load, as retail). */ void send_adpcm(void *arg0) __asm__("FUN_0023afc0"); -void send_adpcm(void *arg0) { - struct AudioDec *ad = arg0; +void send_adpcm(void *audio_decoder) { + struct AudioDec *ad = audio_decoder; int avail = 0; int i, j, n; unsigned char *src, *dst; From 8ff450ec8fd7e7b3e3ea32668f898043d69e9fad Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:05:43 +0000 Subject: [PATCH 096/135] decomp: clarify names in _request_bind arg0 -> bind_request: In _request_bind, struct RpcBindRequest *arg0 is retained from a0 in s0 at 0x0011af58. Loads at 0x0011af70 and 0x0011af74 copy its +0x1c and +0x14 fields into the reply packet, while 0x0011af94 loads its +0x20 field as the SearchSvdata lookup key. The original Ghidra bind-handler decompilation identifies this first argument as the incoming packet, proving its bind request role. arg1 -> rpc_state: The second argument is retained from a1 in s1 at 0x0011af54, passed to GetRpcPacket via a0 at 0x0011af68, and passed unchanged to SearchSvdata via a1 at 0x0011af88. The source shows GetRpcPacket(arg1) and SearchSvdata(arg0->unk20, arg1); the original retail Ghidra signature names this argument SifRpcState *state and uses it for reply allocation and server lookup, establishing its shared RPC state role without changing its s32 type. --- src/sdk/rpc/request_bind.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sdk/rpc/request_bind.c b/src/sdk/rpc/request_bind.c index 8cbae2c7dd..2ffc4dd6bb 100644 --- a/src/sdk/rpc/request_bind.c +++ b/src/sdk/rpc/request_bind.c @@ -34,16 +34,16 @@ struct sceSifServeData { extern s32 GetRpcPacket(); extern s32 SearchSvdata(); extern void isceSifSendCmd(); -void _request_bind(struct RpcBindRequest *arg0, s32 arg1) { +void _request_bind(struct RpcBindRequest *bind_request, s32 rpc_state) { struct RpcBindPacket *packet; s32 new_var; struct sceSifServeData *svdata; - packet = GetRpcPacket(arg1); - new_var = (s32)arg0->unk14; - packet->unk1C = (s32)arg0->unk1C; + packet = GetRpcPacket(rpc_state); + new_var = (s32)bind_request->unk14; + packet->unk1C = (s32)bind_request->unk1C; packet->unk14 = new_var; packet->unk20 = 0x80000009; - svdata = SearchSvdata(arg0->unk20, arg1); + svdata = SearchSvdata(bind_request->unk20, rpc_state); if (svdata == 0) { packet->unk24 = 0; packet->unk28 = 0; From 396546e98772e15b166d8b1f571a987675189f3c Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:05:43 +0000 Subject: [PATCH 097/135] decomp: clarify names in _outputFrame arg2 -> output_enabled: In src/sdk/library/outputframe.c (SHA-256 14a4269769abf16b4958a9bc40a29dbcb47b6472557b731a4f24e5be059d351b), s32 arg2 is used only by if (arg2 != 0), enclosing both _dispRefImage and _dispRefImageField calls. Retail 0x001294d0 branches on incoming a2 == zero directly to 0x0012952c, skipping both calls at 0x001294f8 and 0x00129524. Ghidra param_3 has the same nonzero guard. The later unkF8 transition runs independently, proving this parameter enables image output. --- src/sdk/library/outputframe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdk/library/outputframe.c b/src/sdk/library/outputframe.c index fbc5ef89a2..c8a0711968 100644 --- a/src/sdk/library/outputframe.c +++ b/src/sdk/library/outputframe.c @@ -4,12 +4,12 @@ #include "rnc/sdk/libmpeg.h" extern s32 _dispRefImage(struct MpegDecoder *mpeg, struct MpegRefImage *arg1, s32 arg2); extern s32 _dispRefImageField(struct MpegDecoder *mpeg, struct MpegRefImage *arg1, struct MpegRefImage *arg2, s32 arg3); -void _outputFrame(struct MpegDecoder *mpeg, s32 arg1, s32 arg2) { +void _outputFrame(struct MpegDecoder *mpeg, s32 arg1, s32 output_enabled) { struct MpegRefImage *var_5_14; struct MpegRefImage *var_5_24; struct MpegRefImage *var_6_27; - if (arg2 != 0) { + if (output_enabled != 0) { if (mpeg->picture_structure == 3) { if (mpeg->picture_coding_type == 3) { var_5_14 = mpeg->ref_images[3]; From 4f73ba746d276aca199d7e62299ece3945239140 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:07:48 +0000 Subject: [PATCH 098/135] decomp: clarify names in snd_bank_load_by_loc arg1 -> byte_offset: Retail 0x0012df38 copies the second parameter a1 to s0; 0x0012df8c stores s0 at request base 0x00137b40 + 4. At 0x0012dfd8 and 0x0012dfe8 the same request is passed to RPC command 3 with length 8, followed by the call at 0x0012dff8. The source assigns arg1 to snd_cd_bank_load_request[1] beside location in word 0. Original retail Ghidra names this parameter dwOffset and explicitly describes it as the byte offset within that location, supporting byte_offset. --- src/audio/banks/snd_bank_load_by_loc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/banks/snd_bank_load_by_loc.c b/src/audio/banks/snd_bank_load_by_loc.c index 5f36455305..6d8b87b4da 100644 --- a/src/audio/banks/snd_bank_load_by_loc.c +++ b/src/audio/banks/snd_bank_load_by_loc.c @@ -16,7 +16,7 @@ extern s32 sceSifCallRpc(void *, s32, s32, void *, s32, void *, s32, void *, voi s32 snd_bank_load_by_loc(s32 location, s32 arg1) __asm__("FUN_0012df20"); -s32 snd_bank_load_by_loc(s32 location, s32 arg1) { +s32 snd_bank_load_by_loc(s32 location, s32 byte_offset) { snd_cd_load_error = 0; if (snd_cd_callback_pending != 0) { printf("snd_BankLoadByLoc: Load already in progress!\n"); @@ -26,7 +26,7 @@ s32 snd_bank_load_by_loc(s32 location, s32 arg1) { printf("snd_BankLoadByLoc: CD BUSY!\n"); return 0; } - snd_cd_bank_load_request[1] = arg1; + snd_cd_bank_load_request[1] = byte_offset; snd_cd_callback_arg = 0xFFFFFFFF; snd_cd_bank_load_request[0] = location; while (SceSifCheckStatRpc(D_0015EBE8) != 0) { From ea9a7ebcdec04682b0ccea835b06937bec016eb0 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:07:48 +0000 Subject: [PATCH 099/135] decomp: clarify names in FUN_0020be68 arg0 -> item_index: The source returns item_available[arg0] != 0. Retail 0x0020be68/0x0020be6c forms the byte-array base 0x0013d4c0; 0x0020be70 adds incoming a0 directly to that base, 0x0020be74 loads its unsigned byte, and 0x0020be7c normalizes it to nonzero. Ghidra likewise uses (&DAT_0013d4c0)[param_1]. Thus the int argument is the item availability array index. --- src/gameplay/missions/fun_0020be68.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gameplay/missions/fun_0020be68.c b/src/gameplay/missions/fun_0020be68.c index 18834578f1..d8f2eb50dd 100644 --- a/src/gameplay/missions/fun_0020be68.c +++ b/src/gameplay/missions/fun_0020be68.c @@ -1,7 +1,7 @@ /* Ported from rac1-decomp (src/game/missionfunc.c, func_0020CCB8). */ #include "rnc/gameplay/state/item_state.h" -int FUN_0020be68(int arg0) { - return item_available[arg0] != 0; +int FUN_0020be68(int item_index) { + return item_available[item_index] != 0; } extern __typeof__(FUN_0020be68) func_0020BE68 __attribute__((alias("FUN_0020be68"))); From e638f14d14934e5b23d085120ab12c1e45b62eb0 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:07:48 +0000 Subject: [PATCH 100/135] decomp: clarify names in _pack_header arg0 -> bitstream_context: In src/sdk/library/_pack_header.c (SHA-256 ea421fd090c65c310a35838273d215a9bbe9792e746cac42f4264c9132e77db4), s32 arg0 is the first argument to every _sysbitGet and _sysbitMarker call. Retail 0x0012afd0 saves a0 in s3; 0x0012aff8-0x0012b03c repeatedly passes s3 to the bit-reading and marker helpers with widths 3 and 15. At 0x0012b0b0-0x0012b0b8 it also supplies the context to SignExtendPackedValue with width 32, proving the shared bitstream context role without asserting its internal layout. arg1 -> pack_header_info: The authoritative source declares arg1 as struct PackHeaderInfo * and writes parsed values into its four fields. Retail 0x0012afcc saves a1 in s6; stores at 0x0012b04c, 0x0012b084 and 0x0012b08c write extracted values to offsets 0, 8 and 4. At 0x0012b0c4/0x0012b0d0 offset 12 receives the system-header presence result, and 0x0012b0d4-0x0012b0d8 forwards s6 as argument two to _system_header. This proves it is the pack-header information destination. --- src/sdk/library/_pack_header.c | 36 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/sdk/library/_pack_header.c b/src/sdk/library/_pack_header.c index e24ac760db..86f8a9f275 100644 --- a/src/sdk/library/_pack_header.c +++ b/src/sdk/library/_pack_header.c @@ -10,7 +10,7 @@ extern s32 SignExtendPackedValue(); extern s32 _sysbitGet(); extern s32 _sysbitMarker(); extern s32 _system_header(); -s32 _pack_header(s32 arg0, struct PackHeaderInfo *arg1) { +s32 _pack_header(s32 bitstream_context, struct PackHeaderInfo *pack_header_info) { u32 temp_16_20; u32 temp_17_26; u32 temp_18_32; @@ -18,31 +18,31 @@ s32 _pack_header(s32 arg0, struct PackHeaderInfo *arg1) { u32 var_21_16; var_21_16 = 0; - _sysbitGet(arg0, 0x22); - temp_16_20 = _sysbitGet(arg0, 3); - _sysbitMarker(arg0); - temp_17_26 = _sysbitGet(arg0, 0xF); - _sysbitMarker(arg0); - temp_18_32 = _sysbitGet(arg0, 0xF); - _sysbitMarker(arg0); - arg1->unk0 = _sysbitGet(arg0, 9); - _sysbitGet(arg0, 0x1E); - temp_20_45 = _sysbitGet(arg0, 3); - arg1->unk8 = (s32)((temp_16_20 >> 2) & 1); - arg1->unk4 = (s32)((temp_16_20 << 0x1E) | (temp_17_26 << 0xF) | temp_18_32); + _sysbitGet(bitstream_context, 0x22); + temp_16_20 = _sysbitGet(bitstream_context, 3); + _sysbitMarker(bitstream_context); + temp_17_26 = _sysbitGet(bitstream_context, 0xF); + _sysbitMarker(bitstream_context); + temp_18_32 = _sysbitGet(bitstream_context, 0xF); + _sysbitMarker(bitstream_context); + pack_header_info->unk0 = _sysbitGet(bitstream_context, 9); + _sysbitGet(bitstream_context, 0x1E); + temp_20_45 = _sysbitGet(bitstream_context, 3); + pack_header_info->unk8 = (s32)((temp_16_20 >> 2) & 1); + pack_header_info->unk4 = (s32)((temp_16_20 << 0x1E) | (temp_17_26 << 0xF) | temp_18_32); if (temp_20_45 != 0) { do { do { - _sysbitGet(arg0, 8); + _sysbitGet(bitstream_context, 8); var_21_16 += 1; } while (var_21_16 < temp_20_45); } while (0); } - if (SignExtendPackedValue(arg0, 0x20) == 0x1BB) { - arg1->unkC = 1; - _system_header(arg0, arg1); + if (SignExtendPackedValue(bitstream_context, 0x20) == 0x1BB) { + pack_header_info->unkC = 1; + _system_header(bitstream_context, pack_header_info); } else { - arg1->unkC = 0; + pack_header_info->unkC = 0; } return 1; } From fb2d725f0ae89b40bd0565662b98b8979c24efc8 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:07:48 +0000 Subject: [PATCH 101/135] decomp: clarify names in FUN_00129b38 arg0 -> object: In src/sdk/library/fun_00129b38.c (SHA-256 c6d2bab3f9106cdb452c70ab729682fd6adec224fe079c1d1c03c634e57a4cd0), arg0 is cast to Obj40 *. Retail a0 is the same object base: 0x00129b38 loads +0x08; 0x00129b48 loads +0x118; 0x00129b4c and 0x00129b50 store 2 and that loaded value to +0x08 and +0xAC; 0x00129b5c stores 1 to +0x820. This proves the parameter points to the object whose fields this function reads and updates. --- src/sdk/library/fun_00129b38.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdk/library/fun_00129b38.c b/src/sdk/library/fun_00129b38.c index 266125748e..efc071cc69 100644 --- a/src/sdk/library/fun_00129b38.c +++ b/src/sdk/library/fun_00129b38.c @@ -33,8 +33,8 @@ typedef struct Obj40 { the entry budget at +0xE0; an unsized one has to fit width * height against +0xE4. On a refusal, format the two figures into the message at D_00153A80 and report it. Returns whether it fits. */ -int FUN_00129b38(void *arg0) { - Obj40 *s = (Obj40 *)arg0; +int FUN_00129b38(void *object) { + Obj40 *s = (Obj40 *)object; int r = 1; if (s->unk008 != 2) { int v = s->unk118; From 758684bded7451a672acb1b4eefc50bc43ccc708 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:09:38 +0000 Subject: [PATCH 102/135] decomp: clarify names in handle_sif_initialize_command a0 -> initialize_packet: Retail 0x0011a448 executes lw v0,0x10(a0); the source loads *(s32 *)((u8 *)a0 + 0x10). Original typed Ghidra identifies this input as SifInitializePacket *pPacket and its +0x10 word as dwReceiveBufferAddress, proving the initialization-packet role. a1 -> command_state: Retail 0x0011a450 stores the loaded word with sw v0,0x8(a1) in the return delay slot; the source writes *(s32 *)((u8 *)a1 + 0x8). Original typed Ghidra identifies SifCommandState *pState and dwRemoteReceiveAddress, proving the command-state destination role. --- src/runtime/sio/handle_sif_initialize_command.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/sio/handle_sif_initialize_command.c b/src/runtime/sio/handle_sif_initialize_command.c index 766dc7b6c4..3515c9e2cc 100644 --- a/src/runtime/sio/handle_sif_initialize_command.c +++ b/src/runtime/sio/handle_sif_initialize_command.c @@ -2,11 +2,11 @@ s32 handle_sif_initialize_command(s32 *a0, s32 *a1) __asm__("FUN_0011a448"); -s32 handle_sif_initialize_command(s32 *a0, s32 *a1) { +s32 handle_sif_initialize_command(s32 *initialize_packet, s32 *command_state) { s32 value; - value = *(s32 *)((u8 *)a0 + 0x10); - *(s32 *)((u8 *)a1 + 0x8) = value; + value = *(s32 *)((u8 *)initialize_packet + 0x10); + *(s32 *)((u8 *)command_state + 0x8) = value; return value; } From 2827796ed23d50862b0aa47d0637877bcbc10ea4 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:09:38 +0000 Subject: [PATCH 103/135] decomp: clarify names in sceDbcReceiveData arg2 -> byte_count: The s32 *arg2 is preserved from a2 in s1 at 0x0012495c; 0x00124970 loads *arg2 and 0x00124980 writes it to RPC offset 8. After a nonnegative remote result, 0x001249b8-0x001249bc writes the returned offset-8 value through the same pointer, and 0x001249e8-0x001249f0 uses that value as the byte-copy loop bound. Source state->unk8 = *arg2 and *arg2 = state->unk8 confirms an input/output byte count. arg3 -> destination: The u8 *arg3 is preserved from a3 in s2 at 0x00124954. The copy loop adds the byte index to s2 at 0x001249d8, loads a byte from RPC payload offset 0x0c at 0x001249dc, and stores that byte through the resulting destination address at 0x001249e4. The source assignment arg3[i] = state->payload[i] confirms the caller's byte-copy destination. --- src/sdk/library/scedbcreceivedata.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sdk/library/scedbcreceivedata.c b/src/sdk/library/scedbcreceivedata.c index 0901929a0b..ace7e41049 100644 --- a/src/sdk/library/scedbcreceivedata.c +++ b/src/sdk/library/scedbcreceivedata.c @@ -12,13 +12,13 @@ extern u8 D_001536A0[]; extern s32 debug_print_stub() __asm__("func_00124A20"); extern s32 sceSifCallRpc(); extern struct DbCState RpcReceiveData __asm__("D_0015B080"); -s32 sceDbcReceiveData(s32 arg0, s32 arg1, s32 *arg2, u8 *arg3) { +s32 sceDbcReceiveData(s32 arg0, s32 arg1, s32 *byte_count, u8 *destination) { struct DbCState *state = &RpcReceiveData; s32 i; state->unk0 = arg0; state->unk4 = arg1; - state->unk8 = *arg2; + state->unk8 = *byte_count; if (sceSifCallRpc(RpcQueueData, 0x8000091A, 0, state, 0x400, state, 0x400, 0, 0) < 0) { debug_print_stub(D_001536A0); return 0; @@ -26,11 +26,11 @@ s32 sceDbcReceiveData(s32 arg0, s32 arg1, s32 *arg2, u8 *arg3) { if (state->unk8C < 0) { return state->unk8C; } - *arg2 = state->unk8; + *byte_count = state->unk8; i = 0; if (state->unk8 > 0) { do { - arg3[i] = state->payload[i]; + destination[i] = state->payload[i]; i++; } while (i < state->unk8); return state->unk8C; From 08c0c1bc7bbcba131114765293fd27860c903eec Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:09:38 +0000 Subject: [PATCH 104/135] decomp: clarify names in _decodeOrSkipFrame arg2 -> skip_threshold: The s32 arg2 is incoming a2. At 0x0012be24, a2 == -1 branches to decoding; 0x0012be2c performs signed slt a1,a2 and 0x0012be30 branches to 0x0012be74 when false. That branch calls _updateRefImage, sets the skip flag at 0x0012be7c, and dispatches the nodata callback at 0x0012be84, bypassing _decPicture at 0x0012be60. Thus arg2 is the threshold at or above which arg1 selects skipping, with -1 disabling skipping. The authoritative C and original retail decompilation show the identical condition. --- src/sdk/library/_decodeOrSkipFrame.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdk/library/_decodeOrSkipFrame.c b/src/sdk/library/_decodeOrSkipFrame.c index ada6793db6..1940cf8f82 100644 --- a/src/sdk/library/_decodeOrSkipFrame.c +++ b/src/sdk/library/_decodeOrSkipFrame.c @@ -4,14 +4,14 @@ extern s32 _decPicture(struct MpegDecoder *a0); extern void _dispatchMpegCbNodata(struct sceMpeg *a0); extern void _outputFrame(struct MpegDecoder *a0, s32 a1, s32 a2); extern s32 _updateRefImage(struct MpegDecoder *a0, s32 a1); -s32 _decodeOrSkipFrame(struct sceMpeg *decoder, s32 arg1, s32 arg2) { +s32 _decodeOrSkipFrame(struct sceMpeg *decoder, s32 arg1, s32 skip_threshold) { s32 ret; s32 flag; s32 t; struct MpegDecoder *tmp; flag = 0; tmp = decoder->sys; - if ((arg2 == -1) || (arg1 < arg2)) { + if ((skip_threshold == -1) || (arg1 < skip_threshold)) { if (tmp->unk8 == 0) { decoder->frameCount = 0; tmp->unk8 = 1; From 2fae88b5dc2df881f9d269c995a09fdd063c1deb Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:09:38 +0000 Subject: [PATCH 105/135] decomp: clarify names in scePad2LinkDriver arg0 -> socket_index: In the SHA-256-bound source src/sdk/input/sce_pad2_link_driver.c (4239b4d05488ff38333e7ba0d59135a00e4f40aaf7a43af224a1f80d23d803ef), s32 arg0 indexes D_0015B540 for both dependency and ready-field stores. Retail 0x00124ef0 saves incoming a0 in s0; 0x00124f04 multiplies s0 by the 0x330 record stride, and 0x00124f14 adds it to base 0x0015B540. Stores at 0x00124f1c and 0x00124f20 update offsets 8 and 4 of that selected record only after a nonnegative dependency result. The prepared original Ghidra decompilation calls this parameter socket and indexes g_aPad2Sockets[socket], supporting socket_index. --- src/sdk/input/sce_pad2_link_driver.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdk/input/sce_pad2_link_driver.c b/src/sdk/input/sce_pad2_link_driver.c index 180703f950..6b3f3c1211 100644 --- a/src/sdk/input/sce_pad2_link_driver.c +++ b/src/sdk/input/sce_pad2_link_driver.c @@ -7,12 +7,12 @@ struct Pad { }; extern struct Pad D_0015B540[]; extern s32 sceDbcGetDepNumber(); -s32 scePad2LinkDriver(s32 arg0) { +s32 scePad2LinkDriver(s32 socket_index) { s32 dep; dep = sceDbcGetDepNumber(); if (dep < 0) return dep; - D_0015B540[arg0].unk8 = dep; - D_0015B540[arg0].unk4 = 1; + D_0015B540[socket_index].unk8 = dep; + D_0015B540[socket_index].unk4 = 1; return dep; } From 69be9756f8da6744c915d0d4a1e8a8334cd7477c Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:11:16 +0000 Subject: [PATCH 106/135] decomp: clarify names in _decodeOrSkipField bVar3 -> should_decode: Source initializes this s32 flag to zero and sets it when arg2 == -1 or arg1 < arg2. Retail 0x0012bf70 and 0x0012bf8c-0x0012bfa0 implement that flag in s3. The tests at 0x0012bfcc and 0x0012c03c gate the _decPicture calls at 0x0012bfd4 and 0x0012c044; its zero case also dispatches the nodata callback at 0x0012c088-0x0012c094. Original Ghidra bVar1 has the same control flow, proving the decode-versus-skip decision. iVar4 -> expected_second_field_structure: After source sets p->second_field = 1 and calls _nextHeader, this s32 receives 2 when p->unkD4 == 1 and otherwise 1, then is compared with p->picture_structure; mismatch returns -1. Retail 0x0012bfe4-0x0012bfe8 marks/scans the second field, and 0x0012c008-0x0012c01c constructs v1 and compares it with the picture structure loaded from 0x174(s0). Original Ghidra likewise computes the required opposite structure before this comparison. uVar7 -> second_field_decode_nonzero: Source initializes this s32 to zero and sets it to one only when the second-field _decPicture(p) call returns nonzero, then returns it after _outputFrame and counter updates. Retail 0x0012c038 clears s4; 0x0012c044 calls _decPicture after the second header; 0x0012c04c conditionally moves 1 into s4 if v0 is nonzero; 0x0012c098 returns s4. Original Ghidra uVar4 follows this same normalized return-value flow. --- src/sdk/library/_decodeOrSkipField.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/sdk/library/_decodeOrSkipField.c b/src/sdk/library/_decodeOrSkipField.c index d427793436..39850ce5dd 100644 --- a/src/sdk/library/_decodeOrSkipField.c +++ b/src/sdk/library/_decodeOrSkipField.c @@ -9,26 +9,26 @@ extern s32 _updateRefImage(); extern void _outputFrame(); s32 _decodeOrSkipField(struct sceMpeg *decoder, s32 arg1, s32 arg2) { struct MpegDecoder *p; - s32 bVar3; + s32 should_decode; unsigned int new_var2; - s32 iVar4; + s32 expected_second_field_structure; long lVar5; s32 uVar2; - s32 uVar7; + s32 second_field_decode_nonzero; short new_var; s32 gate; - bVar3 = 0; + should_decode = 0; p = decoder->sys; p->second_field = 0; if ((arg2 == (-1)) || (arg1 < arg2)) { - bVar3 = 1; + should_decode = 1; }; if (p->unk8 == 0) { decoder->frameCount = 0; p->unk8 = 1; } lVar5 = _updateRefImage(p, 0); - if ((lVar5 != 0) && (bVar3 != 0)) { + if ((lVar5 != 0) && (should_decode != 0)) { _decPicture(p); } p->second_field = 1; @@ -38,11 +38,11 @@ s32 _decodeOrSkipField(struct sceMpeg *decoder, s32 arg1, s32 arg2) { p->unk0 = 1; return 0; } - iVar4 = 2; + expected_second_field_structure = 2; if (p->unkD4 != 1) { - iVar4 = 1; + expected_second_field_structure = 1; } - if (p->picture_structure != iVar4) { + if (p->picture_structure != expected_second_field_structure) { return -1; } new_var2 = _updateRefImage(p, 1); @@ -50,15 +50,15 @@ s32 _decodeOrSkipField(struct sceMpeg *decoder, s32 arg1, s32 arg2) { if (new_var2 != 0) { gate = 1; } - uVar7 = 0; + second_field_decode_nonzero = 0; if (gate != 0) { - if (bVar3 == 0) { + if (should_decode == 0) { uVar2 = p->frame_count; goto out; } lVar5 = _decPicture(p); if (lVar5 != 0) { - uVar7 = 1; + second_field_decode_nonzero = 1; } }; out: @@ -68,8 +68,8 @@ s32 _decodeOrSkipField(struct sceMpeg *decoder, s32 arg1, s32 arg2) { decoder->frameCount = p->frame_count - p->frame_base; p->frame_count = p->frame_count + 1; p->unk4 = (unsigned long long)(p->unk4 + 1); - if (bVar3 == 0) { + if (should_decode == 0) { _dispatchMpegCbNodata(decoder); } - return uVar7; + return second_field_decode_nonzero; } From 444f5d7a8752832b0122b6c3f8e9bbc672b0bd40 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:11:16 +0000 Subject: [PATCH 107/135] decomp: clarify names in dpsub arg0 -> minuend: In src/sdk/library/dpsub.c (SHA-256 eb6878b8f909fc1009928717d667a4cda7176bdaef07187395e5102ddf98b384), s64 arg0 is stored in work.unk60 and unpacked into work, the first _fpadd_parts operand. Retail 0x0011fba4 stores a0 at sp+0x60; 0x0011fbac-0x0011fbbc unpack it into sp. At 0x0011fbdc this unchanged-sign record is the first add operand, whereas the second record's sign is inverted. Thus arg0 is the minuend in the packed difference, consistent with original Ghidra left. arg1 -> subtrahend: The source stores s64 arg1 in work.unk68, unpacks it into work.unk20, and applies work.unk24 ^= 1 before _fpadd_parts. Retail 0x0011fba8 stores a1 at sp+0x68; 0x0011fbc4-0x0011fbcc unpack it into sp+0x20. Instructions 0x0011fbd0, 0x0011fbe0 and 0x0011fbe8 load, XOR 1 and store that record's sign at sp+0x24 before addition at 0x0011fbe4. Negating this second operand makes it the subtrahend, matching original Ghidra right. --- src/sdk/library/dpsub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdk/library/dpsub.c b/src/sdk/library/dpsub.c index 55e8bf7333..c796b6f166 100644 --- a/src/sdk/library/dpsub.c +++ b/src/sdk/library/dpsub.c @@ -49,11 +49,11 @@ struct DpsubWork { s64 unk60; s64 unk68; }; -void dpsub(s64 arg0, s64 arg1) { +void dpsub(s64 minuend, s64 subtrahend) { struct DpsubWork work; - work.unk60 = arg0; - work.unk68 = arg1; + work.unk60 = minuend; + work.unk68 = subtrahend; __unpack_d(&work.unk60, &work); __unpack_d(&work.unk68, &work.unk20); work.unk24 ^= 1; From 86f89e6114333fe935533a88bc581a9b42d3bb9d Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:12:45 +0000 Subject: [PATCH 108/135] decomp: clarify names in _PES_packet a2 -> pack_header_field_flag: Source a2 is the second one-bit extension subflag; retail 0x0012b48c-0x0012b494 saves it in s8. The test at 0x0012b4fc leads directly to _Error at 0x0012b508 and failure return. Original retail Ghidra supplies the exact diagnostic at D_001539D8: pack_header_field_flag needs to be '0' in PS. a5 -> pes_extension_2_flag: Source a5 is read after four one-bit extension flags and three skipped bits. Retail 0x0012b4c8-0x0012b4d4 saves that final bit in s1. Its test at 0x0012b538 gates a marker read, seven-bit extension byte length at 0x0012b550, and that many eight-bit reads at 0x0012b568-0x0012b578, proving the second PES extension presence flag. arg0 -> error_context: In the bound C snapshot arg0 is copied to ctx and used only as _Error(ctx, D_001539D8). Retail 0x0012b1c0 saves incoming a0 at sp+0x10; 0x0012b504 reloads it into a0 for the error call at 0x0012b508. Original Ghidra likewise forwards saved param_1 to report_mpeg_decoder_error. v5 -> pes_extension_flag: Source v5 is the one-bit field read immediately before the eight-bit header-data length. Retail 0x0012b304-0x0012b30c saves it in s5; 0x0012b470 compares it with 1 to gate all subsequent PES extension subflags and their conditional data reads, matching the original Ghidra lVar5 extension gate. v7 -> pts_dts_flags: The source reads v7 with _sysbitGet(bs,2); retail 0x0012b2d4-0x0012b2dc retains this two-bit result in s7. Its bit 1 test at 0x0012b320 controls reconstruction of a marker-separated 3+15+15-bit timestamp into hdr+0x10, and equality to 3 at 0x0012b3bc controls the second timestamp at hdr+0x18. This proves the PTS/DTS selection role. --- src/sdk/library/_PES_packet.c | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/sdk/library/_PES_packet.c b/src/sdk/library/_PES_packet.c index c3571452bc..88bd462396 100644 --- a/src/sdk/library/_PES_packet.c +++ b/src/sdk/library/_PES_packet.c @@ -32,18 +32,18 @@ struct PES_TBL { u8 v[16]; } __attribute__((packed)); -s32 _PES_packet(s32 arg0, struct PES_BS *bs, struct PES_HDR *hdr) { +s32 _PES_packet(s32 error_context, struct PES_BS *bs, struct PES_HDR *hdr) { struct PES_TBL tbl; s32 ctx; s32 flag1; s32 len; /* PES_header_data_length */ s32 base; /* (s32)bs->stamp, captured before the header fields */ s64 now; /* the same stamp, re-read at the sync point */ - s32 v7; /* PTS_DTS_flags */ + s32 pts_dts_flags; /* PTS_DTS_flags */ s32 v8; /* 4-bit length, indexes tbl */ - s32 v5; /* PES_extension_flag */ + s32 pes_extension_flag; /* PES_extension_flag */ - ctx = arg0; + ctx = error_context; hdr->unk28 = (s32)bs->stamp; tbl = *(struct PES_TBL *)D_001539C8; _sysbitGet(bs, 0x18); @@ -58,13 +58,13 @@ s32 _PES_packet(s32 arg0, struct PES_BS *bs, struct PES_HDR *hdr) { _sysbitGet(bs, 2); hdr->unkC = _sysbitGet(bs, 2); _sysbitGet(bs, 4); - v7 = _sysbitGet(bs, 2); + pts_dts_flags = _sysbitGet(bs, 2); flag1 = _sysbitGet(bs, 1); v8 = _sysbitGet(bs, 4); - v5 = _sysbitGet(bs, 1); + pes_extension_flag = _sysbitGet(bs, 1); len = _sysbitGet(bs, 8); base = bs->stamp; - if (v7 & 2) { + if (pts_dts_flags & 2) { u32 a, b, c; _sysbitGet(bs, 4); a = _sysbitGet(bs, 3); @@ -75,7 +75,7 @@ s32 _PES_packet(s32 arg0, struct PES_BS *bs, struct PES_HDR *hdr) { _sysbitMarker(bs); hdr->unk10 = ((s64)((a >> 2) & 1) << 0x20) | (s64)(u32)(a << 30 | b << 15 | c); } - if (v7 == 3) { + if (pts_dts_flags == 3) { u32 a, b, c; _sysbitGet(bs, 4); a = _sysbitGet(bs, 3); @@ -92,34 +92,34 @@ s32 _PES_packet(s32 arg0, struct PES_BS *bs, struct PES_HDR *hdr) { if (v8 != 0) { _sysbitGet(bs, tbl.v[v8]); } - if (v5 == 1) { + if (pes_extension_flag == 1) { s32 a1; - s32 a2; + s32 pack_header_field_flag; s32 a3; s32 a4; - s32 a5; + s32 pes_extension_2_flag; a1 = _sysbitGet(bs, 1); - a2 = _sysbitGet(bs, 1); + pack_header_field_flag = _sysbitGet(bs, 1); a3 = _sysbitGet(bs, 1); a4 = _sysbitGet(bs, 1); _sysbitGet(bs, 3); - a5 = _sysbitGet(bs, 1); - if (a1 == v5) { + pes_extension_2_flag = _sysbitGet(bs, 1); + if (a1 == pes_extension_flag) { _sysbitGet(bs, 0x30); _sysbitGet(bs, 0x30); _sysbitGet(bs, 0x20); } - if (a2 == v5) { + if (pack_header_field_flag == pes_extension_flag) { _Error(ctx, D_001539D8); return 0; } - if (a3 == v5) { + if (a3 == pes_extension_flag) { _sysbitGet(bs, 0x10); } - if (a4 == v5) { + if (a4 == pes_extension_flag) { _sysbitGet(bs, 0x10); } - if (a5 == v5) { + if (pes_extension_2_flag == pes_extension_flag) { u32 i; u32 n; _sysbitMarker(bs); From e54afa66388271df450c8d82afd782388d71080a Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:12:45 +0000 Subject: [PATCH 109/135] decomp: clarify names in read arg0 -> file_descriptor: The established newlib read function takes arg0 as its first s32 parameter. Retail 0x00118da0 tests incoming a0 against zero and sends nonzero values to the -1 return at 0x00118de0; descriptor zero alone permits the terminal read. This proves the input descriptor selector role. arg1 -> destination_buffer: The original retail decompilation types the second parameter as byte * and passes it to read_deci2_terminal_line. Retail 0x00118d9c saves a1 into s1, 0x00118dcc restores s1 into a0, and 0x00118dd0 calls that read routine. The source likewise forwards arg1 as sceTtyRead's first argument, identifying the read destination buffer while preserving the existing s32 type. --- src/sdk/library/read.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdk/library/read.c b/src/sdk/library/read.c index ced1fc3ffa..0e2dfdad99 100644 --- a/src/sdk/library/read.c +++ b/src/sdk/library/read.c @@ -10,8 +10,8 @@ extern s32 sceTtyInit(void); extern s32 sceTtyRead(); -s32 read(s32 arg0, s32 arg1, s32 arg2) { - if (arg0 == 0) { +s32 read(s32 file_descriptor, s32 destination_buffer, s32 arg2) { + if (file_descriptor == 0) { if (CoreGlobalWord == 0) { if (sceTtyInit() != 0) { do { @@ -22,7 +22,7 @@ s32 read(s32 arg0, s32 arg1, s32 arg2) { goto block_5; } block_4: - return sceTtyRead(arg1, arg2); + return sceTtyRead(destination_buffer, arg2); } block_5: return -1; From 45f80cc7eb0d348ecf9bedd78772937677ea65dc Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:12:45 +0000 Subject: [PATCH 110/135] decomp: clarify names in SetD3Chcr arg0 -> channel_control: In src/sdk/dma/set_d3_chcr.c (SHA-256 6b226c67cd02d6669c107651bfe644adf65dd9305c02ecf349dcf65dd9305c02ecf349dcf69b4e351d6d), arg0 is assigned directly to volatile u32 MMIO 0x1000B000. Retail 0x0012cb60 preserves incoming a0 in s0, 0x0012cb7c/0x0012cb88 construct 0x1000B000 in v1, and 0x0012cb94 stores s0 there without modifying the value. The supplied original Ghidra decompilation identifies this destination as REG_DMAC_3_IPU_FROM_CHCR and the argument as the complete CHCR control word; surrounding writes set and clear DMAC freeze bit 16. --- src/sdk/dma/set_d3_chcr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdk/dma/set_d3_chcr.c b/src/sdk/dma/set_d3_chcr.c index e6c50a80c8..0fe19a0c90 100644 --- a/src/sdk/dma/set_d3_chcr.c +++ b/src/sdk/dma/set_d3_chcr.c @@ -3,10 +3,10 @@ extern s32 DIntr(); extern s32 EnableInterrupts(); -void SetD3Chcr(s32 arg0) { +void SetD3Chcr(s32 channel_control) { DIntr(); *(volatile u32 *)0x1000F590 = *(volatile u32 *)0x1000F520 | 0x10000; - *(volatile u32 *)0x1000B000 = arg0; + *(volatile u32 *)0x1000B000 = channel_control; *(volatile u32 *)0x1000F590 = *(volatile u32 *)0x1000F520 & 0xFFFEFFFF; EnableInterrupts(); } From 0901b41e5f50c423bf5fda4c42a9b5baf17cb8c2 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:12:46 +0000 Subject: [PATCH 111/135] decomp: clarify names in get_iob arg0 -> slot_index: Retail 0x0011b504 copies a0 to s0; 0x0011b51c checks it unsigned against 0x20, returning null on failure. At 0x0011b538 it is shifted left four bits and at 0x0011b548 added to table base 0x00157D80, then returned at 0x0011b54c. Source equivalently bounds arg0 < 32 and returns &D_00157D80[arg0 << 4]. The original Ghidra decompilation identifies the argument as slot_index and the result as g_sif_file_slots + slot_index. --- src/sdk/library/get_iob.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdk/library/get_iob.c b/src/sdk/library/get_iob.c index 8657cd7156..2ba42f4a5a 100644 --- a/src/sdk/library/get_iob.c +++ b/src/sdk/library/get_iob.c @@ -25,16 +25,16 @@ extern s32 WaitSema(); extern s32 SignalSema(); extern u8 D_00157D80[]; -void *get_iob(u32 arg0) { +void *get_iob(u32 slot_index) { void *result; _sceFsIobSemaMK(); WaitSema(D_0012FCA0[0]); - if (arg0 >= 32) { + if (slot_index >= 32) { SignalSema(D_0012FCA0[0]); return 0; } - result = (void *)&D_00157D80[arg0 << 4]; + result = (void *)&D_00157D80[slot_index << 4]; SignalSema(D_0012FCA0[0]); return result; } From 6d1c5dcdea10eda7e7aa09adacccb31d1577a9a7 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:14:05 +0000 Subject: [PATCH 112/135] decomp: clarify names in _decMB0 arg4 -> motion_vector_state: In src/sdk/library/_decMB0.c (SHA-256 7edd251a39836906af8132c640c5cb26c8fed107346c4f1ef00b2699fe31a9b7), struct MpegMbState *arg4 is the state passed to _motionVectors and _motionVector. Retail 0x00127c3c saves incoming t0 in s1; 0x00127e04 and 0x00127e44 pass s1 as a1 to those helpers, while 0x00127ed8 passes s1+8 for backward single-vector decoding. Retail 0x00127ff4-0x00128010 clears its eight words for intra macroblocks without concealment vectors; 0x00128034-0x00128044 clears the forward subset for P-picture macroblocks lacking intra/forward flags. Original Ghidra param_5/puVar4 follows the same helper and reset data flow, proving motion-vector state storage. --- src/sdk/library/_decMB0.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/sdk/library/_decMB0.c b/src/sdk/library/_decMB0.c index 2a69719f09..71f3d9b98b 100644 --- a/src/sdk/library/_decMB0.c +++ b/src/sdk/library/_decMB0.c @@ -22,7 +22,7 @@ extern s32 _nextBit(struct MpegDecoder *, s32); extern void _sendIpuCommand(); extern void _waitIpuIdle(); extern void receiveDataFromIPU(); -int _decMB0(struct MpegDecoder *decoder, int *mb_type, int *motion_type, int *dct_type_out, struct MpegMbState *arg4, +int _decMB0(struct MpegDecoder *decoder, int *mb_type, int *motion_type, int *dct_type_out, struct MpegMbState *motion_vector_state, int *arg5, int arg6) { int *sp20; int *sp24; @@ -89,22 +89,22 @@ int _decMB0(struct MpegDecoder *decoder, int *mb_type, int *motion_type, int *dc } if (((*mb_type) & 8) || (((*mb_type) & 1) && (decoder->concealment_motion_vectors != 0))) { if (decoder->unk848 != 0) { - _motionVectors(decoder, arg4, arg6, sp24, 0, var_19_84, var_20_86, decoder->f_code_forward_h - 1, + _motionVectors(decoder, motion_vector_state, arg6, sp24, 0, var_19_84, var_20_86, decoder->f_code_forward_h - 1, decoder->f_code_forward_v - 1, motion_flag, var_23_95); } else { temp_7_163 = decoder->unk158 - 1; - _motionVector(decoder, arg4, arg6, temp_7_163, temp_7_163, 0, 0, decoder->unk154); + _motionVector(decoder, motion_vector_state, arg6, temp_7_163, temp_7_163, 0, 0, decoder->unk154); } } var_2_172 = 0; if (decoder->unk11C == 0) { if ((*mb_type) & 4) { if (decoder->unk848 != 0) { - _motionVectors(decoder, arg4, arg6, sp24, 1, var_19_84, var_20_86, decoder->f_code_backward_h - 1, + _motionVectors(decoder, motion_vector_state, arg6, sp24, 1, var_19_84, var_20_86, decoder->f_code_backward_h - 1, decoder->f_code_backward_v - 1, 0, var_23_95); } else { temp_7_200 = decoder->unk160 - 1; - _motionVector(decoder, ((u8 *)arg4) + 8, arg6, temp_7_200, temp_7_200, 0, 0, + _motionVector(decoder, ((u8 *)motion_vector_state) + 8, arg6, temp_7_200, temp_7_200, 0, 0, decoder->unk15C); } } @@ -136,21 +136,21 @@ int _decMB0(struct MpegDecoder *decoder, int *mb_type, int *motion_type, int *dc } if ((((*mb_type) & 1) || ((decoder->dc_reset = 1, ((*mb_type) & 1) != 0))) && (decoder->concealment_motion_vectors == 0)) { - arg4->unk14 = 0; - arg4->unk10 = 0; - arg4->unk4 = 0; - arg4->unk0 = 0; - arg4->unk1C = 0; - arg4->unk18 = 0; - arg4->unkC = 0; - arg4->unk8 = 0; + motion_vector_state->unk14 = 0; + motion_vector_state->unk10 = 0; + motion_vector_state->unk4 = 0; + motion_vector_state->unk0 = 0; + motion_vector_state->unk1C = 0; + motion_vector_state->unk18 = 0; + motion_vector_state->unkC = 0; + motion_vector_state->unk8 = 0; } temp_4_287 = decoder->picture_coding_type; var_2_172 = 1; if (temp_4_287 == 2) { var_2_172 = 1; if (!((*mb_type) & 9)) { - arg4->unk0 = (arg4->unk4 = (arg4->unk10 = (arg4->unk14 = 0))); + motion_vector_state->unk0 = (motion_vector_state->unk4 = (motion_vector_state->unk10 = (motion_vector_state->unk14 = 0))); if (decoder->picture_structure == 3) { *motion_type = temp_4_287; } else { From edb6bb13cff231b8bfb4a16ff6c94f445623bfe1 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:14:05 +0000 Subject: [PATCH 113/135] decomp: clarify names in _cpr8 arg0 -> decoder: In src/sdk/library/cpr8.c (SHA-256 fc553539a63c03c769910e0f78f04b0c81fa872161c4130bb1ddc234b6fe34ec), arg0 has type struct MpegDecoder *. Retail 0x001298c0 preserves a0; 0x001298ec loads its +0xd8 destination base, which reaches SPR_FROM_MADR at 0x00129a3c. Its +0x174 and +0xe0 fields select copy layout at 0x001298f0-0x00129978, and +0xe4 advances the destination between passes at 0x00129ae4-0x00129b04. Thus decoder names the decoder object supplying destination and frame layout. arg1 -> copy_params: The bound C declares arg1 as struct MpegCopyParams *. Retail 0x001298bc preserves it in s6; 0x001298e8 loads offset 0, masks it at 0x001298f4, and writes the resulting source address to SPR_TO_MADR at 0x001299c0. Offset +0x10 determines transfer bytes and QWC at 0x00129924-0x00129934 or 0x00129954-0x00129978, while +0xc bounds the copy loop at 0x00129988 and 0x00129a6c-0x00129ac4. These uses prove copy_params describes the copy configuration object. --- src/sdk/library/cpr8.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sdk/library/cpr8.c b/src/sdk/library/cpr8.c index 5b393331e4..16568d37d8 100644 --- a/src/sdk/library/cpr8.c +++ b/src/sdk/library/cpr8.c @@ -19,7 +19,7 @@ struct MpegDecoderFrame { extern s32 DIntr(); extern s32 EnableInterrupts(); -void _cpr8(struct MpegDecoder *arg0, struct MpegCopyParams *arg1) { +void _cpr8(struct MpegDecoder *decoder, struct MpegCopyParams *copy_params) { struct MpegDecoderFrame *sp0; s32 sp4; s32 sp8; @@ -35,9 +35,9 @@ void _cpr8(struct MpegDecoder *arg0, struct MpegCopyParams *arg1) { s32 var_3_29; s32 var_5_64; - sp0 = (struct MpegDecoderFrame *)arg0; - var_18_22 = arg1->unk0 & 0x0FFFFFFF; - sp8 = arg0->unkD8 & 0x0FFFFFFF; + sp0 = (struct MpegDecoderFrame *)decoder; + var_18_22 = copy_params->unk0 & 0x0FFFFFFF; + sp8 = decoder->unkD8 & 0x0FFFFFFF; if (sp0->unk174 == 3) { goto block_3; } @@ -50,7 +50,7 @@ void _cpr8(struct MpegDecoder *arg0, struct MpegCopyParams *arg1) { block_3: var_3_29 = sp0->unkE0; block_4: - var_21_38 = arg1->unk10 * 0x180; + var_21_38 = copy_params->unk10 * 0x180; var_20_40 = var_21_38 >> 4; if (var_3_29 == 0) { goto block_6; @@ -64,14 +64,14 @@ void _cpr8(struct MpegDecoder *arg0, struct MpegCopyParams *arg1) { goto block_9; block_8: var_30_43 = (temp_4_27 >> 4) * 0xC0; - var_21_38 = ((s32)arg1->unk10 >> 1) * 0x180; + var_21_38 = ((s32)copy_params->unk10 >> 1) * 0x180; sp4 = 2; var_20_40 = var_21_38 >> 4; block_9: var_5_64 = 0; while (var_5_64 < sp4) { var_17_68 = sp8; - for (var_16_70 = 0; var_16_70 < arg1->unkC; var_16_70++) { + for (var_16_70 = 0; var_16_70 < copy_params->unkC; var_16_70++) { temp_2_73 = DIntr(); *(volatile s32 *)0x1000D480 = 0; *(volatile s32 *)0x1000D410 = var_18_22; From cffc1b63a5c6073323f17552bb6d78e9d5968f9a Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:15:20 +0000 Subject: [PATCH 114/135] decomp: clarify names in _motionVector arg0 -> decoder_state: Retail 0x001282dc preserves a0 in s3, subsequently passed to decode_ipu_vlc at 0x0012831c/0x00128374 and read_mpeg_bits at 0x00128334/0x0012838c. Original Ghidra explicitly casts this parameter to MpegVideoDecoderState *pState; source arg0 follows the same _ipuVdec/_nextBit data flow. arg1 -> motion_vector: Source types arg1 as struct MotionVector *. Retail 0x001282e4 preserves it in s2, passes s2 to component decoder FUN_001280a8 at 0x00128354, then s2+4 at 0x001283bc/0x001283c0. Loads/stores at 0x001283a8-0x001283b0 and 0x001283cc-0x001283d4 operate on its second component. arg3 -> first_component_bit_count: Retail 0x00128314 saves a3 in s1; when both s1 and the first VLC result are nonzero, 0x00128334/0x00128338 passes s1 as the bit count to read_mpeg_bits. 0x00128348 then supplies the same value to FUN_001280a8 with the base motion-vector address. Source _nextBit(arg0,arg3) and decode_motion_vector(arg1,arg3,code,bits,arg7) agree. arg4 -> second_component_bit_count: Retail 0x0012830c saves the fifth argument in s4; 0x0012838c/0x00128390 passes s4 as read_mpeg_bits bit count for the second VLC result. 0x001283a4 and 0x001283bc/0x001283c0 pass that count with motion_vector+4 to FUN_001280a8, matching source _nextBit(arg0,arg4) and the second decode_motion_vector call. arg6 -> halve_second_component_for_decode: Retail 0x001282fc preserves the seventh argument in s6. Its nonzero branch at 0x001283a0 enables arithmetic right shift of the second component at 0x001283a8-0x001283b0 before FUN_001280a8; the same flag at 0x001283c4 enables left shift at 0x001283cc-0x001283d4 afterward. Source arg6 gates exactly these pre-decode halving and post-decode doubling operations. --- src/sdk/library/motion_vector.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/sdk/library/motion_vector.c b/src/sdk/library/motion_vector.c index 3aa88c8db3..f24cbf69fb 100644 --- a/src/sdk/library/motion_vector.c +++ b/src/sdk/library/motion_vector.c @@ -15,35 +15,35 @@ extern s32 _ipuVdec(); extern s32 _nextBit(); extern s32 decode_motion_vector() __asm__("func_001280A8"); -void _motionVector(s32 arg0, struct MotionVector *arg1, struct MotionVectorStore *arg2, s32 arg3, s32 arg4, - s32 arg5, s32 arg6, s32 arg7) { +void _motionVector(s32 decoder_state, struct MotionVector *motion_vector, struct MotionVectorStore *arg2, s32 first_component_bit_count, s32 second_component_bit_count, + s32 arg5, s32 halve_second_component_for_decode, s32 arg7) { s32 code; s32 bits; - code = _ipuVdec(arg0, 2); - if (arg3 != 0 && code != 0) { - bits = _nextBit(arg0, arg3); + code = _ipuVdec(decoder_state, 2); + if (first_component_bit_count != 0 && code != 0) { + bits = _nextBit(decoder_state, first_component_bit_count); } else { bits = 0; } - decode_motion_vector(arg1, arg3, code, bits, arg7); + decode_motion_vector(motion_vector, first_component_bit_count, code, bits, arg7); if (arg5 != 0) { - arg2->unk0 = InitializeMemoryCardDirectory(arg0); + arg2->unk0 = InitializeMemoryCardDirectory(decoder_state); } - code = _ipuVdec(arg0, 2); - if (arg4 != 0 && code != 0) { - bits = _nextBit(arg0, arg4); + code = _ipuVdec(decoder_state, 2); + if (second_component_bit_count != 0 && code != 0) { + bits = _nextBit(decoder_state, second_component_bit_count); } else { bits = 0; } - if (arg6 != 0) { - arg1->unk4 >>= 1; + if (halve_second_component_for_decode != 0) { + motion_vector->unk4 >>= 1; } - decode_motion_vector((u8 *)arg1 + 4, arg4, code, bits, arg7); - if (arg6 != 0) { - arg1->unk4 *= 2; + decode_motion_vector((u8 *)motion_vector + 4, second_component_bit_count, code, bits, arg7); + if (halve_second_component_for_decode != 0) { + motion_vector->unk4 *= 2; } if (arg5 != 0) { - arg2->unk4 = InitializeMemoryCardDirectory(arg0); + arg2->unk4 = InitializeMemoryCardDirectory(decoder_state); } } From 682a870ce54ff95bdd97bcf44b1d565142b37099 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:15:20 +0000 Subject: [PATCH 115/135] decomp: clarify names in _decodeOrSkip arg2 -> skip_threshold: In source src/sdk/library/_decodeOrSkip.c (SHA-256 e20026601bc46ff804cf5c11db635261b98978159960333de1c39976863e76eb), arg2 is the third s32 parameter forwarded to both helpers. Root instructions 0x0012bf38/0x0012bf48 preserve a2. Frame helper 0x0012be24 bypasses comparison for a2 == -1; 0x0012be2c performs signed slt a1,a2, and 0x0012be30 selects 0x0012be74 when a1 >= a2, omitting 0x001293f0 and requesting MPEG input at 0x0012be84. Field helper 0x0012bf8c/0x0012bf94 applies the same sentinel/comparison; s3 remains zero for a1 >= a2, gating out 0x001293f0 at 0x0012bfcc and 0x0012c03c and selecting the input request at 0x0012c090. Thus this is the skip decision threshold, with -1 disabling that threshold. --- src/sdk/library/_decodeOrSkip.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdk/library/_decodeOrSkip.c b/src/sdk/library/_decodeOrSkip.c index a2679c06ae..92c76c0503 100644 --- a/src/sdk/library/_decodeOrSkip.c +++ b/src/sdk/library/_decodeOrSkip.c @@ -3,9 +3,9 @@ extern s32 _decodeOrSkipFrame(); extern s32 _decodeOrSkipField(); -s32 _decodeOrSkip(s32 mp, s32 arg1, s32 arg2) { +s32 _decodeOrSkip(s32 mp, s32 arg1, s32 skip_threshold) { if ((*(s32 **)(mp + 0x40))[0x5D] != 3) { - return _decodeOrSkipField(mp, arg1, arg2); + return _decodeOrSkipField(mp, arg1, skip_threshold); } - return _decodeOrSkipFrame(mp, arg1, arg2); + return _decodeOrSkipFrame(mp, arg1, skip_threshold); } From df2b784999a5594716af47a6ae80fcef687f2a12 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:15:20 +0000 Subject: [PATCH 116/135] decomp: clarify names in _nextStartCode arg0 -> decoder_state: At 0x00128a70 the incoming a0 pointer is saved in s0, then used by _waitIpuIdle at 0x00128a78 and restored into a0 at 0x00128aa4, 0x00128ab8 and 0x00128ac4 for _flushBuf and _peepBit. The source passes this same s32 * to the wait, alignment advance, 24-bit peek and eight-bit advance operations. Original retail Ghidra identifies the parameter as MpegVideoDecoderState *pState in this MPEG start-code search, proving decoder_state as its role without changing its type. --- src/sdk/library/nextstartcode.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sdk/library/nextstartcode.c b/src/sdk/library/nextstartcode.c index e6e803ff41..9652e4ce01 100644 --- a/src/sdk/library/nextstartcode.c +++ b/src/sdk/library/nextstartcode.c @@ -2,16 +2,16 @@ extern void _waitIpuIdle(s32 *ctx); extern s32 _peepBit(s32 *ctx, s32 count); extern void _flushBuf(s32 *ctx, s32 count); -void _nextStartCode(s32 *arg0) { +void _nextStartCode(s32 *decoder_state) { s32 raw; s32 amount; - _waitIpuIdle(arg0); + _waitIpuIdle(decoder_state); raw = *(volatile s32 *)0x10002020; amount = (-(raw & 7)) & 7; if (amount != 0) { - _flushBuf(arg0, amount); + _flushBuf(decoder_state, amount); } - while (_peepBit(arg0, 0x18) != 1) { - _flushBuf(arg0, 8); + while (_peepBit(decoder_state, 0x18) != 1) { + _flushBuf(decoder_state, 8); } } From a002c40546ef6da026eb6c3d511d6b4eedf9f479 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:15:20 +0000 Subject: [PATCH 117/135] decomp: clarify names in sceCdMmode arg0 -> media_mode: In sceCdMmode, source mode = arg0 feeds *(s32 *)D_00132900 = mode. Retail 0x0012139c saves incoming a0 to s0; 0x001213b4 stores s0 at 0x00132900 after command acquisition. Instructions 0x001213c0-0x001213c8 write back four bytes, and 0x001213dc-0x001213f8 pass that address and size 4 as the synchronous RPC 0x22 request. The prepared original Ghidra decompilation identifies this same parameter as media_mode and the request as the native CD media selector. --- src/sdk/library/scecdmmode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdk/library/scecdmmode.c b/src/sdk/library/scecdmmode.c index 45895ab47a..dd57e47b52 100644 --- a/src/sdk/library/scecdmmode.c +++ b/src/sdk/library/scecdmmode.c @@ -5,13 +5,13 @@ extern s32 SignalSema(); extern s32 cd_check_scmd() __asm__("func_00120D40"); extern s32 sceSifCallRpc(); extern void sceSifWriteBackDCache(); -s32 sceCdMmode(s32 arg0) { +s32 sceCdMmode(s32 media_mode) { register u8 *state; register s32 mode; s32 result; state = D_00132900; - mode = arg0; + mode = media_mode; if (cd_check_scmd(0x22) == 0) { return 0; } From 415e2cead122377827fcc9dbc04bb701559ef141 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:16:32 +0000 Subject: [PATCH 118/135] decomp: clarify names in receiveDataFromIPU arg0 -> destination_address: Retail 0x0012a140 saves a0 in s0; 0x0012a154 masks it with 0x0FFFFFFF, 0x0012a15c sets 0x80000000, and 0x0012a164 writes it to 0x1000B010, identified by the original decompilation as REG_DMAC_3_IPU_FROM_MADR. In receiveDataFromIPU this is the memory destination address of the from-IPU transfer, exactly matching the source arg0 expression. arg1 -> byte_count: Retail 0x0012a134 saves a1 in s1; 0x0012a16c shifts s1 right by 4 and 0x0012a174 stores it to 0x1000B020, identified by the original decompilation as REG_DMAC_3_IPU_FROM_QWC. The source arg1 >> 4 thus converts the supplied byte count to 16-byte quadword count before the transfer starts at 0x0012a180. --- src/sdk/dma/receive_data_from_ipu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdk/dma/receive_data_from_ipu.c b/src/sdk/dma/receive_data_from_ipu.c index 5560efe3f3..9c9041f93d 100644 --- a/src/sdk/dma/receive_data_from_ipu.c +++ b/src/sdk/dma/receive_data_from_ipu.c @@ -1,12 +1,12 @@ #include "types.h" extern s32 DIntr(); extern void EnableInterrupts(); -void receiveDataFromIPU(s32 arg0, s32 arg1) { +void receiveDataFromIPU(s32 destination_address, s32 byte_count) { s32 old; old = DIntr(); - *(volatile u32 *)0x1000B010 = (arg0 & 0x0FFFFFFF) | 0x80000000; - *(volatile u32 *)0x1000B020 = arg1 >> 4; + *(volatile u32 *)0x1000B010 = (destination_address & 0x0FFFFFFF) | 0x80000000; + *(volatile u32 *)0x1000B020 = byte_count >> 4; *(volatile u32 *)0x1000B000 = 0x100; if (old != 0) { EnableInterrupts(0x100); From 084118e1d6684c4a0fc72c98786c4b4abb99a474 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:16:32 +0000 Subject: [PATCH 119/135] decomp: clarify names in UpdateTempTrackData arg0 -> decoder: In src/sdk/library/update_temp_track_data.c (SHA-256 82088aa86a94502612f3351ae69130bd6e1cf63b0b67c545600870e32cc3daae), arg0 has type struct MpegDecoder * and owns every state access. Retail 0x00129088 copies the first parameter a0 into a2; 0x00129090 reads picture_coding_type at a2+0x150, 0x001290c0 reads state at +0x84c, and 0x001290cc/0x001290e0 and 0x001290f8 write state at +0x1ac and +0x850. The supplied original Ghidra decompilation identifies this same base as MpegVideoDecoderState *pState. These type and base-pointer flows establish decoder as its role. --- src/sdk/library/update_temp_track_data.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/sdk/library/update_temp_track_data.c b/src/sdk/library/update_temp_track_data.c index 642d699e1b..d7f5c0af0d 100644 --- a/src/sdk/library/update_temp_track_data.c +++ b/src/sdk/library/update_temp_track_data.c @@ -1,6 +1,6 @@ #include "types.h" #include "rnc/sdk/libmpeg.h" -void UpdateTempTrackData(struct MpegDecoder *arg0, s32 delta) { +void UpdateTempTrackData(struct MpegDecoder *decoder, s32 delta) { s32 temp_2_30; s32 temp_3_21; s32 temp_4_32; @@ -8,18 +8,18 @@ void UpdateTempTrackData(struct MpegDecoder *arg0, s32 delta) { s32 var_7_4; var_7_4 = 0; var_4_8 = 0; - if ((arg0->picture_coding_type != 3) && (delta != 0)) { + if ((decoder->picture_coding_type != 3) && (delta != 0)) { if (delta < 0) { - var_7_4 = arg0->unk854 == 0; + var_7_4 = decoder->unk854 == 0; } - arg0->unk854 = 0; + decoder->unk854 = 0; var_4_8 = delta; } - temp_3_21 = arg0->unk84C + delta; - arg0->unk1AC = temp_3_21; + temp_3_21 = decoder->unk84C + delta; + decoder->unk1AC = temp_3_21; if ((var_7_4 != 0) && (var_4_8 >= delta)) { - arg0->unk1AC = (s32)(temp_3_21 + 0x400); + decoder->unk1AC = (s32)(temp_3_21 + 0x400); }; - temp_4_32 = arg0->unk1AC; - arg0->unk850 = (s32)((arg0->unk850 < temp_4_32) ? (temp_4_32) : (arg0->unk850)); + temp_4_32 = decoder->unk1AC; + decoder->unk850 = (s32)((decoder->unk850 < temp_4_32) ? (temp_4_32) : (decoder->unk850)); } From 0707a9d9571dd2b789a7e3a4dd38911ca1df4a0b Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:16:32 +0000 Subject: [PATCH 120/135] decomp: clarify names in sceDmaReset arg0 -> enable_dma: In sceDmaReset(s32 arg0), the source uses arg0 only in if (arg0 == 1) before ORing 1 into volatile u32 at 0x1000E000. Retail 0x00123028 preserves incoming a0 in s0; 0x001230ac loads 1 and 0x001230b0 compares s0 with it. The equal path reads DMAC CTRL at 0x001230c0, ORs bit 0 at 0x001230c4, and stores it at 0x001230c8. Original Ghidra reset_dmac(int enable) shows the same conditional enable operation. --- src/sdk/dma/sce_dma_reset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdk/dma/sce_dma_reset.c b/src/sdk/dma/sce_dma_reset.c index 0b7040afdb..97a43836c5 100644 --- a/src/sdk/dma/sce_dma_reset.c +++ b/src/sdk/dma/sce_dma_reset.c @@ -27,7 +27,7 @@ extern s32 DmaChannelsUsed[] __asm__("D_001533F8"); extern s32 Memclr(); extern s32 sceDmaPutEnv(); -s32 sceDmaReset(s32 arg0) { +s32 sceDmaReset(s32 enable_dma) { s32 buf[5]; s32 status; s32 i; @@ -50,7 +50,7 @@ s32 sceDmaReset(s32 arg0) { *(u32 *)0x1000E010 = mask; Memclr(buf, 0x14); sceDmaPutEnv(buf); - if (arg0 == 1) { + if (enable_dma == 1) { *(volatile u32 *)0x1000E000 |= 1; } return status; From 2ee99c52b867850726f02a67154c2d40a862d321 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:16:32 +0000 Subject: [PATCH 121/135] decomp: clarify names in sceDbcGetDepNumber arg0 -> dependency_index: In src/sdk/library/sceDbcGetDepNumber.c (SHA-256 b630d7e6b05a0d04eaf4530e5c9cd42730d6afddfb3665069cd3c0e4504af448), s32 arg0 indexes ((s32 *)D_0015B500)[arg0] and is copied to RpcReceiveData.unk0. Retail 0x001247ec preserves a0 in s2; 0x001248a4 scales s2 by four, 0x001248ac adds the snapshot base, and 0x001248b0 loads the selected word for comparison to one. At 0x001248cc the same s2 is stored to request word zero at 0x0015B080 before RPC 0x80000903 at 0x001248f0. The original Ghidra decompilation identifies the array as the dependency snapshot and the parameter as dependency, supporting dependency_index. --- src/sdk/library/sceDbcGetDepNumber.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdk/library/sceDbcGetDepNumber.c b/src/sdk/library/sceDbcGetDepNumber.c index cbb5f7dbbc..910bf5d271 100644 --- a/src/sdk/library/sceDbcGetDepNumber.c +++ b/src/sdk/library/sceDbcGetDepNumber.c @@ -23,15 +23,15 @@ extern s32 synchronize_cache_range() __asm__("func_00118F88"); extern s32 debug_print_stub() __asm__("func_00124A20"); extern s32 sceSifCallRpc(); extern struct DbCState RpcReceiveData __asm__("D_0015B080"); -s32 sceDbcGetDepNumber(s32 arg0) { +s32 sceDbcGetDepNumber(s32 dependency_index) { s32 result; synchronize_cache_range(D_0015B480, D_0015B480 + 0x80); DIntr(); *(struct DbCBlob *)D_0015B500 = *(struct DbCBlob *)D_0015B480; EnableInterrupts(); - if (((s32 *)D_0015B500)[arg0] == 1) { - RpcReceiveData.unk0 = arg0; + if (((s32 *)D_0015B500)[dependency_index] == 1) { + RpcReceiveData.unk0 = dependency_index; if (sceSifCallRpc(D_0015B008, 0x80000903, 0, &RpcReceiveData, 0x400, &RpcReceiveData, 0x400, 0, 0) < 0) { debug_print_stub(D_001535B8); From e5365424b1d1325204c41f9a6a702734cc3719ed Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:17:45 +0000 Subject: [PATCH 122/135] decomp: clarify names in _request_rdata arg0 -> request: In the bound source, arg0 has type struct RpcRdataRequest *. Retail 0x0011aea0 saves incoming a0 in s0; 0x0011aeb0 and 0x0011aeb8 load its +0x14/+0x1c fields and 0x0011aec0/0x0011aec8 copy them into the newly allocated reply packet. At 0x0011aee0/0x0011aee4/0x0011aee8 its +0x28/+0x20/+0x24 fields become transfer arguments to isceSifSendCmd. The original Ghidra decompilation likewise reads these values from its incoming packet parameter, proving request as its role. --- src/sdk/rpc/request_rdata.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sdk/rpc/request_rdata.c b/src/sdk/rpc/request_rdata.c index c108809f3f..8d0d78e192 100644 --- a/src/sdk/rpc/request_rdata.c +++ b/src/sdk/rpc/request_rdata.c @@ -26,15 +26,15 @@ struct RpcRdataPacket { }; extern s32 GetRpcPacket(); extern void isceSifSendCmd(); -void _request_rdata(struct RpcRdataRequest *arg0, s32 arg1) { +void _request_rdata(struct RpcRdataRequest *request, s32 arg1) { s32 a; s32 b; struct RpcRdataPacket *packet; packet = GetRpcPacket(arg1); - a = (s32)arg0->unk14; - b = (s32)arg0->unk1C; + a = (s32)request->unk14; + b = (s32)request->unk1C; packet->unk14 = a; packet->unk1C = b; packet->unk20 = 0x8000000C; - isceSifSendCmd(0x80000008, packet, 0x40, arg0->unk20, arg0->unk24, arg0->unk28); + isceSifSendCmd(0x80000008, packet, 0x40, request->unk20, request->unk24, request->unk28); } From 2066d2040ecb00c5de6ee7bf68dbe264abbcbd3e Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:17:45 +0000 Subject: [PATCH 123/135] decomp: clarify names in _sysbitInit arg1 -> initial_bit_pointer: In src/sdk/system/sysbit_init.c (SHA-256 41ad116bb624b3cf42566c86394cdc2488be32530b4aa6a84c1c61d7a20a2206), the s32 arg1 is assigned directly to ctx->bit_pointer and ctx->field8. Retail 0x0012a934 saves incoming a1 in t0; 0x0012a93c stores t0 to context offset 0xc (bit_pointer), and 0x0012a94c stores the same value to offset 0x8. Original Ghidra param_2 has precisely these two stores. Thus this parameter is the initial bit_pointer value; 0x0012a948 then sets a1 to zero for _sysbitFlush, independently of the saved incoming value. --- src/sdk/system/sysbit_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdk/system/sysbit_init.c b/src/sdk/system/sysbit_init.c index a915958719..ef5eac2434 100644 --- a/src/sdk/system/sysbit_init.c +++ b/src/sdk/system/sysbit_init.c @@ -14,9 +14,9 @@ typedef struct SysbitState { extern void _sysbitFlush(SysbitState *ctx, s32 amount); -void _sysbitInit(SysbitState *ctx, s32 arg1, s32 base_addr, s32 size) { - ctx->field8 = arg1; - ctx->bit_pointer = arg1; +void _sysbitInit(SysbitState *ctx, s32 initial_bit_pointer, s32 base_addr, s32 size) { + ctx->field8 = initial_bit_pointer; + ctx->bit_pointer = initial_bit_pointer; ctx->bits = 0; ctx->cnt = 0; ctx->total = 0; From 888514eec16c0a38f98d116190a1e083e9be1cff Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:17:45 +0000 Subject: [PATCH 124/135] decomp: clarify names in _dispRefImage arg1 -> ref_image: In the authoritative src/sdk/library/_dispRefImage.c snapshot (SHA-256 b2eb7f40a609f6ca86bc8cd08c8e00edf6e1c65a1633e22d4c66c1e98c4dfc4b), arg1 has type struct MpegRefImage *. Retail 0x00129cfc saves a1 in s1; 0x00129d4c through 0x00129d98 copy fields at s1+0x5c/0x60/0x44..0x58 into decoder display state. Retail 0x00129da4 checks its status at +0x28 against 1, and 0x00129db8 forwards s1 as a1 into _csc_storeRefImage or _cpr8. The original Ghidra param_2 data flow agrees, proving this is the reference image processed by _dispRefImage. --- src/sdk/library/_dispRefImage.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/sdk/library/_dispRefImage.c b/src/sdk/library/_dispRefImage.c index cf084c402a..d78d8f3f45 100644 --- a/src/sdk/library/_dispRefImage.c +++ b/src/sdk/library/_dispRefImage.c @@ -13,32 +13,32 @@ extern s32 _cpr8(); extern s32 _csc_storeRefImage(); extern s32 _getPtsDtsFlags(); extern s32 _isOutSizeOK(); -void _dispRefImage(struct MpegDecoder *decoder, struct MpegRefImage *arg1) { +void _dispRefImage(struct MpegDecoder *decoder, struct MpegRefImage *ref_image) { u64 temp_6_28; struct MpegDisplayState *ref_info; s32 *temp_7_9; temp_7_9 = (s32 *)decoder->mpeg; - _getPtsDtsFlags(decoder, arg1, (s32 *)((u8 *)temp_7_9 + 0x10), (s32 *)((u8 *)temp_7_9 + 0x18), + _getPtsDtsFlags(decoder, ref_image, (s32 *)((u8 *)temp_7_9 + 0x10), (s32 *)((u8 *)temp_7_9 + 0x18), (s32 *)((u8 *)temp_7_9 + 0x20)); ref_info = (struct MpegDisplayState *)decoder->mpeg; decoder->unk80 = (s32)ref_info->unk10; temp_6_28 = D_00132E98[(s32)(ref_info->unk20 >> 5) & 0xF]; - decoder->unkCC = (s32)arg1->unk5C; + decoder->unkCC = (s32)ref_image->unk5C; decoder->unk88 = temp_6_28; - decoder->unkD0 = (s32)arg1->unk60; - decoder->unkB4 = (s32)arg1->unk44; - decoder->unkB8 = (s32)arg1->unk48; - decoder->unkBC = (s32)arg1->unk4C; - decoder->unkC0 = (s32)arg1->unk50; - decoder->unkC4 = (s32)arg1->unk54; - decoder->unkC8 = (s32)arg1->unk58; - if (_isOutSizeOK(decoder, arg1) != 0) { - if (arg1->status == 1) { + decoder->unkD0 = (s32)ref_image->unk60; + decoder->unkB4 = (s32)ref_image->unk44; + decoder->unkB8 = (s32)ref_image->unk48; + decoder->unkBC = (s32)ref_image->unk4C; + decoder->unkC0 = (s32)ref_image->unk50; + decoder->unkC4 = (s32)ref_image->unk54; + decoder->unkC8 = (s32)ref_image->unk58; + if (_isOutSizeOK(decoder, ref_image) != 0) { + if (ref_image->status == 1) { if (decoder->unkB0 != 0) { - _csc_storeRefImage(decoder, arg1); + _csc_storeRefImage(decoder, ref_image); } else { - _cpr8(decoder, arg1); + _cpr8(decoder, ref_image); } func_00129B38(decoder); } From 92f8383c9b9727475dfb0844ba1832531e048407 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:18:59 +0000 Subject: [PATCH 125/135] decomp: clarify names in SetD4Chcr arg0 -> channel_control: In SetD4Chcr, retail 0x0012cbc8 copies incoming a0 into s0 across DIntr; 0x0012cbf0 forms MMIO 0x1000b400 and 0x0012cbfc stores s0 there unchanged. The source assigns arg0 directly to *(volatile u32 *)0x1000B400. Original Ghidra identifies this destination as REG_DMAC_4_IPU_TO_CHCR and the parameter as the complete CHCR value. Thus arg0 is the channel control word, not a pointer or a single flag. --- src/sdk/dma/set_d4_chcr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdk/dma/set_d4_chcr.c b/src/sdk/dma/set_d4_chcr.c index 68c7db255f..6ec68a1950 100644 --- a/src/sdk/dma/set_d4_chcr.c +++ b/src/sdk/dma/set_d4_chcr.c @@ -3,10 +3,10 @@ extern s32 DIntr(); extern s32 EnableInterrupts(); -void SetD4Chcr(s32 arg0) { +void SetD4Chcr(s32 channel_control) { DIntr(); *(volatile u32 *)0x1000F590 = *(volatile u32 *)0x1000F520 | 0x10000; - *(volatile u32 *)0x1000B400 = arg0; + *(volatile u32 *)0x1000B400 = channel_control; *(volatile u32 *)0x1000F590 = *(volatile u32 *)0x1000F520 & 0xFFFEFFFF; EnableInterrupts(); } From a72a61f336c1919abd7c89791536a5146944a4ac Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:18:59 +0000 Subject: [PATCH 126/135] decomp: clarify names in __sinit arg0 -> reent_context: In authoritative src/sdk/library/sinit.c (SHA-256 054328bc65eb6d5bd5ac315d15907eb0557109994cf94f2081b688c68ac1141e), __sinit takes struct Reent *arg0. Retail 0x00113af0 retains a0 in s0; 0x00113b04/0x00113b08 write context offsets 0x3c/0x38. The original decompilation derives all three helper destinations from this same base (+0x1e4, +0x23c, +0x294), and instructions 0x00113b10, 0x00113b24 and 0x00113b38 pass s0 as a3 to each std call. Final stores at 0x00113b4c-0x00113b54 initialize offsets 0x1e0, 0x1dc and 0x1d8 of the same object. These uses prove reent_context as the typed initialization context. --- src/sdk/library/sinit.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/sdk/library/sinit.c b/src/sdk/library/sinit.c index ce136b713e..432995ea82 100644 --- a/src/sdk/library/sinit.c +++ b/src/sdk/library/sinit.c @@ -30,16 +30,16 @@ struct Reent { }; extern void std(); -void __sinit(struct Reent *arg0) { +void __sinit(struct Reent *reent_context) { s32 *temp_17_9; - temp_17_9 = ((u8 *)arg0 + (0x1E4)); - arg0->unk3C = D_00113AC8; - arg0->unk38 = 1; - std(temp_17_9, 4, 0, arg0); - std(((u8 *)arg0 + (0x23C)), 9, 1, arg0); - std(((u8 *)arg0 + (0x294)), 0xA, 2, arg0); - arg0->unk1E0 = temp_17_9; - arg0->unk1DC = 3; - arg0->unk1D8 = 0; + temp_17_9 = ((u8 *)reent_context + (0x1E4)); + reent_context->unk3C = D_00113AC8; + reent_context->unk38 = 1; + std(temp_17_9, 4, 0, reent_context); + std(((u8 *)reent_context + (0x23C)), 9, 1, reent_context); + std(((u8 *)reent_context + (0x294)), 0xA, 2, reent_context); + reent_context->unk1E0 = temp_17_9; + reent_context->unk1DC = 3; + reent_context->unk1D8 = 0; } From faf19b08bfab96a056a75f5d645e6124f14b4c8f Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:20:13 +0000 Subject: [PATCH 127/135] decomp: clarify names in sceCdCallback arg0 -> callback: In src/sdk/library/sceCdCallback.c (SHA-256 ca81bd6ba8174ac851f1f6a9242ad48521865563be6170ca331e4e5e3f98f84b), s32 arg0 is assigned to D_00159740[0] after sceCdSync(1) succeeds. Retail 0x00120680 preserves a0 in s1; 0x001206a8 loads the previous registration into s0, and 0x001206b0 stores s1 into the same slot before 0x001206bc returns s0. The original Ghidra decompilation identifies this slot as g_pNativeCdCallback and the incoming value as callback, proving the replacement callback role. --- src/sdk/library/sceCdCallback.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdk/library/sceCdCallback.c b/src/sdk/library/sceCdCallback.c index ace7e7fbff..4fafe9f846 100644 --- a/src/sdk/library/sceCdCallback.c +++ b/src/sdk/library/sceCdCallback.c @@ -5,7 +5,7 @@ extern s32 sceCdSync(); extern s32 DIntr(); extern s32 EnableInterrupts(); -s32 sceCdCallback(s32 arg0) { +s32 sceCdCallback(s32 callback) { s32 intr; s32 old; @@ -14,7 +14,7 @@ s32 sceCdCallback(s32 arg0) { } intr = DIntr(); old = D_00159740[0]; - D_00159740[0] = arg0; + D_00159740[0] = callback; if (intr != 0) { EnableInterrupts(); } From 9d3974c0997fe7806b4803e1ef8709197fffe7f1 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:20:13 +0000 Subject: [PATCH 128/135] decomp: clarify names in SetD4ChcrVariant arg0 -> chcr_value: At 0x0012ced0 incoming a0 is preserved in s0 across DIntr; 0x0012ceec/0x0012cef8 form MMIO address 0x1000B400, and 0x0012cf04 stores s0 there unchanged. The authoritative C assigns s32 arg0 directly to *(volatile u32 *)0x1000B400. Original Ghidra identifies this as REG_DMAC_4_IPU_TO_CHCR = dwControl, proving a complete CHCR value rather than a mask or address. --- src/sdk/dma/set_d4_chcr_variant.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdk/dma/set_d4_chcr_variant.c b/src/sdk/dma/set_d4_chcr_variant.c index c2606d5501..62524c6515 100644 --- a/src/sdk/dma/set_d4_chcr_variant.c +++ b/src/sdk/dma/set_d4_chcr_variant.c @@ -3,10 +3,10 @@ extern s32 DIntr(); extern s32 EnableInterrupts(); -void SetD4ChcrVariant(s32 arg0) { +void SetD4ChcrVariant(s32 chcr_value) { DIntr(); *(volatile u32 *)0x1000F590 = *(volatile u32 *)0x1000F520 | 0x10000; - *(volatile u32 *)0x1000B400 = arg0; + *(volatile u32 *)0x1000B400 = chcr_value; *(volatile u32 *)0x1000F590 = *(volatile u32 *)0x1000F520 & 0xFFFEFFFF; EnableInterrupts(); } From 4e7942c46e6e52bbc16ff2dc92bba22f14305965 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:21:25 +0000 Subject: [PATCH 129/135] decomp: clarify names in sceIpuSync arg0 -> sync_mode: In the authoritative sceIpuSync source (SHA-256 7a2d2f2611c3db1c84d4e1757a1fa5a39cd0eef31be225ac8d57912cde5819a2), s32 arg0 controls the switch. Retail 0x0012ce58 tests a0 against zero to select the signed CTRL read loop at 0x0012ce80/0x0012ce94; 0x0012ce60-0x0012ce64 compares it with one to select the single CTRL read and bit-31 extraction at 0x0012ceac-0x0012ceb0. Other values return zero without reading CTRL. Original Ghidra nMode has the same flow, proving this parameter is the synchronization mode. --- src/sdk/video/ipu/sce_ipu_sync.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdk/video/ipu/sce_ipu_sync.c b/src/sdk/video/ipu/sce_ipu_sync.c index 69a56131b5..0e16d6a5a9 100644 --- a/src/sdk/video/ipu/sce_ipu_sync.c +++ b/src/sdk/video/ipu/sce_ipu_sync.c @@ -1,9 +1,9 @@ #include "types.h" -u32 sceIpuSync(s32 arg0) { +u32 sceIpuSync(s32 sync_mode) { u32 result; result = 0; - switch (arg0) { + switch (sync_mode) { case 0: while (*(volatile s32 *)0x10002010 < 0) { } From 12fe676897e7bc4444a572e270bd45e37aeeb463 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:22:37 +0000 Subject: [PATCH 130/135] decomp: clarify names in scePad2GetSide arg0 -> port_index: In the authoritative src/sdk/input/sce_pad2_get_side.c snapshot (SHA-256 d225444d3c7b16471756a3f9f1bb66ac6572d871ea0fd34c1816fd519f127065), s32 arg0 is used as D_0015B540[arg0].unkC. Retail 0x00124f38 loads the PadPort stride 0x330, 0x00124f40 multiplies incoming a0 by it, 0x00124f44-0x00124f50 add the table base 0x0015B540, and 0x00124f54 loads the selected entry's pointer at offset 0xC. The supplied original Ghidra decompilation likewise indexes g_aPad2Sockets[socket].pDouble_buffer. This proves the argument is the pad-port table index. --- src/sdk/input/sce_pad2_get_side.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdk/input/sce_pad2_get_side.c b/src/sdk/input/sce_pad2_get_side.c index f8deec03db..052e2cb647 100644 --- a/src/sdk/input/sce_pad2_get_side.c +++ b/src/sdk/input/sce_pad2_get_side.c @@ -9,10 +9,10 @@ typedef struct PadPort { extern PadPort D_0015B540[]; extern void synchronize_cache_range(s32, s32) __asm__("func_00118F88"); -void *scePad2GetSide(s32 arg0) { +void *scePad2GetSide(s32 port_index) { u8 *sides[2]; - sides[0] = D_0015B540[arg0].unkC; + sides[0] = D_0015B540[port_index].unkC; sides[1] = sides[0] + 0x80; synchronize_cache_range((s32)sides[0], (s32)(sides[0] + 0x100)); return sides[*(s32 *)(sides[0] + 0x7C) < *(s32 *)(sides[1] + 0x7C)]; From 5ea7eb822b6d52893f3cdd9a9f5328db85ab47a1 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:22:37 +0000 Subject: [PATCH 131/135] decomp: clarify names in scePad2CheckDma arg0 -> socket_index: In the authoritative source src/sdk/input/sce_pad2_check_dma.c (SHA-256 ce91e037f304cf547934e94ac343a08d02f24dbfcb608d7eeb56a1de2e5d305d), s32 arg0 indexes D_0015B540[arg0].unkC. Retail 0x00124fa0 loads stride 0x330, 0x00124fa8 multiplies incoming a0 by that stride, 0x00124fb4 adds the array base, and 0x00124fb8 loads the selected record's buffer pointer at +0xC. Prepared Ghidra expresses the same flow as g_aPad2Sockets[socket].pDouble_buffer. Thus the argument is a socket record index; subsequent +0x7C sequence reads and +0x80 bank selection operate on its chosen buffer. --- src/sdk/input/sce_pad2_check_dma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdk/input/sce_pad2_check_dma.c b/src/sdk/input/sce_pad2_check_dma.c index 07c6e7d9cf..a04ae4139a 100644 --- a/src/sdk/input/sce_pad2_check_dma.c +++ b/src/sdk/input/sce_pad2_check_dma.c @@ -15,12 +15,12 @@ extern PadPort D_0015B540[]; __attribute__((section(".data"))) extern DmaState D_00132DD8; -s32 scePad2CheckDma(s32 arg0) { +s32 scePad2CheckDma(s32 socket_index) { u32 sides[2]; u32 p; s32 value; - p = (u32)D_0015B540[arg0].unkC; + p = (u32)D_0015B540[socket_index].unkC; value = *(s32 *)(p + 0x7C); sides[0] = p; sides[1] = p + 0x80; From 0a76c53bf6f53ab0c9dc86983c1dee74d1abbd0b Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:23:50 +0000 Subject: [PATCH 132/135] decomp: clarify names in _lastFrame arg0 -> decoder: In the authoritative C, arg0 has type struct MpegDecoder * and owns frame_count, second_field, picture_structure and ref_images. Retail 0x0012c144 preserves incoming a0 in s0; 0x0012c148/150/168 read decoder fields at +0x120/+0x118/+0x174, and 0x0012c178/190/194 load its reference-image pointers. At 0x0012c184 and 0x0012c19c this same pointer is passed as a0 to _dispRefImage and _dispRefImageField; the error path passes it to _Error and every path clears its +0x120 field. Original Ghidra likewise casts param_1 to MpegVideoDecoderState *pState. These uses prove the decoder role. --- src/sdk/library/_lastFrame.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sdk/library/_lastFrame.c b/src/sdk/library/_lastFrame.c index b42d8d8656..382b461997 100644 --- a/src/sdk/library/_lastFrame.c +++ b/src/sdk/library/_lastFrame.c @@ -5,17 +5,17 @@ extern s32 _Error(struct MpegDecoder *, u8 *, s32); extern s32 _dispRefImage(struct MpegDecoder *, struct MpegRefImage *, s32); extern s32 _dispRefImageField(struct MpegDecoder *, struct MpegRefImage *, struct MpegRefImage *, s32); -void _lastFrame(struct MpegDecoder *arg0) { +void _lastFrame(struct MpegDecoder *decoder) { s32 count; - count = arg0->frame_count; - if (arg0->second_field != 0) { - _Error(arg0, D_00153AB8, count); + count = decoder->frame_count; + if (decoder->second_field != 0) { + _Error(decoder, D_00153AB8, count); } else { - if (arg0->picture_structure == 3) { - _dispRefImage(arg0, arg0->ref_images[1], count - 1); + if (decoder->picture_structure == 3) { + _dispRefImage(decoder, decoder->ref_images[1], count - 1); } else { - _dispRefImageField(arg0, arg0->ref_images[5], arg0->ref_images[9], count - 1); + _dispRefImageField(decoder, decoder->ref_images[5], decoder->ref_images[9], count - 1); } } - arg0->second_field = 0; + decoder->second_field = 0; } From ca613fa84cb6391f79ff6be7235ea857c25ad516 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:25:02 +0000 Subject: [PATCH 133/135] decomp: clarify names in sceDbcSetWorkAddr arg0 -> work_address: In the bound source src/sdk/library/sceDbcSetWorkAddr.c (SHA-256 06ed92f4316d0b5bf9785b55227612a99865a76638ee76bb50000415095f8e9f), s32 arg0 is assigned directly to RpcReceiveData.unk4. Retail 0x001246c0 forms the shared buffer pointer in a3 and 0x001246c8 stores incoming a0 to 4(a3); 0x001246e4 submits that buffer to sceSifCallRpc with command 0x80000904 and 0x400-byte send/receive sizes. The established function sceDbcSetWorkAddr and supplied original Ghidra decompilation identify this unchanged request word as work_address. Thus work_address describes the parameter's address payload without changing its s32 type. --- src/sdk/library/sceDbcSetWorkAddr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdk/library/sceDbcSetWorkAddr.c b/src/sdk/library/sceDbcSetWorkAddr.c index f9550e3944..8da44c5779 100644 --- a/src/sdk/library/sceDbcSetWorkAddr.c +++ b/src/sdk/library/sceDbcSetWorkAddr.c @@ -16,8 +16,8 @@ extern u8 D_00153558[]; extern s32 debug_print_stub() __asm__("func_00124A20"); extern s32 sceSifCallRpc(); extern struct DbCState RpcReceiveData __asm__("D_0015B080"); -s32 sceDbcSetWorkAddr(s32 arg0) { - RpcReceiveData.unk4 = arg0; +s32 sceDbcSetWorkAddr(s32 work_address) { + RpcReceiveData.unk4 = work_address; if (sceSifCallRpc(RpcQueueData, 0x80000904, 0, &RpcReceiveData, 0x400, &RpcReceiveData, 0x400, 0, 0) < 0) { debug_print_stub(D_00153558); From 6f526654e7cd1375c5963b168da7f44de8fecb40 Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:25:03 +0000 Subject: [PATCH 134/135] decomp: clarify names in _flushBuf arg1 -> bit_count: In the authoritative C, s32 arg1 flows unchanged through value into command = value | 0x40000000. Retail 0x00128850 preserves a1 in s1; 0x001288b8 loads the FDEC opcode 0x40000000, 0x001288c0 ORs s1 into it, and 0x001288c8 writes it to IPU_CMD at 0x10002000. The original retail decompilation identifies this operand as nBitCount, the number of bits advanced; the completed result becomes the refreshed bit window at 0x001288fc with 32 available bits at 0x001288f8. Thus bit_count describes the second parameter's proven bit-advance role. --- src/sdk/library/_flushBuf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdk/library/_flushBuf.c b/src/sdk/library/_flushBuf.c index 0ad9018122..bd6bff8570 100644 --- a/src/sdk/library/_flushBuf.c +++ b/src/sdk/library/_flushBuf.c @@ -35,7 +35,7 @@ typedef struct FlushBufContext { extern s32 _dispatchMpegCbNodata(); extern s64 _waitIpuIdle64(); -void _flushBuf(FlushBufContext *context, s32 arg1) { +void _flushBuf(FlushBufContext *context, s32 bit_count) { s32 value; s32 counter; u32 command; @@ -43,7 +43,7 @@ void _flushBuf(FlushBufContext *context, s32 arg1) { s32 index; s64 idle_result; - value = arg1; + value = bit_count; counter = 0; if ((*(volatile u32 *)0x10002010 & 0x80004000) == 0x80000000) { do { From 317dc082a09491d90486a2033e5b19c28f7c63ea Mon Sep 17 00:00:00 2001 From: Ben Perry <7693062+ben-perry@users.noreply.github.com> Date: Sat, 17 Oct 2026 02:26:13 +0000 Subject: [PATCH 135/135] decomp: clarify names in _sceSifLoadModuleBuffer arg0 -> iop_address: Retail 0x0011cb84 saves first parameter a0 in s3; 0x0011cbd8 stores s3 into the request word at 0x00158200, matching source SIFCMD->unk0 = arg0. At 0x0011cd14/0x0011cd1c/0x0011cd2c this request is sent through sceSifCallRpc operation 6. The supplied original Ghidra signature calls this uint iop_address and its plate identifies loading a module already resident in IOP memory. The parameter is forwarded as the module's IOP address, while the separate src/size parameters supply argument bytes at request offset 0x104. --- src/sdk/rpc/sce_sif_load_module_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdk/rpc/sce_sif_load_module_buffer.c b/src/sdk/rpc/sce_sif_load_module_buffer.c index bdcadd261f..e16efc6484 100644 --- a/src/sdk/rpc/sce_sif_load_module_buffer.c +++ b/src/sdk/rpc/sce_sif_load_module_buffer.c @@ -10,7 +10,7 @@ extern s32 sif_load_module_server_changed() __asm__("func_0011CAE0"); extern s32 memcpy(); extern s32 sceSifCallRpc(); #define SIFCMD ((struct SifLoadModuleArgs *)D_00158200) -s32 _sceSifLoadModuleBuffer(s32 arg0, s32 size, s32 src, s32 *result_out) { +s32 _sceSifLoadModuleBuffer(s32 iop_address, s32 size, s32 src, s32 *result_out) { s32 var_2_18; s32 temp; @@ -21,7 +21,7 @@ s32 _sceSifLoadModuleBuffer(s32 arg0, s32 size, s32 src, s32 *result_out) { if (sif_load_module_server_changed() != 0) { return 0xFFFEFFFC; } - SIFCMD->unk0 = arg0; + SIFCMD->unk0 = iop_address; if (src != 0) { if (size >= 0xFD) { memcpy(D_00158200 + 0x104, (void *)src, 0xFC);