diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index e5d806c52..90db37f73 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -81,6 +81,11 @@ Each such file says so in a comment on its first lines (`C adapted from rac3-dec exact donor file, function and commit of every one are recorded in the maintainers' review notes. The text was then given this game's names and checked against this game's code. +The PAL bit writer `src/pal/overlays/shared/L00_006FAC10.c` also used matching +C from rac3-decomp as a reference. Its counterpart is +[`func_L39_0066EC58`](https://github.com/OpenRAC/rac3-decomp/blob/d66fd79203489f73636921ae12aec3fbad935f1d/src/levels/shared/L39_0066EC58.c#L3-L48). +The RAC4 implementation was checked against all 47 PAL level program images. + The C of 3 functions started from the matching C of equivalent functions in [rac2-decomp](https://github.com/OpenRAC/rac2-decomp) (*Ratchet & Clank: Going Commando*, GPL-3.0, commit `1243c8ea`): `src/core/001399E0.c`, `src/core/00139A80.c`, `src/core/00139AE0.c`. They were found the same way (opcode sequences), renamed and checked against this game's code; diff --git a/config/pal/map.tsv b/config/pal/map.tsv index a289dc5d1..d54ac3098 100644 --- a/config/pal/map.tsv +++ b/config/pal/map.tsv @@ -10932,3 +10932,16 @@ func_L41_004447E8 nonmatching/shared/func_L41_004447E8.c near func_L41_004458E8 func_L41_00446500 nonmatching/shared/func_L41_00446500.c near func_L41_00447608 level_41:.text:00447608:836 94.50 func_L41_0044C720 nonmatching/shared/func_L41_0044C720.c near func_L41_0044D828 level_41:.text:0044D828:272 84.56 func_L41_0061C668 nonmatching/shared/func_L41_0061C668.c near func_L41_00620DE0 level_41:.text:00620DE0:148 95.27 +func_0046F3A8 src/pal/game/0046F3A8.c match func_0046F3A8 main:.text:0046F3A8:260 100.00 +func_00479920 src/pal/game/00479920.c match func_00479920 main:.text:00479920:200 100.00 +func_L00_0070D1A8 src/pal/overlays/l00_multiplayer_menu/L00_0070D1A8.c match func_L00_0070D1A8 level_00:.text:0070D1A8:276 100.00 +func_L00_0070D2C0 src/pal/overlays/l00_multiplayer_menu/L00_0070D2C0.c match func_L00_0070D2C0 level_00:.text:0070D2C0:236 100.00 +func_L00_0070DEB0 src/pal/overlays/l00_multiplayer_menu/L00_0070DEB0.c match func_L00_0070DEB0 level_00:.text:0070DEB0:108 100.00 +func_L01_0055B760 src/pal/overlays/shared/L01_0055B760.c match func_L01_0055B760 level_01:.text:0055B760:68 100.00 +func_L01_00575700 src/pal/overlays/shared/L01_00575700.c match func_L01_00575700 level_01:.text:00575700:40 100.00 +func_00540A00 src/pal/game/00540A00.c match func_00540A00 main:.text:00540A00:176 100.00 +func_L41_003BDF18 src/pal/overlays/l41_battledome_tower/L41_003BDF18.c match func_L41_003BDF18 level_41:.text:003BDF18:56 100.00 +func_00499650 src/pal/game/00499650.c match func_00499650 main:.text:00499650:56 100.00 +func_004FD000 src/pal/game/004FD000.c match func_004FD000 main:.text:004FD000:64 100.00 +func_L41_004475C0 src/pal/overlays/l41_battledome_tower/L41_004475C0.c match func_L41_004475C0 level_41:.text:004475C0:72 100.00 +func_L00_006FAC10 src/pal/overlays/shared/L00_006FAC10.c match func_L00_006FAC10 level_00:.text:006FAC10:300 100.00 diff --git a/config/us/map.tsv b/config/us/map.tsv index f81df7432..84e57d54e 100644 --- a/config/us/map.tsv +++ b/config/us/map.tsv @@ -10932,3 +10932,16 @@ func_L41_004447E8 nonmatching/shared/func_L41_004447E8.c near func_L41_004447E8 func_L41_00446500 nonmatching/shared/func_L41_00446500.c near func_L41_00446500 level_41:.text:00446500:836 94.50 func_L41_0044C720 nonmatching/shared/func_L41_0044C720.c near func_L41_0044C720 level_41:.text:0044C720:272 84.56 func_L41_0061C668 nonmatching/shared/func_L41_0061C668.c near func_L41_0061C668 level_41:.text:0061C668:148 95.27 +func_0046F3A8 src/pal/game/0046F3A8.c other - - 0.00 +func_00479920 src/pal/game/00479920.c other - - 0.00 +func_L00_0070D1A8 src/pal/overlays/l00_multiplayer_menu/L00_0070D1A8.c other - - 0.00 +func_L00_0070D2C0 src/pal/overlays/l00_multiplayer_menu/L00_0070D2C0.c other - - 0.00 +func_L00_0070DEB0 src/pal/overlays/l00_multiplayer_menu/L00_0070DEB0.c other - - 0.00 +func_L01_0055B760 src/pal/overlays/shared/L01_0055B760.c other - - 0.00 +func_L01_00575700 src/pal/overlays/shared/L01_00575700.c other - - 0.00 +func_00540A00 src/pal/game/00540A00.c other - - 0.00 +func_L41_003BDF18 src/pal/overlays/l41_battledome_tower/L41_003BDF18.c other - - 0.00 +func_00499650 src/pal/game/00499650.c other - - 0.00 +func_004FD000 src/pal/game/004FD000.c other - - 0.00 +func_L41_004475C0 src/pal/overlays/l41_battledome_tower/L41_004475C0.c other - - 0.00 +func_L00_006FAC10 src/pal/overlays/shared/L00_006FAC10.c other - - 0.00 diff --git a/nonmatching/README.md b/nonmatching/README.md index 0f44debb2..798bc7764 100644 --- a/nonmatching/README.md +++ b/nonmatching/README.md @@ -5,6 +5,7 @@ Best attempts at functions that do not match yet. They are not built; see | Function | Directory | Size | What differs | |---|---|---|---| +| [`func_00421C48`](pal/game/func_00421C48.c) | pal/game | 36 | SIZE 44/36, compiler materializes a zero quadword and schedules stores differently | | [`func_00461570`](game/func_00461570.c) | game | 284 | BYTES 0/284, exact only with inline asm (plzcw), which matched C may not use | | [`func_00461690`](game/func_00461690.c) | game | 176 | BYTES 0/176, exact only with inline asm (plzcw and blezl/sub abs), which matched C may not use | | [`func_00461740`](game/func_00461740.c) | game | 588 | BYTES 0/588, exact only with inline asm (plzcw), which matched C may not use | @@ -52,7 +53,6 @@ Best attempts at functions that do not match yet. They are not built; see | [`func_L00_0068AC58`](shared/func_L00_0068AC58.c) | shared | 688 | BYTES 9/684 | | [`func_L41_0040F218`](shared/func_L41_0040F218.c) | shared | 376 | BYTES 5/376 | | [`func_004934F8`](game/func_004934F8.c) | game | 288 | BYTES 4/288 | -| [`func_00479920`](pal/game/func_00479920.c) | pal/game | 200 | BYTES 3/200 (3 words differ); bindings/semantics unapproved | | [`func_L00_005F0BD8`](pal/shared/func_L00_005F0BD8.c) | pal/shared | 200 | BYTES 3/200 (3 words differ); bindings/semantics unapproved | | [`func_00147BA8`](core/func_00147BA8.c) | core | 132 | BYTES 2/132 | | [`func_0051AE28`](game/func_0051AE28.c) | game | 200 | BYTES 3/196 | @@ -60,7 +60,6 @@ Best attempts at functions that do not match yet. They are not built; see | [`func_004BF658`](game/func_004BF658.c) | game | 192 | BYTES 3/188 | | [`func_004BF718`](game/func_004BF718.c) | game | 192 | BYTES 3/188 | | [`func_0053F600`](game/func_0053F600.c) | game | 176 | BYTES 3/176 | -| [`func_00540A00`](pal/game/func_00540A00.c) | pal/game | 176 | BYTES 3/176 (1 words differ); bindings/semantics unapproved | | [`func_01EE992C`](net/func_01EE992C.c) | net | 116 | BYTES 2/116 | | [`func_004F9680`](game/func_004F9680.c) | game | 232 | BYTES 4/228 | | [`func_004B41F8`](game/func_004B41F8.c) | game | 336 | BYTES 6/332 | @@ -119,7 +118,6 @@ Best attempts at functions that do not match yet. They are not built; see | [`func_L00_00528178`](l00_multiplayer_menu/func_L00_00528178.c) | l00_multiplayer_menu | 464 | BYTES 23/464 | | [`func_0047EB98`](game/func_0047EB98.c) | game | 24 | BYTES 1/20 - the OR operand order (regmove tie); delay slot fixed by -fno-delayed-branch | | [`func_004DC200`](game/func_004DC200.c) | game | 200 | BYTES 10/200 | -| [`func_L41_003BDF18`](pal/l41_battledome_tower/func_L41_003BDF18.c) | pal/l41_battledome_tower | 56 | BYTES 3/56 (3 words differ); bindings/semantics unapproved | | [`func_00548280`](game/func_00548280.c) | game | 280 | BYTES 15/276 | | [`func_L01_0047F050`](shared/func_L01_0047F050.c) | shared | 128 | BYTES 7/128 | | [`func_00146570`](core/func_00146570.c) | core | 200 | BYTES 11/200 | @@ -143,7 +141,6 @@ Best attempts at functions that do not match yet. They are not built; see | [`func_004C3140`](game/func_004C3140.c) | game | 104 | BYTES 7/104 | | [`func_L00_00528670`](l00_multiplayer_menu/func_L00_00528670.c) | l00_multiplayer_menu | 416 | BYTES 28/416 | | [`func_0011C568`](core/func_0011C568.c) | core | 116 | BYTES 8/116 | -| [`func_L41_004475C0`](pal/l41_battledome_tower/func_L41_004475C0.c) | pal/l41_battledome_tower | 72 | BYTES 5/72 (3 words differ); bindings/semantics unapproved | | [`func_L00_00517208`](l00_multiplayer_menu/func_L00_00517208.c) | l00_multiplayer_menu | 104 | BYTES 7/100 | | [`func_004F6750`](game/func_004F6750.c) | game | 496 | BYTES 35/496 | | [`func_L41_004447E8`](shared/func_L41_004447E8.c) | shared | 168 | BYTES 12/168 | @@ -199,7 +196,6 @@ Best attempts at functions that do not match yet. They are not built; see | [`func_004766F8`](game/func_004766F8.c) | game | 8 | BYTES 1/8 | | [`func_004A8CB0`](game/func_004A8CB0.c) | game | 8 | BYTES 1/8 | | [`func_01EEF358`](net/func_01EEF358.c) | net | 160 | BYTES 20/160 | -| [`func_L00_006FAC10`](pal/shared/func_L00_006FAC10.c) | pal/shared | 300 | BYTES 38/300 (18 words differ); bindings/semantics unapproved | | [`func_L01_00591730`](shared/func_L01_00591730.c) | shared | 112 | BYTES 14/108 | | [`func_L00_0067FB70`](shared/func_L00_0067FB70.c) | shared | 512 | BYTES 67/508 | | [`func_001614C0`](core/func_001614C0.c) | core | 104 | BYTES 14/104 | @@ -387,7 +383,7 @@ Best attempts at functions that do not match yet. They are not built; see | [`func_L00_005D5CE0`](shared/func_L00_005D5CE0.c) | shared | 400 | SIZE ours 340 / retail 400 | | [`func_L00_006969F0`](pal/shared/func_L00_006969F0.c) | pal/shared | 120 | SIZE ours 124 / disc 120; bindings/semantics unapproved | | [`func_L00_006AA5F8`](shared/func_L00_006AA5F8.c) | shared | 280 | SIZE ours 212 / retail 280 | -| [`func_L00_006BED98`](pal/shared/func_L00_006BED98.c) | pal/shared | 52 | SIZE ours 56 / disc 52; bindings/semantics unapproved | +| [`func_L00_006BED98`](pal/shared/func_L00_006BED98.c) | pal/shared | 52 | SIZE 56/52, compiler materializes a zero quadword and schedules stores differently | | [`func_L00_006CF328`](pal/l00_multiplayer_menu/func_L00_006CF328.c) | pal/l00_multiplayer_menu | 84 | 16/21 (76.19%) relocation-masked positional words; 84/84 candidate/target bytes. The s64 local is a code-generation hypothesis. | | [`func_L00_006D1C68`](shared/func_L00_006D1C68.c) | shared | 304 | SIZE ours 288 / retail 304 | | [`func_L00_006EE598`](shared/func_L00_006EE598.c) | shared | 368 | SIZE 208/368 | diff --git a/nonmatching/pal/game/func_00421C48.c b/nonmatching/pal/game/func_00421C48.c new file mode 100644 index 000000000..73e6b0edd --- /dev/null +++ b/nonmatching/pal/game/func_00421C48.c @@ -0,0 +1,31 @@ +/* Not matching yet: SIZE 44/36, compiler materializes a zero quadword and schedules stores differently. + * Reproduce with python3 tools/check_func.py --version pal func_00421C48 nonmatching/pal/game/func_00421C48.c --diff + */ + +#include "common.h" + +typedef unsigned int u128 __attribute__((mode(TI))); + +typedef struct { + u128 f0; + u128 f10; + u8 pad20[0x10]; + u32 f30; + u32 f34; + s16 f38; + s16 f3A; + u8 pad3C[2]; + s8 f3E; +} Type1; + +/* Clear the selected fields and set the signed fields to their sentinel. */ +void func_00421C48(Type1 *arg0) +{ + arg0->f0 = 0; + arg0->f3E = -1; + arg0->f10 = 0; + arg0->f30 = 0; + arg0->f34 = 0; + arg0->f38 = -1; + arg0->f3A = -1; +} diff --git a/nonmatching/pal/game/func_00479920.c b/nonmatching/pal/game/func_00479920.c deleted file mode 100644 index 43d6e60be..000000000 --- a/nonmatching/pal/game/func_00479920.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Not matched: PAL SCES_532.85. - * Stored-object comparison: BYTES 3/200 (3 words differ). - * Function text: 200 B; native catalogue: 200 B; 1 placement(s). - * Instruction/size differences remain; symbol bindings, ownership and semantics also need review. - * Relocated instruction fields are masked in this comparison, not certified targets. - * Reproduce with the original compiler setup: - * python3 tools/check_func.py --version pal func_00479920 nonmatching/pal/game/func_00479920.c --diff - */ -#include "common.h" - -extern f32 func_0046C940(void *object); - -s32 func_00479920(void *object, f32 target) { - f32 current = func_0046C940(object); - f32 delta = *(f32 *)((u8 *)object + 0x48); - s32 targetFixed = (s32)(target * 4096.0f + 0.5f); - s32 currentFixed = (s32)(current * 4096.0f + 0.5f); - s32 previousFixed = (s32)((current - delta * 1.2f * 0.5f) * 4096.0f + 0.5f); - if (delta < 0.0f) { - if (targetFixed < currentFixed || !(targetFixed < previousFixed)) { - return 0; - } - } else { - if (currentFixed < targetFixed || !(previousFixed < targetFixed)) { - return 0; - } - } - return 1; -} diff --git a/nonmatching/pal/game/func_00540A00.c b/nonmatching/pal/game/func_00540A00.c deleted file mode 100644 index 9068883a9..000000000 --- a/nonmatching/pal/game/func_00540A00.c +++ /dev/null @@ -1,44 +0,0 @@ -/* Not matched: PAL SCES_532.85. - * Stored-object comparison: BYTES 3/176 (1 words differ). - * Function text: 176 B; native catalogue: 176 B; 15 placement(s). - * Instruction/size differences remain; symbol bindings, ownership and semantics also need review. - * Relocated instruction fields are masked in this comparison, not certified targets. - * Reproduce with the original compiler setup: - * python3 tools/check_func.py --version pal func_00540A00 nonmatching/pal/game/func_00540A00.c --diff - */ -#include "common.h" - -extern s32 D_0021EE54; -extern void *func_0053E038(void *); - -/* Checks the live interface payload and the object's two flag bits. */ -s32 func_00540A00(void *arg0, s32 arg1) -{ - void *payload; - s32 mode; - u8 flags; - - if (*(s32 *)((u8 *)arg0 + 0x98) != 0) { - payload = func_0053E038(arg0); - if (payload != NULL) { - if (!(*(f32 *)((u8 *)payload + 0x2E8) <= 0.0f)) { - mode = D_0021EE54; - if (mode == 1) { - flags = *(u8 *)((u8 *)arg0 + 0xBE); - if (flags & 0x18) { - if (!(flags & 8) || arg1 != mode) { - if (flags & 0x10) { - if (arg1 == 0) - return 0; - } - return 1; - } - return 0; - } - return 1; - } - } - } - } - return 0; -} diff --git a/nonmatching/pal/l41_battledome_tower/func_L41_003BDF18.c b/nonmatching/pal/l41_battledome_tower/func_L41_003BDF18.c deleted file mode 100644 index 0797f52e5..000000000 --- a/nonmatching/pal/l41_battledome_tower/func_L41_003BDF18.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Not matched: PAL SCES_532.85. - * Stored-object comparison: BYTES 3/56 (3 words differ). - * Function text: 56 B; native catalogue: 56 B; 1 placement(s). - * Instruction/size differences remain; symbol bindings, ownership and semantics also need review. - * Relocated instruction fields are masked in this comparison, not certified targets. - * Reproduce with the original compiler setup: - * python3 tools/check_func.py --version pal func_L41_003BDF18 nonmatching/pal/l41_battledome_tower/func_L41_003BDF18.c --diff - */ -#include "common.h" - -/* Automatischer m2c-Grobentwurf, kein geprüfter Match. - * Unbekannte M2C_* und saved_reg_* müssen manuell aufgelöst werden. - * Signaturen, Datenbesitz und Funktionsgrenzen prüfen. - */ - - -f32 func_L41_003BDF18(void *arg0, void *arg1, f32 fparg0) { - f32 var_f0; - s32 var_v0; - - var_v0 = 1; - if (!((*(f32 *)((s8 *)((*(void **)((s8 *)(arg1) + (0x20)))) + (0x18))) < (*(f32 *)((s8 *)(arg0) + (0x18))))) { - var_v0 = 0; - } - var_f0 = 0.0f; - if (!(var_v0 & 0xFF)) { - var_f0 = fparg0; - } - return var_f0; -} diff --git a/nonmatching/pal/l41_battledome_tower/func_L41_004475C0.c b/nonmatching/pal/l41_battledome_tower/func_L41_004475C0.c deleted file mode 100644 index 25f0ec912..000000000 --- a/nonmatching/pal/l41_battledome_tower/func_L41_004475C0.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Not matched: PAL SCES_532.85. - * Stored-object comparison: BYTES 5/72 (3 words differ). - * Function text: 72 B; native catalogue: 72 B; 1 placement(s). - * Instruction/size differences remain; symbol bindings, ownership and semantics also need review. - * Retains unresolved literal-address accesses from the draft; these are not approved data bindings. - * Relocated instruction fields are masked in this comparison, not certified targets. - * Reproduce with the original compiler setup: - * python3 tools/check_func.py --version pal func_L41_004475C0 nonmatching/pal/l41_battledome_tower/func_L41_004475C0.c --diff - */ -#include "common.h" - -/* Automatischer m2c-Grobentwurf, kein geprüfter Match. - * Unbekannte M2C_* und saved_reg_* müssen manuell aufgelöst werden. - * Signaturen, Datenbesitz und Funktionsgrenzen prüfen. - */ - - -extern void *D_0021E078; - -s32 func_L41_004475C0(void *arg0) { - s32 temp_a1; - - temp_a1 = *(s32 *)0x21E714; - if ((temp_a1 != 1) || ((*(u8 *)((s8 *)(D_0021E078) + (0x32))) == 0)) { - return 0; - } - if (arg0 != NULL) { - return (((*(s32 *)((s8 *)(arg0) + (0x2F14))) ^ 1) != 0) ? 0 : temp_a1; - } - return 0; -} diff --git a/nonmatching/pal/shared/func_L00_006BED98.c b/nonmatching/pal/shared/func_L00_006BED98.c index 7738358b8..44ce98216 100644 --- a/nonmatching/pal/shared/func_L00_006BED98.c +++ b/nonmatching/pal/shared/func_L00_006BED98.c @@ -1,33 +1,27 @@ -/* cflags: -fno-schedule-insns -fno-schedule-insns2 */ -/* Not matched: PAL SCES_532.85. - * Stored-object comparison: SIZE ours 56 / disc 52. - * Function text: 56 B; native catalogue: 52 B; 14 placement(s). - * Instruction/size differences remain; symbol bindings, ownership and semantics also need review. - * The draft s128 placeholder does not establish the native transfer width. - * Relocated instruction fields are masked in this comparison, not certified targets. - * Reproduce with the original compiler setup: - * python3 tools/check_func.py --version pal func_L00_006BED98 nonmatching/pal/shared/func_L00_006BED98.c --diff +/* Not matching yet: SIZE 56/52. The source uses aligned 128-bit transfers. + * The compiler materializes a zero quadword in a register. Retail uses $zero + * directly and orders the stores differently. + * Reproduce with python3 tools/check_func.py --version pal func_L00_006BED98 nonmatching/pal/shared/func_L00_006BED98.c --diff */ -#include "common.h" -typedef long long s128; -/* Automatischer m2c-Grobentwurf, kein geprüfter Match. - * Unbekannte M2C_* und saved_reg_* müssen manuell aufgelöst werden. - * Signaturen, Datenbesitz und Funktionsgrenzen prüfen. - */ +#include "common.h" +typedef int Type1 __attribute__((mode(TI))); +/* Clear selected state words and aligned 16-byte fields. */ void func_L00_006BED98(void *arg0) { - (*(s32 *)((s8 *)(arg0) + (0x1B0))) = 0; - (*(s32 *)((s8 *)(arg0) + (0x1780))) = 0; - (*(s32 *)((s8 *)(arg0) + (0x1784))) = 0; - (*(s128 *)((s8 *)(arg0) + (0x140))) = 0; - (*(s128 *)((s8 *)(arg0) + (0x130))) = 0; - (*(s128 *)((s8 *)(arg0) + (0x150))) = 0; - (*(s128 *)((s8 *)(arg0) + (0x160))) = 0; - (*(s128 *)((s8 *)(arg0) + (0x170))) = 0; - (*(s128 *)((s8 *)(arg0) + (0x1A0))) = 0; - (*(s128 *)((s8 *)(arg0) + (0xC0))) = 0; - (*(s32 *)((s8 *)(arg0) + (0x17A4))) = 0; - (*(s32 *)((s8 *)(arg0) + (0x1B8))) = 0; + u8 *p = arg0; + + *(u32 *)(p + 0x1B0) = 0; + *(u32 *)(p + 0x1780) = 0; + *(u32 *)(p + 0x1784) = 0; + *(Type1 *)(p + 0x140) = 0; + *(Type1 *)(p + 0x130) = 0; + *(Type1 *)(p + 0x150) = 0; + *(Type1 *)(p + 0x160) = 0; + *(Type1 *)(p + 0x170) = 0; + *(Type1 *)(p + 0x1A0) = 0; + *(Type1 *)(p + 0xC0) = 0; + *(u32 *)(p + 0x17A4) = 0; + *(u32 *)(p + 0x1B8) = 0; } diff --git a/nonmatching/pal/shared/func_L00_006FAC10.c b/nonmatching/pal/shared/func_L00_006FAC10.c deleted file mode 100644 index 84d8c7472..000000000 --- a/nonmatching/pal/shared/func_L00_006FAC10.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Not matched: PAL SCES_532.85. - * Stored-object comparison: BYTES 38/300 (18 words differ). - * Function text: 300 B; native catalogue: 300 B; 14 placement(s). - * Instruction/size differences remain; symbol bindings, ownership and semantics also need review. - * Relocated instruction fields are masked in this comparison, not certified targets. - * Reproduce with the original compiler setup: - * python3 tools/check_func.py --version pal func_L00_006FAC10 nonmatching/pal/shared/func_L00_006FAC10.c --diff - */ -#include "common.h" - -void func_L00_006FAC10(u8 *arg0, s32 arg1, s32 *arg2, s32 arg3) { - s32 temp_a0; - s32 temp_a0_2; - s32 temp_a2; - s32 temp_v0; - s32 temp_v1; - s32 temp_v1_3; - s32 var_a1; - s32 var_a2; - u8 *var_t0; - - temp_a2 = *arg2; - arg3 &= 0xFF; - temp_v1 = temp_a2 / 8; - var_t0 = arg0 + temp_v1; - temp_v1 = temp_a2 - (temp_v1 * 8); - temp_a0 = 8 - temp_v1; - if (temp_a0 < arg3) { - var_a1 = temp_a0 & 0xFF; - var_a2 = 0; - } else { - var_a1 = arg3; - var_a2 = (8 - (arg3 + temp_v1)) & 0xFF; - } - *arg2 += var_a1; - arg3 -= var_a1; - temp_v1_3 = (0xFF >> (8 - var_a1)) & 0xFF; - temp_a0 = ((temp_v1_3 & (arg1 >> arg3)) << var_a2) | (*var_t0 & ~(temp_v1_3 << var_a2)); - arg3 &= 0xFF; - *var_t0 = temp_a0; - if (arg3 != 0) { - do { - var_t0 += 1; - if ((u32) arg3 >= 9U) { - var_a2 = 0; - var_a1 = 8; - } else { - var_a1 = arg3; - var_a2 = (8 - arg3) & 0xFF; - } - temp_v0 = (0xFF >> (8 - var_a1)) & 0xFF; - arg3 -= var_a1; - *arg2 += var_a1; - temp_a0_2 = arg1 >> arg3; - arg3 &= 0xFF; - *var_t0 = (*var_t0 & ~(temp_v0 << var_a2)) | ((temp_v0 & temp_a0_2) << var_a2); - } while (arg3 != 0); - } -} diff --git a/progress/pal/report.json b/progress/pal/report.json index 6a8f1960e..5eb715d6f 100644 --- a/progress/pal/report.json +++ b/progress/pal/report.json @@ -1,34 +1,34 @@ { "version": 2, "measures": { - "fuzzy_match_percent": 21.032314, + "fuzzy_match_percent": 21.0525, "total_code": "5810792", - "matched_code": "1167384", - "matched_code_percent": 20.089929, + "matched_code": "1169296", + "matched_code_percent": 20.122834, "total_functions": 18136, - "matched_functions": 9849, - "matched_functions_percent": 54.306352, - "complete_code": "629148", - "complete_code_percent": 10.827233, - "total_units": 5359, - "complete_units": 5301 + "matched_functions": 9862, + "matched_functions_percent": 54.378033, + "complete_code": "629904", + "complete_code_percent": 10.840243, + "total_units": 5364, + "complete_units": 5306 }, "categories": [ { "id": "core", "name": "Main program", "measures": { - "fuzzy_match_percent": 29.967733, + "fuzzy_match_percent": 29.983081, "total_code": "2202184", - "matched_code": "629148", - "matched_code_percent": 28.569275, + "matched_code": "629904", + "matched_code_percent": 28.603604, "total_functions": 8952, - "matched_functions": 5330, - "matched_functions_percent": 59.539768, - "complete_code": "629148", - "complete_code_percent": 28.569275, - "total_units": 5344, - "complete_units": 5301 + "matched_functions": 5335, + "matched_functions_percent": 59.595621, + "complete_code": "629904", + "complete_code_percent": 28.603604, + "total_units": 5349, + "complete_units": 5306 } }, { @@ -103,17 +103,17 @@ "id": "menu_text", "name": "Resident menus (.text)", "measures": { - "fuzzy_match_percent": 27.225876, + "fuzzy_match_percent": 27.249644, "total_code": "1422048", - "matched_code": "363036", - "matched_code_percent": 25.529096, + "matched_code": "363792", + "matched_code_percent": 25.582259, "total_functions": 4797, - "matched_functions": 2742, - "matched_functions_percent": 57.160725, + "matched_functions": 2747, + "matched_functions_percent": 57.264957, "complete_code": "0", "complete_code_percent": 0.0, - "total_units": 2757, - "complete_units": 2735 + "total_units": 2762, + "complete_units": 2740 } }, { @@ -137,13 +137,13 @@ "id": "level_code", "name": "Level code", "measures": { - "fuzzy_match_percent": 15.579398, + "fuzzy_match_percent": 15.602537, "total_code": "3608608", - "matched_code": "538236", - "matched_code_percent": 14.915336, + "matched_code": "539392", + "matched_code_percent": 14.94737, "total_functions": 9184, - "matched_functions": 4519, - "matched_functions_percent": 49.205139, + "matched_functions": 4527, + "matched_functions_percent": 49.292247, "complete_code": "0", "complete_code_percent": 0.0, "total_units": 15, @@ -154,13 +154,13 @@ "id": "common", "name": "Shared level code", "measures": { - "fuzzy_match_percent": 12.298733, + "fuzzy_match_percent": 12.307993, "total_code": "2008632", - "matched_code": "237244", - "matched_code_percent": 11.811223, + "matched_code": "237652", + "matched_code_percent": 11.831535, "total_functions": 5088, - "matched_functions": 2371, - "matched_functions_percent": 46.599843, + "matched_functions": 2374, + "matched_functions_percent": 46.658805, "complete_code": "0", "complete_code_percent": 0.0, "total_units": 1, @@ -171,13 +171,13 @@ "id": "levels", "name": "Level-specific code", "measures": { - "fuzzy_match_percent": 19.69799, + "fuzzy_match_percent": 19.738553, "total_code": "1599976", - "matched_code": "300992", - "matched_code_percent": 18.812282, + "matched_code": "301740", + "matched_code_percent": 18.859033, "total_functions": 4096, - "matched_functions": 2148, - "matched_functions_percent": 52.441406, + "matched_functions": 2153, + "matched_functions_percent": 52.563477, "complete_code": "0", "complete_code_percent": 0.0, "total_units": 14, @@ -188,13 +188,13 @@ "id": "level_00", "name": "Level 00: Multiplayer Menu", "measures": { - "fuzzy_match_percent": 26.899817, + "fuzzy_match_percent": 26.955017, "total_code": "943832", - "matched_code": "242116", - "matched_code_percent": 25.652447, + "matched_code": "242736", + "matched_code_percent": 25.718136, "total_functions": 2837, - "matched_functions": 1599, - "matched_functions_percent": 56.362355, + "matched_functions": 1602, + "matched_functions_percent": 56.4681, "complete_code": "0", "complete_code_percent": 0.0, "total_units": 1, @@ -409,13 +409,13 @@ "id": "level_41", "name": "Level 41: Battledome Tower (all 22 multiplayer maps)", "measures": { - "fuzzy_match_percent": 16.512782, + "fuzzy_match_percent": 16.603989, "total_code": "140340", - "matched_code": "20776", - "matched_code_percent": 14.804047, + "matched_code": "20904", + "matched_code_percent": 14.895254, "total_functions": 374, - "matched_functions": 201, - "matched_functions_percent": 53.743316, + "matched_functions": 203, + "matched_functions_percent": 54.278075, "complete_code": "0", "complete_code_percent": 0.0, "total_units": 1, @@ -183875,6 +183875,41 @@ ] } }, + { + "name": "pal/game/0046F3A8", + "measures": { + "fuzzy_match_percent": 100.0, + "total_code": "260", + "matched_code": "260", + "matched_code_percent": 100.0, + "total_functions": 1, + "matched_functions": 1, + "matched_functions_percent": 100.0, + "complete_code": "260", + "complete_code_percent": 100.0, + "total_units": 1, + "complete_units": 1 + }, + "functions": [ + { + "name": "func_0046F3A8", + "size": "260", + "fuzzy_match_percent": 100.0, + "address": "0", + "metadata": { + "virtual_address": "4649896" + } + } + ], + "metadata": { + "complete": true, + "source_path": "src/pal/game/0046F3A8.c", + "progress_categories": [ + "core", + "menu_text" + ] + } + }, { "name": "pal/game/004778A8", "measures": { @@ -183910,6 +183945,41 @@ ] } }, + { + "name": "pal/game/00479920", + "measures": { + "fuzzy_match_percent": 100.0, + "total_code": "200", + "matched_code": "200", + "matched_code_percent": 100.0, + "total_functions": 1, + "matched_functions": 1, + "matched_functions_percent": 100.0, + "complete_code": "200", + "complete_code_percent": 100.0, + "total_units": 1, + "complete_units": 1 + }, + "functions": [ + { + "name": "func_00479920", + "size": "200", + "fuzzy_match_percent": 100.0, + "address": "0", + "metadata": { + "virtual_address": "4692256" + } + } + ], + "metadata": { + "complete": true, + "source_path": "src/pal/game/00479920.c", + "progress_categories": [ + "core", + "menu_text" + ] + } + }, { "name": "pal/game/0047FE68", "measures": { @@ -184050,6 +184120,41 @@ ] } }, + { + "name": "pal/game/00499650", + "measures": { + "fuzzy_match_percent": 100.0, + "total_code": "56", + "matched_code": "56", + "matched_code_percent": 100.0, + "total_functions": 1, + "matched_functions": 1, + "matched_functions_percent": 100.0, + "complete_code": "56", + "complete_code_percent": 100.0, + "total_units": 1, + "complete_units": 1 + }, + "functions": [ + { + "name": "func_00499650", + "size": "56", + "fuzzy_match_percent": 100.0, + "address": "0", + "metadata": { + "virtual_address": "4822608" + } + } + ], + "metadata": { + "complete": true, + "source_path": "src/pal/game/00499650.c", + "progress_categories": [ + "core", + "menu_text" + ] + } + }, { "name": "pal/game/004A2A90", "measures": { @@ -185275,6 +185380,41 @@ ] } }, + { + "name": "pal/game/004FD000", + "measures": { + "fuzzy_match_percent": 100.0, + "total_code": "64", + "matched_code": "64", + "matched_code_percent": 100.0, + "total_functions": 1, + "matched_functions": 1, + "matched_functions_percent": 100.0, + "complete_code": "64", + "complete_code_percent": 100.0, + "total_units": 1, + "complete_units": 1 + }, + "functions": [ + { + "name": "func_004FD000", + "size": "64", + "fuzzy_match_percent": 100.0, + "address": "0", + "metadata": { + "virtual_address": "5230592" + } + } + ], + "metadata": { + "complete": true, + "source_path": "src/pal/game/004FD000.c", + "progress_categories": [ + "core", + "menu_text" + ] + } + }, { "name": "pal/game/004FD1D0", "measures": { @@ -185835,6 +185975,41 @@ ] } }, + { + "name": "pal/game/00540A00", + "measures": { + "fuzzy_match_percent": 100.0, + "total_code": "176", + "matched_code": "176", + "matched_code_percent": 100.0, + "total_functions": 1, + "matched_functions": 1, + "matched_functions_percent": 100.0, + "complete_code": "176", + "complete_code_percent": 100.0, + "total_units": 1, + "complete_units": 1 + }, + "functions": [ + { + "name": "func_00540A00", + "size": "176", + "fuzzy_match_percent": 100.0, + "address": "0", + "metadata": { + "virtual_address": "5507584" + } + } + ], + "metadata": { + "complete": true, + "source_path": "src/pal/game/00540A00.c", + "progress_categories": [ + "core", + "menu_text" + ] + } + }, { "name": "pal/game/00549A30", "measures": { @@ -192815,11 +192990,11 @@ { "name": "main/.text/0046xxxx", "measures": { - "fuzzy_match_percent": 3.842307, - "total_code": "46040", + "fuzzy_match_percent": 3.328965, + "total_code": "45780", "matched_code": "0", "matched_code_percent": 0.0, - "total_functions": 148, + "total_functions": 147, "matched_functions": 0, "matched_functions_percent": 0.0, "complete_code": "0", @@ -194079,15 +194254,6 @@ "virtual_address": "4649352" } }, - { - "name": "func_0046F3A8", - "size": "260", - "fuzzy_match_percent": 94.23, - "address": "61816", - "metadata": { - "virtual_address": "4649896" - } - }, { "name": "func_0046F4B0", "size": "516", @@ -194173,11 +194339,11 @@ { "name": "main/.text/0047xxxx", "measures": { - "fuzzy_match_percent": 0.566218, - "total_code": "54752", + "fuzzy_match_percent": 0.568294, + "total_code": "54552", "matched_code": "0", "matched_code_percent": 0.0, - "total_functions": 162, + "total_functions": 161, "matched_functions": 0, "matched_functions_percent": 0.0, "complete_code": "0", @@ -195077,15 +195243,6 @@ "virtual_address": "4692224" } }, - { - "name": "func_00479920", - "size": "200", - "fuzzy_match_percent": 0.0, - "address": "38776", - "metadata": { - "virtual_address": "4692256" - } - }, { "name": "func_004799E8", "size": "12", @@ -196412,11 +196569,11 @@ { "name": "main/.text/0049xxxx", "measures": { - "fuzzy_match_percent": 2.110666, - "total_code": "41172", + "fuzzy_match_percent": 2.113541, + "total_code": "41116", "matched_code": "0", "matched_code_percent": 0.0, - "total_functions": 137, + "total_functions": 136, "matched_functions": 0, "matched_functions_percent": 0.0, "complete_code": "0", @@ -197379,15 +197536,6 @@ "virtual_address": "4822120" } }, - { - "name": "func_00499650", - "size": "56", - "fuzzy_match_percent": 0.0, - "address": "37784", - "metadata": { - "virtual_address": "4822608" - } - }, { "name": "func_004998F0", "size": "60", @@ -201158,11 +201306,11 @@ { "name": "main/.text/004Fxxxx", "measures": { - "fuzzy_match_percent": 9.265582, - "total_code": "41260", + "fuzzy_match_percent": 9.279977, + "total_code": "41196", "matched_code": "0", "matched_code_percent": 0.0, - "total_functions": 115, + "total_functions": 114, "matched_functions": 0, "matched_functions_percent": 0.0, "complete_code": "0", @@ -201909,15 +202057,6 @@ "virtual_address": "5230504" } }, - { - "name": "func_004FD000", - "size": "64", - "fuzzy_match_percent": 0.0, - "address": "53024", - "metadata": { - "virtual_address": "5230592" - } - }, { "name": "func_004FD2F8", "size": "12", @@ -204879,11 +205018,11 @@ { "name": "main/.text/0054xxxx", "measures": { - "fuzzy_match_percent": 2.886699, - "total_code": "42472", + "fuzzy_match_percent": 2.48967, + "total_code": "42296", "matched_code": "0", "matched_code_percent": 0.0, - "total_functions": 76, + "total_functions": 75, "matched_functions": 0, "matched_functions_percent": 0.0, "complete_code": "0", @@ -204928,15 +205067,6 @@ "virtual_address": "5507544" } }, - { - "name": "func_00540A00", - "size": "176", - "fuzzy_match_percent": 98.3, - "address": "1640", - "metadata": { - "virtual_address": "5507584" - } - }, { "name": "func_00540AB0", "size": "800", @@ -219941,13 +220071,13 @@ { "name": "Shared level code", "measures": { - "fuzzy_match_percent": 12.298733, + "fuzzy_match_percent": 12.307993, "total_code": "2008632", - "matched_code": "237244", - "matched_code_percent": 11.811223, + "matched_code": "237652", + "matched_code_percent": 11.831535, "total_functions": 5088, - "matched_functions": 2371, - "matched_functions_percent": 46.599843, + "matched_functions": 2374, + "matched_functions_percent": 46.658805, "complete_code": "0", "complete_code_percent": 0.0, "total_units": 1, @@ -242043,7 +242173,7 @@ { "name": "func_L01_0055B760", "size": "68", - "fuzzy_match_percent": 0.0, + "fuzzy_match_percent": 100.0, "address": "1664000", "metadata": { "virtual_address": "5617504" @@ -243456,7 +243586,7 @@ { "name": "func_L01_00575700", "size": "40", - "fuzzy_match_percent": 0.0, + "fuzzy_match_percent": 100.0, "address": "1770400", "metadata": { "virtual_address": "5723904" @@ -263076,7 +263206,7 @@ { "name": "func_L00_006FAC10", "size": "300", - "fuzzy_match_percent": 74.0, + "fuzzy_match_percent": 100.0, "address": "3365040", "metadata": { "virtual_address": "7318544" @@ -265759,13 +265889,13 @@ { "name": "Level 00: Multiplayer Menu", "measures": { - "fuzzy_match_percent": 26.899817, + "fuzzy_match_percent": 26.955017, "total_code": "943832", - "matched_code": "242116", - "matched_code_percent": 25.652447, + "matched_code": "242736", + "matched_code_percent": 25.718136, "total_functions": 2837, - "matched_functions": 1599, - "matched_functions_percent": 56.362355, + "matched_functions": 1602, + "matched_functions_percent": 56.4681, "complete_code": "0", "complete_code_percent": 0.0, "total_units": 1, @@ -278258,7 +278388,7 @@ { "name": "func_L00_0070D1A8", "size": "276", - "fuzzy_match_percent": 0.0, + "fuzzy_match_percent": 100.0, "address": "2219432", "metadata": { "virtual_address": "7393704" @@ -278267,7 +278397,7 @@ { "name": "func_L00_0070D2C0", "size": "236", - "fuzzy_match_percent": 0.0, + "fuzzy_match_percent": 100.0, "address": "2219712", "metadata": { "virtual_address": "7393984" @@ -278411,7 +278541,7 @@ { "name": "func_L00_0070DEB0", "size": "108", - "fuzzy_match_percent": 91.67, + "fuzzy_match_percent": 100.0, "address": "2222768", "metadata": { "virtual_address": "7397040" @@ -299608,13 +299738,13 @@ { "name": "Level 41: Battledome Tower (all 22 multiplayer maps)", "measures": { - "fuzzy_match_percent": 16.512782, + "fuzzy_match_percent": 16.603989, "total_code": "140340", - "matched_code": "20776", - "matched_code_percent": 14.804047, + "matched_code": "20904", + "matched_code_percent": 14.895254, "total_functions": 374, - "matched_functions": 201, - "matched_functions_percent": 53.743316, + "matched_functions": 203, + "matched_functions_percent": 54.278075, "complete_code": "0", "complete_code_percent": 0.0, "total_units": 1, @@ -299741,7 +299871,7 @@ { "name": "func_L41_003BDF18", "size": "56", - "fuzzy_match_percent": 0.0, + "fuzzy_match_percent": 100.0, "address": "8296", "metadata": { "virtual_address": "3923736" @@ -301865,7 +301995,7 @@ { "name": "func_L41_004475C0", "size": "72", - "fuzzy_match_percent": 0.0, + "fuzzy_match_percent": 100.0, "address": "571152", "metadata": { "virtual_address": "4486592" diff --git a/src/pal/game/0046F3A8.c b/src/pal/game/0046F3A8.c new file mode 100644 index 000000000..6271e1fd6 --- /dev/null +++ b/src/pal/game/0046F3A8.c @@ -0,0 +1,40 @@ +#include "common.h" + +extern void func_0046A080(void *, s32, s32); +extern void func_0046A0C0(void); +extern void func_0046E7D8(f32, f32); + +void func_0046F3A8(u8 *arg0, f32 t, f32 u) +{ + s32 i; + f32 frac; + s32 next; + u8 *base; + s32 count; + s32 off; + u8 *a; + u8 *b; + + i = (s32)t; + frac = t - (f32)i; + next = i + 1; + base = *(u8 **)(arg0 + 0x1C); + off = base[1]; + count = base[2]; + if (next == arg0[0x10]) { + next = 0; + } + a = base + (off + i * count) * 16; + b = base + (next * count + off) * 16; + if (off != 0) { + func_0046A080(base, off, 0x2000); + func_0046A0C0(); + } + if (count != 0) { + func_0046A080(a, count, 0x3000); + func_0046A0C0(); + func_0046A080(b, count, 0x3800); + func_0046A0C0(); + } + func_0046E7D8(frac, u * u * (3.0f - (u + u))); +} diff --git a/src/pal/game/00479920.c b/src/pal/game/00479920.c new file mode 100644 index 000000000..39975d18a --- /dev/null +++ b/src/pal/game/00479920.c @@ -0,0 +1,24 @@ +#include "common.h" + +extern f32 func_0046C940(u8 *); + +// Returns 1 if the value, in 1/4096 units, lies between func_0046C940's result and that result minus +// 0.6 times the moby's +0x48 (either order, by the sign of +0x48), else 0. +s32 func_00479920(u8 *moby, f32 value) { + f32 cur = func_0046C940(moby); + f32 len = *(f32 *)(moby + 0x48); + s32 v = (s32)(value * 4096.0f + 0.5f); + s32 lo = (s32)(cur * 4096.0f + 0.5f); + s32 hi = (s32)((cur - len * 1.2f * 0.5f) * 4096.0f + 0.5f); + + if (len < 0.0f) { + if (v >= lo && v < hi) { + return 1; + } + return 0; + } + if (v <= lo && v > hi) { + return 1; + } + return 0; +} diff --git a/src/pal/game/00499650.c b/src/pal/game/00499650.c new file mode 100644 index 000000000..d2c3d575d --- /dev/null +++ b/src/pal/game/00499650.c @@ -0,0 +1,12 @@ +#include "common.h" + +extern u32 D_003D8D90[][4]; + +/* Returns the color for a row and column, or the default for negative indices. */ +u32 func_00499650(s32 row, s32 column) +{ + if (row < 0 || column < 0) { + return 0x80000000u; + } + return D_003D8D90[row][column]; +} diff --git a/src/pal/game/004997D0.c b/src/pal/game/004997D0.c index 787d0253c..97caa1944 100644 --- a/src/pal/game/004997D0.c +++ b/src/pal/game/004997D0.c @@ -4,7 +4,7 @@ extern s32 D_0021EE54; extern void *func_00511CC0(s32); extern void *func_0054A290(s32, s32); extern s32 func_005492C0(void *, s32); -extern s32 func_00499650(s32, s32); +extern u32 func_00499650(s32, s32); extern f32 func_00475FF0(f32, f32, f32); extern s32 func_00454480(s32, s32, f32); diff --git a/src/pal/game/004A8FF0.c b/src/pal/game/004A8FF0.c index f64bbe2da..63dff0cdf 100644 --- a/src/pal/game/004A8FF0.c +++ b/src/pal/game/004A8FF0.c @@ -12,7 +12,7 @@ typedef struct State { extern u8 D_00308208[]; extern s32 D_00221750; extern s32 func_00506BB8(void); -extern s32 func_00499650(s32 selector, s32 mode); +extern u32 func_00499650(s32 selector, s32 mode); extern u32 func_004993A8(f32 *phase, u32 first, f32 step, u32 second); extern s32 func_004A2798(s32 *base, s32 offset); extern s32 func_005063C0(s32 handle, u32 color); diff --git a/src/pal/game/004C3010.c b/src/pal/game/004C3010.c index 65637765d..e1b846ebc 100644 --- a/src/pal/game/004C3010.c +++ b/src/pal/game/004C3010.c @@ -7,7 +7,7 @@ s32 func_0045E850(s32); /* extern */ s32 func_00498518(s32); /* extern */ void func_00498818(s32, s32, s32, f32, f32); /* extern */ s32 func_00498FA8(s32, s32, s32, s32, s32); /* extern */ -s32 func_00499650(s32, s32); /* extern */ +u32 func_00499650(s32, s32); /* extern */ s32 func_004A2798(void *, s32); /* extern */ s32 func_005062D0(u32, const char *); /* extern */ s32 func_00506760(s32, s32, s32, s32, s32); /* extern */ diff --git a/src/pal/game/004FD000.c b/src/pal/game/004FD000.c new file mode 100644 index 000000000..e49c24831 --- /dev/null +++ b/src/pal/game/004FD000.c @@ -0,0 +1,24 @@ +/* cflags: @ee29 */ +#include "common.h" + +typedef struct { + s32 f0; + s32 f4; + u8 pad8[0x10]; +} Type1; + +extern Type1 D_003DD560[]; + +/* Find the record with both keys or return the table's first record. */ +Type1 *func_004FD000(s32 arg0, s32 arg1) { + Type1 *entry = D_003DD560; + Type1 *end = entry + 30; + + do { + if (entry->f0 == arg0 && entry->f4 == arg1) { + return entry; + } + entry++; + } while ((s32)entry < (s32)end); + return D_003DD560; +} diff --git a/src/pal/game/00540A00.c b/src/pal/game/00540A00.c new file mode 100644 index 000000000..ac0821622 --- /dev/null +++ b/src/pal/game/00540A00.c @@ -0,0 +1,50 @@ +#include "common.h" + +typedef struct { + u8 pad0[0x98]; + u32 f98; + u8 pad9C[0x22]; + u8 fBE; +} Type1; + +typedef struct { + u8 pad0[0x2E8]; + f32 f2E8; +} Type2; + +extern s32 D_0021EE54; +extern Type2 *func_0053E038(Type1 *); + +/* Checks the live interface payload and the object's two flag bits. */ +s32 func_00540A00(Type1 *arg0, s32 arg1) +{ + Type2 *payload; + s32 mode; + u8 flags; + + if (arg0->f98 == 0) { + return 0; + } + payload = func_0053E038(arg0); + if (payload != NULL) { + if (!(payload->f2E8 <= 0.0f)) { + mode = D_0021EE54; + if (mode == 1) { + flags = arg0->fBE; + if (flags & 0x18) { + if (!(flags & 8) || arg1 != mode) { + if (flags & 0x10) { + if (arg1 == 0) { + return 0; + } + } + return 1; + } + return 0; + } + return 1; + } + } + } + return 0; +} diff --git a/src/pal/overlays/l00_multiplayer_menu/L00_0070D1A8.c b/src/pal/overlays/l00_multiplayer_menu/L00_0070D1A8.c new file mode 100644 index 000000000..55c5ae3d8 --- /dev/null +++ b/src/pal/overlays/l00_multiplayer_menu/L00_0070D1A8.c @@ -0,0 +1,51 @@ +#include "common.h" + +typedef struct MenuFlags { u8 pad[4]; u8 flags[2]; } MenuFlags; + +typedef struct MenuRequest { + s32 entry; + s32 mode; + s32 value; + char prefix[15]; + char text[0x180]; +} MenuRequest; + +extern s32 func_0011AB04(const char *); +extern char *func_0011A9EC(char *, const char *); +extern char *func_0011AFC8(char *, const char *, s32); +extern void func_L00_005C2988(char *, const char *, s32); +extern s32 func_L00_0070D860(char *, s32 *, char **); +extern MenuFlags *func_L00_0070D838(s32); +extern void func_L00_0070DA00(MenuRequest *); + +void func_L00_0070D1A8(s32 *arg0) { + char input[16]; + char parsed[0x180]; + MenuRequest req; + s32 entry; + char *text; + MenuFlags *data; + s32 mode; + + __builtin_memcpy(input, arg0 + 8, 14); + input[14] = 0; + func_L00_005C2988(parsed, (char *)arg0 + 0x2F, func_0011AB04((char *)arg0 + 0x2F)); + if (func_L00_0070D860(parsed, &entry, &text) != 0) { + data = func_L00_0070D838(entry); + mode = 2; + if (*(s32 *)((u8 *)arg0 + 0x1C) == 0) { + mode = 0; + } else if (*(s32 *)((u8 *)arg0 + 0x1C) == 1) { + mode = 1; + } + if (mode < 2 && data->flags[*(s32 *)((u8 *)arg0 + 0x1C)] != 0) { + req.entry = entry; + req.mode = mode; + req.value = *(s32 *)((u8 *)arg0 + 0x18); + func_0011A9EC(req.prefix, input); + func_0011AFC8(req.text, text, 0x180); + req.text[0x17F] = 0; + func_L00_0070DA00(&req); + } + } +} diff --git a/src/pal/overlays/l00_multiplayer_menu/L00_0070D2C0.c b/src/pal/overlays/l00_multiplayer_menu/L00_0070D2C0.c new file mode 100644 index 000000000..1e177f5bc --- /dev/null +++ b/src/pal/overlays/l00_multiplayer_menu/L00_0070D2C0.c @@ -0,0 +1,51 @@ +#include "common.h" + +typedef struct MenuFlags { + u8 pad[4]; + u8 flags[2]; +} MenuFlags; + +typedef struct MenuRequest { + s32 entry; + s32 mode; + s32 value; + char prefix[15]; + char text[0x180]; +} MenuRequest; + +extern s32 func_0011AB04(const char *); +extern char *func_0011AFC8(char *, const char *, s32); +extern void func_L00_005C2988(char *, const char *, s32); +extern s32 func_L00_0070D860(char *, s32 *, char **); +extern MenuFlags *func_L00_0070D838(s32); +extern void func_L00_0070DA00(MenuRequest *); + +void func_L00_0070D2C0(s32 *arg0) { + char parsed[0x40]; + MenuRequest req; + s32 entry; + char *text; + MenuFlags *data; + s32 mode; + + func_L00_005C2988(parsed, (char *)arg0 + 0x2C, func_0011AB04((char *)arg0 + 0x2C)); + if (func_L00_0070D860(parsed, &entry, &text) != 0) { + data = func_L00_0070D838(entry); + mode = 2; + if (arg0[2] == 0) { + mode = 0; + } else if (arg0[2] == 1) { + mode = 1; + } + if (mode < 2 && data->flags[arg0[2]] != 0) { + req.entry = entry; + req.mode = mode; + req.value = arg0[1]; + func_0011AFC8(req.prefix, (char *)arg0 + 0xC, 14); + req.prefix[14] = 0; + func_0011AFC8(req.text, text, 0x180); + req.text[0x17F] = 0; + func_L00_0070DA00(&req); + } + } +} diff --git a/src/pal/overlays/l00_multiplayer_menu/L00_0070DEB0.c b/src/pal/overlays/l00_multiplayer_menu/L00_0070DEB0.c new file mode 100644 index 000000000..1c6cc0bda --- /dev/null +++ b/src/pal/overlays/l00_multiplayer_menu/L00_0070DEB0.c @@ -0,0 +1,18 @@ +#include "common.h" + +void *D_00220AD8 = 0; + +/* Replaces the current owner, notifying the old and new owners. */ +void *func_L00_0070DEB0(void *arg0) +{ + void *previous = D_00220AD8; + + if (previous != 0) { + (*(void (**)(void *, s32, s32))((u8 *)*(void **)((u8 *)previous + 0x58) + 0x20))(previous, 1, 0); + } + if (arg0 != 0) { + (*(void (**)(void *, s32, s32))((u8 *)*(void **)((u8 *)arg0 + 0x58) + 0x20))(arg0, 1, 0); + } + D_00220AD8 = arg0; + return previous; +} diff --git a/src/pal/overlays/l41_battledome_tower/L41_003BDF18.c b/src/pal/overlays/l41_battledome_tower/L41_003BDF18.c new file mode 100644 index 000000000..b143f0232 --- /dev/null +++ b/src/pal/overlays/l41_battledome_tower/L41_003BDF18.c @@ -0,0 +1,35 @@ +#include "common.h" + +typedef struct { + u8 p0[0x18]; + f32 f18; +} Type1; + +typedef struct { + u8 p0[0x20]; + Type1 *f20; +} Type2; + +/* Return zero when the second value is lower. */ +f32 func_L41_003BDF18(Type1 *arg0, Type2 *arg1, f32 arg2) { + union { + Type1 *p; + u32 flag; + } value; + f32 left; + f32 right; + f32 result; + + value.p = arg1->f20; + left = value.p->f18; + right = arg0->f18; + value.flag = 1; + if (!(left < right)) { + value.flag = 0; + } + result = 0.0f; + if ((u8)value.flag == 0) { + result = arg2; + } + return result; +} diff --git a/src/pal/overlays/l41_battledome_tower/L41_004475C0.c b/src/pal/overlays/l41_battledome_tower/L41_004475C0.c new file mode 100644 index 000000000..3760ce74d --- /dev/null +++ b/src/pal/overlays/l41_battledome_tower/L41_004475C0.c @@ -0,0 +1,25 @@ +/* cflags: -fno-cse-follow-jumps */ +#include "common.h" + +#include "pal/mask_state.h" + +extern s32 D_0021E714; + +/* Check the global enable state and the object's mode. */ +s32 func_L41_004475C0(void *arg0) +{ + s32 mode = D_0021E714; + register s32 result; + if (mode != 1 || ((u8 *)D_0021E078)[0x32] == 0) { + return 0; + } + result = mode; + if (arg0 == NULL) { + result = 0; + return result; + } + if (*(s32 *)((u8 *)arg0 + 0x2F14) != 1) { + result = 0; + } + return result; +} diff --git a/src/pal/overlays/shared/L00_006FAC10.c b/src/pal/overlays/shared/L00_006FAC10.c new file mode 100644 index 000000000..9027d7794 --- /dev/null +++ b/src/pal/overlays/shared/L00_006FAC10.c @@ -0,0 +1,56 @@ +#include "common.h" + +/* Writes the low bits of value, most significant bit first, at the bit cursor. + * The matching C in rac3-decomp func_L39_0066EC58 informed the reconstruction. + */ +void func_L00_006FAC10(u8 *output, s32 value, s32 *cursor, s32 width) +{ + u8 bits_left = width; + s32 byte_offset; + s32 bit_offset; + s32 available; + u8 chunk_size; + u8 dest_shift; + u8 first_mask; + s32 source_shift; + + byte_offset = *cursor / 8; + bit_offset = *cursor % 8; + output += byte_offset; + available = 8 - bit_offset; + + if (bits_left > available) { + chunk_size = available; + dest_shift = 0; + } else { + chunk_size = bits_left; + dest_shift = 8 - (bits_left + bit_offset); + } + + *cursor += chunk_size; + first_mask = 0xff >> (8 - chunk_size); + source_shift = bits_left - chunk_size; + bits_left = source_shift; + *output = (*output & ~(first_mask << dest_shift)) + | ((first_mask & (value >> source_shift)) << dest_shift); + + while (bits_left != 0) { + u8 byte_mask; + + ++output; + if (bits_left > 8) { + dest_shift = 0; + chunk_size = 8; + } else { + chunk_size = bits_left; + dest_shift = 8 - bits_left; + } + + *cursor += chunk_size; + byte_mask = 0xff >> (8 - chunk_size); + source_shift = bits_left - chunk_size; + bits_left = source_shift; + *output = (*output & ~(byte_mask << dest_shift)) + | ((byte_mask & (value >> source_shift)) << dest_shift); + } +} diff --git a/src/pal/overlays/shared/L01_0055B760.c b/src/pal/overlays/shared/L01_0055B760.c new file mode 100644 index 000000000..ae5b5f455 --- /dev/null +++ b/src/pal/overlays/shared/L01_0055B760.c @@ -0,0 +1,35 @@ +#include "common.h" + +typedef struct { + u8 pad0[0xB]; + u8 fB; +} Type1; + +typedef struct { + u8 pad0[0x10]; + Type1 *f10[0x25]; + s32 fA4; +} Type2; + +/* Return whether any entry in the list has its byte at offset 0x0B clear. */ +s32 func_L01_0055B760(void *arg0, const Type2 *arg1) +{ + s32 value = arg1->fA4; + s32 index = 0; + Type1 *const *entry; + + if (value > 0) { + s64 limit = value; + + entry = arg1->f10; + do { + index++; + value = (*entry)->fB; + if (value == 0) { + return 1; + } + entry++; + } while (index < limit); + } + return 0; +} diff --git a/src/pal/overlays/shared/L01_00575700.c b/src/pal/overlays/shared/L01_00575700.c new file mode 100644 index 000000000..c6efa41fa --- /dev/null +++ b/src/pal/overlays/shared/L01_00575700.c @@ -0,0 +1,20 @@ +#include "common.h" + +typedef struct { + void *f0; + u8 p4[2]; + u16 f6; + u8 p8[4]; + u16 fC; +} Type1; + +/* Update the buffer pointer and two fields when the destination is present. */ +s32 func_L01_00575700(Type1 *arg0, u16 arg1, void *arg2, u16 arg3) { + if (arg0 == NULL) { + return 1; + } + arg0->f0 = arg2; + arg0->f6 = arg3; + arg0->fC = arg1; + return 1; +}