Skip to content

decomp: name hero control modes, levels, card states, the game camera and syscall stubs - #278

Merged
mateuszklysz merged 5 commits into
mainfrom
decomp/rac1-enums-camera
Nov 3, 2026
Merged

mateuszklysz merged 5 commits into
mainfrom
decomp/rac1-enums-camera

Conversation

@mateuszklysz

@mateuszklysz mateuszklysz commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Before

Hero control modes, level indices and memory card states were raw numbers
(state.control_mode == 0xD, current_level_index == 14,
mode_freeze_state = 0x11). Three files named the card states after the dialog
text they draw (MODE_FREEZE_ALTERNATE_LEFT_PAIRED_FOOTER_MESSAGE). The
camera block at D_00186F40 was called PreviewCamera, its shake channels
were padding or a local struct of unk fields, and the level copy
(LevelCamera) had unk180, unk184, unk270, unk350, unk394,
unk398. 18 EE kernel stubs were named invoke_kernel_syscall_XXXX.

After

Names come from rac1-decomp's recent refactor, each one checked against our
code before it went in. Nothing else of theirs was taken.

  • enum HeroControlMode (rnc/hero/hero_state.h): 18 values, named from
    the states hero_set_state pairs with each one. 0x9, 0xA, 0xB, 0x10,
    0x13, 0x15, 0x16 and 0x18 stay numbers. 1493 compares and stores in 89
    files use it.
  • enum LevelId (rnc/world/level_id.h, included by rnc/globals.h):
    names follow config/us/levels/levels.json. 318 current_level_index
    compares use it.
  • enum CardState (rnc/ui/menus/save_data/save_card_state.h): the game's
    own CS_* names, from the table of strings that follows the handler table
    run_state_handler indexes (same order, 25 entries). The global
    D_0015EEB0 is now save_card_state (was mode_freeze_state); the local
    MODE_FREEZE_* enums in update_mode_freeze.c, draw_dialog_text.c and
    level_draw_dialog_text.c are replaced by the CS_* values.
  • Camera: PreviewCamera / preview_camera become GameCamera /
    game_camera (the item preview files keep their own local view).
    New struct CameraShake (rnc/camera/camera_shake.h), named from
    apply_camera_shake; GameCamera.shake[2] replaces the padding.
    LevelCamera gets the same names at the same offsets: current_camera
    and previous_camera (struct UpdateCam *: the code reads +0x30 pos
    and +0x86 from it), the shake offset and frames_max fields,
    transition_mode, rows, underwater, frame_count.
  • 18 syscall stubs renamed and moved out of assembly/sdk/syscalls/
    (file, yaml, symbol_addrs, unit_categories): Interrupt2Iop,
    _iEnableIntc, iTerminateThread, iChangeThreadPriority,
    iReleaseWaitThread, iCancelWakeupThread, iResumeThread, iPollSema,
    SetGsHParam, DisableIntcHandler, DisableDmacHandler,
    DisableCache, iGetCop0, SetCPUTimerHandler, SetPgifHandler,
    ExecOSD, _GetGsDxDyOffset, FindAddress. Each number was read from
    the stub's addiu $3, $0, N and matched to the public ps2sdk syscall
    table; the existing neighbours (0x29 ChangeThreadPriority, -0x34
    _iWakeupThread ...) match the same table. 0x0, 0x8, 0x52, 0x56, -0x5A,
    -0xFE and the 0x5A copies keep their old names: the table is not clear
    for them.

Not taken: their function names from reading the code (about 800 rows),
the full moby class enum and the Wrench pvars. They need checking one by
one.

Verification

  • make elf ends with PASS: reconstructed boot ELF matches retail
  • make overlays ends with PASS after a clean overlay rebuild (3014 functions, 24318 data objects)
  • scripts/check-cleanup.py: no new problems
  • clang -fsyntax-only on every changed file: no new errors

@mateuszklysz mateuszklysz added the enhancement New feature or request label Nov 3, 2026 — with Claude
@mateuszklysz mateuszklysz self-assigned this Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Decompilation progress

C_EXACT Change Matched bytes Functions C_FUZZY
All code 100.00 % — 3,547,932 / 3,547,932 B (—) 4,244 / 4,244 (—) 100.00 %
Boot executable 100.00 % — 354,504 / 354,504 B (—) 1,230 / 1,230 (—) 100.00 %
Game 100.00 % — 264,872 / 264,872 B (—) 850 / 850 (—) 100.00 %
SDK 100.00 % — 89,632 / 89,632 B (—) 380 / 380 (—) 100.00 %
Level overlays 100.00 % — 3,193,428 / 3,193,428 B (—) 3,014 / 3,014 (—) 100.00 %
Shared level code 100.00 % — 1,130,492 / 1,130,492 B (—) 1,583 / 1,583 (—) 100.00 %
Per-level code 100.00 % — 2,062,936 / 2,062,936 B (—) 1,431 / 1,431 (—) 100.00 %
Data in C Change Matched bytes
All data 62.81 % — 7,809,078 / 12,433,372 B (—)
Boot executable 26.98 % — 188,645 / 699,136 B (—)
Level overlays 64.94 % — 7,620,433 / 11,734,236 B (—)

No function changed its match state compared with main (1f76672).

Compared with main (1f76672). C_FUZZY uses main's last measurement.

@mateuszklysz
mateuszklysz merged commit cda8433 into main Nov 3, 2026
4 of 5 checks passed
@mateuszklysz
mateuszklysz deleted the decomp/rac1-enums-camera branch November 3, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant