Merge pull request #27 from nanaian/coverage

remove matched asm, add NON_MATCHING
This commit is contained in:
Ethan Roseman 2020-08-20 12:38:42 -04:00 committed by GitHub
commit b498086436
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 168 additions and 477 deletions

13
.github/workflows/coverage.yaml vendored Normal file
View File

@ -0,0 +1,13 @@
name: Coverage
on:
pull_request:
paths:
- 'src/*'
jobs:
build:
name: Check matched assembly files are deleted
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: ./coverage.py --fail-matched-undeleted

2
.gitmodules vendored
View File

@ -3,4 +3,4 @@
url = https://github.com/nanaian/star-rod.git
[submodule "tools/n64splat"]
path = tools/n64splat
url = https://github.com/ethteck/n64splat.git
url = https://github.com/ethteck/n64splat.git

View File

@ -94,11 +94,12 @@ You're on your own now. Get your C code compiling to match the original assembly
If you use Visual Studio Code, you can use _Run Test Task_ to run `diff.py` and show you errors and warnings from the compiler inline. You might want to attach _Run Test Task_ to a keybinding, as you'll be using it often.
#### Formatting and linting
#### After matching
Once your function is matching, you'll want to make a pull request. Before you do that, run the following script to reformat your code. (You can also format specific files with `./format.sh path/to/file.c`.)
Once you've matched a function, run the following scripts:
```sh
$ ./coverage.py --delete-matched
$ ./format.sh
```

View File

@ -1,10 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel func_80036640
/* 011A40 80036640 03E00008 */ jr $ra
/* 011A44 80036644 00000000 */ nop
/* 011A48 80036648 00000000 */ nop
/* 011A4C 8003664C 00000000 */ nop

View File

@ -1,10 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel default_trigger_function_handler
/* 0DBD70 80145670 8C820000 */ lw $v0, ($a0)
/* 0DBD74 80145674 34420002 */ ori $v0, $v0, 2
/* 0DBD78 80145678 03E00008 */ jr $ra
/* 0DBD7C 8014567C AC820000 */ sw $v0, ($a0)

View File

@ -1,39 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel delete_trigger
/* 0DC2F4 80145BF4 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 0DC2F8 80145BF8 AFB10014 */ sw $s1, 0x14($sp)
/* 0DC2FC 80145BFC 3C118016 */ lui $s1, 0x8016
/* 0DC300 80145C00 26319390 */ addiu $s1, $s1, -0x6c70
/* 0DC304 80145C04 AFBF0018 */ sw $ra, 0x18($sp)
/* 0DC308 80145C08 AFB00010 */ sw $s0, 0x10($sp)
/* 0DC30C 80145C0C 8E250000 */ lw $a1, ($s1)
/* 0DC310 80145C10 0000802D */ daddu $s0, $zero, $zero
/* 0DC314 80145C14 00A0182D */ daddu $v1, $a1, $zero
.L80145C18:
/* 0DC318 80145C18 8C620000 */ lw $v0, ($v1)
/* 0DC31C 80145C1C 10440006 */ beq $v0, $a0, .L80145C38
/* 0DC320 80145C20 2A020040 */ slti $v0, $s0, 0x40
/* 0DC324 80145C24 26100001 */ addiu $s0, $s0, 1
/* 0DC328 80145C28 2A020040 */ slti $v0, $s0, 0x40
/* 0DC32C 80145C2C 1440FFFA */ bnez $v0, .L80145C18
/* 0DC330 80145C30 24630004 */ addiu $v1, $v1, 4
/* 0DC334 80145C34 2A020040 */ slti $v0, $s0, 0x40
.L80145C38:
/* 0DC338 80145C38 10400007 */ beqz $v0, .L80145C58
/* 0DC33C 80145C3C 00108080 */ sll $s0, $s0, 2
/* 0DC340 80145C40 02051021 */ addu $v0, $s0, $a1
/* 0DC344 80145C44 0C00AB4B */ jal heap_free
/* 0DC348 80145C48 8C440000 */ lw $a0, ($v0)
/* 0DC34C 80145C4C 8E220000 */ lw $v0, ($s1)
/* 0DC350 80145C50 02028021 */ addu $s0, $s0, $v0
/* 0DC354 80145C54 AE000000 */ sw $zero, ($s0)
.L80145C58:
/* 0DC358 80145C58 8FBF0018 */ lw $ra, 0x18($sp)
/* 0DC35C 80145C5C 8FB10014 */ lw $s1, 0x14($sp)
/* 0DC360 80145C60 8FB00010 */ lw $s0, 0x10($sp)
/* 0DC364 80145C64 03E00008 */ jr $ra
/* 0DC368 80145C68 27BD0020 */ addiu $sp, $sp, 0x20

View File

@ -1,12 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel get_trigger_by_id
/* 0DC3D0 80145CD0 3C028016 */ lui $v0, 0x8016
/* 0DC3D4 80145CD4 8C429390 */ lw $v0, -0x6c70($v0)
/* 0DC3D8 80145CD8 00042080 */ sll $a0, $a0, 2
/* 0DC3DC 80145CDC 00822021 */ addu $a0, $a0, $v0
/* 0DC3E0 80145CE0 03E00008 */ jr $ra
/* 0DC3E4 80145CE4 8C820000 */ lw $v0, ($a0)

View File

@ -1,26 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel init_trigger_list
/* 0DBE28 80145728 3C028007 */ lui $v0, 0x8007
/* 0DBE2C 8014572C 8C42419C */ lw $v0, 0x419c($v0)
/* 0DBE30 80145730 80420070 */ lb $v0, 0x70($v0)
/* 0DBE34 80145734 14400005 */ bnez $v0, .L8014574C
/* 0DBE38 80145738 00000000 */ nop
/* 0DBE3C 8014573C 3C028016 */ lui $v0, 0x8016
/* 0DBE40 80145740 24429190 */ addiu $v0, $v0, -0x6e70
/* 0DBE44 80145744 080515D5 */ j .L80145754
/* 0DBE48 80145748 00000000 */ nop
.L8014574C:
/* 0DBE4C 8014574C 3C028016 */ lui $v0, 0x8016
/* 0DBE50 80145750 24429290 */ addiu $v0, $v0, -0x6d70
.L80145754:
/* 0DBE54 80145754 3C018016 */ lui $at, 0x8016
/* 0DBE58 80145758 AC229390 */ sw $v0, -0x6c70($at)
/* 0DBE5C 8014575C 3C018015 */ lui $at, 0x8015
/* 0DBE60 80145760 A4201334 */ sh $zero, 0x1334($at)
/* 0DBE64 80145764 03E00008 */ jr $ra
/* 0DBE68 80145768 00000000 */ nop

View File

@ -1,35 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel suspend_all_script
/* 0E8DD0 802C4420 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 0E8DD4 802C4424 AFB10014 */ sw $s1, 0x14($sp)
/* 0E8DD8 802C4428 0080882D */ daddu $s1, $a0, $zero
/* 0E8DDC 802C442C AFB00010 */ sw $s0, 0x10($sp)
/* 0E8DE0 802C4430 0000802D */ daddu $s0, $zero, $zero
/* 0E8DE4 802C4434 AFBF0018 */ sw $ra, 0x18($sp)
.L802C4438:
/* 0E8DE8 802C4438 3C03802E */ lui $v1, 0x802e
/* 0E8DEC 802C443C 8C63A890 */ lw $v1, -0x5770($v1)
/* 0E8DF0 802C4440 00101080 */ sll $v0, $s0, 2
/* 0E8DF4 802C4444 00431021 */ addu $v0, $v0, $v1
/* 0E8DF8 802C4448 8C440000 */ lw $a0, ($v0)
/* 0E8DFC 802C444C 50800007 */ beql $a0, $zero, .L802C446C
/* 0E8E00 802C4450 26100001 */ addiu $s0, $s0, 1
/* 0E8E04 802C4454 8C820144 */ lw $v0, 0x144($a0)
/* 0E8E08 802C4458 54510004 */ bnel $v0, $s1, .L802C446C
/* 0E8E0C 802C445C 26100001 */ addiu $s0, $s0, 1
/* 0E8E10 802C4460 0C0B10B6 */ jal suspend_group_script
/* 0E8E14 802C4464 240500EF */ addiu $a1, $zero, 0xef
/* 0E8E18 802C4468 26100001 */ addiu $s0, $s0, 1
.L802C446C:
/* 0E8E1C 802C446C 2A020080 */ slti $v0, $s0, 0x80
/* 0E8E20 802C4470 1440FFF1 */ bnez $v0, .L802C4438
/* 0E8E24 802C4474 00000000 */ nop
/* 0E8E28 802C4478 8FBF0018 */ lw $ra, 0x18($sp)
/* 0E8E2C 802C447C 8FB10014 */ lw $s1, 0x14($sp)
/* 0E8E30 802C4480 8FB00010 */ lw $s0, 0x10($sp)
/* 0E8E34 802C4484 03E00008 */ jr $ra
/* 0E8E38 802C4488 27BD0020 */ addiu $sp, $sp, 0x20

View File

@ -1,28 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel si_handle_AND_const
/* 0EAC84 802C62D4 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 0EAC88 802C62D8 AFB10014 */ sw $s1, 0x14($sp)
/* 0EAC8C 802C62DC 0080882D */ daddu $s1, $a0, $zero
/* 0EAC90 802C62E0 AFBF001C */ sw $ra, 0x1c($sp)
/* 0EAC94 802C62E4 AFB20018 */ sw $s2, 0x18($sp)
/* 0EAC98 802C62E8 AFB00010 */ sw $s0, 0x10($sp)
/* 0EAC9C 802C62EC 8E22000C */ lw $v0, 0xc($s1)
/* 0EACA0 802C62F0 8C520000 */ lw $s2, ($v0)
/* 0EACA4 802C62F4 8C500004 */ lw $s0, 4($v0)
/* 0EACA8 802C62F8 0C0B1EAF */ jal get_variable
/* 0EACAC 802C62FC 0240282D */ daddu $a1, $s2, $zero
/* 0EACB0 802C6300 0220202D */ daddu $a0, $s1, $zero
/* 0EACB4 802C6304 0240282D */ daddu $a1, $s2, $zero
/* 0EACB8 802C6308 0C0B2026 */ jal set_variable
/* 0EACBC 802C630C 02023024 */ and $a2, $s0, $v0
/* 0EACC0 802C6310 8FBF001C */ lw $ra, 0x1c($sp)
/* 0EACC4 802C6314 8FB20018 */ lw $s2, 0x18($sp)
/* 0EACC8 802C6318 8FB10014 */ lw $s1, 0x14($sp)
/* 0EACCC 802C631C 8FB00010 */ lw $s0, 0x10($sp)
/* 0EACD0 802C6320 24020002 */ addiu $v0, $zero, 2
/* 0EACD4 802C6324 03E00008 */ jr $ra
/* 0EACD8 802C6328 27BD0020 */ addiu $sp, $sp, 0x20

View File

@ -1,28 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel si_handle_OR_const
/* 0EAD40 802C6390 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 0EAD44 802C6394 AFB10014 */ sw $s1, 0x14($sp)
/* 0EAD48 802C6398 0080882D */ daddu $s1, $a0, $zero
/* 0EAD4C 802C639C AFBF001C */ sw $ra, 0x1c($sp)
/* 0EAD50 802C63A0 AFB20018 */ sw $s2, 0x18($sp)
/* 0EAD54 802C63A4 AFB00010 */ sw $s0, 0x10($sp)
/* 0EAD58 802C63A8 8E22000C */ lw $v0, 0xc($s1)
/* 0EAD5C 802C63AC 8C520000 */ lw $s2, ($v0)
/* 0EAD60 802C63B0 8C500004 */ lw $s0, 4($v0)
/* 0EAD64 802C63B4 0C0B1EAF */ jal get_variable
/* 0EAD68 802C63B8 0240282D */ daddu $a1, $s2, $zero
/* 0EAD6C 802C63BC 0220202D */ daddu $a0, $s1, $zero
/* 0EAD70 802C63C0 0240282D */ daddu $a1, $s2, $zero
/* 0EAD74 802C63C4 0C0B2026 */ jal set_variable
/* 0EAD78 802C63C8 02023025 */ or $a2, $s0, $v0
/* 0EAD7C 802C63CC 8FBF001C */ lw $ra, 0x1c($sp)
/* 0EAD80 802C63D0 8FB20018 */ lw $s2, 0x18($sp)
/* 0EAD84 802C63D4 8FB10014 */ lw $s1, 0x14($sp)
/* 0EAD88 802C63D8 8FB00010 */ lw $s0, 0x10($sp)
/* 0EAD8C 802C63DC 24020002 */ addiu $v0, $zero, 2
/* 0EAD90 802C63E0 03E00008 */ jr $ra
/* 0EAD94 802C63E4 27BD0020 */ addiu $sp, $sp, 0x20

View File

@ -1,29 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel resolve_npc
/* 0F2470 802CDAC0 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0F2474 802CDAC4 0080182D */ daddu $v1, $a0, $zero
/* 0F2478 802CDAC8 00A0202D */ daddu $a0, $a1, $zero
/* 0F247C 802CDACC 2402FFFF */ addiu $v0, $zero, -1
/* 0F2480 802CDAD0 14820004 */ bne $a0, $v0, .L802CDAE4
/* 0F2484 802CDAD4 AFBF0010 */ sw $ra, 0x10($sp)
/* 0F2488 802CDAD8 8C64014C */ lw $a0, 0x14c($v1)
/* 0F248C 802CDADC 080B36BE */ j .L802CDAF8
/* 0F2490 802CDAE0 00000000 */ nop
.L802CDAE4:
/* 0F2494 802CDAE4 3C02EFE8 */ lui $v0, 0xefe8
/* 0F2498 802CDAE8 34422080 */ ori $v0, $v0, 0x2080
/* 0F249C 802CDAEC 0082102A */ slt $v0, $a0, $v0
/* 0F24A0 802CDAF0 14400003 */ bnez $v0, .L802CDB00
/* 0F24A4 802CDAF4 0080102D */ daddu $v0, $a0, $zero
.L802CDAF8:
/* 0F24A8 802CDAF8 0C00EAD2 */ jal get_npc_safe
/* 0F24AC 802CDAFC 00000000 */ nop
.L802CDB00:
/* 0F24B0 802CDB00 8FBF0010 */ lw $ra, 0x10($sp)
/* 0F24B4 802CDB04 03E00008 */ jr $ra
/* 0F24B8 802CDB08 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,13 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel ContinueSpeech
/* 0F4C98 802D02E8 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0F4C9C 802D02EC AFBF0010 */ sw $ra, 0x10($sp)
/* 0F4CA0 802D02F0 0C0B40C8 */ jal _show_message
/* 0F4CA4 802D02F4 24060002 */ addiu $a2, $zero, 2
/* 0F4CA8 802D02F8 8FBF0010 */ lw $ra, 0x10($sp)
/* 0F4CAC 802D02FC 03E00008 */ jr $ra
/* 0F4CB0 802D0300 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,13 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel SpeakToNpc
/* 0F4CB4 802D0304 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0F4CB8 802D0308 AFBF0010 */ sw $ra, 0x10($sp)
/* 0F4CBC 802D030C 0C0B40C8 */ jal _show_message
/* 0F4CC0 802D0310 24060003 */ addiu $a2, $zero, 3
/* 0F4CC4 802D0314 8FBF0010 */ lw $ra, 0x10($sp)
/* 0F4CC8 802D0318 03E00008 */ jr $ra
/* 0F4CCC 802D031C 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,67 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel AddKeyItem
/* 0FB278 802D68C8 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0FB27C 802D68CC AFBF0014 */ sw $ra, 0x14($sp)
/* 0FB280 802D68D0 AFB00010 */ sw $s0, 0x10($sp)
/* 0FB284 802D68D4 8C82000C */ lw $v0, 0xc($a0)
/* 0FB288 802D68D8 0C0B1EAF */ jal get_variable
/* 0FB28C 802D68DC 8C450000 */ lw $a1, ($v0)
/* 0FB290 802D68E0 3C108011 */ lui $s0, 0x8011
/* 0FB294 802D68E4 2610F290 */ addiu $s0, $s0, -0xd70
/* 0FB298 802D68E8 0040282D */ daddu $a1, $v0, $zero
/* 0FB29C 802D68EC 24020010 */ addiu $v0, $zero, 0x10
/* 0FB2A0 802D68F0 14A20006 */ bne $a1, $v0, .L802D690C
/* 0FB2A4 802D68F4 0000182D */ daddu $v1, $zero, $zero
/* 0FB2A8 802D68F8 9203000E */ lbu $v1, 0xe($s0)
/* 0FB2AC 802D68FC 24020002 */ addiu $v0, $zero, 2
/* 0FB2B0 802D6900 24630001 */ addiu $v1, $v1, 1
/* 0FB2B4 802D6904 080B5A51 */ j .L802D6944
/* 0FB2B8 802D6908 A203000E */ sb $v1, 0xe($s0)
.L802D690C:
/* 0FB2BC 802D690C 0200202D */ daddu $a0, $s0, $zero
.L802D6910:
/* 0FB2C0 802D6910 84820074 */ lh $v0, 0x74($a0)
/* 0FB2C4 802D6914 10400006 */ beqz $v0, .L802D6930
/* 0FB2C8 802D6918 28620020 */ slti $v0, $v1, 0x20
/* 0FB2CC 802D691C 24630001 */ addiu $v1, $v1, 1
/* 0FB2D0 802D6920 28620020 */ slti $v0, $v1, 0x20
/* 0FB2D4 802D6924 1440FFFA */ bnez $v0, .L802D6910
/* 0FB2D8 802D6928 24840002 */ addiu $a0, $a0, 2
/* 0FB2DC 802D692C 28620020 */ slti $v0, $v1, 0x20
.L802D6930:
/* 0FB2E0 802D6930 10400003 */ beqz $v0, .L802D6940
/* 0FB2E4 802D6934 00031040 */ sll $v0, $v1, 1
/* 0FB2E8 802D6938 02021021 */ addu $v0, $s0, $v0
/* 0FB2EC 802D693C A4450074 */ sh $a1, 0x74($v0)
.L802D6940:
/* 0FB2F0 802D6940 24020002 */ addiu $v0, $zero, 2
.L802D6944:
/* 0FB2F4 802D6944 8FBF0014 */ lw $ra, 0x14($sp)
/* 0FB2F8 802D6948 8FB00010 */ lw $s0, 0x10($sp)
/* 0FB2FC 802D694C 03E00008 */ jr $ra
/* 0FB300 802D6950 27BD0018 */ addiu $sp, $sp, 0x18
glabel func_802D6954
/* 0FB304 802D6954 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0FB308 802D6958 AFBF0010 */ sw $ra, 0x10($sp)
/* 0FB30C 802D695C 0C038069 */ jal func_800E01A4
/* 0FB310 802D6960 00000000 */ nop
/* 0FB314 802D6964 0C038050 */ jal disable_player_physics
/* 0FB318 802D6968 00000000 */ nop
/* 0FB31C 802D696C 0C03BD80 */ jal func_800EF600
/* 0FB320 802D6970 00000000 */ nop
/* 0FB324 802D6974 3C03800A */ lui $v1, 0x800a
/* 0FB328 802D6978 2463A650 */ addiu $v1, $v1, -0x59b0
/* 0FB32C 802D697C 8C640000 */ lw $a0, ($v1)
/* 0FB330 802D6980 2405FFBF */ addiu $a1, $zero, -0x41
/* 0FB334 802D6984 00852024 */ and $a0, $a0, $a1
/* 0FB338 802D6988 AC640000 */ sw $a0, ($v1)
/* 0FB33C 802D698C 8FBF0010 */ lw $ra, 0x10($sp)
/* 0FB340 802D6990 24020002 */ addiu $v0, $zero, 2
/* 0FB344 802D6994 03E00008 */ jr $ra
/* 0FB348 802D6998 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,42 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel FindKeyItem
/* 0FB3C4 802D6A14 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 0FB3C8 802D6A18 AFB10014 */ sw $s1, 0x14($sp)
/* 0FB3CC 802D6A1C 0080882D */ daddu $s1, $a0, $zero
/* 0FB3D0 802D6A20 AFBF0018 */ sw $ra, 0x18($sp)
/* 0FB3D4 802D6A24 AFB00010 */ sw $s0, 0x10($sp)
/* 0FB3D8 802D6A28 8E30000C */ lw $s0, 0xc($s1)
/* 0FB3DC 802D6A2C 8E050000 */ lw $a1, ($s0)
/* 0FB3E0 802D6A30 0C0B1EAF */ jal get_variable
/* 0FB3E4 802D6A34 26100004 */ addiu $s0, $s0, 4
/* 0FB3E8 802D6A38 0040302D */ daddu $a2, $v0, $zero
/* 0FB3EC 802D6A3C 0000182D */ daddu $v1, $zero, $zero
/* 0FB3F0 802D6A40 3C048011 */ lui $a0, 0x8011
/* 0FB3F4 802D6A44 2484F290 */ addiu $a0, $a0, -0xd70
/* 0FB3F8 802D6A48 8E050000 */ lw $a1, ($s0)
.L802D6A4C:
/* 0FB3FC 802D6A4C 84820074 */ lh $v0, 0x74($a0)
/* 0FB400 802D6A50 10460006 */ beq $v0, $a2, .L802D6A6C
/* 0FB404 802D6A54 24020020 */ addiu $v0, $zero, 0x20
/* 0FB408 802D6A58 24630001 */ addiu $v1, $v1, 1
/* 0FB40C 802D6A5C 28620020 */ slti $v0, $v1, 0x20
/* 0FB410 802D6A60 1440FFFA */ bnez $v0, .L802D6A4C
/* 0FB414 802D6A64 24840002 */ addiu $a0, $a0, 2
/* 0FB418 802D6A68 24020020 */ addiu $v0, $zero, 0x20
.L802D6A6C:
/* 0FB41C 802D6A6C 10620002 */ beq $v1, $v0, .L802D6A78
/* 0FB420 802D6A70 2406FFFF */ addiu $a2, $zero, -1
/* 0FB424 802D6A74 0060302D */ daddu $a2, $v1, $zero
.L802D6A78:
/* 0FB428 802D6A78 0C0B2026 */ jal set_variable
/* 0FB42C 802D6A7C 0220202D */ daddu $a0, $s1, $zero
/* 0FB430 802D6A80 8FBF0018 */ lw $ra, 0x18($sp)
/* 0FB434 802D6A84 8FB10014 */ lw $s1, 0x14($sp)
/* 0FB438 802D6A88 8FB00010 */ lw $s0, 0x10($sp)
/* 0FB43C 802D6A8C 24020002 */ addiu $v0, $zero, 2
/* 0FB440 802D6A90 03E00008 */ jr $ra
/* 0FB444 802D6A94 27BD0020 */ addiu $sp, $sp, 0x20

View File

@ -1,38 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel HasKeyItem
/* 0FB34C 802D699C 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 0FB350 802D69A0 AFB10014 */ sw $s1, 0x14($sp)
/* 0FB354 802D69A4 0080882D */ daddu $s1, $a0, $zero
/* 0FB358 802D69A8 AFBF0018 */ sw $ra, 0x18($sp)
/* 0FB35C 802D69AC AFB00010 */ sw $s0, 0x10($sp)
/* 0FB360 802D69B0 8E30000C */ lw $s0, 0xc($s1)
/* 0FB364 802D69B4 8E050000 */ lw $a1, ($s0)
/* 0FB368 802D69B8 0C0B1EAF */ jal get_variable
/* 0FB36C 802D69BC 26100004 */ addiu $s0, $s0, 4
/* 0FB370 802D69C0 0040202D */ daddu $a0, $v0, $zero
/* 0FB374 802D69C4 0000302D */ daddu $a2, $zero, $zero
/* 0FB378 802D69C8 3C038011 */ lui $v1, 0x8011
/* 0FB37C 802D69CC 2463F290 */ addiu $v1, $v1, -0xd70
/* 0FB380 802D69D0 8E050000 */ lw $a1, ($s0)
.L802D69D4:
/* 0FB384 802D69D4 84620074 */ lh $v0, 0x74($v1)
/* 0FB388 802D69D8 50440006 */ beql $v0, $a0, .L802D69F4
/* 0FB38C 802D69DC 0220202D */ daddu $a0, $s1, $zero
/* 0FB390 802D69E0 24C60001 */ addiu $a2, $a2, 1
/* 0FB394 802D69E4 28C20020 */ slti $v0, $a2, 0x20
/* 0FB398 802D69E8 1440FFFA */ bnez $v0, .L802D69D4
/* 0FB39C 802D69EC 24630002 */ addiu $v1, $v1, 2
/* 0FB3A0 802D69F0 0220202D */ daddu $a0, $s1, $zero
.L802D69F4:
/* 0FB3A4 802D69F4 0C0B2026 */ jal set_variable
/* 0FB3A8 802D69F8 28C60020 */ slti $a2, $a2, 0x20
/* 0FB3AC 802D69FC 8FBF0018 */ lw $ra, 0x18($sp)
/* 0FB3B0 802D6A00 8FB10014 */ lw $s1, 0x14($sp)
/* 0FB3B4 802D6A04 8FB00010 */ lw $s0, 0x10($sp)
/* 0FB3B8 802D6A08 24020002 */ addiu $v0, $zero, 2
/* 0FB3BC 802D6A0C 03E00008 */ jr $ra
/* 0FB3C0 802D6A10 27BD0020 */ addiu $sp, $sp, 0x20

View File

@ -1,17 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel RemoveItemEntity
/* 0FB97C 802D6FCC 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0FB980 802D6FD0 AFBF0010 */ sw $ra, 0x10($sp)
/* 0FB984 802D6FD4 8C82000C */ lw $v0, 0xc($a0)
/* 0FB988 802D6FD8 0C0B1EAF */ jal get_variable
/* 0FB98C 802D6FDC 8C450000 */ lw $a1, ($v0)
/* 0FB990 802D6FE0 0C04CE7F */ jal remove_item_entity_by_index
/* 0FB994 802D6FE4 0040202D */ daddu $a0, $v0, $zero
/* 0FB998 802D6FE8 8FBF0010 */ lw $ra, 0x10($sp)
/* 0FB99C 802D6FEC 24020002 */ addiu $v0, $zero, 2
/* 0FB9A0 802D6FF0 03E00008 */ jr $ra
/* 0FB9A4 802D6FF4 27BD0018 */ addiu $sp, $sp, 0x18

73
coverage.py Executable file
View File

@ -0,0 +1,73 @@
#!/usr/bin/env python3
from os import path
from os import remove
from sys import argv
import re
from glob import glob
DIR = path.dirname(__file__)
C_FILES = glob(path.join(DIR, "src/*.c"))
ASM_FILES = glob(path.join(DIR, "asm/nonmatchings/**/*.s"))
def strip_c_comments(text):
def replacer(match):
s = match.group(0)
if s.startswith('/'):
return " "
else:
return s
pattern = re.compile(
r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
re.DOTALL | re.MULTILINE
)
return re.sub(pattern, replacer, text)
c_func_pattern = re.compile(
r"^[^\s]+\s+([^\s(]+)\(([^\n)]*)\)\s+{",
re.MULTILINE
)
def funcs_in_c(text):
return (match.group(1) for match in c_func_pattern.finditer(text))
asm_func_pattern = re.compile(
r"INCLUDE_(?:API_)?ASM\([^,]+, ([^,)]+)",
re.MULTILINE
)
def include_asms_in_c(text):
return (match.group(1) for match in asm_func_pattern.finditer(text))
matched = []
asm = []
for filename in C_FILES:
with open(filename, "r") as file:
text = strip_c_comments(file.read())
matched.extend((m for m in funcs_in_c(text) if not m in matched))
asm.extend((m for m in include_asms_in_c(text) if not m in asm))
non_matched = [path.splitext(path.basename(filename))[0] for filename in ASM_FILES]
partial_matched = [f for f in matched if f in asm]
matched = [f for f in matched if not f in partial_matched]
matched_but_undeleted_asm = [f for f in matched if f in non_matched and not f in partial_matched]
if __name__ == "__main__":
if "--help" in argv:
print("--fail-matched-undeleted exit with error code 1 if matched function(s) exist in asm/nonmatchings/")
print("--delete-matched delete matched function(s) from asm/nonmatchings/ without asking")
exit()
total = len(matched) + len(non_matched)
print(f"{len(matched)}+{len(partial_matched)} / {total} functions ({(len(matched) / total) * 100:.2f}% matched)")
if len(matched_but_undeleted_asm) > 0:
print(f"The following functions have been matched but still exist in asm/nonmatchings/: {' '.join(matched_but_undeleted_asm)}")
if "--fail-matched-undeleted" in argv:
exit(1)
elif "--delete-matched" in argv or input("Delete them [y/N]? ").upper() == "Y":
for func in matched_but_undeleted_asm:
file = glob(path.join(DIR, f"../asm/nonmatchings/*/{func}.s"))[0]
remove(file)
elif len(asm) != len(non_matched):
print(f"warning: number of INCLUDE_ASM macros ({len(asm)}) != number of asm files ({len(non_matched)})")

View File

@ -54,9 +54,12 @@ INCLUDE_ASM("code_6000", collision_heap_create);
INCLUDE_ASM("code_6000", collision_heap_malloc);
INCLUDE_ASM("code_6000", collision_heap_free);
/*s32 collision_heap_free(s32 size) {
#ifdef NON_MATCHING
s32 collision_heap_free(s32 size) {
s32 isBattle = (*gGameStatusPtr)->isBattle;
return _heap_free((isBattle == 0) ? (&D_80268000) : (&D_803DA800), size);
}*/
}
#else
INCLUDE_ASM("code_6000", collision_heap_free);
#endif

View File

@ -714,10 +714,10 @@ void reset_status_menu(void) {
func_801452B4(uiStatus->iconIndexC, uiStatus->iconIndexC);
}
#ifdef NON_MATCHING
// uses a jumptable, which we need .rodata support for.
s32 INCLUDE_ASM("code_80850_len_3060", is_ability_active, s32 arg0);
// Somewhat close. Needs work.
/*s32 is_ability_active(s32 arg0) {
s32 is_ability_active(s32 arg0) {
s32 iVar2;
u32 uVar3;
s32 iVar5;
@ -732,8 +732,8 @@ s32 INCLUDE_ASM("code_80850_len_3060", is_ability_active, s32 arg0);
iVar5 = 0;
//iVar7 = 0;
for(i = 5; i >= 0; i--) {
local_20[i] = 0;
for (i = 5; i >= 0; i--) {
local_20[i] = 0;
}
if (((*gGameStatusPtr)->unk_7E & 1) == 0) {
@ -744,7 +744,7 @@ s32 INCLUDE_ASM("code_80850_len_3060", is_ability_active, s32 arg0);
s32 index = i;
badge = playerData->equippedBadges[index];
if (playerData->equippedBadges[index] != 0) {
uVar4 = gItemTable[badge].moveID;
uVar4 = gItemTable[badge].moveID;
}
switch (arg0) {
case 0:
@ -766,10 +766,10 @@ s32 INCLUDE_ASM("code_80850_len_3060", is_ability_active, s32 arg0);
break;
case 6:
if (uVar4 == 0x53) {
iVar7++;
iVar7++;
}
if (playerData->hasActionCommands != 0) {
iVar7++;
iVar7++;
}
continue;
case 7:
@ -798,40 +798,40 @@ s32 INCLUDE_ASM("code_80850_len_3060", is_ability_active, s32 arg0);
break;
case 0xf:
if (uVar4 == 0x54) {
local_20[piVar6] = 1;
piVar6++;
iVar5++;
iVar7 = -1;
local_20[piVar6] = 1;
piVar6++;
iVar5++;
iVar7 = -1;
}
if (uVar4 == 0x55) {
local_20[piVar6] = 2;
piVar6++;
iVar5++;
iVar7 = -1;
local_20[piVar6] = 2;
piVar6++;
iVar5++;
iVar7 = -1;
}
if (uVar4 == 0x56) {
local_20[piVar6] = 3;
piVar6++;
iVar5++;
iVar7 = -1;
local_20[piVar6] = 3;
piVar6++;
iVar5++;
iVar7 = -1;
}
if (uVar4 == 0x57) {
local_20[piVar6] = 4;
piVar6++;
iVar5++;
iVar7 = -1;
local_20[piVar6] = 4;
piVar6++;
iVar5++;
iVar7 = -1;
}
if (uVar4 == 0x58) {
local_20[piVar6] = 5;
piVar6++;
iVar5++;
iVar7 = -1;
local_20[piVar6] = 5;
piVar6++;
iVar5++;
iVar7 = -1;
}
if (uVar4 == 0x59) {
local_20[piVar6] = 6;
piVar6++;
iVar5++;
iVar7 = -1;
local_20[piVar6] = 6;
piVar6++;
iVar5++;
iVar7 = -1;
}
continue;
case 0x10:
@ -955,7 +955,7 @@ s32 INCLUDE_ASM("code_80850_len_3060", is_ability_active, s32 arg0);
uVar3 = 0x4a;
}
if (uVar4 == uVar3) {
iVar7++;
iVar7++;
}
}
if (iVar7 < 0) {
@ -963,7 +963,10 @@ s32 INCLUDE_ASM("code_80850_len_3060", is_ability_active, s32 arg0);
}
return iVar7;
}
}*/
}
#else
s32 INCLUDE_ASM("code_80850_len_3060", is_ability_active, s32 arg0);
#endif
s32 is_partner_ability_active(void) {
return 0;

View File

@ -1,6 +1,5 @@
#include "common.h"
void default_trigger_function_handler(s32* arg0) {
arg0[0] |= 2;
}
@ -21,7 +20,6 @@ INCLUDE_ASM("code_dbd70_len_700", create_trigger);
INCLUDE_ASM("code_dbd70_len_700", update_triggers);
void delete_trigger(Trigger* toDelete) {
s32 i;
@ -43,8 +41,8 @@ Trigger* get_trigger_by_id(s32 triggerID) {
return (*gCurrentTriggerListPtr)[triggerID];
}
INCLUDE_ASM("code_dbd70_len_700", func_80145CE8);
/*s32 func_80145CE8(s32 arg0) {
#ifdef NON_MATCHING
s32 func_80145CE8(s32 arg0) {
s32 i;
s32 ret;
@ -62,4 +60,7 @@ INCLUDE_ASM("code_dbd70_len_700", func_80145CE8);
}
return ret;
}*/
}
#else
INCLUDE_ASM("code_dbd70_len_700", func_80145CE8);
#endif

View File

@ -18,8 +18,7 @@ INCLUDE_ASM("code_e79b0_len_1920", start_child_script);
INCLUDE_ASM("code_e79b0_len_1920", func_802C39F8);
INCLUDE_ASM("code_e79b0_len_1920", restart_script);
/*
#ifdef NON_MATCHING
ScriptInstance* restart_script(ScriptInstance* script) {
script->loopDepth = -1;
script->switchDepth = -1;
@ -39,7 +38,9 @@ ScriptInstance* restart_script(ScriptInstance* script) {
return script;
}
*/
#else
INCLUDE_ASM("code_e79b0_len_1920", restart_script);
#endif
INCLUDE_ASM("code_e79b0_len_1920", update_scripts);
@ -103,22 +104,23 @@ void set_script_timescale(ScriptInstance* script, f32 timescale) {
script->timeScale = timescale * gGlobalTimeSpace;
}
INCLUDE_ASM("code_e79b0_len_1920", set_global_timespace);
/*
#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("code_e79b0_len_1920", set_global_timespace);
#endif
INCLUDE_ASM("code_e79b0_len_1920", get_global_timespace);
/*
#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("code_e79b0_len_1920", get_global_timespace);
#endif
void set_script_group(ScriptInstance* script, s8 groupFlags) {
script->groupFlags = groupFlags;
@ -303,8 +305,7 @@ void set_script_flags(ScriptInstance* script, s32 flags) {
}
}
INCLUDE_ASM("code_e79b0_len_1920", clear_script_flags);
/*
#ifdef NON_MATCHING
// TODO: Really close but some weirdness is going on
void clear_script_flags(ScriptInstance* script, s32 flags) {
int i;
@ -316,11 +317,13 @@ 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 < ARRAY_COUNT(gCurrentScriptListPtr); i++) {
scriptContextPtr = (*gCurrentScriptListPtr)[i];
if (scriptContextPtr != NULL && scriptContextPtr->parentScript == script) {
clear_script_flags(script->parentScript, flags);
}
}
}
*/
#else
INCLUDE_ASM("code_e79b0_len_1920", clear_script_flags);
#endif

View File

@ -370,7 +370,6 @@ INCLUDE_ASM("code_e92d0_len_5da0", si_handle_allocate_array);
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_AND);
//INCLUDE_ASM("code_e92d0_len_5da0", si_handle_AND_const);
ApiStatus si_handle_AND_const(ScriptInstance* script) {
Bytecode* ptrReadPos = script->ptrReadPos;
@ -385,7 +384,6 @@ ApiStatus si_handle_AND_const(ScriptInstance* script) {
INCLUDE_ASM("code_e92d0_len_5da0", si_handle_OR);
//INCLUDE_ASM("code_e92d0_len_5da0", si_handle_OR_const);
ApiStatus si_handle_OR_const(ScriptInstance* script) {
Bytecode* ptrReadPos = script->ptrReadPos;

View File

@ -66,10 +66,9 @@ ApiStatus SetMessageString(ScriptInstance* script, s32 isInitialCall) {
return ApiStatus_DONE2;
}
INCLUDE_API_ASM("code_f4c60_len_4300", SetMessageValue);
#ifdef NON_MATCHING
// TODO: Figure out why there's an extra NOP after this function
// It's probably because of a file split issue
/*
ApiStatus SetMessageValue(ScriptInstance* script, s32 initialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
Bytecode value = get_variable(script, *ptrReadPos++);
@ -78,7 +77,9 @@ ApiStatus SetMessageValue(ScriptInstance* script, s32 initialCall) {
set_message_value(value, index);
return ApiStatus_DONE2;
}
*/
#else
INCLUDE_API_ASM("code_f4c60_len_4300", SetMessageValue);
#endif
INCLUDE_API_ASM("code_f4c60_len_4300", HidePlayerShadow);

View File

@ -335,8 +335,7 @@ ApiStatus AddStarPieces(ScriptInstance* script, s32 isInitialCall) {
return ApiStatus_DONE2;
}
INCLUDE_API_ASM("code_fa4c0_len_3bf0", GetItemPower);
/*
#ifdef NON_MATCHING
// Close to working
ApiStatus GetItemPower(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
@ -349,7 +348,9 @@ ApiStatus GetItemPower(ScriptInstance* script, s32 isInitialCall) {
set_variable(script, ptrNextPos++, item->potencyB);
return ApiStatus_DONE2;
}
*/
#else
INCLUDE_API_ASM("code_fa4c0_len_3bf0", GetItemPower);
#endif
INCLUDE_API_ASM("code_fa4c0_len_3bf0", ShowGotItem);
@ -359,8 +360,7 @@ INCLUDE_ASM("code_fa4c0_len_3bf0", func_802D74C0);
INCLUDE_API_ASM("code_fa4c0_len_3bf0", ShowEmote);
INCLUDE_API_ASM("code_fa4c0_len_3bf0", RemoveEffect);
/*
#ifdef NON_MATCHING
// Works
ApiStatus RemoveEffect(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
@ -398,8 +398,10 @@ ApiStatus func_802D7B74(ScriptInstance* script, s32 isInitialCall) {
return ApiStatus_DONE2;
}
// More functions still in RemoveEffect.s but the ones above are matching properly
*/
// TODO: More functions still in RemoveEffect.s but the ones above are matching properly
#else
INCLUDE_API_ASM("code_fa4c0_len_3bf0", RemoveEffect);
#endif
INCLUDE_API_ASM("code_fa4c0_len_3bf0", ShowSleepBubble);