From 95eef02120efeeb8b830752df4b8de7007345bec Mon Sep 17 00:00:00 2001 From: Antonio Date: Sun, 12 Dec 2021 21:01:34 -0800 Subject: [PATCH] Renamed function checksum + length variables. --- asm/non_matchings/unknown_003260/audioNewThread.s | 8 ++++---- src/object_models.c | 8 ++++---- src/object_models.h | 4 ++-- src/unknown_003260.c | 4 ++-- src/unknown_003260.h | 4 ++-- src/unknown_043920.c | 8 ++++---- src/unknown_043920.h | 4 ++-- tools/python/calc_func_checksums.py | 10 +++++----- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/asm/non_matchings/unknown_003260/audioNewThread.s b/asm/non_matchings/unknown_003260/audioNewThread.s index 8ec5d4ce..d11e48ce 100644 --- a/asm/non_matchings/unknown_003260/audioNewThread.s +++ b/asm/non_matchings/unknown_003260/audioNewThread.s @@ -150,8 +150,8 @@ glabel audioNewThread /* 003498 80002898 AE420010 */ sw $v0, 0x10($s2) /* 00349C 8000289C 25AD9808 */ addiu $t5, %lo(func_80019808) # addiu $t5, $t5, -0x67f8 /* 0034A0 800028A0 A1000000 */ sb $zero, ($t0) -/* 0034A4 800028A4 3C05800E */ lui $a1, %hi(D_800DC694) # $a1, 0x800e -/* 0034A8 800028A8 8CA5C694 */ lw $a1, %lo(D_800DC694)($a1) +/* 0034A4 800028A4 3C05800E */ lui $a1, %hi(gFunc80019808Length) # $a1, 0x800e +/* 0034A8 800028A8 8CA5C694 */ lw $a1, %lo(gFunc80019808Length)($a1) /* 0034AC 800028AC 01A61823 */ subu $v1, $t5, $a2 /* 0034B0 800028B0 00C33821 */ addu $a3, $a2, $v1 /* 0034B4 800028B4 00008825 */ move $s1, $zero @@ -169,8 +169,8 @@ glabel audioNewThread /* 0034E0 800028E0 1420FFF8 */ bnez $at, .L800028C4 /* 0034E4 800028E4 006E1821 */ addu $v1, $v1, $t6 .L800028E8: -/* 0034E8 800028E8 3C19800E */ lui $t9, %hi(D_800DC690) # $t9, 0x800e -/* 0034EC 800028EC 8F39C690 */ lw $t9, %lo(D_800DC690)($t9) +/* 0034E8 800028E8 3C19800E */ lui $t9, %hi(gFunc80019808Checksum) # $t9, 0x800e +/* 0034EC 800028EC 8F39C690 */ lw $t9, %lo(gFunc80019808Checksum)($t9) /* 0034F0 800028F0 3C108011 */ lui $s0, %hi(D_80115F98) # $s0, 0x8011 /* 0034F4 800028F4 10790003 */ beq $v1, $t9, .L80002904 /* 0034F8 800028F8 26105F98 */ addiu $s0, %lo(D_80115F98) # addiu $s0, $s0, 0x5f98 diff --git a/src/object_models.c b/src/object_models.c index d83ab093..45d4f6a8 100644 --- a/src/object_models.c +++ b/src/object_models.c @@ -10,8 +10,8 @@ /************ .data ************/ -s32 D_800DCEA0 = 116315; //func_80024D54 checksum -s32 D_800DCEA4 = 1980; +s32 gFunc80024D54Checksum = 116315; +s32 gFunc80024D54Length = 1980; /*******************************/ @@ -63,10 +63,10 @@ void func_8005F850(void) { // Anti-tamper check. checksum = 0; - for (i = 0; i < D_800DCEA4; i++) { + for (i = 0; i < gFunc80024D54Length; i++) { checksum += *(u8 *)(((s32)&func_80024D54) + i); } - if (checksum != D_800DCEA0) { + if (checksum != gFunc80024D54Checksum) { func_8005C25C(); } } diff --git a/src/object_models.h b/src/object_models.h index 77def6e7..b47d2f15 100644 --- a/src/object_models.h +++ b/src/object_models.h @@ -11,8 +11,8 @@ typedef struct unk8011D624 { ObjectModel *model; } unk8011D624; -extern s32 D_800DCEA0; -extern s32 D_800DCEA4; +extern s32 gFunc80024D54Checksum; +extern s32 gFunc80024D54Length; void func_8005F850(void); void func_800619F4(s32 arg0); diff --git a/src/unknown_003260.c b/src/unknown_003260.c index ada655a2..e2229e53 100644 --- a/src/unknown_003260.c +++ b/src/unknown_003260.c @@ -44,8 +44,8 @@ u32 audFrameCt = 0; // Currently unknown, might be a different type. s32 D_800DC684 = 0; // Currently unknown, might be a different type. s32 D_800DC688 = 0; // Currently unknown, might be a different type. s32 D_800DC68C = 0; // Currently unknown, might be a different type. -s32 D_800DC690 = 0x35281; // Checksum of func_80019808 -s32 D_800DC694 = 0xFD0; // Size of func_80019808 (for checksum). +s32 gFunc80019808Checksum = 0x35281; +s32 gFunc80019808Length = 0xFD0; s32 D_800DC698 = 0; // Currently unknown, might be a different type. s32 D_800DC69C = 0; // Currently unknown, might be a different type. s32 D_800DC6A0 = 1; // Currently unknown, might be a different type. diff --git a/src/unknown_003260.h b/src/unknown_003260.h index e65d2f78..dcacce3b 100644 --- a/src/unknown_003260.h +++ b/src/unknown_003260.h @@ -85,8 +85,8 @@ extern u32 audFrameCt; extern s32 D_800DC684; extern s32 D_800DC688; extern s32 D_800DC68C; -extern s32 D_800DC690; -extern s32 D_800DC694; +extern s32 gFunc80019808Checksum; +extern s32 gFunc80019808Length; extern s32 D_800DC698; extern s32 D_800DC69C; extern s32 D_800DC6A0; diff --git a/src/unknown_043920.c b/src/unknown_043920.c index 8414f44f..ad7e380f 100644 --- a/src/unknown_043920.c +++ b/src/unknown_043920.c @@ -21,7 +21,7 @@ /************ .data ************/ -s32 D_800DCB50 = 0x310; +s32 gFunc8003B4BCLength = 0x310; s16 D_800DCB54 = 0; s32 D_800DCB58 = 0; // Currently unknown, might be a different type. s32 D_800DCB5C = 0; // Currently unknown, might be a different type. @@ -111,7 +111,7 @@ s16 D_800DCDB0[16] = { }; // Checksum count for func_8003B4BC -s32 D_800DCDD0 = 42391; +s32 gFunc8003B4BCChecksum = 42391; s16 D_800DCDD4[4] = { 0, 0, 0x32, -1 @@ -922,11 +922,11 @@ void func_8005A3D0(void) { s32 count = 0; u8 *temp = (u8 *)&func_8003B4BC; - for (i = 0; i < D_800DCB50; i++) { + for (i = 0; i < gFunc8003B4BCLength; i++) { count += temp[i]; } - if (count != D_800DCDD0) { + if (count != gFunc8003B4BCChecksum) { D_800DCB54 = 0x800; } } diff --git a/src/unknown_043920.h b/src/unknown_043920.h index 8fc6c2ad..a0c5670d 100644 --- a/src/unknown_043920.h +++ b/src/unknown_043920.h @@ -147,7 +147,7 @@ typedef struct unk8005C270 { s8 unk193; } unk8005C270; -extern s32 D_800DCB50; +extern s32 gFunc8003B4BCLength; extern s16 D_800DCB54; extern s32 D_800DCB58; extern s32 D_800DCB5C; @@ -185,7 +185,7 @@ extern s8 D_800DCDA8[8]; // Unused? extern s16 D_800DCDB0[16]; -extern s32 D_800DCDD0; +extern s32 gFunc8003B4BCChecksum; extern s16 D_800DCDD4[4]; diff --git a/tools/python/calc_func_checksums.py b/tools/python/calc_func_checksums.py index bbe33767..1bca8970 100644 --- a/tools/python/calc_func_checksums.py +++ b/tools/python/calc_func_checksums.py @@ -11,10 +11,10 @@ MAP_FILEPATH = BUILD_DIR + '/dkr.map' ROM_FILEPATH = BUILD_DIR + '/dkr.z64' FUNCTIONS_TO_CALC = [ - # function checksum func size - ('func_80019808', 'D_800DC690', 'D_800DC694'), - ('func_80024D54', 'D_800DCEA0', 'D_800DCEA4'), - ('func_8003B4BC', 'D_800DCDD0', 'D_800DCB50'), + # function checksum variable func size variable + ('func_80019808', 'gFunc80019808Checksum', 'gFunc80019808Length'), + ('func_80024D54', 'gFunc80024D54Checksum', 'gFunc80024D54Length'), + ('func_8003B4BC', 'gFunc8003B4BCChecksum', 'gFunc8003B4BCLength'), ('func_80068158', 'gFunc80068158Checksum', 'gFunc80068158Length') ] @@ -52,7 +52,7 @@ def calculate_checksum_for_function(funcLabel, varLabel, funcSizeLabel): count = 0 for i in range(0, funcLength): count += rom[funcRomOffset + i] - # Save checksum. + # Save function checksum. varEntry = mapFile[varLabel] varAddress = varEntry['value'] varRomOffset = varAddress - RAM_TO_ROM