From 31124801c0b9e916421eb734bf84ae033eefd66e Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 27 Feb 2025 14:27:28 -0500 Subject: [PATCH] Score update fixes (#467) * Fixed a couple of issues for score calculations * Update README --- README.md | 24 ++++++++++++------------ asm/collision/func_80031600.s | 8 ++++---- asm/non_matchings/printf/vsprintf.s | 8 ++++---- lib/asm/params.s | 11 +++++++++++ lib/asm/spaces.s | 27 --------------------------- tools/python/score.py | 20 ++++++++++++++++---- 6 files changed, 47 insertions(+), 51 deletions(-) create mode 100644 lib/asm/params.s delete mode 100644 lib/asm/spaces.s diff --git a/README.md b/README.md index 5f60c7ea..584ee981 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,11 @@ This repo contains a work-in-progress decompilation of Diddy Kong Racing for the Currently, only the US 1.0 version (SHA1 = 0cb115d8716dbbc2922fda38e533b9fe63bb9670) of the game is supported. US 1.1, EU 1.0, EU 1.1, and JP are not supported at this time. -As of February 22, 2025, this is our current score: +As of February 25, 2025, this is our current score: -    Decomp progress: 71.39% +    Decomp progress: 70.83% -    Documentation progress: 50.35% +    Documentation progress: 49.99% --- @@ -126,30 +126,30 @@ s32 is_drumstick_unlocked(void) { ``` -As of February 22nd, 2025, this is our current score: +As of February 25th, 2025, this is our current score: ``` =============================================== ADVENTURE ONE (ASM -> C Decompilation) - ---- 71.39% Complete (74.02% NON_MATCHING) ---- - # Decompiled functions: 1726 + ---- 70.83% Complete (73.99% NON_MATCHING) ---- + # Decompiled functions: 1808 # GLOBAL_ASM remaining: 133 # NON_MATCHING functions: 15 # NON_EQUIVALENT WIP functions: 44 ----------------- Game Status ----------------- - Balloons: 35/47, Keys: 4/4, Trophies: 3/5 + Balloons: 34/47, Keys: 4/4, Trophies: 3/5 T.T. Amulets: 3/4, Wizpig Amulets: 3/4 ----------------------------------------------- - We are racing the dragon boss Smokey. (Lap 1/3) + We are racing in Haunted Woods. (Lap 3/3) =============================================== ADVENTURE TWO (Cleanup & Documentation) - --------------- 50.35% Complete --------------- + --------------- 49.99% Complete --------------- # Documented functions: 1091 - # Undocumented remaining: 471 + # Undocumented remaining: 556 ----------------- Game Status ----------------- - Balloons: 25/47, Keys: 3/4, Trophies: 2/5 + Balloons: 24/47, Keys: 3/4, Trophies: 2/5 T.T. Amulets: 2/4, Wizpig Amulets: 2/4 ----------------------------------------------- - We are racing in Treasure Caves. (Lap 1/3) + We are racing in Pirate Lagoon. (Lap 3/3) =============================================== ``` diff --git a/asm/collision/func_80031600.s b/asm/collision/func_80031600.s index 343da3f6..0e58a121 100644 --- a/asm/collision/func_80031600.s +++ b/asm/collision/func_80031600.s @@ -238,7 +238,7 @@ glabel func_80031600 .L80031934: /* 032534 80031934 E4A00000 */ swc1 $f0, ($a1) /* 032538 80031938 E4A20004 */ swc1 $f2, 4($a1) -/* 03253C 8003193C 0800C655 */ j func_80031954 +/* 03253C 8003193C 0800C655 */ j .L80031954 /* 032540 80031940 E4A40008 */ swc1 $f4, 8($a1) .L80031944: /* 032544 80031944 2508FFFF */ addiu $t0, $t0, -1 @@ -246,7 +246,7 @@ glabel func_80031600 /* 032548 80031948 25AD0001 */ addiu $t5, $t5, 1 /* 03254C 8003194C 1500FF3C */ bnez $t0, .L80031640 /* 032550 80031950 25290004 */ addiu $t1, $t1, 4 -glabel func_80031954 +.L80031954: /* 032554 80031954 15E0FF33 */ bnez $t7, .L80031624 /* 032558 80031958 00000000 */ nop /* 03255C 8003195C 11C00008 */ beqz $t6, .L80031980 @@ -367,14 +367,14 @@ glabel func_80031954 .L80031B08: /* 032708 80031B08 E4A00000 */ swc1 $f0, ($a1) /* 03270C 80031B0C E4A20004 */ swc1 $f2, 4($a1) -/* 032710 80031B10 0800C6C9 */ j func_80031B24 +/* 032710 80031B10 0800C6C9 */ j .L80031B24 /* 032714 80031B14 E4A40008 */ swc1 $f4, 8($a1) .L80031B18: /* 032718 80031B18 2508FFFF */ addiu $t0, $t0, -1 .L80031B1C: /* 03271C 80031B1C 1500FFA0 */ bnez $t0, .L800319A0 /* 032720 80031B20 25290004 */ addiu $t1, $t1, 4 -glabel func_80031B24 +.L80031B24: /* 032724 80031B24 15E0FF99 */ bnez $t7, .L8003198C /* 032728 80031B28 00000000 */ nop /* 03272C 80031B2C 8FA80010 */ lw $t0, 0x10($sp) diff --git a/asm/non_matchings/printf/vsprintf.s b/asm/non_matchings/printf/vsprintf.s index 4f7c5f7a..16bb92a6 100644 --- a/asm/non_matchings/printf/vsprintf.s +++ b/asm/non_matchings/printf/vsprintf.s @@ -4,7 +4,7 @@ glabel jpt_800E8CAC glabel jpt_800E8CF0 .word L800B4DB0, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DB8, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4D90, L800B4DC4, L800B4DC4, L800B4DC4, L800B4D98, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC4, L800B4DC0 glabel jpt_800E8D88 -.word L800B52C4, amGetSfxCount, L800B5794, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, L800B4F84, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, L800B5AC4, L800B4E38, L800B52C4, L800B57A4, L800B5794, amGetSfxCount, L800B4E38, amGetSfxCount, amGetSfxCount, amGetSfxCount, amGetSfxCount, L800B5D78, L800B4F64, L800B5C8C, amGetSfxCount, amGetSfxCount, L800B5B48, amGetSfxCount, L800B4F44, amGetSfxCount, amGetSfxCount, L800B4FA4 +.word L800B52C4, L800B5E0C, L800B5794, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B4F84, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5AC4, L800B4E38, L800B52C4, L800B57A4, L800B5794, L800B5E0C, L800B4E38, L800B5E0C, L800B5E0C, L800B5E0C, L800B5E0C, L800B5D78, L800B4F64, L800B5C8C, L800B5E0C, L800B5E0C, L800B5B48, L800B5E0C, L800B4F44, L800B5E0C, L800B5E0C, L800B4FA4 .text glabel vsprintf @@ -288,7 +288,7 @@ glabel L800B4DC4 /* 0B5A08 800B4E08 266EFFBB */ addiu $t6, $s3, -0x45 /* 0B5A0C 800B4E0C 2DC10034 */ sltiu $at, $t6, 0x34 /* 0B5A10 800B4E10 256B0001 */ addiu $t3, $t3, 1 -/* 0B5A14 800B4E14 102003FD */ beqz $at, .amGetSfxCount +/* 0B5A14 800B4E14 102003FD */ beqz $at, L800B5E0C /* 0B5A18 800B4E18 A3B3019A */ sb $s3, 0x19a($sp) /* 0B5A1C 800B4E1C 000E7080 */ sll $t6, $t6, 2 /* 0B5A20 800B4E20 3C01800F */ lui $at, %hi(jpt_800E8D88) # $at, 0x800f @@ -1460,8 +1460,8 @@ glabel L800B5D78 /* 0B6A00 800B5E00 8C632EF0 */ lw $v1, %lo(D_800E2EF0)($v1) /* 0B6A04 800B5E04 10000004 */ b .L800B5E18 /* 0B6A08 800B5E08 00000000 */ nop -.amGetSfxCount: -glabel amGetSfxCount +.L800B5E0C: +glabel L800B5E0C /* 0B6A0C 800B5E0C 3C03800E */ lui $v1, %hi(D_800E2EF0) # $v1, 0x800e /* 0B6A10 800B5E10 8C632EF0 */ lw $v1, %lo(D_800E2EF0)($v1) /* 0B6A14 800B5E14 00000000 */ nop diff --git a/lib/asm/params.s b/lib/asm/params.s new file mode 100644 index 00000000..b30cf354 --- /dev/null +++ b/lib/asm/params.s @@ -0,0 +1,11 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800C9AF0 */ + +.include "macros.inc" + +.set noat # allow manual use of $at +.set noreorder # dont insert nops after branches +.set gp=64 # 64-bit instructions are used + +/* params.s - All libultra games have this padding */ +.space 0x40 diff --git a/lib/asm/spaces.s b/lib/asm/spaces.s deleted file mode 100644 index 5d17eb1a..00000000 --- a/lib/asm/spaces.s +++ /dev/null @@ -1,27 +0,0 @@ -/* The comment below is needed for this file to be picked up by generate_ld */ -/* RAM_POS: 0x800C9AF0 */ - -.include "macros.inc" - -.set noat # allow manual use of $at -.set noreorder # dont insert nops after branches -.set gp=64 # 64-bit instructions are used - -/* Hacky workaround. This is required because after alSynSetPriority, the linker seems to have added a bunch of nops. */ -glabel __NOPS_NEEDED -/* 0CA6F0 800C9AF0 00000000 */ nop -/* 0CA6F4 800C9AF4 00000000 */ nop -/* 0CA6F8 800C9AF8 00000000 */ nop -/* 0CA6FC 800C9AFC 00000000 */ nop -/* 0CA700 800C9B00 00000000 */ nop -/* 0CA704 800C9B04 00000000 */ nop -/* 0CA708 800C9B08 00000000 */ nop -/* 0CA70C 800C9B0C 00000000 */ nop -/* 0CA710 800C9B10 00000000 */ nop -/* 0CA714 800C9B14 00000000 */ nop -/* 0CA718 800C9B18 00000000 */ nop -/* 0CA71C 800C9B1C 00000000 */ nop -/* 0CA720 800C9B20 00000000 */ nop -/* 0CA724 800C9B24 00000000 */ nop -/* 0CA728 800C9B28 00000000 */ nop -/* 0CA72C 800C9B2C 00000000 */ nop diff --git a/tools/python/score.py b/tools/python/score.py index 1332532d..1bd0ae4f 100644 --- a/tools/python/score.py +++ b/tools/python/score.py @@ -12,7 +12,9 @@ ASM_FOLDERS = [ ] BLACKLIST = [ - '/non_matchings/' + '/non_matchings/', + '/assets/', + '/boot/' ] BLACKLIST_C = [ @@ -73,7 +75,9 @@ class DkrMapFile: address = int(line[18:18+8], 16) if address >= CODE_START and address < CODE_END: symbol = line[line.rfind(' ')+1:] - functions.append((symbol, address)) + if (not symbol.startswith(".L") and not symbol.startswith("L800") + and not self.contains_forbidden_func(symbol)): + functions.append((symbol, address)) functions.sort(key=lambda x:x[1]) # Sort by RAM address for i in range(0, len(functions) - 1): self.functionSizes[functions[i][0]] = functions[i + 1][1] - functions[i][1] @@ -82,6 +86,13 @@ class DkrMapFile: except FileNotFoundError: print("You must build a rom before it can be scored!") sys.exit() + + + def contains_forbidden_func(self, string): + for forbidden in ['__FUNC_RAM_START', 'cosf', 'sinf']: + if forbidden in string: + return True + return False MAP_FILE = DkrMapFile() @@ -219,13 +230,14 @@ def main(): scoreFiles.append(scoreFile) - totalNumberOfFunctions = totalNumberOfDecompiledFunctions + totalNumberOfGlobalAsms for asm_function in ASM_LABELS: if asm_function in MAP_FILE.functionSizes: + totalNumberOfDecompiledFunctions += 1 # Consider hand written asm as "decompiled" asmFuncSize = MAP_FILE.functionSizes[asm_function] totalSizeOfDecompiledFunctions += asmFuncSize totalSizeOfDecompiledAndNonMatchingFunctions += asmFuncSize - + + totalNumberOfFunctions = totalNumberOfDecompiledFunctions + totalNumberOfGlobalAsms adventureOnePercentage = (totalSizeOfDecompiledFunctions / CODE_SIZE) * 100 adventureOnePercentageWithNonMatching = (totalSizeOfDecompiledAndNonMatchingFunctions / CODE_SIZE) * 100 adventureTwoPercentage = (totalSizeOfDocumentedFunctions / (CODE_SIZE - ignoreSizeDocumentedFunctions)) * 100