Skip to content

Add PAL C for 11 PAL-only functions - #139

Open
chistianh wants to merge 11 commits into
OpenRAC:mainfrom
chistianh:pal-oficial-17
Open

chistianh wants to merge 11 commits into
OpenRAC:mainfrom
chistianh:pal-oficial-17

Conversation

@chistianh

Copy link
Copy Markdown
Contributor

11 PAL-only functions, one commit each, all reserved in #112 (my comment there).

PAL Where Size
func_0045E478 src/pal/game/ 412
func_004E0218 src/pal/game/ 432
func_L02_004CDB98 src/pal/overlays/shared/ 436
func_L15_004D8F88 src/pal/overlays/l15_control_level/ 456
func_L00_00691168 src/pal/overlays/shared/ 456
func_00448DC8 src/pal/game/ 468
func_L01_00589AE8 src/pal/overlays/shared/ 468
func_00466458 src/pal/game/ 488
func_L01_004FDE98 src/pal/overlays/shared/ 524
func_L01_0046D5B8 src/pal/overlays/shared/ 772
func_0046C320 src/pal/game/ 908

Checks: every file in src/pal/ MATCHES with tools/check_func.py --version pal, checked with src/pal/ set aside. The only failures are four files that fail in my checker only, as before: L15_004D8550.c, L01_00496500.c, L01_004AC708.c and core/0012C680.c. The branch is based on main (0bddadf). config/ and the reports are not regenerated. The C is plain C (no volatile, asm, #define aliases or hardcoded addresses).

Notes

What made these match, found by trying forms and comparing the output. I did not check the reasons in the compiler.

  1. Globals reached through $gp outside a delay slot are defined in the file. Retail reads D_00222460, D_0021EA98–D_0021EAAC, D_0021EC58, D_002208F4, D_002221EC and D_002203B4 with $gp in ordinary slots. As described in docs/TOOLCHAIN.md, ps2eeas does that only for a definition it has seen, so these files define them (s32 D_x = 0;). Globals read with lui stay extern.
  2. An extern declared as a struct or an array, not a scalar, keeps lui + offset. D_001F6808 (u16) was otherwise reached through $gp. In func_L01_0046D5B8, D_00222C50 and D_00222B9C as u8[] had their high halves hoisted into saved registers.
  3. Separate statements for flag masks. In func_00466458, D &= ~0x10; D &= ~0x4000; keeps two addiu/and pairs, as in retail. One expression folds them into a single mask. The global must also be s32: as u32, ~4 is built with lui/ori.
  4. The order of the increments in a for step. In func_004E0218, i++, e++, flags++ gives retail's order. The same increments in the body give the pointers swapped registers.
  5. A local for the constant 6 before a call puts addiu $sN, 6 in that call's delay slot (func_L01_0046D5B8).
  6. -ffast-math and hi < d ? hi : d give min.s with retail's operand order (func_L01_004FDE98), with the limits assigned in both arms of the if.

🤖 Generated with Claude Code

chistianh and others added 11 commits November 9, 2026 16:47
PAL-only; matches its PAL bytes with tools/check_func.py --version pal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PAL-only; matches its PAL bytes with tools/check_func.py --version pal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PAL-only; matches its PAL bytes with tools/check_func.py --version pal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PAL-only; matches its PAL bytes with tools/check_func.py --version pal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PAL-only; matches its PAL bytes with tools/check_func.py --version pal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PAL-only; matches its PAL bytes with tools/check_func.py --version pal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PAL-only; matches its PAL bytes with tools/check_func.py --version pal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PAL-only; matches its PAL bytes with tools/check_func.py --version pal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PAL-only; matches its PAL bytes with tools/check_func.py --version pal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PAL-only; matches its PAL bytes with tools/check_func.py --version pal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PAL-only; matches its PAL bytes with tools/check_func.py --version pal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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