Clean up math_util.s (#649)

* Update some submodules, and tweak some printf code to more closely match the exact names and style of the official glibc version

* Update some offsets

* Clean up math_util.s, and figure out how to fix the sins functions just being labels. Now the elf file properly shows up as a function with the correct offset.

* Fix tables, and clean up some float values
This commit is contained in:
Ryan Myers
2025-06-26 07:32:25 -04:00
committed by GitHub
parent a6533ddb1d
commit 55293e4f6e
11 changed files with 1562 additions and 1419 deletions
+7
View File
@@ -29,3 +29,10 @@
\label:
.ent \label
.endm
# Used for alternative entries for Sin functions
.macro altleaf label
.global \label
\label:
.aent \label
.endm
+2 -2
View File
@@ -351,8 +351,8 @@ typedef struct HudElement {
/* 0x06 */ s16 spriteID;
/* 0x08 */ f32 scale;
/* 0x0C */ Vec3f pos;
/* 0x14 */ s16 spriteOffset;
/* 0x16 */ union {
/* 0x18 */ s16 spriteOffset;
/* 0x1A */ union {
u8 filler[4]; // Ensures this union is 6 bytes, since Rare never actually use more than four.
HudElement_ChallengeEggs challengeEggs;
HudElement_RaceStartGo raceStartGo;
+1517 -1381
View File
File diff suppressed because one or more lines are too long
+24 -24
View File
@@ -142,16 +142,6 @@ Gfx dDebugFontSettings[] = {
/*******************************/
/************ .rodata ************/
const char gLowerCase[] = "0123456789abcdefghijklmnopqrstuvwxyz";
const char gUpperCase[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const char D_800E8C50[] = "";
const char D_800E8C54[] = "(null)";
const char D_800E8C5C[] = "(nil)";
/*********************************/
/************ .bss ************/
TextureHeader *gTexture[3];
@@ -174,20 +164,24 @@ char *gDebugPrintBufferEnd;
/******************************/
const char _itoa_lower_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
const char _itoa_upper_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/**
* Standard C Library function that converts integers to strings.
* Exact match to glibc 1.09 version.
*/
char *_itoa(u64 n, char *outBuffer, u32 radix, s32 useUpperCase) {
char *alphabet;
char *buffer;
char *_itoa(unsigned long long int n, char *buflim, unsigned int base, int upper_case) {
/* Base-36 digits for numbers. */
const char *alphabet = upper_case ? _itoa_upper_digits : _itoa_lower_digits;
register char *bp = buflim;
alphabet = (useUpperCase) ? (char *) gUpperCase : (char *) gLowerCase;
for (buffer = outBuffer; n > 0; n /= radix) {
*(--buffer) = alphabet[n % radix];
while (n > 0) {
*(--bp) = alphabet[n % base];
n /= base;
}
return buffer;
return bp;
}
/**
@@ -199,15 +193,18 @@ void sprintfSetSpacingCodes(s32 setting) {
}
/**
* Exact match to glibc 1.09 version.
* Official name: sprintf
*/
UNUSED int sprintf(char *s, const char *format, ...) {
s32 ret;
va_list args;
va_start(args, format);
ret = vsprintf(s, format, args);
va_end(args);
return ret;
va_list arg;
int done;
va_start(arg, format);
done = vsprintf(s, format, arg);
va_end(arg);
return done;
}
#define outchar(x) \
@@ -934,6 +931,9 @@ int vsprintf(char *s, const char *fmt, va_list args) {
}
#else
#pragma GLOBAL_ASM("asm/nonmatchings/printf/vsprintf.s")
const char D_800E8C50[] = "";
const char D_800E8C54[] = "(null)";
const char D_800E8C5C[] = "(nil)";
#endif
/**
+2 -2
View File
@@ -3454,8 +3454,8 @@ D_800E8B10 = 0x800EA5C0;
D_800E8B44 = 0x800EA5F4;
// printf.c .rodata size:0x270
gLowerCase = 0x800EA6B0; // type:asciz force_not_migration:true defined:true
gUpperCase = 0x800EA6D8; // type:asciz force_not_migration:true defined:true
_itoa_lower_digits = 0x800EA6B0; // type:asciz force_not_migration:true defined:true
_itoa_upper_digits = 0x800EA6D8; // type:asciz force_not_migration:true defined:true
D_800E8C50 = 0x800EA700; // type:asciz force_not_migration:true defined:true
D_800E8C54 = 0x800EA704; // type:asciz force_not_migration:true defined:true
D_800E8C5C = 0x800EA70C; // type:asciz force_not_migration:true defined:true
+2 -2
View File
@@ -3203,8 +3203,8 @@ D_800E8AB4 = 0x800E8B44;
D_800E8AD8 = 0x800E8B68;
D_800E8B10 = 0x800E8BA0;
D_800E8B44 = 0x800E8BD4;
gLowerCase = 0x800E8C90; // type:asciz force_not_migration:true defined:true
gUpperCase = 0x800E8CB8; // type:asciz force_not_migration:true defined:true
_itoa_lower_digits = 0x800E8C90; // type:asciz force_not_migration:true defined:true
_itoa_upper_digits = 0x800E8CB8; // type:asciz force_not_migration:true defined:true
D_800E8C50 = 0x800E8CE0; // type:asciz force_not_migration:true defined:true
D_800E8C54 = 0x800E8CE4; // type:asciz force_not_migration:true defined:true
D_800E8C5C = 0x800E8CEC; // type:asciz force_not_migration:true defined:true
+2 -2
View File
@@ -3133,8 +3133,8 @@ D_800E8AB4 = 0x800E90C4;
D_800E8AD8 = 0x800E90E8;
D_800E8B10 = 0x800E9120;
D_800E8B44 = 0x800E9154;
gLowerCase = 0x800E9210; // type:asciz force_not_migration:true defined:true
gUpperCase = 0x800E9238; // type:asciz force_not_migration:true defined:true
_itoa_lower_digits = 0x800E9210; // type:asciz force_not_migration:true defined:true
_itoa_upper_digits = 0x800E9238; // type:asciz force_not_migration:true defined:true
D_800E8C50 = 0x800E9260; // type:asciz force_not_migration:true defined:true
D_800E8C54 = 0x800E9264; // type:asciz force_not_migration:true defined:true
D_800E8C5C = 0x800E926C; // type:asciz force_not_migration:true defined:true
+2 -2
View File
@@ -3554,8 +3554,8 @@ D_800E8B10 = 0x800E8B10;
D_800E8B44 = 0x800E8B44;
// printf.c .rodata size:0x270
gLowerCase = 0x800E8C00; // type:asciz force_not_migration:true defined:true
gUpperCase = 0x800E8C28; // type:asciz force_not_migration:true defined:true
_itoa_lower_digits = 0x800E8C00; // type:asciz force_not_migration:true defined:true
_itoa_upper_digits = 0x800E8C28; // type:asciz force_not_migration:true defined:true
D_800E8C50 = 0x800E8C50; // type:asciz force_not_migration:true defined:true
D_800E8C54 = 0x800E8C54; // type:asciz force_not_migration:true defined:true
D_800E8C5C = 0x800E8C5C; // type:asciz force_not_migration:true defined:true
+2 -2
View File
@@ -3129,8 +3129,8 @@ D_800E8AB4 = 0x800E9034;
D_800E8AD8 = 0x800E9058;
D_800E8B10 = 0x800E9090;
D_800E8B44 = 0x800E90C4;
gLowerCase = 0x800E9180; // type:asciz force_not_migration:true defined:true
gUpperCase = 0x800E91A8; // type:asciz force_not_migration:true defined:true
_itoa_lower_digits = 0x800E9180; // type:asciz force_not_migration:true defined:true
_itoa_upper_digits = 0x800E91A8; // type:asciz force_not_migration:true defined:true
D_800E8C50 = 0x800E91D0; // type:asciz force_not_migration:true defined:true
D_800E8C54 = 0x800E91D4; // type:asciz force_not_migration:true defined:true
D_800E8C5C = 0x800E91DC; // type:asciz force_not_migration:true defined:true