From 63985a001145d5e3721c35c725ae981073d6e106 Mon Sep 17 00:00:00 2001 From: Tharo <17233964+Thar0@users.noreply.github.com> Date: Fri, 15 May 2020 23:53:58 +0100 Subject: [PATCH] Rename variables in code_800FD970 (#142) * Decompile code_800FD970 * Comment cleanups, ensure formatter won't cause a matching issue later * Make code_800FD970 variables static and rename * Delete data and bss asm files --- data/code_800FD970.bss.s | 11 ----------- data/code_800FD970.data.s | 11 ----------- src/code/code_800FD970.c | 28 ++++++++++++++-------------- 3 files changed, 14 insertions(+), 36 deletions(-) delete mode 100644 data/code_800FD970.bss.s delete mode 100644 data/code_800FD970.data.s diff --git a/data/code_800FD970.bss.s b/data/code_800FD970.bss.s deleted file mode 100644 index 9ae68ff307..0000000000 --- a/data/code_800FD970.bss.s +++ /dev/null @@ -1,11 +0,0 @@ -.include "macro.inc" - -# assembler directives -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 # allow use of 64-bit general purposee registers - -.section .bss - -glabel D_80175640 - .space 0x10 diff --git a/data/code_800FD970.data.s b/data/code_800FD970.data.s deleted file mode 100644 index 9e04642e93..0000000000 --- a/data/code_800FD970.data.s +++ /dev/null @@ -1,11 +0,0 @@ -.include "macro.inc" - -# assembler directives -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 # allow use of 64-bit general purposee registers - -.section .data - -glabel D_801344C0 - .incbin "baserom.z64", 0xBAB660, 0x10 diff --git a/src/code/code_800FD970.c b/src/code/code_800FD970.c index ba981a07bc..b99281774e 100644 --- a/src/code/code_800FD970.c +++ b/src/code/code_800FD970.c @@ -2,23 +2,23 @@ #include // The latest generated random number, used to generate the next number in the sequence. -u32 randomNumber = 1; +static u32 sRandInt = 1; // Space to store a value to be re-interpreted as a float. -u32 floatStore; +static u32 sRandFloat; /** * Gets the next integer in the sequence of pseudo-random numbers. */ u32 Math_Rand_Next() { - return randomNumber = (randomNumber * 1664525) + 1013904223; + return sRandInt = (sRandInt * 1664525) + 1013904223; } /** * Seeds the pseudo-random number generator by providing a starting value. */ void Math_Rand_Seed(u32 seed) { - randomNumber = seed; + sRandInt = seed; } /** @@ -27,9 +27,9 @@ void Math_Rand_Seed(u32 seed) { * between 1.0f and 2.0f, returning the result subtract 1.0f. */ f32 Math_Rand_ZeroOne() { - randomNumber = (randomNumber * 1664525) + 1013904223; - floatStore = ((randomNumber >> 9) | 0x3F800000); - return *((f32*)&floatStore) - 1.0f; + sRandInt = (sRandInt * 1664525) + 1013904223; + sRandFloat = ((sRandInt >> 9) | 0x3F800000); + return *((f32*)&sRandFloat) - 1.0f; } /** @@ -37,9 +37,9 @@ f32 Math_Rand_ZeroOne() { * manner in which Math_Rand_ZeroOne generates its result. */ f32 Math_Rand_Centered() { - randomNumber = (randomNumber * 1664525) + 1013904223; - floatStore = ((randomNumber >> 9) | 0x3F800000); - return *((f32*)&floatStore) - 1.5f; + sRandInt = (sRandInt * 1664525) + 1013904223; + sRandFloat = ((sRandInt >> 9) | 0x3F800000); + return *((f32*)&sRandFloat) - 1.5f; } /** @@ -65,9 +65,9 @@ f32 Math_Rand_ZeroOne_Variable(u32* rndNum) { next = (*rndNum * 1664525) + 1013904223; // clang-format off - *rndNum = next; floatStore = (next >> 9) | 0x3F800000; + *rndNum = next; sRandFloat = (next >> 9) | 0x3F800000; // clang-format on - return *((f32*)&floatStore) - 1.0f; + return *((f32*)&sRandFloat) - 1.0f; } /** @@ -79,7 +79,7 @@ f32 Math_Rand_Centered_Variable(u32* rndNum) { next = (*rndNum * 1664525) + 1013904223; // clang-format off - *rndNum = next; floatStore = (next >> 9) | 0x3F800000; + *rndNum = next; sRandFloat = (next >> 9) | 0x3F800000; // clang-format on - return *((f32*)&floatStore) - 1.5f; + return *((f32*)&sRandFloat) - 1.5f; }