diff --git a/.clang-tidy b/.clang-tidy index 861332a8f2..bbfbd5c7db 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,2 +1,2 @@ -Checks: '-*,clang-analyzer-core.*,clang-analyzer-deadcode.*,readability-*,-readability-magic-numbers,-readability-else-after-return,-readability-named-parameter,-readability-braces-around-statements,-readability-isolate-declaration,-readability-uppercase-literal-suffix,-readability-function-size,-readability-non-const-parameter,-clang-diagnostic-error' +Checks: '-*,clang-analyzer-core.*,clang-analyzer-deadcode.*,readability-*,-readability-magic-numbers,-readability-else-after-return,-readability-named-parameter,-readability-braces-around-statements,-readability-isolate-declaration,-readability-uppercase-literal-suffix,-readability-function-size,-readability-non-const-parameter' HeaderFilterRegex: '(src|include)\/.*\.h' diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 61956f6155..29a5706a47 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,13 +1,11 @@ name: Lint on: - push: - paths: - - 'src/*' - - 'include/*' pull_request: paths: - 'src/*' - 'include/*' + - 'format.sh' + - '.clang-tidy' jobs: build: @@ -18,18 +16,9 @@ jobs: - run: sudo apt-get install -y astyle clang-tidy - # lint files changed by the push/pr - - id: files - uses: trilom/file-changes-action@v1.2.4 - with: - output: ' ' - continue-on-error: true - - run: ./format.sh ${{ steps.files.outputs.files}} - if: ${{ steps.files.outcome == 'success' }} - run: ./format.sh - if: ${{ steps.files.outcome == 'failure' }} - # fail if any files were changed by ./format.sh + # Detect any files changed by ./format.sh - id: files_formatted uses: jackton1/find-changed-files@v1.1 with: diff --git a/Makefile b/Makefile index 8637925dad..9f7051e130 100644 --- a/Makefile +++ b/Makefile @@ -68,7 +68,7 @@ submodules: git submodule update --init --recursive split: - rm -rf $(DATA_DIRS) && ./tools/n64splat/split.py baserom.z64 tools/splat.yaml . + rm -rf $(DATA_DIRS) && ./tools/n64splat/split.py baserom.z64 tools/splat.yaml . --modes ld bin papermario.ld: tools/splat.yaml ./tools/n64splat/split.py baserom.z64 tools/splat.yaml . --modes ld diff --git a/README.md b/README.md index f1aa3786ce..5f375e3b78 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,9 @@ Discord: [Paper Mario Modding](https://discord.gg/urUm3VG) ## Setup -You'll need Linux, a Linux VM, or Windows 10 (WSL) to work on this project. For WSL, we've included `windows_termainl.bat` under tools that you can use to quickly spin up a terminal for your default distro set using `wsl --set-default `. +You'll need Linux, a Linux VM, or [Windows 10 (WSL2)](#wsl) to work on this project. #### Clone the repository - ```sh $ git clone https://github.com/ethteck/papermario.git $ cd papermario @@ -49,6 +48,10 @@ If you get `OK`, you're all set! Otherwise, please feel free to reach out to us There are a few additional dependencies needed when contributing to this project. You can install them with `./install.sh --extra`. +### WSL + +We provide [windows_terminal.bat](tools/windows_terminal.bat) to open a [Windows Terminal](https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701) with a recommended layout. Make sure a default distro (e.g. `wsl --set-default ubuntu`) is set beforehand. + ### Rebuilding Setting the `PM_HEADER_REBUILD` environment variable will cause `make` to rebuild all `.c` files whenever a `.h` file is modified. diff --git a/asm/nonmatchings/code_dc470_len_14c0/func_8014720C.s b/asm/nonmatchings/code_dc470_len_14c0/func_8014720C.s deleted file mode 100644 index f3b3c111bb..0000000000 --- a/asm/nonmatchings/code_dc470_len_14c0/func_8014720C.s +++ /dev/null @@ -1,8 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_8014720C -/* DD90C 8014720C 24020001 */ addiu $v0, $zero, 1 -/* DD910 80147210 3C018015 */ lui $at, 0x8015 -/* DD914 80147214 03E00008 */ jr $ra -/* DD918 80147218 A022F12F */ sb $v0, -0xed1($at) diff --git a/asm/nonmatchings/code_dc470_len_14c0/func_8014721C.s b/asm/nonmatchings/code_dc470_len_14c0/func_8014721C.s deleted file mode 100644 index 4614b1ef73..0000000000 --- a/asm/nonmatchings/code_dc470_len_14c0/func_8014721C.s +++ /dev/null @@ -1,9 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_8014721C -/* DD91C 8014721C 3C018015 */ lui $at, 0x8015 -/* DD920 80147220 03E00008 */ jr $ra -/* DD924 80147224 A020F12F */ sb $zero, -0xed1($at) -/* DD928 80147228 00000000 */ nop -/* DD92C 8014722C 00000000 */ nop diff --git a/asm/nonmatchings/code_ddaf0_len_c50/func_801473F0.s b/asm/nonmatchings/code_ddaf0_len_c50/func_801473F0.s deleted file mode 100644 index c2bccdcf73..0000000000 --- a/asm/nonmatchings/code_ddaf0_len_c50/func_801473F0.s +++ /dev/null @@ -1,14 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_801473F0 -/* DDAF0 801473F0 3C038016 */ lui $v1, 0x8016 -/* DDAF4 801473F4 24639D50 */ addiu $v1, $v1, -0x62b0 -/* DDAF8 801473F8 2402003F */ addiu $v0, $zero, 0x3f -.L801473FC: -/* DDAFC 801473FC A0600000 */ sb $zero, ($v1) -/* DDB00 80147400 2442FFFF */ addiu $v0, $v0, -1 -/* DDB04 80147404 0441FFFD */ bgez $v0, .L801473FC -/* DDB08 80147408 24630020 */ addiu $v1, $v1, 0x20 -/* DDB0C 8014740C 03E00008 */ jr $ra -/* DDB10 80147410 00000000 */ nop diff --git a/asm/nonmatchings/code_e0b30_len_b80/func_8014AFA0.s b/asm/nonmatchings/code_e0b30_len_b80/func_8014AFA0.s deleted file mode 100644 index 0122aa3054..0000000000 --- a/asm/nonmatchings/code_e0b30_len_b80/func_8014AFA0.s +++ /dev/null @@ -1,8 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_8014AFA0 -/* E16A0 8014AFA0 03E00008 */ jr $ra -/* E16A4 8014AFA4 00000000 */ nop -/* E16A8 8014AFA8 00000000 */ nop -/* E16AC 8014AFAC 00000000 */ nop diff --git a/asm/nonmatchings/code_e79b0_len_1920/clear_script_list.s b/asm/nonmatchings/code_e79b0_len_1920/clear_script_list.s deleted file mode 100644 index 33ac82a572..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/clear_script_list.s +++ /dev/null @@ -1,77 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel clear_script_list -/* E7B8C 802C31DC 3C028007 */ lui $v0, %hi(gGameStatusPtr) -/* E7B90 802C31E0 8C42419C */ lw $v0, %lo(gGameStatusPtr)($v0) -/* E7B94 802C31E4 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* E7B98 802C31E8 AFBF0010 */ sw $ra, 0x10($sp) -/* E7B9C 802C31EC 80420070 */ lb $v0, 0x70($v0) -/* E7BA0 802C31F0 1440000D */ bnez $v0, .L802C3228 -/* E7BA4 802C31F4 00000000 */ nop -/* E7BA8 802C31F8 3C02802E */ lui $v0, %hi(gWorldScriptList) -/* E7BAC 802C31FC 2442A490 */ addiu $v0, $v0, %lo(gWorldScriptList) -/* E7BB0 802C3200 3C01802E */ lui $at, %hi(gCurrentScriptListPtr) -/* E7BB4 802C3204 AC22A890 */ sw $v0, %lo(gCurrentScriptListPtr)($at) -/* E7BB8 802C3208 3C02802E */ lui $v0, 0x802e -/* E7BBC 802C320C 2442BCA8 */ addiu $v0, $v0, -0x4358 -/* E7BC0 802C3210 3C01802E */ lui $at, %hi(gMapVars) -/* E7BC4 802C3214 AC22A484 */ sw $v0, %lo(gMapVars)($at) -/* E7BC8 802C3218 3C02802E */ lui $v0, 0x802e -/* E7BCC 802C321C 2442BC70 */ addiu $v0, $v0, -0x4390 -/* E7BD0 802C3220 080B0C94 */ j .L802C3250 -/* E7BD4 802C3224 00000000 */ nop -.L802C3228: -/* E7BD8 802C3228 3C02802E */ lui $v0, %hi(gBattleScriptList) -/* E7BDC 802C322C 2442A690 */ addiu $v0, $v0, %lo(gBattleScriptList) -/* E7BE0 802C3230 3C01802E */ lui $at, %hi(gCurrentScriptListPtr) -/* E7BE4 802C3234 AC22A890 */ sw $v0, %lo(gCurrentScriptListPtr)($at) -/* E7BE8 802C3238 3C02802E */ lui $v0, 0x802e -/* E7BEC 802C323C 2442BCE8 */ addiu $v0, $v0, -0x4318 -/* E7BF0 802C3240 3C01802E */ lui $at, %hi(gMapVars) -/* E7BF4 802C3244 AC22A484 */ sw $v0, %lo(gMapVars)($at) -/* E7BF8 802C3248 3C02802E */ lui $v0, 0x802e -/* E7BFC 802C324C 2442BD34 */ addiu $v0, $v0, -0x42cc -.L802C3250: -/* E7C00 802C3250 3C01802E */ lui $at, %hi(gMapFlags) -/* E7C04 802C3254 AC22A480 */ sw $v0, %lo(gMapFlags)($at) -/* E7C08 802C3258 3C02802E */ lui $v0, %hi(gCurrentScriptListPtr) -/* E7C0C 802C325C 8C42A890 */ lw $v0, %lo(gCurrentScriptListPtr)($v0) -/* E7C10 802C3260 2403007F */ addiu $v1, $zero, 0x7f -/* E7C14 802C3264 244201FC */ addiu $v0, $v0, 0x1fc -.L802C3268: -/* E7C18 802C3268 AC400000 */ sw $zero, ($v0) -/* E7C1C 802C326C 2463FFFF */ addiu $v1, $v1, -1 -/* E7C20 802C3270 0461FFFD */ bgez $v1, .L802C3268 -/* E7C24 802C3274 2442FFFC */ addiu $v0, $v0, -4 -/* E7C28 802C3278 3C02802E */ lui $v0, %hi(gMapVars) -/* E7C2C 802C327C 8C42A484 */ lw $v0, %lo(gMapVars)($v0) -/* E7C30 802C3280 2403000F */ addiu $v1, $zero, 0xf -/* E7C34 802C3284 3C01802E */ lui $at, %hi(gNumScripts) -/* E7C38 802C3288 AC20A488 */ sw $zero, %lo(gNumScripts)($at) -/* E7C3C 802C328C 3C01802E */ lui $at, %hi(gScriptListCount) -/* E7C40 802C3290 AC20AC98 */ sw $zero, %lo(gScriptListCount)($at) -/* E7C44 802C3294 3C01802E */ lui $at, %hi(D_802D9CA4) -/* E7C48 802C3298 AC209CA4 */ sw $zero, %lo(D_802D9CA4)($at) -/* E7C4C 802C329C 2442003C */ addiu $v0, $v0, 0x3c -.L802C32A0: -/* E7C50 802C32A0 AC400000 */ sw $zero, ($v0) -/* E7C54 802C32A4 2463FFFF */ addiu $v1, $v1, -1 -/* E7C58 802C32A8 0461FFFD */ bgez $v1, .L802C32A0 -/* E7C5C 802C32AC 2442FFFC */ addiu $v0, $v0, -4 -/* E7C60 802C32B0 3C02802E */ lui $v0, %hi(gMapFlags) -/* E7C64 802C32B4 8C42A480 */ lw $v0, %lo(gMapFlags)($v0) -/* E7C68 802C32B8 24030002 */ addiu $v1, $zero, 2 -/* E7C6C 802C32BC 24420008 */ addiu $v0, $v0, 8 -.L802C32C0: -/* E7C70 802C32C0 AC400000 */ sw $zero, ($v0) -/* E7C74 802C32C4 2463FFFF */ addiu $v1, $v1, -1 -/* E7C78 802C32C8 0461FFFD */ bgez $v1, .L802C32C0 -/* E7C7C 802C32CC 2442FFFC */ addiu $v0, $v0, -4 -/* E7C80 802C32D0 0C0B5122 */ jal func_802D4488 -/* E7C84 802C32D4 00000000 */ nop -/* E7C88 802C32D8 0C0B352D */ jal func_802CD4B4 -/* E7C8C 802C32DC 00000000 */ nop -/* E7C90 802C32E0 8FBF0010 */ lw $ra, 0x10($sp) -/* E7C94 802C32E4 03E00008 */ jr $ra -/* E7C98 802C32E8 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_e79b0_len_1920/func_802C3390.s b/asm/nonmatchings/code_e79b0_len_1920/func_802C3390.s deleted file mode 100644 index a44d4258fb..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/func_802C3390.s +++ /dev/null @@ -1,26 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_802C3390 -/* E7D40 802C3390 3C03800A */ lui $v1, %hi(D_8009A5D8) -/* E7D44 802C3394 8C63A5D8 */ lw $v1, %lo(D_8009A5D8)($v1) -/* E7D48 802C3398 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* E7D4C 802C339C 2C620005 */ sltiu $v0, $v1, 5 -/* E7D50 802C33A0 1040000C */ beqz $v0, .L802C33D4 -/* E7D54 802C33A4 AFBF0010 */ sw $ra, 0x10($sp) -/* E7D58 802C33A8 00031080 */ sll $v0, $v1, 2 -/* E7D5C 802C33AC 3C01802E */ lui $at, 0x802e -/* E7D60 802C33B0 00220821 */ addu $at, $at, $v0 -/* E7D64 802C33B4 8C229D80 */ lw $v0, -0x6280($at) -/* E7D68 802C33B8 00400008 */ jr $v0 -/* E7D6C 802C33BC 00000000 */ nop -/* E7D70 802C33C0 080B0CF3 */ j .L802C33CC -/* E7D74 802C33C4 24040001 */ addiu $a0, $zero, 1 -/* E7D78 802C33C8 24040002 */ addiu $a0, $zero, 2 -.L802C33CC: -/* E7D7C 802C33CC 0C0B117A */ jal suspend_all_group -/* E7D80 802C33D0 00000000 */ nop -.L802C33D4: -/* E7D84 802C33D4 8FBF0010 */ lw $ra, 0x10($sp) -/* E7D88 802C33D8 03E00008 */ jr $ra -/* E7D8C 802C33DC 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_e79b0_len_1920/func_802C39F8.s b/asm/nonmatchings/code_e79b0_len_1920/func_802C39F8.s index b4153908fc..6254775f2f 100644 --- a/asm/nonmatchings/code_e79b0_len_1920/func_802C39F8.s +++ b/asm/nonmatchings/code_e79b0_len_1920/func_802C39F8.s @@ -124,9 +124,9 @@ glabel func_802C39F8 /* E8564 802C3BB4 8E030144 */ lw $v1, 0x144($s0) /* E8568 802C3BB8 24420001 */ addiu $v0, $v0, 1 /* E856C 802C3BBC ACA20000 */ sw $v0, ($a1) -/* E8570 802C3BC0 3C01802E */ lui $at, %hi(gScriptIndexList) +/* E8570 802C3BC0 3C01802E */ lui $at, %hi(gScriptIdList) /* E8574 802C3BC4 00240821 */ addu $at, $at, $a0 -/* E8578 802C3BC8 AC23AA98 */ sw $v1, %lo(gScriptIndexList)($at) +/* E8578 802C3BC8 AC23AA98 */ sw $v1, %lo(gScriptIdList)($at) .L802C3BCC: /* E857C 802C3BCC 3C03802E */ lui $v1, 0x802e /* E8580 802C3BD0 24639CA0 */ addiu $v1, $v1, -0x6360 diff --git a/asm/nonmatchings/code_e79b0_len_1920/func_802C3C10.s b/asm/nonmatchings/code_e79b0_len_1920/func_802C3C10.s deleted file mode 100644 index 6350130a99..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/func_802C3C10.s +++ /dev/null @@ -1,68 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_802C3C10 -/* E85C0 802C3C10 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* E85C4 802C3C14 AFB10014 */ sw $s1, 0x14($sp) -/* E85C8 802C3C18 0080882D */ daddu $s1, $a0, $zero -/* E85CC 802C3C1C AFBF0018 */ sw $ra, 0x18($sp) -/* E85D0 802C3C20 AFB00010 */ sw $s0, 0x10($sp) -/* E85D4 802C3C24 92220000 */ lbu $v0, ($s1) -/* E85D8 802C3C28 3C013F80 */ lui $at, 0x3f80 -/* E85DC 802C3C2C 44810000 */ mtc1 $at, $f0 -/* E85E0 802C3C30 8E240060 */ lw $a0, 0x60($s1) -/* E85E4 802C3C34 AE250008 */ sw $a1, 8($s1) -/* E85E8 802C3C38 AE25015C */ sw $a1, 0x15c($s1) -/* E85EC 802C3C3C AE250164 */ sw $a1, 0x164($s1) -/* E85F0 802C3C40 A2200002 */ sb $zero, 2($s1) -/* E85F4 802C3C44 AE200154 */ sw $zero, 0x154($s1) -/* E85F8 802C3C48 00461025 */ or $v0, $v0, $a2 -/* E85FC 802C3C4C A2220000 */ sb $v0, ($s1) -/* E8600 802C3C50 10800004 */ beqz $a0, .L802C3C64 -/* E8604 802C3C54 E6200150 */ swc1 $f0, 0x150($s1) -/* E8608 802C3C58 0C00AB4B */ jal heap_free -/* E860C 802C3C5C 00000000 */ nop -/* E8610 802C3C60 AE200060 */ sw $zero, 0x60($s1) -.L802C3C64: -/* E8614 802C3C64 8E240068 */ lw $a0, 0x68($s1) -/* E8618 802C3C68 10800003 */ beqz $a0, .L802C3C78 -/* E861C 802C3C6C 0000802D */ daddu $s0, $zero, $zero -/* E8620 802C3C70 0C0B0FCF */ jal kill_script -/* E8624 802C3C74 00000000 */ nop -.L802C3C78: -/* E8628 802C3C78 3C03802E */ lui $v1, %hi(gCurrentScriptListPtr) -/* E862C 802C3C7C 8C63A890 */ lw $v1, %lo(gCurrentScriptListPtr)($v1) -/* E8630 802C3C80 00101080 */ sll $v0, $s0, 2 -/* E8634 802C3C84 00431021 */ addu $v0, $v0, $v1 -/* E8638 802C3C88 8C440000 */ lw $a0, ($v0) -/* E863C 802C3C8C 10800006 */ beqz $a0, .L802C3CA8 -/* E8640 802C3C90 26100001 */ addiu $s0, $s0, 1 -/* E8644 802C3C94 8C82006C */ lw $v0, 0x6c($a0) -/* E8648 802C3C98 14510003 */ bne $v0, $s1, .L802C3CA8 -/* E864C 802C3C9C 00000000 */ nop -/* E8650 802C3CA0 0C0B0FCF */ jal kill_script -/* E8654 802C3CA4 00000000 */ nop -.L802C3CA8: -/* E8658 802C3CA8 2A020080 */ slti $v0, $s0, 0x80 -/* E865C 802C3CAC 1440FFF2 */ bnez $v0, .L802C3C78 -/* E8660 802C3CB0 2402FFFF */ addiu $v0, $zero, -1 -/* E8664 802C3CB4 A2220006 */ sb $v0, 6($s1) -/* E8668 802C3CB8 A2220007 */ sb $v0, 7($s1) -/* E866C 802C3CBC 3C01802E */ lui $at, 0x802e -/* E8670 802C3CC0 C4209CA8 */ lwc1 $f0, -0x6358($at) -/* E8674 802C3CC4 0220202D */ daddu $a0, $s1, $zero -/* E8678 802C3CC8 AE200064 */ sw $zero, 0x64($s1) -/* E867C 802C3CCC AE20006C */ sw $zero, 0x6c($s1) -/* E8680 802C3CD0 AE200068 */ sw $zero, 0x68($s1) -/* E8684 802C3CD4 AE200154 */ sw $zero, 0x154($s1) -/* E8688 802C3CD8 AE200158 */ sw $zero, 0x158($s1) -/* E868C 802C3CDC 0C0B0C52 */ jal find_script_labels -/* E8690 802C3CE0 E6200150 */ swc1 $f0, 0x150($s1) -/* E8694 802C3CE4 0C0B0CE4 */ jal func_802C3390 -/* E8698 802C3CE8 0220202D */ daddu $a0, $s1, $zero -/* E869C 802C3CEC 0220102D */ daddu $v0, $s1, $zero -/* E86A0 802C3CF0 8FBF0018 */ lw $ra, 0x18($sp) -/* E86A4 802C3CF4 8FB10014 */ lw $s1, 0x14($sp) -/* E86A8 802C3CF8 8FB00010 */ lw $s0, 0x10($sp) -/* E86AC 802C3CFC 03E00008 */ jr $ra -/* E86B0 802C3D00 27BD0020 */ addiu $sp, $sp, 0x20 diff --git a/asm/nonmatchings/code_e79b0_len_1920/func_802C3EE4.s b/asm/nonmatchings/code_e79b0_len_1920/func_802C3EE4.s index 02a85ee021..ca3c1d52e1 100644 --- a/asm/nonmatchings/code_e79b0_len_1920/func_802C3EE4.s +++ b/asm/nonmatchings/code_e79b0_len_1920/func_802C3EE4.s @@ -9,10 +9,10 @@ glabel func_802C3EE4 /* E88A4 802C3EF4 3C08802E */ lui $t0, %hi(gCurrentScriptListPtr) /* E88A8 802C3EF8 8D08A890 */ lw $t0, %lo(gCurrentScriptListPtr)($t0) /* E88AC 802C3EFC 0040382D */ daddu $a3, $v0, $zero -/* E88B0 802C3F00 3C06802E */ lui $a2, %hi(gScriptIndexList) -/* E88B4 802C3F04 24C6AA98 */ addiu $a2, $a2, %lo(gScriptIndexList) -/* E88B8 802C3F08 3C05802E */ lui $a1, 0x802e -/* E88BC 802C3F0C 24A5A898 */ addiu $a1, $a1, -0x5768 +/* E88B0 802C3F00 3C06802E */ lui $a2, %hi(gScriptIdList) +/* E88B4 802C3F04 24C6AA98 */ addiu $a2, $a2, %lo(gScriptIdList) +/* E88B8 802C3F08 3C05802E */ lui $a1, %hi(gScriptIndexList) +/* E88BC 802C3F0C 24A5A898 */ addiu $a1, $a1, %lo(gScriptIndexList) .L802C3F10: /* E88C0 802C3F10 8CA20000 */ lw $v0, ($a1) /* E88C4 802C3F14 00021080 */ sll $v0, $v0, 2 diff --git a/asm/nonmatchings/code_e79b0_len_1920/get_global_timespace.s b/asm/nonmatchings/code_e79b0_len_1920/get_global_timespace.s deleted file mode 100644 index 18737723e5..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/get_global_timespace.s +++ /dev/null @@ -1,7 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel get_global_timespace -/* E8BBC 802C420C 3C01802E */ lui $at, 0x802e -/* E8BC0 802C4210 03E00008 */ jr $ra -/* E8BC4 802C4214 C4209CA8 */ lwc1 $f0, -0x6358($at) diff --git a/asm/nonmatchings/code_e79b0_len_1920/init_script_list.s b/asm/nonmatchings/code_e79b0_len_1920/init_script_list.s deleted file mode 100644 index 5120057c73..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/init_script_list.s +++ /dev/null @@ -1,47 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel init_script_list -/* E7C9C 802C32EC 3C028007 */ lui $v0, %hi(gGameStatusPtr) -/* E7CA0 802C32F0 8C42419C */ lw $v0, %lo(gGameStatusPtr)($v0) -/* E7CA4 802C32F4 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* E7CA8 802C32F8 AFBF0010 */ sw $ra, 0x10($sp) -/* E7CAC 802C32FC 80420070 */ lb $v0, 0x70($v0) -/* E7CB0 802C3300 1440000D */ bnez $v0, .L802C3338 -/* E7CB4 802C3304 00000000 */ nop -/* E7CB8 802C3308 3C02802E */ lui $v0, %hi(gWorldScriptList) -/* E7CBC 802C330C 2442A490 */ addiu $v0, $v0, %lo(gWorldScriptList) -/* E7CC0 802C3310 3C01802E */ lui $at, %hi(gCurrentScriptListPtr) -/* E7CC4 802C3314 AC22A890 */ sw $v0, %lo(gCurrentScriptListPtr)($at) -/* E7CC8 802C3318 3C02802E */ lui $v0, 0x802e -/* E7CCC 802C331C 2442BCA8 */ addiu $v0, $v0, -0x4358 -/* E7CD0 802C3320 3C01802E */ lui $at, %hi(gMapVars) -/* E7CD4 802C3324 AC22A484 */ sw $v0, %lo(gMapVars)($at) -/* E7CD8 802C3328 3C02802E */ lui $v0, 0x802e -/* E7CDC 802C332C 2442BC70 */ addiu $v0, $v0, -0x4390 -/* E7CE0 802C3330 080B0CD8 */ j .L802C3360 -/* E7CE4 802C3334 00000000 */ nop -.L802C3338: -/* E7CE8 802C3338 3C02802E */ lui $v0, %hi(gBattleScriptList) -/* E7CEC 802C333C 2442A690 */ addiu $v0, $v0, %lo(gBattleScriptList) -/* E7CF0 802C3340 3C01802E */ lui $at, %hi(gCurrentScriptListPtr) -/* E7CF4 802C3344 AC22A890 */ sw $v0, %lo(gCurrentScriptListPtr)($at) -/* E7CF8 802C3348 3C02802E */ lui $v0, 0x802e -/* E7CFC 802C334C 2442BCE8 */ addiu $v0, $v0, -0x4318 -/* E7D00 802C3350 3C01802E */ lui $at, %hi(gMapVars) -/* E7D04 802C3354 AC22A484 */ sw $v0, %lo(gMapVars)($at) -/* E7D08 802C3358 3C02802E */ lui $v0, 0x802e -/* E7D0C 802C335C 2442BD34 */ addiu $v0, $v0, -0x42cc -.L802C3360: -/* E7D10 802C3360 3C01802E */ lui $at, %hi(gMapFlags) -/* E7D14 802C3364 AC22A480 */ sw $v0, %lo(gMapFlags)($at) -/* E7D18 802C3368 3C01802E */ lui $at, %hi(gNumScripts) -/* E7D1C 802C336C AC20A488 */ sw $zero, %lo(gNumScripts)($at) -/* E7D20 802C3370 3C01802E */ lui $at, %hi(D_802D9CA4) -/* E7D24 802C3374 0C0B5158 */ jal func_802D4560 -/* E7D28 802C3378 AC209CA4 */ sw $zero, %lo(D_802D9CA4)($at) -/* E7D2C 802C337C 0C0B355F */ jal func_802CD57C -/* E7D30 802C3380 00000000 */ nop -/* E7D34 802C3384 8FBF0010 */ lw $ra, 0x10($sp) -/* E7D38 802C3388 03E00008 */ jr $ra -/* E7D3C 802C338C 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_e79b0_len_1920/kill_script.s b/asm/nonmatchings/code_e79b0_len_1920/kill_script.s deleted file mode 100644 index 95d2345aa5..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/kill_script.s +++ /dev/null @@ -1,105 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel kill_script -/* E88EC 802C3F3C 3C03802E */ lui $v1, %hi(gCurrentScriptListPtr) -/* E88F0 802C3F40 8C63A890 */ lw $v1, %lo(gCurrentScriptListPtr)($v1) -/* E88F4 802C3F44 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* E88F8 802C3F48 AFB20018 */ sw $s2, 0x18($sp) -/* E88FC 802C3F4C 0080902D */ daddu $s2, $a0, $zero -/* E8900 802C3F50 AFB00010 */ sw $s0, 0x10($sp) -/* E8904 802C3F54 0000802D */ daddu $s0, $zero, $zero -/* E8908 802C3F58 AFBF001C */ sw $ra, 0x1c($sp) -/* E890C 802C3F5C AFB10014 */ sw $s1, 0x14($sp) -.L802C3F60: -/* E8910 802C3F60 8C620000 */ lw $v0, ($v1) -/* E8914 802C3F64 10520006 */ beq $v0, $s2, .L802C3F80 -/* E8918 802C3F68 2A020080 */ slti $v0, $s0, 0x80 -/* E891C 802C3F6C 26100001 */ addiu $s0, $s0, 1 -/* E8920 802C3F70 2A020080 */ slti $v0, $s0, 0x80 -/* E8924 802C3F74 1440FFFA */ bnez $v0, .L802C3F60 -/* E8928 802C3F78 24630004 */ addiu $v1, $v1, 4 -/* E892C 802C3F7C 2A020080 */ slti $v0, $s0, 0x80 -.L802C3F80: -/* E8930 802C3F80 10400044 */ beqz $v0, .L802C4094 -/* E8934 802C3F84 00000000 */ nop -/* E8938 802C3F88 8E440068 */ lw $a0, 0x68($s2) -/* E893C 802C3F8C 10800003 */ beqz $a0, .L802C3F9C -/* E8940 802C3F90 0000882D */ daddu $s1, $zero, $zero -/* E8944 802C3F94 0C0B0FCF */ jal kill_script -/* E8948 802C3F98 00000000 */ nop -.L802C3F9C: -/* E894C 802C3F9C 3C03802E */ lui $v1, %hi(gCurrentScriptListPtr) -/* E8950 802C3FA0 8C63A890 */ lw $v1, %lo(gCurrentScriptListPtr)($v1) -/* E8954 802C3FA4 00111080 */ sll $v0, $s1, 2 -/* E8958 802C3FA8 00431021 */ addu $v0, $v0, $v1 -/* E895C 802C3FAC 8C440000 */ lw $a0, ($v0) -/* E8960 802C3FB0 10800006 */ beqz $a0, .L802C3FCC -/* E8964 802C3FB4 26310001 */ addiu $s1, $s1, 1 -/* E8968 802C3FB8 8C82006C */ lw $v0, 0x6c($a0) -/* E896C 802C3FBC 14520003 */ bne $v0, $s2, .L802C3FCC -/* E8970 802C3FC0 00000000 */ nop -/* E8974 802C3FC4 0C0B0FCF */ jal kill_script -/* E8978 802C3FC8 00000000 */ nop -.L802C3FCC: -/* E897C 802C3FCC 2A220080 */ slti $v0, $s1, 0x80 -/* E8980 802C3FD0 1440FFF2 */ bnez $v0, .L802C3F9C -/* E8984 802C3FD4 00000000 */ nop -/* E8988 802C3FD8 8E450064 */ lw $a1, 0x64($s2) -/* E898C 802C3FDC 10A00018 */ beqz $a1, .L802C4040 -/* E8990 802C3FE0 0000882D */ daddu $s1, $zero, $zero -/* E8994 802C3FE4 0240202D */ daddu $a0, $s2, $zero -/* E8998 802C3FE8 90A20000 */ lbu $v0, ($a1) -/* E899C 802C3FEC 00A0182D */ daddu $v1, $a1, $zero -/* E89A0 802C3FF0 ACA00068 */ sw $zero, 0x68($a1) -/* E89A4 802C3FF4 304200EF */ andi $v0, $v0, 0xef -/* E89A8 802C3FF8 A0A20000 */ sb $v0, ($a1) -.L802C3FFC: -/* E89AC 802C3FFC 8C820084 */ lw $v0, 0x84($a0) -/* E89B0 802C4000 24840004 */ addiu $a0, $a0, 4 -/* E89B4 802C4004 26310001 */ addiu $s1, $s1, 1 -/* E89B8 802C4008 AC620084 */ sw $v0, 0x84($v1) -/* E89BC 802C400C 2A220010 */ slti $v0, $s1, 0x10 -/* E89C0 802C4010 1440FFFA */ bnez $v0, .L802C3FFC -/* E89C4 802C4014 24630004 */ addiu $v1, $v1, 4 -/* E89C8 802C4018 0000882D */ daddu $s1, $zero, $zero -/* E89CC 802C401C 0240202D */ daddu $a0, $s2, $zero -/* E89D0 802C4020 00A0182D */ daddu $v1, $a1, $zero -.L802C4024: -/* E89D4 802C4024 8C8200C4 */ lw $v0, 0xc4($a0) -/* E89D8 802C4028 24840004 */ addiu $a0, $a0, 4 -/* E89DC 802C402C 26310001 */ addiu $s1, $s1, 1 -/* E89E0 802C4030 AC6200C4 */ sw $v0, 0xc4($v1) -/* E89E4 802C4034 2A220003 */ slti $v0, $s1, 3 -/* E89E8 802C4038 1440FFFA */ bnez $v0, .L802C4024 -/* E89EC 802C403C 24630004 */ addiu $v1, $v1, 4 -.L802C4040: -/* E89F0 802C4040 8E440060 */ lw $a0, 0x60($s2) -/* E89F4 802C4044 10800004 */ beqz $a0, .L802C4058 -/* E89F8 802C4048 00000000 */ nop -/* E89FC 802C404C 0C00AB4B */ jal heap_free -/* E8A00 802C4050 00000000 */ nop -/* E8A04 802C4054 AE400060 */ sw $zero, 0x60($s2) -.L802C4058: -/* E8A08 802C4058 3C11802E */ lui $s1, %hi(gCurrentScriptListPtr) -/* E8A0C 802C405C 2631A890 */ addiu $s1, $s1, %lo(gCurrentScriptListPtr) -/* E8A10 802C4060 8E220000 */ lw $v0, ($s1) -/* E8A14 802C4064 00108080 */ sll $s0, $s0, 2 -/* E8A18 802C4068 02021021 */ addu $v0, $s0, $v0 -/* E8A1C 802C406C 0C00AB4B */ jal heap_free -/* E8A20 802C4070 8C440000 */ lw $a0, ($v0) -/* E8A24 802C4074 3C04802E */ lui $a0, %hi(gNumScripts) -/* E8A28 802C4078 2484A488 */ addiu $a0, $a0, %lo(gNumScripts) -/* E8A2C 802C407C 8E230000 */ lw $v1, ($s1) -/* E8A30 802C4080 8C820000 */ lw $v0, ($a0) -/* E8A34 802C4084 02038021 */ addu $s0, $s0, $v1 -/* E8A38 802C4088 2442FFFF */ addiu $v0, $v0, -1 -/* E8A3C 802C408C AE000000 */ sw $zero, ($s0) -/* E8A40 802C4090 AC820000 */ sw $v0, ($a0) -.L802C4094: -/* E8A44 802C4094 8FBF001C */ lw $ra, 0x1c($sp) -/* E8A48 802C4098 8FB20018 */ lw $s2, 0x18($sp) -/* E8A4C 802C409C 8FB10014 */ lw $s1, 0x14($sp) -/* E8A50 802C40A0 8FB00010 */ lw $s0, 0x10($sp) -/* E8A54 802C40A4 03E00008 */ jr $ra -/* E8A58 802C40A8 27BD0020 */ addiu $sp, $sp, 0x20 diff --git a/asm/nonmatchings/code_e79b0_len_1920/set_global_timespace.s b/asm/nonmatchings/code_e79b0_len_1920/set_global_timespace.s deleted file mode 100644 index cca1cb0612..0000000000 --- a/asm/nonmatchings/code_e79b0_len_1920/set_global_timespace.s +++ /dev/null @@ -1,7 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel set_global_timespace -/* E8BB0 802C4200 3C01802E */ lui $at, 0x802e -/* E8BB4 802C4204 03E00008 */ jr $ra -/* E8BB8 802C4208 E42C9CA8 */ swc1 $f12, -0x6358($at) diff --git a/asm/nonmatchings/code_e79b0_len_1920/sort_scripts.s b/asm/nonmatchings/code_e79b0_len_1920/sort_scripts.s index 602f3f5cc6..cab05f9a45 100644 --- a/asm/nonmatchings/code_e79b0_len_1920/sort_scripts.s +++ b/asm/nonmatchings/code_e79b0_len_1920/sort_scripts.s @@ -5,12 +5,12 @@ glabel sort_scripts /* E79B0 802C3000 27BDFFF8 */ addiu $sp, $sp, -8 /* E79B4 802C3004 0000682D */ daddu $t5, $zero, $zero /* E79B8 802C3008 01A0482D */ daddu $t1, $t5, $zero -/* E79BC 802C300C 3C05802E */ lui $a1, %hi(gScriptIndexList) -/* E79C0 802C3010 24A5AA98 */ addiu $a1, $a1, %lo(gScriptIndexList) +/* E79BC 802C300C 3C05802E */ lui $a1, %hi(gScriptIdList) +/* E79C0 802C3010 24A5AA98 */ addiu $a1, $a1, %lo(gScriptIdList) /* E79C4 802C3014 3C06802E */ lui $a2, %hi(gCurrentScriptListPtr) /* E79C8 802C3018 8CC6A890 */ lw $a2, %lo(gCurrentScriptListPtr)($a2) -/* E79CC 802C301C 3C04802E */ lui $a0, 0x802e -/* E79D0 802C3020 2484A898 */ addiu $a0, $a0, -0x5768 +/* E79CC 802C301C 3C04802E */ lui $a0, %hi(gScriptIndexList) +/* E79D0 802C3020 2484A898 */ addiu $a0, $a0, %lo(gScriptIndexList) /* E79D4 802C3024 AFB00000 */ sw $s0, ($sp) .L802C3028: /* E79D8 802C3028 8CC30000 */ lw $v1, ($a2) @@ -37,11 +37,11 @@ glabel sort_scripts /* E7A28 802C3078 0000482D */ daddu $t1, $zero, $zero /* E7A2C 802C307C 3C10802E */ lui $s0, %hi(gCurrentScriptListPtr) /* E7A30 802C3080 2610A890 */ addiu $s0, $s0, %lo(gCurrentScriptListPtr) -/* E7A34 802C3084 3C0E802E */ lui $t6, %hi(gScriptIndexList) -/* E7A38 802C3088 25CEAA98 */ addiu $t6, $t6, %lo(gScriptIndexList) +/* E7A34 802C3084 3C0E802E */ lui $t6, %hi(gScriptIdList) +/* E7A38 802C3088 25CEAA98 */ addiu $t6, $t6, %lo(gScriptIdList) /* E7A3C 802C308C 01C0C82D */ daddu $t9, $t6, $zero -/* E7A40 802C3090 3C18802E */ lui $t8, 0x802e -/* E7A44 802C3094 2718A898 */ addiu $t8, $t8, -0x5768 +/* E7A40 802C3090 3C18802E */ lui $t8, %hi(gScriptIndexList) +/* E7A44 802C3094 2718A898 */ addiu $t8, $t8, %lo(gScriptIndexList) /* E7A48 802C3098 0300782D */ daddu $t7, $t8, $zero .L802C309C: /* E7A4C 802C309C 25280001 */ addiu $t0, $t1, 1 diff --git a/asm/nonmatchings/code_e79b0_len_1920/start_child_script.s b/asm/nonmatchings/code_e79b0_len_1920/start_child_script.s index 5904de2185..9cb10702eb 100644 --- a/asm/nonmatchings/code_e79b0_len_1920/start_child_script.s +++ b/asm/nonmatchings/code_e79b0_len_1920/start_child_script.s @@ -129,9 +129,9 @@ glabel start_child_script /* E8348 802C3998 8E030144 */ lw $v1, 0x144($s0) /* E834C 802C399C 24420001 */ addiu $v0, $v0, 1 /* E8350 802C39A0 ACA20000 */ sw $v0, ($a1) -/* E8354 802C39A4 3C01802E */ lui $at, %hi(gScriptIndexList) +/* E8354 802C39A4 3C01802E */ lui $at, %hi(gScriptIdList) /* E8358 802C39A8 00240821 */ addu $at, $at, $a0 -/* E835C 802C39AC AC23AA98 */ sw $v1, %lo(gScriptIndexList)($at) +/* E835C 802C39AC AC23AA98 */ sw $v1, %lo(gScriptIdList)($at) .L802C39B0: /* E8360 802C39B0 0C0B0CE4 */ jal func_802C3390 /* E8364 802C39B4 0200202D */ daddu $a0, $s0, $zero diff --git a/asm/nonmatchings/code_e79b0_len_1920/start_script.s b/asm/nonmatchings/code_e79b0_len_1920/start_script.s index fabdad9d00..371bfd3a7d 100644 --- a/asm/nonmatchings/code_e79b0_len_1920/start_script.s +++ b/asm/nonmatchings/code_e79b0_len_1920/start_script.s @@ -113,9 +113,9 @@ glabel start_script /* E7F20 802C3570 8E030144 */ lw $v1, 0x144($s0) /* E7F24 802C3574 24420001 */ addiu $v0, $v0, 1 /* E7F28 802C3578 ACA20000 */ sw $v0, ($a1) -/* E7F2C 802C357C 3C01802E */ lui $at, %hi(gScriptIndexList) +/* E7F2C 802C357C 3C01802E */ lui $at, %hi(gScriptIdList) /* E7F30 802C3580 00240821 */ addu $at, $at, $a0 -/* E7F34 802C3584 AC23AA98 */ sw $v1, %lo(gScriptIndexList)($at) +/* E7F34 802C3584 AC23AA98 */ sw $v1, %lo(gScriptIdList)($at) .L802C3588: /* E7F38 802C3588 0C0B0CE4 */ jal func_802C3390 /* E7F3C 802C358C 0200202D */ daddu $a0, $s0, $zero diff --git a/asm/nonmatchings/code_e79b0_len_1920/start_script_in_group.s b/asm/nonmatchings/code_e79b0_len_1920/start_script_in_group.s index 0a97ca5c66..022a1a52a4 100644 --- a/asm/nonmatchings/code_e79b0_len_1920/start_script_in_group.s +++ b/asm/nonmatchings/code_e79b0_len_1920/start_script_in_group.s @@ -114,9 +114,9 @@ glabel start_script_in_group /* E8114 802C3764 8E030144 */ lw $v1, 0x144($s0) /* E8118 802C3768 24420001 */ addiu $v0, $v0, 1 /* E811C 802C376C ACA20000 */ sw $v0, ($a1) -/* E8120 802C3770 3C01802E */ lui $at, %hi(gScriptIndexList) +/* E8120 802C3770 3C01802E */ lui $at, %hi(gScriptIdList) /* E8124 802C3774 00240821 */ addu $at, $at, $a0 -/* E8128 802C3778 AC23AA98 */ sw $v1, %lo(gScriptIndexList)($at) +/* E8128 802C3778 AC23AA98 */ sw $v1, %lo(gScriptIdList)($at) .L802C377C: /* E812C 802C377C 0C0B0CE4 */ jal func_802C3390 /* E8130 802C3780 0200202D */ daddu $a0, $s0, $zero diff --git a/asm/nonmatchings/code_e79b0_len_1920/update_scripts.s b/asm/nonmatchings/code_e79b0_len_1920/update_scripts.s index 04e8a89585..f9dd62f99f 100644 --- a/asm/nonmatchings/code_e79b0_len_1920/update_scripts.s +++ b/asm/nonmatchings/code_e79b0_len_1920/update_scripts.s @@ -30,8 +30,8 @@ glabel update_scripts /* E8788 802C3DD8 4481A800 */ mtc1 $at, $f21 /* E878C 802C3DDC 4480A000 */ mtc1 $zero, $f20 /* E8790 802C3DE0 2415FFFF */ addiu $s5, $zero, -1 -/* E8794 802C3DE4 3C14802E */ lui $s4, %hi(gScriptIndexList) -/* E8798 802C3DE8 2694AA98 */ addiu $s4, $s4, %lo(gScriptIndexList) +/* E8794 802C3DE4 3C14802E */ lui $s4, %hi(gScriptIdList) +/* E8798 802C3DE8 2694AA98 */ addiu $s4, $s4, %lo(gScriptIdList) /* E879C 802C3DEC 3C13802E */ lui $s3, 0x802e /* E87A0 802C3DF0 2673A898 */ addiu $s3, $s3, -0x5768 .L802C3DF4: diff --git a/asm/nonmatchings/code_f8f60_len_1560/func_802D4BDC.s b/asm/nonmatchings/code_f8f60_len_1560/func_802D4BDC.s deleted file mode 100644 index a996d6672f..0000000000 --- a/asm/nonmatchings/code_f8f60_len_1560/func_802D4BDC.s +++ /dev/null @@ -1,36 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_802D4BDC -/* F958C 802D4BDC 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* F9590 802D4BE0 AFBF0010 */ sw $ra, 0x10($sp) -/* F9594 802D4BE4 10A00003 */ beqz $a1, .L802D4BF4 -/* F9598 802D4BE8 0080182D */ daddu $v1, $a0, $zero -/* F959C 802D4BEC AC600070 */ sw $zero, 0x70($v1) -/* F95A0 802D4BF0 AC600074 */ sw $zero, 0x74($v1) -.L802D4BF4: -/* F95A4 802D4BF4 8C620070 */ lw $v0, 0x70($v1) -/* F95A8 802D4BF8 14400011 */ bnez $v0, .L802D4C40 -/* F95AC 802D4BFC 0000102D */ daddu $v0, $zero, $zero -/* F95B0 802D4C00 8C620074 */ lw $v0, 0x74($v1) -/* F95B4 802D4C04 240400FF */ addiu $a0, $zero, 0xff -/* F95B8 802D4C08 14440003 */ bne $v0, $a0, .L802D4C18 -/* F95BC 802D4C0C 2442000A */ addiu $v0, $v0, 0xa -/* F95C0 802D4C10 080B5310 */ j .L802D4C40 -/* F95C4 802D4C14 24020002 */ addiu $v0, $zero, 2 -.L802D4C18: -/* F95C8 802D4C18 AC620074 */ sw $v0, 0x74($v1) -/* F95CC 802D4C1C 28420100 */ slti $v0, $v0, 0x100 -/* F95D0 802D4C20 50400001 */ beql $v0, $zero, .L802D4C28 -/* F95D4 802D4C24 AC640074 */ sw $a0, 0x74($v1) -.L802D4C28: -/* F95D8 802D4C28 C4600074 */ lwc1 $f0, 0x74($v1) -/* F95DC 802D4C2C 46800020 */ cvt.s.w $f0, $f0 -/* F95E0 802D4C30 44050000 */ mfc1 $a1, $f0 -/* F95E4 802D4C34 0C04DF69 */ jal func_80137DA4 -/* F95E8 802D4C38 2404000A */ addiu $a0, $zero, 0xa -/* F95EC 802D4C3C 0000102D */ daddu $v0, $zero, $zero -.L802D4C40: -/* F95F0 802D4C40 8FBF0010 */ lw $ra, 0x10($sp) -/* F95F4 802D4C44 03E00008 */ jr $ra -/* F95F8 802D4C48 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_f8f60_len_1560/func_802D4C4C.s b/asm/nonmatchings/code_f8f60_len_1560/func_802D4C4C.s deleted file mode 100644 index e141272ddb..0000000000 --- a/asm/nonmatchings/code_f8f60_len_1560/func_802D4C4C.s +++ /dev/null @@ -1,38 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_802D4C4C -/* F95FC 802D4C4C 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* F9600 802D4C50 AFBF0010 */ sw $ra, 0x10($sp) -/* F9604 802D4C54 10A00004 */ beqz $a1, .L802D4C68 -/* F9608 802D4C58 0080182D */ daddu $v1, $a0, $zero -/* F960C 802D4C5C 240200FF */ addiu $v0, $zero, 0xff -/* F9610 802D4C60 AC600070 */ sw $zero, 0x70($v1) -/* F9614 802D4C64 AC620074 */ sw $v0, 0x74($v1) -.L802D4C68: -/* F9618 802D4C68 8C620070 */ lw $v0, 0x70($v1) -/* F961C 802D4C6C 14400012 */ bnez $v0, .L802D4CB8 -/* F9620 802D4C70 0000102D */ daddu $v0, $zero, $zero -/* F9624 802D4C74 8C620074 */ lw $v0, 0x74($v1) -/* F9628 802D4C78 14400006 */ bnez $v0, .L802D4C94 -/* F962C 802D4C7C 2442FFF6 */ addiu $v0, $v0, -0xa -/* F9630 802D4C80 3C05BF80 */ lui $a1, 0xbf80 -/* F9634 802D4C84 0C04DF69 */ jal func_80137DA4 -/* F9638 802D4C88 240400FF */ addiu $a0, $zero, 0xff -/* F963C 802D4C8C 080B532E */ j .L802D4CB8 -/* F9640 802D4C90 24020002 */ addiu $v0, $zero, 2 -.L802D4C94: -/* F9644 802D4C94 04410002 */ bgez $v0, .L802D4CA0 -/* F9648 802D4C98 AC620074 */ sw $v0, 0x74($v1) -/* F964C 802D4C9C AC600074 */ sw $zero, 0x74($v1) -.L802D4CA0: -/* F9650 802D4CA0 C4600074 */ lwc1 $f0, 0x74($v1) -/* F9654 802D4CA4 46800020 */ cvt.s.w $f0, $f0 -/* F9658 802D4CA8 44050000 */ mfc1 $a1, $f0 -/* F965C 802D4CAC 0C04DF69 */ jal func_80137DA4 -/* F9660 802D4CB0 2404000A */ addiu $a0, $zero, 0xa -/* F9664 802D4CB4 0000102D */ daddu $v0, $zero, $zero -.L802D4CB8: -/* F9668 802D4CB8 8FBF0010 */ lw $ra, 0x10($sp) -/* F966C 802D4CBC 03E00008 */ jr $ra -/* F9670 802D4CC0 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/format.sh b/format.sh index 4e464c9780..16adddc764 100755 --- a/format.sh +++ b/format.sh @@ -33,4 +33,7 @@ astyle ${FILES} \ find ${FILES} -exec sed -i -e '$a\' {} \; # lint -clang-tidy -p . ${FILES} -- ${COMPILER_OPTS} +C_FILES=$(echo "$FILES" | grep '\.c$') +if [[ ! -z $C_FILES ]]; then + clang-tidy -p . ${C_FILES} -- ${COMPILER_OPTS} +fi diff --git a/include/common_structs.h b/include/common_structs.h index 9d89f0d271..90a8052da6 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -1,6 +1,7 @@ #ifndef _COMMON_STRUCTS_H_ #define _COMMON_STRUCTS_H_ +#include "macros.h" #include "ultra64.h" #include "types.h" #include "si.h" @@ -260,9 +261,9 @@ typedef struct ScriptInstance { /* 0x007 */ s8 switchDepth; /* how many nested switches we are in, max = 8 */ /* 0x008 */ Bytecode* ptrNextLine; /* 0x00C */ Bytecode* ptrReadPos; - /* 0x010 */ s32 labelIndices[4]; + /* 0x010 */ s8 labelIndices[16]; /* 0x020 */ UNK_PTR labelPositions[16]; - /* 0x060 */ s32 deleted; /* set to zero in KillScript when malloc'd */ + /* 0x060 */ UNK_PTR unk_60; /* unknown pointer; allocated on the heap, free'd in kill_script() */ /* 0x064 */ struct ScriptInstance* blockingParent; /* parent? */ /* 0x068 */ struct ScriptInstance* childScript; /* 0x06C */ struct ScriptInstance* parentScript; /* brother? */ @@ -288,6 +289,8 @@ typedef struct ScriptInstance { /* 0x164 */ Bytecode* ptrCurrentLine; } ScriptInstance; // size = 0x168 +typedef ScriptInstance* ScriptList[MAX_SCRIPTS]; + typedef struct Entity { /* 0x00 */ s32 flags; /* 0x04 */ char unk_04[2]; @@ -1407,9 +1410,10 @@ typedef struct PlayerStatus { /* 0x0B8 */ s32 anim; /* 0x0BC */ char unk_BC[2]; /* 0x0BE */ u8 renderMode; - /* 0x0BF */ char unk_BF; + /* 0x0BF */ s8 unk_BF; /* 0x0C0 */ u32* decorationList; - /* 0x0C4 */ char unk_C4[8]; + /* 0x0C4 */ char unk_C4[4]; + /* 0x0C8 */ UNK_PTR unk_C8; /* 0x0CC */ s32 shadowID; /* 0x0D0 */ char unk_D0[8]; /* 0x0D8 */ UNK_PTR** unk_D8; diff --git a/include/functions.h b/include/functions.h index 61f4b4779d..31ba98407f 100644 --- a/include/functions.h +++ b/include/functions.h @@ -45,6 +45,7 @@ f32 set_float_variable(ScriptInstance* script, Bytecode var, f32 value); void set_script_timescale(ScriptInstance* script, f32 timescale); f32 sin_deg(f32 x); f32 cos_deg(f32 x); +s16 round(f32); f32 atan2(f32 startX, f32 startZ, f32 endX, f32 endZ); f32 clamp_angle(f32 theta); s32 func_80055448(s32); @@ -56,8 +57,8 @@ s32 osGetId(); s32 func_800EF394(f32); s32 does_script_exist(s32 id); -ScriptInstance* start_script(Bytecode* script, s32 priority, s32 flags); -ScriptInstance* start_script_in_group(ScriptInstance* script, s32 priority, s32 flags, s32 groups); +ScriptInstance* start_script(Bytecode* initialLine, s32 priority, s32 initialState); +ScriptInstance* start_script_in_group(Bytecode* initialLine, u8 priority, s32 initialState, u8 groupFlags); void func_8011B7C0(u16, s32, s32); void func_80137D88(s32, f32); @@ -91,4 +92,7 @@ s32 set_music_track(s32 musicPlayer, s32 songID, s32 variation, s32 unk, s32 vol ScriptInstance* get_script_by_index(s32 index); +void suspend_all_group(s32 groupFlags); +void kill_script(ScriptInstance* instanceToKill); + #endif diff --git a/include/macros.h b/include/macros.h index 79b7384cb4..43e52c1882 100644 --- a/include/macros.h +++ b/include/macros.h @@ -1,6 +1,8 @@ #ifndef _MACROS_H_ #define _MACROS_H_ +#include "common.h" + #ifndef SPLAT #define INCLUDE_ASM(TYPE, FOLDER, NAME, ARGS...) \ TYPE __attribute__((naked)) NAME(ARGS) { __asm__( ".include \"include/macro.inc\"\n.include \"asm/nonmatchings/"FOLDER"/"#NAME".s\"\n.set reorder\n.set at"); } @@ -16,6 +18,31 @@ #define GAME_STATUS (*gGameStatusPtr) +#define MAX_MAPVARS 16 +#define MAX_MAPFLAGS 3 + +#define MAX_SCRIPTS 128 + +//NOTE: SCRIPT_ALLOC is probably not quite correct, but this is the closest thing to matching for the functions its used in. Needs more work. +#define SCRIPT_ALLOC(new, index) \ +{ \ + ScriptList** temp = &gCurrentScriptListPtr; \ + s32 *numScripts = &gNumScripts; \ + new = heap_malloc(sizeof(ScriptInstance)); \ + (**temp)[index] = new; \ + (*numScripts)++; \ + ASSERT(new != NULL); \ +} + +#define SCRIPT_FREE(index) \ +{ \ + ScriptList** temp = &gCurrentScriptListPtr; \ + s32 *numScripts = &gNumScripts; \ + heap_free((**temp)[index]); \ + (**temp)[index] = NULL; \ + (*numScripts)--; \ +} + #define SQ(x) (x*x) #endif diff --git a/include/variables.h b/include/variables.h index 92544ee41c..15b078815c 100644 --- a/include/variables.h +++ b/include/variables.h @@ -4,6 +4,7 @@ #include "ultra64.h" #include "common_structs.h" #include "types.h" +#include "macros.h" #include "enums.h" extern UiStatus gUIStatus; @@ -21,14 +22,17 @@ extern UNK_FUN_PTR(gCurrentUpdateFunction); extern BattleStatus gBattleStatus; -extern ScriptInstance* gWorldScriptList[128]; -extern ScriptInstance* gBattleScriptList[128]; -extern ScriptInstance** gCurrentScriptListPtr[128]; +extern ScriptList gWorldScriptList; +extern ScriptList gBattleScriptList; +extern ScriptList* gCurrentScriptListPtr; + +extern s32 gNumScripts; +extern s32 D_802DAC98; extern s32 gScriptListCount; -extern s32 gScriptIdList[128]; -extern s32 gScriptIndexList[128]; +extern s32 gScriptIdList[MAX_SCRIPTS]; +extern s32 gScriptIndexList[MAX_SCRIPTS]; extern Model* gWorldModelList[256]; extern Model* gBattleModelList[256]; @@ -58,8 +62,6 @@ extern Shadow** gCurrentShadowListPtr[60]; extern Camera gCameras[4]; extern s32 gCurrentCameraID; -extern f32 gGlobalTimeSpace; - extern Npc* gPlayerNpcPtr; extern s8 D_800A0900; @@ -76,7 +78,6 @@ extern s32 D_801595A0; extern s16 D_80159AE2; extern s16 D_80159AE4; extern BackgroundHeader gBackgroundImage; -extern s8 D_8014F12F; extern PrintContext* gCurrentPrintContext; extern s32 D_802DB264; diff --git a/papermario.ld b/papermario.ld index 89f062e225..0681454aaa 100644 --- a/papermario.ld +++ b/papermario.ld @@ -214,7 +214,7 @@ SECTIONS build/bin/code_E5830.o(.data); } - /* 0x802C3000 E79B0-FEE30 (len 17480) */ + /* 0x802C3000 E79B0-FE748 (len 16D98) */ .text_E79B0 0x802C3000 : AT(0xE79B0) { build/src/code_e79b0_len_1920.o(.text); build/src/code_e92d0_len_5da0.o(.text); @@ -226,7 +226,14 @@ SECTIONS build/src/code_f8f60_len_1560.o(.text); build/src/code_fa4c0_len_3bf0.o(.text); build/src/code_fe0b0_len_5a0.o(.text); - build/bin/code_FE650.o(.data); + build/src/code_e79b0_len_1920.o(.data); + build/bin/code_FE660.o(.data); + build/src/code_e79b0_len_1920.o(.rodata); + } + + /* 0x00000000 FE748-FEE30 [6E8] */ + .data_FE748 0xFE748 : AT(0xFE748) { + build/bin/FE748.o(.data); } /* 0x802DBD40 FEE30-102610 (len 37E0) */ diff --git a/src/code_42e0_len_1f60.c b/src/code_42e0_len_1f60.c index 4970ab5780..225cf65921 100644 --- a/src/code_42e0_len_1f60.c +++ b/src/code_42e0_len_1f60.c @@ -88,7 +88,7 @@ f32 signF(f32 val) { return sign; } -INCLUDE_ASM(s32, "code_42e0_len_1f60", round); +INCLUDE_ASM(s16, "code_42e0_len_1f60", round, f32 arg0); INCLUDE_ASM(f32, "code_42e0_len_1f60", clamp_angle, f32 theta); diff --git a/src/code_dc470_len_14c0.c b/src/code_dc470_len_14c0.c index c561cd055b..d6feef829d 100644 --- a/src/code_dc470_len_14c0.c +++ b/src/code_dc470_len_14c0.c @@ -15,7 +15,6 @@ void load_map_bg(char* optAssetName) { // StoryProgress check if (get_variable(0, 0xF5DE0180) >= 0x35) { // Use sunny Flower Fields bg rather than cloudy - // TODO: these globals should be string literals if (!strcmp(assetName, gCloudyFlowerFieldsBg)) { assetName = gSunnyFlowerFieldsBg; } @@ -60,7 +59,7 @@ void set_background_size(s16 startX, s16 startY, s16 sizeX, s16 sizeY) { u16 func_80145E98(s32 arg0, s32 arg1, s32 arg2) { s32 temp_lo; - temp_lo = (arg1 - (u16)(arg0)) * arg2; + temp_lo = (arg1 - (u16)arg0) * arg2; if (temp_lo < 0) { temp_lo = temp_lo + 0xFF; } @@ -70,6 +69,10 @@ u16 func_80145E98(s32 arg0, s32 arg1, s32 arg2) { INCLUDE_ASM(s32, "code_dc470_len_14c0", func_80145EC0); -INCLUDE_ASM(s32, "code_dc470_len_14c0", func_8014720C); +void func_8014720C(void) { + D_8014F12F = 1; +} -INCLUDE_ASM(s32, "code_dc470_len_14c0", func_8014721C); +void func_8014721C(void) { + D_8014F12F = 0; +} diff --git a/src/code_dd930_len_1c0.c b/src/code_dd930_len_1c0.c index a7f425eb0a..ffbda92f3d 100644 --- a/src/code_dd930_len_1c0.c +++ b/src/code_dd930_len_1c0.c @@ -1,11 +1,12 @@ #include "common.h" +// TODO: most likely part of the MusicPlayer struct typedef struct { - s16 unk0; - s16 unk2; - s32 unk4; - s32 unk8; - s32 unkC; + /* 0x0 */ s16 fadeFlags; + /* 0x2 */ s16 fadeState; + /* 0x4 */ s32 fadeOutTime; + /* 0x8 */ s32 fadeInTime; + /* 0xC */ s32 unkC; } struct_80147230; extern struct_80147230 D_8014F140; @@ -18,58 +19,59 @@ void func_80147230(void) { void func_80147264(void) { struct_80147230* temp = &D_8015C7C0; - switch (temp->unk2) { - case 0: + switch (temp->fadeState) { + case 0: // idle break; - case 1: - if (temp->unk0 & 1) { + case 1: // fading out + if (temp->fadeFlags & 1) { s32 phi_v0; - if (temp->unk4 < 0xFA) { - phi_v0 = func_800554A4(0, temp->unk4); + if (temp->fadeOutTime < 0xFA) { + phi_v0 = func_800554A4(0, temp->fadeOutTime); } else { - phi_v0 = func_800554E8(0, temp->unk4); + phi_v0 = func_800554E8(0, temp->fadeOutTime); } + if (phi_v0 != 0) { return; } } - temp->unk2 = 2; + temp->fadeState = 2; break; - case 2: - if (temp->unk0 & 1) { + case 2: // fading in + if (temp->fadeFlags & 1) { if (func_800555E4(0) != 0) { return; } - temp->unk0 &= ~1; + temp->fadeFlags &= ~1; } - if (temp->unk8 < 0) { - temp->unk2 = 0; - } else if (func_80055448(temp->unk8) == 0) { + if (temp->fadeInTime < 0) { + temp->fadeState = 0; + } else if (func_80055448(temp->fadeInTime) == 0) { if (func_80055464(0, 0) == 0) { - temp->unk2 = 0; - temp->unk0 |= 1; + temp->fadeState = 0; + temp->fadeFlags |= 1; } } break; } } -s32 play_ambient_sounds(s32 arg0, s32 arg1) { +s32 play_ambient_sounds(s32 fadeInTime, s32 fadeOutTime) { struct_80147230* temp1 = &D_8015C7C0; struct_80147230* temp2 = &D_8015C7C0; if (!GAME_STATUS->musicEnabled) { - func_800554A4(temp1->unk8, arg1); - temp1->unk0 &= ~1; + func_800554A4(temp1->fadeInTime, fadeOutTime); + temp1->fadeFlags &= ~1; return 1; } - if (temp1->unk8 == arg0) { + if (temp1->fadeInTime == fadeInTime) { return 2; } - temp2->unk8 = arg0; - temp2->unk4 = arg1; - temp2->unk2 = 1; + temp2->fadeInTime = fadeInTime; + temp2->fadeOutTime = fadeOutTime; + temp2->fadeState = 1; return 1; } diff --git a/src/code_ddaf0_len_c50.c b/src/code_ddaf0_len_c50.c index ec27285311..dee04850a4 100644 --- a/src/code_ddaf0_len_c50.c +++ b/src/code_ddaf0_len_c50.c @@ -1,6 +1,24 @@ #include "common.h" -INCLUDE_ASM(s32, "code_ddaf0_len_c50", func_801473F0); +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x04 */ s32 unk_04; + /* 0x08 */ s32 unk_08; + /* 0x0C */ char unk_01[0x10]; + /* 0x1C */ u8 unk_1C; +} struct_80159D50; // size = 0x20 + +extern struct_80159D50 D_80159D50[0x40]; + +void func_801473F0(void) { + struct_80159D50* phi_v1 = &D_80159D50; + s32 i; + + for (i = 0; i < 0x40; i++) { + phi_v1->unk_00 = 0; + phi_v1++; + } +} INCLUDE_ASM(s32, "code_ddaf0_len_c50", func_80147414); diff --git a/src/code_e0b30_len_b80.c b/src/code_e0b30_len_b80.c index e527d33aae..40acc5fde5 100644 --- a/src/code_e0b30_len_b80.c +++ b/src/code_e0b30_len_b80.c @@ -48,4 +48,5 @@ INCLUDE_ASM(s32, "code_e0b30_len_b80", func_8014AEF8); INCLUDE_ASM(s32, "code_e0b30_len_b80", func_8014AF8C); -INCLUDE_ASM(s32, "code_e0b30_len_b80", func_8014AFA0); +void func_8014AFA0(void) { +} diff --git a/src/code_e79b0_len_1920.c b/src/code_e79b0_len_1920.c index 61102eb221..3ef4d877bd 100644 --- a/src/code_e79b0_len_1920.c +++ b/src/code_e79b0_len_1920.c @@ -1,25 +1,420 @@ #include "common.h" +s32 gStaticScriptCounter = 1; +s32 D_802D9CA4 = 0; +f32 gGlobalTimeSpace = 1.0f; + +#ifdef NON_MATCHING +// regalloc issues. +void sort_scripts(void) { + s32 temp_a0; + s32 temp_a1; + s32 tempID; + ScriptInstance* curScript; + ScriptList** currentScriptListPtr; + s32 i; + s32 j; + s32 numValidScripts = 0; + s32* scriptIndexList = gScriptIndexList; + s32* scriptIdList = gScriptIdList; + + for (i = 0; i < MAX_SCRIPTS; i++) { + curScript = (*gCurrentScriptListPtr)[i]; + if (curScript != NULL) { + if (curScript->state != 0) { + scriptIndexList[numValidScripts] = i; + scriptIdList[numValidScripts] = curScript->uniqueID; + numValidScripts++; + } + } + } + + gScriptListCount = numValidScripts; + j = numValidScripts; + for (i = 0; i < (j - 1); i++) { + currentScriptListPtr = &gCurrentScriptListPtr; + scriptIdList = gScriptIdList; + scriptIndexList = gScriptIndexList; + for (j = i + 1; j < numValidScripts; j++) { + temp_a1 = scriptIndexList[i]; + temp_a0 = scriptIndexList[j]; + if ((**currentScriptListPtr)[temp_a1]->priority > (**currentScriptListPtr)[temp_a0]->priority) { + scriptIndexList[i] = temp_a0; + scriptIndexList[j] = temp_a1; + tempID = scriptIdList[i]; + scriptIdList[i] = scriptIdList[j]; + scriptIdList[j] = tempID; + } + } + } +} +#else INCLUDE_ASM(s32, "code_e79b0_len_1920", sort_scripts); +#endif -INCLUDE_ASM(s32, "code_e79b0_len_1920", find_script_labels); +#ifdef NON_MATCHING +// Very close. Reordering/branch likely issues +void find_script_labels(ScriptInstance* script) { + Bytecode* curLine; + s32 type; + s32 label; + s32 numArgs; + s32 i; + s32 j; -INCLUDE_ASM(s32, "code_e79b0_len_1920", clear_script_list); + for (i = 0; i < ARRAY_COUNT(script->labelIndices); i++) { + script->labelIndices[i] = -1; + script->labelPositions[i] = 0; + } -INCLUDE_ASM(s32, "code_e79b0_len_1920", init_script_list); + j = 0; + curLine = script->ptrNextLine; + for (j = 0; j < ARRAY_COUNT(script->labelIndices); j++) { + type = *curLine++; + numArgs = *curLine++; + label = *curLine; + curLine += numArgs; -INCLUDE_ASM(s32, "code_e79b0_len_1920", func_802C3390); + if (type == 1) { + return; + } -INCLUDE_ASM(ScriptInstance*, "code_e79b0_len_1920", start_script, Bytecode* script, s32 priority, s32 flags); + if (type == 3) { + script->labelIndices[j] = label; + script->labelPositions[j] = curLine; + } + } + PANIC(); +} +#else +INCLUDE_ASM(void, "code_e79b0_len_1920", find_script_labels); +#endif -INCLUDE_ASM(ScriptInstance*, "code_e79b0_len_1920", start_script_in_group, ScriptInstance* script, s32 priority, - s32 flags, s32 groups); +void clear_script_list(void) { + s32 i; + + if (GAME_STATUS->isBattle == 0) { + gCurrentScriptListPtr = &gWorldScriptList; + gMapVars = gWorldMapVars; + gMapFlags = gWorldMapFlags; + } else { + gCurrentScriptListPtr = &gBattleScriptList; + gMapVars = gBattleMapVars; + gMapFlags = gBattleMapFlags; + } + + for (i = 0; i < MAX_SCRIPTS; i++) { + (*gCurrentScriptListPtr)[i] = NULL; + } + + gNumScripts = 0; + gScriptListCount = 0; + D_802D9CA4 = 0; + + for (i = 0; i < MAX_MAPVARS; i++) { + gMapVars[i] = 0; + } + + for (i = 0; i < MAX_MAPFLAGS; i++) { + gMapFlags[i] = 0; + } + + func_802D4488(); + func_802CD4B4(); +} + +void init_script_list(void) { + + if (GAME_STATUS->isBattle == 0) { + gCurrentScriptListPtr = &gWorldScriptList; + gMapVars = gWorldMapVars; + gMapFlags = gWorldMapFlags; + } else { + gCurrentScriptListPtr = &gBattleScriptList; + gMapVars = gBattleMapVars; + gMapFlags = gBattleMapFlags; + } + + gNumScripts = 0; + D_802D9CA4 = 0; + + func_802D4560(); + func_802CD57C(); +} + +void func_802C3390(ScriptInstance* script) { + s32 arg; + + switch (D_8009A5D8) { + default: + case 0: + case 4: + return; + case 1: + arg = 1; + break; + case 2: + case 3: + arg = 2; + break; + } + suspend_all_group(arg); +} + +#ifdef NON_MATCHING +ScriptInstance* start_script(Bytecode* initialLine, s32 priority, s32 initialState) { + ScriptInstance* newScript; + s32 curScriptIndex; + s32 scriptListCount; + s32 i; + + for (i = 0; i < MAX_SCRIPTS; i++) { + if ((*gCurrentScriptListPtr)[i] == NULL) { + break; + } + } + + ASSERT(i < MAX_SCRIPTS); + curScriptIndex = i; + + SCRIPT_ALLOC(newScript, curScriptIndex); + + newScript->state = initialState | 1; + newScript->currentOpcode = 0; + newScript->priority = priority; + newScript->ptrNextLine = initialLine; + newScript->ptrFirstLine = initialLine; + newScript->ptrCurrentLine = initialLine; + newScript->unk_60 = NULL; + newScript->blockingParent = NULL; + newScript->childScript = NULL; + newScript->parentScript = NULL; + newScript->uniqueID = gStaticScriptCounter++; + newScript->ownerActorID = -1; + newScript->ownerID = -1; + newScript->loopDepth = -1; + newScript->switchDepth = -1; + newScript->groupFlags = ~0x10; + newScript->ptrSavedPosition = NULL; + newScript->frameCounter = 0.0f; + newScript->unk_158 = 0; + newScript->timeScale = gGlobalTimeSpace; + + scriptListCount = 0; + + for (i = 0; i < 16; i++) { + newScript->varTable[i] = 0; + } + + for (i = 0; i < 3; i++) { + newScript->varFlags[i] = 0; + } + + find_script_labels(newScript); + + if ((D_802D9CA4 != 0) && ((newScript->state & 0x20) != 0)) { + scriptListCount = gScriptListCount++; + gScriptIndexList[scriptListCount] = curScriptIndex; + gScriptIdList[scriptListCount] = newScript->uniqueID; + } + func_802C3390(newScript); + { + s32* tempCounter = &gStaticScriptCounter; + if (*tempCounter == 0) { + *tempCounter = 1; + } + } + return newScript; +} +#else +INCLUDE_ASM(ScriptInstance*, "code_e79b0_len_1920", start_script, Bytecode* initialLine, s32 priority, + s32 initialState); +#endif + +#ifdef NON_MATCHING +ScriptInstance* start_script_in_group(Bytecode* initialLine, u8 priority, s32 initialState, u8 groupFlags) { + ScriptInstance* newScript; + s32 scriptListCount; + s32 i; + s32 curScriptIndex; + s32* tempCounter = &gStaticScriptCounter; + + for (i = 0; i < MAX_SCRIPTS; i++) { + if ((*gCurrentScriptListPtr)[i] == NULL) { + break; + } + } + + ASSERT(i < MAX_SCRIPTS); + curScriptIndex = i; + + SCRIPT_ALLOC(newScript, curScriptIndex); + + newScript->state = (initialState | 1); + newScript->ptrNextLine = initialLine; + newScript->ptrFirstLine = initialLine; + newScript->ptrCurrentLine = initialLine; + newScript->currentOpcode = 0; + newScript->priority = priority; + newScript->unk_60 = NULL; + newScript->blockingParent = NULL; + newScript->childScript = NULL; + newScript->parentScript = NULL; + newScript->uniqueID = gStaticScriptCounter++; + newScript->ownerActorID = -1; + newScript->ownerID = -1; + newScript->loopDepth = -1; + newScript->switchDepth = -1; + newScript->groupFlags = groupFlags; + newScript->ptrSavedPosition = NULL; + newScript->frameCounter = 0.0f; + newScript->unk_158 = 0; + newScript->timeScale = gGlobalTimeSpace; + + scriptListCount = 0; + + for (i = 0; i < 16; i++) { + newScript->varTable[i] = 0; + } + + for (i = 0; i < 3; i++) { + newScript->varFlags[i] = 0; + } + + find_script_labels(newScript); + + if ((D_802D9CA4 != 0) && ((newScript->state & 0x20) != 0)) { + scriptListCount = gScriptListCount++; + gScriptIndexList[scriptListCount] = curScriptIndex; + gScriptIdList[scriptListCount] = newScript->uniqueID; + } + + func_802C3390(newScript); + if (*tempCounter == 0) { + *tempCounter = 1; + } +} + +return newScript; +} +#else +INCLUDE_ASM(ScriptInstance*, "code_e79b0_len_1920", start_script_in_group, Bytecode* initialLine, u8 priority, + s32 initialState, u8 groupFlags); +#endif INCLUDE_ASM(s32, "code_e79b0_len_1920", start_child_script); -INCLUDE_ASM(s32, "code_e79b0_len_1920", func_802C39F8); +#ifdef NON_MATCHING +// appears to be functionally equivalent, some ordering and regalloc issues +ScriptInstance* func_802C39F8(ScriptInstance* parentScript, Bytecode* nextLine, s32 newState) { + ScriptInstance* child; + s32* temp6; + s32 curScriptIndex; + s32 i; + s32 scriptListCount; -INCLUDE_ASM(s32, "code_e79b0_len_1920", func_802C3C10); + for (i = 0; i < MAX_SCRIPTS; i++) { + if ((*gCurrentScriptListPtr)[i] == NULL) { + break; + } + } + + ASSERT(i < MAX_SCRIPTS); + curScriptIndex = i; + SCRIPT_ALLOC(child, curScriptIndex); + + child->state = newState | 1; + child->ptrNextLine = nextLine; + child->ptrFirstLine = nextLine; + child->ptrCurrentLine = nextLine; + child->currentOpcode = 0; + child->unk_60 = NULL; + child->blockingParent = NULL; + child->parentScript = parentScript; + child->childScript = NULL; + child->priority = parentScript->priority; + child->uniqueID = gStaticScriptCounter++; + child->ownerActorID = parentScript->ownerActorID; + child->ownerID = parentScript->ownerID; + child->loopDepth = -1; + child->switchDepth = -1; + child->groupFlags = parentScript->groupFlags; + child->ptrSavedPosition = NULL; + child->array = parentScript->array; + child->flagArray = parentScript->flagArray; + child->timeScale = gGlobalTimeSpace; + child->frameCounter = 0.0f; + child->unk_158 = 0; + + scriptListCount = 0; + + for (i = 0; i < ARRAY_COUNT(child->varTable); i++) { + child->varTable[i] = parentScript->varTable[i]; + } + + for (i = 0; i < ARRAY_COUNT(child->varFlags); i++) { + child->varFlags[i] = parentScript->varFlags[i]; + } + + find_script_labels(child); + if (D_802D9CA4 != 0) { + scriptListCount = gScriptListCount++; + gScriptIndexList[scriptListCount] = curScriptIndex; + gScriptIdList[scriptListCount] = child->uniqueID; + } + + temp6 = &gStaticScriptCounter; + if (*temp6 == 0) { + *temp6 = 1; + } + func_802C3390(child); + return child; +} +#else +INCLUDE_ASM(ScriptInstance*, "code_e79b0_len_1920", func_802C39F8, ScriptInstance* parentScript, Bytecode* nextLine, + s32 newState); +#endif + +ScriptInstance* func_802C3C10(ScriptInstance* script, Bytecode* line, s32 arg2) { + ScriptInstance* curScript; + s32 i; + + script->ptrNextLine = line; + script->ptrFirstLine = line; + script->ptrCurrentLine = line; + script->currentOpcode = 0; + script->frameCounter = 0; + script->state |= arg2; + script->timeScale = 1.0f; + + if (script->unk_60 != NULL) { + heap_free(script->unk_60); + script->unk_60 = NULL; + } + + if (script->childScript != 0) { + kill_script(script->childScript); + } + + for (i = 0; i < MAX_SCRIPTS; i++) { + curScript = (*gCurrentScriptListPtr)[i]; + if ((curScript != 0) && (curScript->parentScript == script)) { + kill_script(curScript); + } + } + script->loopDepth = -1; + script->switchDepth = -1; + script->blockingParent = NULL; + script->parentScript = NULL; + script->childScript = NULL; + script->frameCounter = 0.0f; + script->unk_158 = 0; + script->timeScale = gGlobalTimeSpace; + find_script_labels(script); + func_802C3390(script); + + return script; +} ScriptInstance* restart_script(ScriptInstance* script) { Bytecode* ptrFirstLine = script->ptrFirstLine; @@ -29,17 +424,16 @@ ScriptInstance* restart_script(ScriptInstance* script) { script->switchDepth = -1; script->frameCounter = 0; script->currentOpcode = 0; - script->frameCounter = 0; - script->unk_158 = 0; script->ptrNextLine = ptrFirstLine; script->ptrCurrentLine = ptrFirstLine; - - // ??? script->timeScale = 1.0f; + script->frameCounter = 0; + script->unk_158 = 0; + script->timeScale = gGlobalTimeSpace; - find_script_labels(); + find_script_labels(script); func_802C3390(script); return script; @@ -47,15 +441,66 @@ ScriptInstance* restart_script(ScriptInstance* script) { INCLUDE_ASM(s32, "code_e79b0_len_1920", update_scripts); +// this function is evil. INCLUDE_ASM(s32, "code_e79b0_len_1920", func_802C3EE4); -INCLUDE_ASM(s32, "code_e79b0_len_1920", kill_script); +void kill_script(ScriptInstance* instanceToKill) { + ScriptInstance* childScript; + ScriptInstance* blockingParent; + s32 j; + s32 i; + + for (i = 0; i < MAX_SCRIPTS; i++) { + if ((*gCurrentScriptListPtr)[i] == instanceToKill) { + break; + } + } + + if (i >= MAX_SCRIPTS) { + return; + } + + childScript = instanceToKill->childScript; + if (childScript != NULL) { + kill_script(childScript); + } + + for (j = 0; j < MAX_SCRIPTS; j++) { + ScriptInstance* tempScriptInstance = (*gCurrentScriptListPtr)[j]; + if (tempScriptInstance != NULL) { + if (tempScriptInstance->parentScript == instanceToKill) { + kill_script(tempScriptInstance); + } + } + } + + blockingParent = instanceToKill->blockingParent; + if (blockingParent != NULL) { + blockingParent->childScript = NULL; + blockingParent->state &= ~0x10; + + for (j = 0; j < ARRAY_COUNT(blockingParent->varTable); j++) { + blockingParent->varTable[j] = instanceToKill->varTable[j]; + } + + for (j = 0; j < ARRAY_COUNT(blockingParent->varFlags); j++) { + blockingParent->varFlags[j] = instanceToKill->varFlags[j]; + } + } + + if (instanceToKill->unk_60 != NULL) { + heap_free(instanceToKill->unk_60); + instanceToKill->unk_60 = NULL; + } + + SCRIPT_FREE(i); +} void kill_script_by_ID(s32 id) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { kill_script(scriptContextPtr); @@ -63,11 +508,12 @@ void kill_script_by_ID(s32 id) { } } + void kill_all_scripts(void) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL) { kill_script(scriptContextPtr); @@ -79,7 +525,7 @@ s32 does_script_exist(s32 id) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { return 1; @@ -91,7 +537,7 @@ s32 does_script_exist(s32 id) { s32 does_script_exist_by_ref(ScriptInstance* script) { s32 i; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { if (script == (*gCurrentScriptListPtr)[i]) { return 1; } @@ -107,23 +553,13 @@ void set_script_timescale(ScriptInstance* script, f32 timescale) { script->timeScale = timescale * gGlobalTimeSpace; } -#ifdef NON_MATCHING -// TODO: figure out why compiler/assembler isn't putting SWC1 in delay slot void set_global_timespace(f32 timeScale) { gGlobalTimeSpace = timeScale; } -#else -INCLUDE_ASM(s32, "code_e79b0_len_1920", set_global_timespace); -#endif -#ifdef NON_MATCHING -// TODO: figure out why compiler/assembler isn't putting LWC1 in delay slot f32 get_global_timespace(void) { return gGlobalTimeSpace; } -#else -INCLUDE_ASM(s32, "code_e79b0_len_1920", get_global_timespace); -#endif void set_script_group(ScriptInstance* script, s8 groupFlags) { script->groupFlags = groupFlags; @@ -163,7 +599,7 @@ void suspend_group_script(ScriptInstance* script, s32 groupFlags) { suspend_group_script(childScript, groupFlags); } - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->parentScript == script) { suspend_group_script(scriptContextPtr, groupFlags); @@ -184,7 +620,7 @@ void resume_group_script(ScriptInstance* script, s32 groupFlags) { resume_group_script(childScript, groupFlags); } - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->parentScript == script) { suspend_group_script(scriptContextPtr, groupFlags); @@ -200,7 +636,7 @@ s32 suspend_all_script(s32 id) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { suspend_group_script(scriptContextPtr, 0xEF); @@ -212,7 +648,7 @@ s32 resume_all_script(s32 id) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { resume_group_script(scriptContextPtr, 0xEF); @@ -224,7 +660,7 @@ void suspend_group_script_index(s32 id, s32 groupFlags) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { suspend_group_script(scriptContextPtr, groupFlags); @@ -236,7 +672,7 @@ void resume_group_script_index(s32 id, s32 groupFlags) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) { resume_group_script(scriptContextPtr, groupFlags); @@ -244,11 +680,11 @@ void resume_group_script_index(s32 id, s32 groupFlags) { } } -s32 suspend_all_group(s32 groupFlags) { +void suspend_all_group(s32 groupFlags) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL) { suspend_group_script(scriptContextPtr, groupFlags); @@ -260,7 +696,7 @@ s32 resume_all_group(s32 groupFlags) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL) { resume_group_script(scriptContextPtr, groupFlags); @@ -272,7 +708,7 @@ void suspend_group_others(ScriptInstance* script, s32 groupFlags) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr != script) { suspend_group_script(scriptContextPtr, groupFlags); @@ -284,7 +720,7 @@ void resume_group_others(ScriptInstance* script, s32 groupFlags) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr != script) { resume_group_script(scriptContextPtr, groupFlags); @@ -300,7 +736,7 @@ ScriptInstance* get_script_by_id(s32 id) { s32 i; ScriptInstance* scriptContextPtr; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { if ((*gCurrentScriptListPtr)[i] != NULL) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr->uniqueID == id) { @@ -321,7 +757,7 @@ void set_script_flags(ScriptInstance* script, s32 flags) { set_script_flags(childScript, flags); } - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->parentScript == script) { set_script_flags(script->parentScript, flags); @@ -329,7 +765,6 @@ void set_script_flags(ScriptInstance* script, s32 flags) { } } - void clear_script_flags(ScriptInstance* script, s32 flags) { int i; ScriptInstance* scriptContextPtr; @@ -340,7 +775,7 @@ void clear_script_flags(ScriptInstance* script, s32 flags) { clear_script_flags(childScript, flags); } - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { scriptContextPtr = (*gCurrentScriptListPtr)[i]; if (scriptContextPtr != NULL && scriptContextPtr->parentScript == script) { clear_script_flags(scriptContextPtr, flags); diff --git a/src/code_e92d0_len_5da0.c b/src/code_e92d0_len_5da0.c index 0311bafe06..b045b51f6a 100644 --- a/src/code_e92d0_len_5da0.c +++ b/src/code_e92d0_len_5da0.c @@ -1103,12 +1103,11 @@ ApiStatus func_802C73B0(ScriptInstance* script) { s32 func_802C73B8(ScriptInstance* script) { s32 i; - for (i = 0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) { + for (i = 0; i < MAX_SCRIPTS; i++) { if (script == get_script_by_index(i)) { break; } } - return 1; } diff --git a/src/code_ef070_len_3400.c b/src/code_ef070_len_3400.c index 4d0a507eae..54258a89f6 100644 --- a/src/code_ef070_len_3400.c +++ b/src/code_ef070_len_3400.c @@ -67,22 +67,17 @@ ApiStatus func_802CA988(ScriptInstance* script, s32 isInitialCall) { Bytecode outVar3 = *ptrReadPos++; Bytecode outVar4 = *ptrReadPos++; f32 temp1, temp2, temp3; - f32 tempSqrt; (&gCameras[id])->mode = 2; - (&gCameras[id])->unk_1C = -1 * round((&gCameras[id])->currentPitch); - (&gCameras[id])->unk_1E = -1 * (&gCameras[id])->currentBlendedYawNegated; (&gCameras[id])->unk_06 = 0; + (&gCameras[id])->unk_1C = -round((&gCameras[id])->currentPitch); + (&gCameras[id])->unk_1E = -(&gCameras[id])->currentBlendedYawNegated; temp1 = (&gCameras[id])->lookAt_obj[0] - (&gCameras[id])->lookAt_eye[0]; temp2 = (&gCameras[id])->lookAt_obj[1] - (&gCameras[id])->lookAt_eye[1]; temp3 = (&gCameras[id])->lookAt_obj[2] - (&gCameras[id])->lookAt_eye[2]; - tempSqrt = sqrtf((temp1 * temp1) + (temp2 * temp2) + (temp3 * temp3)); - if (tempSqrt != tempSqrt) { - (&gCameras[id])->unk_20 = round(tempSqrt); - } - + (&gCameras[id])->unk_20 = round(sqrtf((temp1 * temp1) + (temp2 * temp2) + (temp3 * temp3))); (&gCameras[id])->unk_22 = 0; (&gCameras[id])->unk_54 = (&gCameras[id])->lookAt_obj[0]; (&gCameras[id])->unk_58 = (&gCameras[id])->lookAt_obj[1]; diff --git a/src/code_f8f60_len_1560.c b/src/code_f8f60_len_1560.c index f4f292c777..8672aede22 100644 --- a/src/code_f8f60_len_1560.c +++ b/src/code_f8f60_len_1560.c @@ -188,8 +188,6 @@ ApiStatus AddVectorPolar(ScriptInstance* script, s32 isInitialCall) { return ApiStatus_DONE2; } -INCLUDE_ASM(s32, "code_f8f60_len_1560", func_802D4BDC, ScriptInstance* script, s32 isInitialCall); -/* ApiStatus func_802D4BDC(ScriptInstance* script, s32 initialCall) { s32* t0 = &script->functionTemp[0]; s32* t1 = &script->functionTemp[1]; @@ -202,32 +200,55 @@ ApiStatus func_802D4BDC(ScriptInstance* script, s32 initialCall) { if (*t0 == 0) { t1v = *t1; - if (t1v != 0xFF) { - t1v += 0xA; - *t1 = t1v; - if (t1v < 0x100) { - // Void, debug stuff was probably here - } - t1v = 0xFF; - func_80137DA4(0xA, (f32) *t1); - } else { + if (t1v == 255) { return ApiStatus_DONE2; } + + t1v += 10; + *t1 = t1v; + if (t1v > 255) { + *t1 = 255; + } + + func_80137DA4(10, *t1); } - return 0; + return ApiStatus_BLOCK; } -*/ -// Very similar to func_802D4BDC -INCLUDE_ASM(s32, "code_f8f60_len_1560", func_802D4C4C, ScriptInstance* script, s32 isInitialCall); +ApiStatus func_802D4C4C(ScriptInstance* script, s32 initialCall) { + s32* t0 = &script->functionTemp[0]; + s32* t1 = &script->functionTemp[1]; + s32 t1v; + + if (initialCall) { + *t0 = 0; + *t1 = 255; + } + + if (*t0 == 0) { + t1v = *t1; + if (t1v == 0) { + func_80137DA4(255, -1.0f); + return ApiStatus_DONE2; + } + t1v -= 10; + *t1 = t1v; + if (t1v < 0) { + *t1 = 0; + } + func_80137DA4(10, *t1); + } + + return ApiStatus_BLOCK; +} ApiStatus func_802D4CC4(ScriptInstance* script, s32 initialCall) { s32 value = get_variable(script, *script->ptrReadPos); if (value < 0) { - func_80137DA4(0xFF, -1.0f); + func_80137DA4(255, -1.0f); } else { - func_80137DA4(0xA, value); + func_80137DA4(10, value); } return ApiStatus_DONE2; @@ -248,7 +269,85 @@ ApiStatus func_802D4D88(ScriptInstance* script, s32 initialCall) { return ApiStatus_DONE2; } +#ifdef NON_MATCHING +// most likely functionally equivalent, lots of issues though. +void setup_path_data(s32 numVecs, f32* arg1, struct Vec3f* arg2, struct Vec3f* arg3) { + struct Vec3f* temp_s4; + f32* temp_s7; + s32 i; + f32* temp; + f32 new_var; + f32 new_var2; + + temp_s7 = heap_malloc(numVecs * sizeof(f32)); + temp_s4 = heap_malloc(numVecs * sizeof(Vec3f)); + arg1[0] = 0.0f; + + for (i = 1; i < numVecs; i++) { + f32 temp_x = SQ(arg2[i].x - arg2[i - 1].x); + f32 temp_y = SQ(arg2[i].y - arg2[i - 1].y); + f32 temp_z = SQ(arg2[i].z - arg2[i - 1].z); + arg1[i] = arg1[i - 1] + sqrtf(temp_x + temp_y + temp_z); + } + + for (i = 1; i < numVecs; i++) { + arg1[i] = arg1[i] / arg1[numVecs - 1]; + } + + arg3[0].x = 0; + + arg3[numVecs - 1].z = 0; + arg3[0].z = 0; + + arg3[numVecs - 1].x = 0; + + arg3[0].y = 0; + arg3[numVecs - 1].y = 0; + + for (i = 0; i < (numVecs - 1); i++) { + f32 temp = temp_s7[i]; + temp_s7[i] = arg1[i + 1] - arg1[i]; + temp_s4[i + 1].x = ((arg2[i + 1].x - arg2[i].x) / temp_s7[i]); + temp_s4[i + 1].y = ((arg2[i + 1].y - arg2[i].y) / temp); + temp_s4[i + 1].z = ((arg2[i + 1].z - arg2[i].z) / temp); + } + + arg3[1].x = temp_s4[2].x - temp_s4[1].x; + arg3[1].y = temp_s4[2].y - temp_s4[1].y; + arg3[1].z = temp_s4[2].z - temp_s4[1].z; + temp_s4[1].x = ((arg1[2] - arg1[0]) * 2); + temp_s4[1].y = ((arg1[2] - arg1[0]) * 2); + temp_s4[1].z = ((arg1[2] - arg1[0]) * 2); + + for (i = 1; i < numVecs - 2; i++) { + f32 temp_x = temp_s7[i] / temp_s4[i].x; + f32 temp_y = temp_s7[i] / temp_s4[i].y; + f32 temp_z = temp_s7[i] / temp_s4[i].z; + new_var = arg3[i].x; + arg3[i + 1].x = (temp_s4[i + 2].x - temp_s4[i].x) - (new_var * temp_x); + arg3[i + 1].y = (temp_s4[i + 2].y - temp_s4[i].y) - (new_var * temp_y); + arg3[i + 1].z = (temp_s4[i + 2].z - temp_s4[i].z) - (new_var * temp_z); + temp_s4[i].x = ((arg1[i + 2] - arg1[i]) * 2) - (temp_s7[i] * temp_x); + temp_s4[i].y = ((arg1[i + 2] - arg1[i]) * 2) - (temp_s7[i] * temp_y); + temp_s4[i].z = ((arg1[i + 2] - arg1[i]) * 2) - (temp_s7[i] * temp_z); + } + + arg3[numVecs - 2].x = arg3[numVecs - 2].x - (temp_s7[numVecs - 2] * arg3[numVecs - 1].x); + arg3[numVecs - 2].y = arg3[numVecs - 2].y - (temp_s7[numVecs - 2] * arg3[numVecs - 1].y); + arg3[numVecs - 2].z = arg3[numVecs - 2].z - (temp_s7[numVecs - 2] * arg3[numVecs - 1].z); + + for (i = (numVecs - 2); i > 0 ; i--) { + arg3[i].x = (arg3[i].x - (temp_s7[i] * arg3[i + 1].x)) / temp_s4[i].x; + arg3[i].y = (arg3[i].y - (temp_s7[i] * arg3[i + 1].y)) / temp_s4[i].y; + arg3[i].z = (arg3[i].z - (temp_s7[i] * arg3[i + 1].z)) / temp_s4[i].z; + } + + heap_free(temp_s7); + heap_free(temp_s4); +} +#else INCLUDE_ASM(s32, "code_f8f60_len_1560", setup_path_data); +#endif INCLUDE_ASM(s32, "code_f8f60_len_1560", func_802D5270); @@ -334,10 +433,10 @@ ApiStatus ShowStatusMenu(ScriptInstance* script, s32 isInitialCall) { } ApiStatus SetGameMode(ScriptInstance* script, s32 isInitialCall) { - set_game_mode( - // Clear upper half - (get_variable(script, *script->ptrReadPos) << 0x10) >> 0x10 - ); + s16 mode = get_variable(script, *script->ptrReadPos); + + set_game_mode(mode); + return ApiStatus_DONE2; } diff --git a/tools/mips-nintendo-nu64-as b/tools/mips-nintendo-nu64-as index 05ae6219d7..6beeb5bf65 100755 Binary files a/tools/mips-nintendo-nu64-as and b/tools/mips-nintendo-nu64-as differ diff --git a/tools/splat.yaml b/tools/splat.yaml index 583deaeac8..6dd8f7aea8 100644 --- a/tools/splat.yaml +++ b/tools/splat.yaml @@ -2,7 +2,6 @@ name: "Paper Mario (North America)" basename: "papermario" options: find-file-boundaries: True - skip-asm: True pycparser_flags: ["-Iinclude", "-D_LANGUAGE_C", "-ffreestanding", "-DF3DEX_GBI_2", "-DSPLAT"] compiler: "GCC" segments: @@ -240,7 +239,10 @@ segments: - [0xf8f60, "c", "code_f8f60_len_1560"] - [0xfa4c0, "c", "code_fa4c0_len_3bf0"] - [0xfe0b0, "c", "code_fe0b0_len_5a0"] - - [0xFE650, "bin"] + - [0xFE650, ".data", "code_e79b0_len_1920"] + - [0xFE660, "bin"] + - [0xFE730, ".rodata", "code_e79b0_len_1920"] + - [0xFE748, "bin"] # rodata chunk for above overlay; here to avoid the 0x10 alignment - name: code type: code start: 0xFEE30 diff --git a/tools/windows_terminal.bat b/tools/windows_terminal.bat index 9dd5cda1cc..0402031eb1 100644 --- a/tools/windows_terminal.bat +++ b/tools/windows_terminal.bat @@ -1,3 +1,2 @@ REM first set your default distro using: wsl --set-default -ehco "first set your default distro using: wsl --set-default " wt --title "diff.py" -d "../" ; split-pane -d "../" -V ; new-tab --title "mips_to_c.py" -d "../" ; focus-tab -t 0 diff --git a/undefined_syms.txt b/undefined_syms.txt index edfcb69f2b..bf8c022a42 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -9,12 +9,22 @@ gPlayerStatus = 0x8010EFC8; gItemTable = 0x800878E0; gWorldScriptList = 0x802DA490; gBattleScriptList = 0x802DA690; +gNumScripts = 0x802DA488; gCurrentScriptListPtr = 0x802DA890; +gStaticScriptCounter = 0x802D9CA0; +D_802D9CA4 = 0x802D9CA4; gGlobalTimeSpace = 0x802D9CA8; gPlayerNpcPtr = 0x802D9D20; D_80147574 = 0x80147574; D_8010EBB0 = 0x8010EBB0; D_8010F250 = 0x8010F250; +D_80159D50 = 0x80159D50; + +gWorldMapVars = 0x802DBCA8; +gBattleMapVars = 0x802DBCE8; + +gWorldMapFlags = 0x802DBC70; +gBattleMapFlags = 0x802DBD34; gMapTransitionAlpha = 0x800A0940; D_800E92D8 = 0x800E92D8; @@ -137,16 +147,14 @@ gWorldDynamicEntityList = 0x801543A0; gBattleDynamicEntityList = 0x801543E0; gCurrentDynamicEntityListPtr = 0x80154420; -gScriptIdList = 0x802D1898; -gScriptIndexList = 0x802DAA98; +gScriptIndexList = 0x802DA898; +gScriptIdList = 0x802DAA98; gScriptListCount = 0x802DAC98; gCurrentSaveFile = 0x800DACC0; -D_802D9CA4 = 0x802D9CA4; gMapFlags = 0x802DA480; gMapVars = 0x802DA484; -gNumScripts = 0x802DA488; func_802A91F8 = 0x802A91F8; func_802A9208 = 0x802A9208;