Skip to content

refactor(names): name the controller vibration code and the hero's set-action copies - #471

Open
Promises wants to merge 5 commits into
OpenRAC:masterfrom
Promises:refactor/actuator-patterns
Open

Promises wants to merge 5 commits into
OpenRAC:masterfrom
Promises:refactor/actuator-patterns

Conversation

@Promises

@Promises Promises commented Nov 23, 2026 •

Copy link
Copy Markdown

What

Readable names and comments for the level code's controller vibration (rumble) pattern player, next to LevelActuatorCalcPower in src/levels/shared/L00_002D67A8.c. Names and comments only, plus readable struct and field names; no code changes.

Symbol New name Was
func_L00_002D6900 actuator_play_pattern queue_copy_record_by_index
func_L00_002D6998 actuator_play_waves slot_copy_records_to_free
func_L00_002D6940 actuator_stop_all slot_clear_active_bytes
func_L00_002D6B70 actuator_end_looping_waves slot_reset_active
func_L00_002D6978 actuator_is_channel_active slot_is_entry_nonzero
D_L00_0025E120 g_actuator_patterns g_queue_source_records
D_L04_001B94C0 g_wave_l04_channels g_free_slot_records
D_L24_001B8500 g_wave_l24_channels g_slot_entry_table
  • g_wave_l04_channels and g_wave_l24_channels are the same eight-entry WaveChannel array as g_wave_l00_channels, named by the address the code uses in levels 04 and 24. In every USA v2.00 level program, all five functions and the mixer use one address.
  • In the unit, the hashed Rac2Native_…_src_record / _dst_record structs and ConditionalResetSlot become WaveRecord (one wave of a pattern: WaveChannel's fields, with the peak level instead of the amplitude) and WaveChannel (the envelope file's layout).
  • The comments explain:
    • what a pattern index is.
    • that the table holds 48 patterns (measured in all 27 USA v2.00 levels), even though the bound check is < 0x62.
    • that the hero's set-action functions call actuator_stop_all on every action change unless hero halfword 0x1FA is set.
    • that callers pass actuator_end_looping_waves the handle actuator_play_waves returned, but it ends every looping wave.
  • tools/names.py rename changed the call sites (155 files across src/, src/pal, src/us2).

Why: I found this while porting Going Commando's rumble to a Ratchet & Clank 1 mod. With these names, calls such as actuator_play_pattern(18) in the hero's hit state read as rumble, not as a slot copy.

Checked

  • python3 tools/build.py all --version us2 --strict: 28 of 28 programs OK. The five functions are in placed.json as C in the levels I checked.
  • python3 tools/build.py boot --version pal --strict: pal boot: OK.
  • The object of src/levels/shared/L00_002D67A8.c (the only file with more than name changes) is byte-identical to master's. I compiled both with tools/check.py: 27 of 27 places match.
  • The other 155 changed C files are token-identical to master once tools/srcnames.py turns names back into address names, comments aside. So the objects do not depend on the release.
  • python3 -m unittest discover -s tests passes, except three tests that need a C compiler on the host. Those fail on master the same way, and they pass in the build container. python3 tests/check_repository.py, python3 tools/progress.py --check and python3 tools/names.py check pass.
  • Not run: the USA v1.01 build (I had no v1.01 disc) and the PAL level builds (I had only the PAL boot executable). No functions were added; progress/report.json is unchanged.

Added: four more commits

refactor(names): name the vibration's update, actuator_update

func_L00_002D6FD8 (was math_add_wrapping_counter) is the vibration's update. It calls LevelActuatorCalcPower: ref_L00_002D6FD8_02 resolves to it in all 27 USA v2.00 levels. When the option byte ref_L00_002D6FD8_01[2] is set, it writes the pad's motor bytes at g_pad_state +0x188 (small) and +0x189 (large); ref_L00_002D6FD8_03 is 0x138180 in every program. The "wrapping counter" is the small motor's running sum. The motor turns on each time the sum reaches 256, and the sum then drops by 255, so the mixed value sets how often the small motor is on. The hashed struct view becomes PadMotors { small_motor, large_motor }, and each external gets a comment.

refactor(names): name the weapons' and vehicles' rumble wave lists

Eighteen data symbols named as sound, HUD or effect records are WaveRecord lists. Each is only ever passed to actuator_play_waves, and the handle the caller keeps is what it later gives actuator_end_looping_waves. I checked with git grep: no other use. They take g_<user>_rumble_waves after the function that plays them:

  • g_blitz_gun_, g_bouncer_, g_lock_on_weapon_, g_charging_weapon_, g_spread_weapon_, g_gravity_bomb_, g_megarocket_, g_mini_nuke_, g_mini_nuke_l04_, g_minirocket_, g_scoped_weapon_ and g_vaporizer_rumble_waves.
  • g_lancer_shot_rumble_waves: a shot of MOBY_CLASS_LANCER.
  • g_lancer_held_rumble_waves: the Lancer's other class, looping until its button is let go.
  • g_ferry_rumble_waves_a..c: Oozla's path_ferry_update.
  • g_ship_l05_rumble_waves: Feltzin's ship.

refactor(names): one name for the levels' copies of SetHeroMoveState

Fifteen levels have their own copy of the hero's action change: the function that ends in a switch on the new action and stops the vibration on its way in. Level 01's copy is the recovered SetHeroMoveState. The other copies were hero_lNN_set_action, _enter_state, _set_state, _change_action and hero_change_action; they now take the style's per-level name, hero_lNN_set_move_state. Their PAL and USA v2.00 versions get the same name plus _pal or _us2. hero_set_move_state_us2 becomes SetHeroMoveState_us2, next to the existing SetHeroMoveState_pal. 43 names change, all through tools/names.py rename, and no old name is left in the repository.

docs(src): say what hero 0x1FA holds back at the action change's stop-all

if (SHORT(0x1FA) == 0) actuator_stop_all(); gets a comment in all 45 copies (v1.01, PAL and USA v2.00). Hero 0x1FA is a timer:

  • State 0x14, the wrench slam, sets it to 50 as it plays its rumble on striking the ground (L00_002BA7D8.c in its case 0x14, L13_002C5760.c, and the L22 and L23 hero copies).
  • The hero's timer update counts it down (FastDecTimer in the *-timers-g8.c units).

So the slam's rumble outlasts the action changes that follow it.

Checked (the whole branch, at d7bec2e)

  • python3 tools/build.py all --version us2 --strict: 28 of 28 programs OK.
  • python3 tools/build.py boot --version pal --strict: OK.
  • The objects of L00_002D67A8.c and L00_002D6FD8.c, the only files with more than name changes, are byte-identical to master's. I compiled both on master and on the branch with tools/check.py; each function matched in 27 of 27 places.
  • The other 425 changed C files are token-identical to master once tools/srcnames.py turns names back into address names, comments aside.
  • tests/check_repository.py, tools/progress.py --check and tools/names.py check pass.
  • Unit tests: 725 run. The same three compiler-dependent tests as on master fail on the host and pass in the build container.
  • Not run: the USA v1.01 build and the PAL level builds, for lack of those discs.

The level code's small rumble player next to LevelActuatorCalcPower had
slot/queue names. Its table is the eight wave channels the mixer reads:
the functions start a list of waves in free channels, play a numbered
pattern from the level's table, stop all waves, end looping waves and
test one channel.

- func_L00_002D6900 actuator_play_pattern (was queue_copy_record_by_index)
- func_L00_002D6998 actuator_play_waves (was slot_copy_records_to_free)
- func_L00_002D6940 actuator_stop_all (was slot_clear_active_bytes)
- func_L00_002D6B70 actuator_end_looping_waves (was slot_reset_active)
- func_L00_002D6978 actuator_is_channel_active (was slot_is_entry_nonzero)
- D_L00_0025E120 g_actuator_patterns (was g_queue_source_records)
- D_L04_001B94C0 g_wave_l04_channels, D_L24_001B8500 g_wave_l24_channels
  (were g_free_slot_records, g_slot_entry_table): the same channel array
  as g_wave_l00_channels, by the address the code forms in level 04 / 24.

In L00_002D67A8.c the hashed record structs become WaveRecord (a pattern
entry, with its peak level) and WaveChannel (the envelope file's layout),
with field names, and each function gets a comment: what a pattern index
is, that the table holds 48 patterns although the bound is 0x62, that
the hero's set-action functions call actuator_stop_all on every action
change unless hero halfword 0x1FA is set, and that callers pass a handle
actuator_end_looping_waves ignores.

Checked: tools/build.py all --version us2 --strict: 28 programs OK;
tools/build.py boot --version pal --strict: OK. The object of
L00_002D67A8.c is byte-identical to master's; the other 155 changed C
files are token-identical to master in address names (comments aside).
No USA v1.01 disc to hand, so v1.01 and PAL levels were not built.
Tests, tests/check_repository.py, tools/progress.py --check and
tools/names.py check pass.
func_L00_002D6FD8 (was math_add_wrapping_counter) runs the level's
vibration mixer, LevelActuatorCalcPower (ref_L00_002D6FD8_02 is it in all
27 USA v2.00 levels), and with the option byte set writes the pad's motor
bytes at +0x188 (small) and +0x189 (large) of g_pad_state
(ref_L00_002D6FD8_03 is 0x138180 in every program). The "wrapping
counter" is the small motor's running sum: on each time it reaches 256,
which then drops by 255, so the mixed value says how often the small motor
is on. The struct view and its fields get readable names (PadMotors,
small_motor, large_motor) and the externals a comment each.

Checked with the branch's other commits; see the pull request.
Eighteen data symbols named as sound, HUD or effect records are wave
lists for the vibration: each is only ever passed to actuator_play_waves
(the WaveRecord lists it copies into the wave channels), and the handles
the callers keep are what they later give actuator_end_looping_waves.
They take g_<user>_rumble_waves after the function that plays them:

- blitz_gun_update, bouncer_update, UpdateLockOnWeapon,
  charging_weapon_update, UpdateSpreadWeapon, gravity_bomb_launcher_update,
  megarocket_cannon_update, mini_l00_nuke_update, minirocket_tube_update,
  UpdateScopedWeapon, vaporizer_update; mini_l04_nuke_update's own list
  (g_mini_nuke_l04_rumble_waves)
- lancer_update's two: g_lancer_shot_rumble_waves for a shot of
  MOBY_CLASS_LANCER and g_lancer_held_rumble_waves for its other class,
  held until the button is let go
- Oozla's ferry (path_ferry_update): g_ferry_rumble_waves_a..c
- Feltzin's ship (UpdateTimedTransformState,
  ResolveLinkedMobyMovementCollisions): g_ship_l05_rumble_waves

Checked with the branch's other commits; see the pull request.
Fifteen levels have their own copy of the hero's action change, the
function that keeps the last action, stops the vibration
(actuator_stop_all unless hero 0x1FA is set) and switches on the new
action to set it up. Level 01's is the recovered SetHeroMoveState; the
others were named hero_lNN_set_action, _enter_state, _set_state,
_change_action and hero_change_action. They take the style's name for a
level's copy, hero_lNN_set_move_state, and their PAL and USA v2.00
versions the same plus _pal or _us2 (hero_set_move_state_us2 becomes
SetHeroMoveState_us2, beside SetHeroMoveState_pal). 43 names change; the
uses follow through tools/names.py rename.

Checked with the branch's other commits; see the pull request.
…-all

Each copy of SetHeroMoveState stops the vibration on a change of action
unless the hero's halfword at 0x1FA is set. It is a timer: state 0x14 (the
wrench slam) sets it to 50 as it plays its rumble on striking the ground
(L00_002BA7D8.c, L13_002C5760.c, the L22 and L23 copies), and the
hero's timer update counts it down (FastDecTimer in the *-timers-g8.c
units), so the slam's rumble outlasts the actions that follow it. A
comment above the call in all 45 copies (v1.01, PAL, USA v2.00).

Checked with the branch's other commits; see the pull request.
@Promises Promises changed the title refactor(names): name the controller vibration pattern player refactor(names): name the controller vibration code and the hero's set-action copies Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant