various building updates, ovl_5E compiled w/ rodata/data

This commit is contained in:
Rainchus 2023-04-09 22:12:46 -05:00
parent b11b47b164
commit 64ba4ee3c9
17 changed files with 591 additions and 83 deletions

View File

@ -85,9 +85,9 @@ ENDLINE := \n'
ASFLAGS := -G 0 -I include -mips3 -mabi=32
CFLAGS := -G0 -mips3 -mgp32 -mfp32 -Wa,--vr4300mul-off -D_LANGUAGE_C
CPPFLAGS := -I include -I include/PR -I include/engine -I include/gcc -I $(BUILD_DIR)/include -I src -DF3DEX_GBI_2
CPPFLAGS := -I. -I include -I include/PR -I include/engine -I include/gcc -I $(BUILD_DIR)/include -I src -DF3DEX_GBI_2
LDFLAGS := -T symbol_addrs.txt -T undefined_syms.txt -T undefined_funcs.txt -T undefined_funcs_auto.txt -T undefined_syms_auto.txt -T $(LD_SCRIPT) -Map $(LD_MAP) --no-check-sections
CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -m32
CHECK_WARNINGS := -Wall -Wextra -Wunused-but-set-variable -Wno-format-security -Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -m32
CFLAGS_CHECK := -fsyntax-only -fsigned-char -nostdinc -fno-builtin -D CC_CHECK -D _LANGUAGE_C -std=gnu90 $(CHECK_WARNINGS)
ifneq ($(CHECK),1)

View File

@ -20,15 +20,15 @@ else:
# fix patch applied by mod_configure if it exist
# open the file for reading
with open('src/engine/gameman.c', 'r') as f:
filedata = f.read()
# with open('src/engine/gameman.c', 'r') as f:
# filedata = f.read()
# replace the string 'cPerFrameFunction' with 'SleepVProcess'
newdata = filedata.replace('cPerFrameFunction', 'SleepVProcess')
# # replace the string 'cPerFrameFunction' with 'SleepVProcess'
# newdata = filedata.replace('cPerFrameFunction', 'SleepVProcess')
# open the file for writing and write the updated content
with open('src/engine/gameman.c', 'w') as f:
f.write(newdata)
# # open the file for writing and write the updated content
# with open('src/engine/gameman.c', 'w') as f:
# f.write(newdata)
with open('build.ninja', 'w') as f:
f.write(f'DETECTED_OS = {DETECTED_OS}\n')
@ -46,7 +46,7 @@ header = (
'CFLAGS = -G0 -mips3 -mgp32 -mfp32 -Wa,--vr4300mul-off -D_LANGUAGE_C\n'
'CPPFLAGS = -I. -I include -I include/PR -I include/engine -I include/gcc -I build/include -I src -DF3DEX_GBI_2 -DNDEBUG\n'
'LDFLAGS = -T symbol_addrs.txt -T undefined_syms.txt -T undefined_funcs.txt -T undefined_funcs_auto.txt -T undefined_syms_auto.txt -T $LD_SCRIPT -Map $LD_MAP --no-check-sections\n'
'CHECK_WARNINGS = -Wall -Wextra -Wno-format-security -Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -m32\n'
'CHECK_WARNINGS = -Wall -Wextra -Wunused-but-set-variable -Wno-format-security -Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -m32\n'
'CFLAGS_CHECK = -fsyntax-only -fsigned-char -nostdinc -fno-builtin -D CC_CHECK -D _LANGUAGE_C -std=gnu90 $CHECK_WARNINGS\n'
'AS = mips-linux-gnu-as\n'
'LD = mips-linux-gnu-ld\n'

View File

@ -15,7 +15,7 @@ typedef struct OverlayInfo {
extern u8 D_800C1C70;
extern OverlayInfo D_800C1C74[];
extern OverlayInfo overlay_table[];
extern Vec4f D_800C2F94[];
extern Vec3f D_800C2F04[];
extern Vec3f D_800C2F4C[];

View File

@ -80,7 +80,7 @@ void func_8004E0E8(s32);
Process* func_80041C04(s16);
void SetPlayerLandedSpaceType(s16, u8);
void ShowPlayerCoinChange(s32, s32);
void func_800415CC(s16, s16);
void func_800415CC(s16, s32);
Process* func_800419D8(s16);
Process* func_80048000(s32);
void func_8005884C(Vec3f*);

View File

@ -1528,8 +1528,8 @@ segments:
exclusive_ram_id: minigame
subsegments:
- [0x298AE0, c]
- type: bin
start: 0x29A2C0
- [0x29A2C0, .data, 298AE0]
- [0x29A3D0, .rodata, 298AE0]
- type: code
start: 0x29A400
vram: 0x800F65E0

View File

@ -36,7 +36,7 @@ header = (
'CFLAGS = -G0 -mips3 -mgp32 -mfp32 -Wa,--vr4300mul-off -D_LANGUAGE_C\n'
'CPPFLAGS = -I. -I include -I include/PR -I include/engine -I include/gcc -I build/include -I src -DF3DEX_GBI_2 -DNDEBUG\n'
'LDFLAGS = -T symbol_addrs.txt -T undefined_syms.txt -T undefined_funcs.txt -T undefined_funcs_auto.txt -T undefined_syms_auto.txt -T $LD_SCRIPT -Map $LD_MAP --no-check-sections\n'
'CHECK_WARNINGS = -Wall -Wextra -Wno-format-security -Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -m32\n'
'CHECK_WARNINGS = -Wall -Wextra -Wunused-but-set-variable -Wno-format-security -Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -m32\n'
'CFLAGS_CHECK = -fsyntax-only -fsigned-char -nostdinc -fno-builtin -D CC_CHECK -D _LANGUAGE_C -std=gnu90 $CHECK_WARNINGS\n'
'AS = mips-linux-gnu-as\n'
'LD = mips-linux-gnu-ld\n'
@ -121,23 +121,23 @@ with open('asm/nonmatchings/59E80/func_8005B6D0.s', 'w') as file:
file.writelines(lines)
# define the path to the file we want to modify
filepath = "src/engine/gameman.c"
# # define the path to the file we want to modify
# filepath = "src/engine/gameman.c"
# read in the contents of the file
with open(filepath, "r") as f:
filedata = f.read()
# # read in the contents of the file
# with open(filepath, "r") as f:
# filedata = f.read()
# define the text we want to search for and replace
old_text = "void func_8001A454(void) {\n while (1) {\n SleepVProcess();"
new_text = "void func_8001A454(void) {\n while (1) {\n cPerFrameFunction();"
# # define the text we want to search for and replace
# old_text = "void func_8001A454(void) {\n while (1) {\n SleepVProcess();"
# new_text = "void func_8001A454(void) {\n while (1) {\n cPerFrameFunction();"
# do the replacement
filedata = filedata.replace(old_text, new_text)
# # do the replacement
# filedata = filedata.replace(old_text, new_text)
# write the modified contents back to the file
with open(filepath, "w") as f:
f.write(filedata)
# # write the modified contents back to the file
# with open(filepath, "w") as f:
# f.write(filedata)
file_path = "src/mod/mod_boot_func_hook.s"
@ -174,21 +174,21 @@ J 0x8005B730
nop
""")
file_path = "src/mod/mod_main.c"
# file_path = "src/mod/mod_main.c"
if not os.path.exists(file_path):
with open(file_path, "w") as f:
f.write("""\
#include "common.h"
# if not os.path.exists(file_path):
# with open(file_path, "w") as f:
# f.write("""\
# #include "common.h"
void cBootFunction(void) {
//
}
# void cBootFunction(void) {
# //
# }
void cPerFrameFunction(void) {
SleepVProcess(); //restore from hook
}
""")
# void cPerFrameFunction(void) {
# SleepVProcess(); //restore from hook
# }
# """)

View File

@ -1,5 +1,6 @@
compiler_command = "tools/gcc_2.7.2/linux/gcc -w -Ibuild/include -Iinclude -Isrc -Iassets/us -D_LANGUAGE_C -D_FINALROM -DVERSION=us -DF3DEX_GBI_2 -D_MIPS_SZLONG=32 -nostdinc -c -O1 -G0 -mips3 -mgp32 -mfp32 -fno-common -B tools/gcc_2.7.2/linux/ -Wuninitialized -Wmissing-braces -Wimplicit -Wredundant-decls -Wstrict-prototypes -DPERMUTER"
compiler_command = "tools/gcc_2.7.2/linux/gcc -w -I. -I include -I include/PR -I include/engine -I include/gcc -D_LANGUAGE_C -D_FINALROM -DVERSION=us -DF3DEX_GBI_2 -D_MIPS_SZLONG=32 -nostdinc -c -O1 -G0 -mips3 -mgp32 -mfp32 -fno-common -B tools/gcc_2.7.2/linux/ -Wuninitialized -Wmissing-braces -Wimplicit -Wredundant-decls -Wstrict-prototypes -DPERMUTER"
assembler_command = "mips-linux-gnu-as -EB -march=vr4300 -mtune=vr4300 -Iinclude -G 0 -I include -mips3 -mabi=32"
compiler_type = "gcc"
[preserve_macros]
"gs?[DS]P.*" = "void"

View File

@ -3,7 +3,7 @@
/* TODO: set .data here. */
// u8 D_800C1C70;
// OverlayInfo D_800C1C74[];
// OverlayInfo overlay_table[];
// Vec4f D_800C2F94[];
// Vec3f D_800C2F04[];
// Vec3f D_800C2F4C[];
@ -44,12 +44,12 @@ void LoadOverlay(s32 overlayIndex) {
u8 *bss_end;
u8 *temp;
rom_start = D_800C1C74[overlayIndex].rom_start;
rom_end = D_800C1C74[overlayIndex].rom_end;
bss_start = D_800C1C74[overlayIndex].bss_start;
bss_end = D_800C1C74[overlayIndex].bss_end;
rom_start = overlay_table[overlayIndex].rom_start;
rom_end = overlay_table[overlayIndex].rom_end;
bss_start = overlay_table[overlayIndex].bss_start;
bss_end = overlay_table[overlayIndex].bss_end;
HuRomDmaCodeRead(rom_start, D_800C1C74[overlayIndex].ram_start, rom_end - rom_start);
HuRomDmaCodeRead(rom_start, overlay_table[overlayIndex].ram_start, rom_end - rom_start);
temp = bss_start;
while (bss_start < bss_end) {

View File

@ -26,6 +26,6 @@ void func_800F8608_284848(void);
void func_800F8C6C_284EAC(void);
void func_800F8DF4_285034(void);
void func_800F8C20_284E60(unkObjectStruct*);
void func_8004DBD4(s32, u8); //for some reason defined differently between files
void func_8004DBD4(s32, u8);
void func_800F8B1C_284D5C(void);

View File

@ -1,6 +1,97 @@
#include "common.h"
#include "298AE0.h"
Object* D_800F7DC0_29A2C0 = 0;
Object* D_800F7DC4_29A2C4 = 0;
s32 D_800F7DC8_29A2C8 = 0;
s32 D_800F7DCC_29A2CC = 0;
s32 D_800F7DD0_29A2D0 = 0;
Vec3f D_800F7DD4_29A2D4 = {-115.0f, 0.0f, 1120.0f};
Vec3f D_800F7DE0_29A2E0 = {115.0f, 0.0f, 1520.0f};
Vec3f D_800F7DEC_29A2EC = {0.0f, 0.0f, 1250.0f};
typedef struct unk_ovl5E_Struct0 {
s32 unk0;
s32 unk4;
s32 unk8;
s32 unkC;
s32 unk10;
s32 unk14;
s32 unk18;
} unk_ovl5E_Struct0;
s32 D_800F7DF8_29A2F8[] = {
0x00000004, 0x000A00E7,
0x000A00E8, 0x000A00E9,
0x000A00EC
};
unk_ovl5E_Struct0 D_800F7E0C_29A30C[] = {
{
0x00000006, 0x00010003,
0x00010000, 0x000A008B,
0x00010018, 0x0001000F,
0x0001003F
}
};
unk_ovl5E_Struct0 D_800F7E28_29A328[] = {
{
0x00000006, 0x00020003,
0x00020000, 0x000A008C,
0x00020018, 0x0002000F,
0x0002003F
}
};
unk_ovl5E_Struct0 D_800F7E44_29A344[] = {
{
0x00000006, 0x00060003,
0x00060000, 0x000A008D,
0x00060018, 0x0006000F,
0x0006003F
}
};
unk_ovl5E_Struct0 D_800F7E60_29A360[] = {
{
0x00000006, 0x00030003,
0x00030000, 0x000A008E,
0x00030018, 0x0003000F,
0x0003003F
}
};
unk_ovl5E_Struct0 D_800F7E7C_29A37C[] = {
{
0x00000006, 0x00040003,
0x00040000, 0x000A008F,
0x00040018, 0x0004000F,
0x0004003F
}
};
unk_ovl5E_Struct0 D_800F7E98_29A398[] = {
{
0x00000006, 0x00050003,
0x00050000, 0x000A0090,
0x00050018, 0x0005000F,
0x0005003F
}
};
unk_ovl5E_Struct0* D_800F7EB4_29A3B4[] = {
D_800F7E0C_29A30C,
D_800F7E28_29A328,
D_800F7E44_29A344,
D_800F7E60_29A360,
D_800F7E7C_29A37C,
D_800F7E98_29A398
};
const u8 D_800F7ED0_29A3D0[4] = {1, 2, 4, 8};
void func_800F65E0_298AE0(void) {
D_800F7F00 = D_800ED5DD;
InitObjSystem(50, 50);
@ -22,7 +113,7 @@ void func_800F65E0_298AE0(void) {
}
}
void func_800F66D8_298BD8(s32 arg0) {
s32 func_800F66D8_298BD8(s32 arg0) {
s16 sp18[4];
unk_ovl_5E sp20;
s32 i;
@ -49,12 +140,312 @@ void func_800F66D8_298BD8(s32 arg0) {
} else {
func_800710A4(sp18[0], sp18[1], sp18[2], sp18[3]);
}
func_8006FCF0(arg0, 0, 1);
return func_8006FCF0(arg0, 0, 1);
}
INCLUDE_ASM(s32, "ovl_5E_StarVisitEternalStar/298AE0", func_800F6898_298D98);
void SleepProcess(s32);
void func_80040780(u8);
void func_800415B0(u8, s32);
s8 func_800415E8(u8);
s32 func_8004D8A4(void);
void func_8004DBD4(s32, u8);
void func_80055994(u8, s32);
extern s32 D_800F3FF0;
extern u16 D_800F5460[];
INCLUDE_ASM(s32, "ovl_5E_StarVisitEternalStar/298AE0", func_800F76D4_299BD4);
void func_800F6898_298D98(void) {
Object* Obj;
f32 temp_f20;
s32 windowID;
s32 var_s0;
s32 var_s2;
s32 temp_s1;
s32 i;
u8 array[2];
Vec3f* vec;
func_80040780(D_800F7F00);
func_800415CC(D_800F7F00, (((GetRandomByte() & 0xFF) % 3) & 0xFF) + 8);
SleepProcess(0x14);
func_8004F4D4(D_800F7F08, 0, 2);
func_8004E3E0(0, &D_800F7DEC_29A2EC, 0x14, D_800F7F08);
SleepProcess(0xF);
func_8004F4D4(D_800F7F08, 3, 0);
func_8004F40C(D_800F7F08, 1, 2);
func_8004EE14(0, D_800F32A0, 0xA, D_800F7F08);
func_8004F9F4(D_800F7F0C, D_800F7F08->coords.x, D_800F7F08->coords.y - 22.0f, D_800F7F08->coords.z + 50.0f, 1);
SleepProcess(3);
func_8004F9F4(D_800F7F0C, D_800F7F08->coords.x + 20.0f, D_800F7F08->coords.y - 22.0f, D_800F7F08->coords.z + 50.0f, 1);
SleepProcess(3);
func_8004F9F4(D_800F7F0C, D_800F7F08->coords.x - 20.0f, D_800F7F08->coords.y - 22.0f, D_800F7F08->coords.z + 50.0f, 1);
SleepProcess(4);
var_s0 = 0;
var_s2 = 0;
temp_s1 = 0;
while (var_s0 != 2) {
switch (var_s0) {
case 0:
if (((gPlayers[D_800F7F00].unk_06 & 1) && (var_s2 >= 0xF)) || (!(gPlayers[D_800F7F00].unk_06 & 1) && (D_800F5460[gPlayers[D_800F7F00].flags] & 0x8000))) {
var_s0 = 1;
func_8003E81C(D_800F7F08, 2, 0);
func_8004F40C(D_800F7F08, 1, 2);
}
break;
case 1:
if (++temp_s1 == 5) {
var_s0 = 2;
func_800413B0(D_800F7F00);
}
break;
}
var_s2++;
SleepVProcess();
}
SleepProcess(0x28);
array[0] = func_800415E8(D_800F7F00);
func_800405DC(D_800F7F00);
func_8004F4D4(D_800F7F08, 0, 2);
func_8004E3E0(0, &D_800F7DE0_29A2E0, 0x14, D_800F7F08);
SleepProcess(0xF);
func_8004F4D4(D_800F7F08, 3, 0);
func_8004F40C(D_800F7F08, 1, 2);
func_8004EE14(0, &D_800F7DD4_29A2D4, 0xA, D_800F7F08);
func_8004F9F4(D_800F7F0C, D_800F7F08->coords.x, D_800F7F08->coords.y - 22.0f, D_800F7F08->coords.z + 50.0f, 1);
SleepProcess(3);
func_8004F9F4(D_800F7F0C, D_800F7F08->coords.x + 20.0f, D_800F7F08->coords.y - 22.0f, D_800F7F08->coords.z + 50.0f, 1);
SleepProcess(3);
func_8004F9F4(D_800F7F0C, D_800F7F08->coords.x - 20.0f, D_800F7F08->coords.y - 22.0f, D_800F7F08->coords.z + 50.0f, 1);
SleepProcess(4);
func_80040780(D_800F7F00);
while (1) {
array[1] = GetRandomByte() % 10 + 1;
if (array[1] == array[0]) {
continue;
} else {
func_800415CC(D_800F7F00, array[1]);
break;
}
}
SleepProcess(0x14);
func_8004F4D4(D_800F7F04, 3, 2);
func_8004E3E0(0, &D_800F7DEC_29A2EC, 0x14, D_800F7F04);
SleepProcess(0xF);
func_8004F4D4(D_800F7F04, -1, 2);
func_8004EE14(0, D_800F32A0, 0xA, D_800F7F04);
SleepProcess(0xA);
var_s2 = 0;
temp_s1 = 0;
var_s0 = 0;
while (var_s0 != 2) {
switch (var_s0) {
case 0:
if ((var_s2 >= 0xF)) {
var_s0 = 1;
func_8003E81C(D_800F7F04, 0, 0);
func_8004F40C(D_800F7F04, -1, 2);
}
break;
case 1:
if (++temp_s1 == 5) {
var_s0 = 2;
func_800413B0(D_800F7F00);
}
break;
}
var_s2++;
SleepVProcess();
}
SleepProcess(0x28);
array[1] = func_800415E8(D_800F7F00);
func_800405DC(D_800F7F00);
func_800415B0(D_800F7F00, D_800F3FF0);
func_8004F4D4(D_800F7F04, 3, 2);
func_8004EE14(0, &D_800F7DD4_29A2D4, 0xA, D_800F7F04);
SleepProcess(0xA);
func_8004E3E0(0, &D_800F7DD4_29A2D4, 0x14, D_800F7F04);
SleepProcess(0xF);
func_8004F4D4(D_800F7F04, -1, 2);
func_8004EE14(0, &D_800F7DE0_29A2E0, 0xA, D_800F7F04);
SleepProcess(0xA);
if (array[0] > array[1]) {
windowID = CreateTextWindow(0x3C, 0x3C, 0xE, 3);
LoadStringIntoWindow(windowID, (void* )0x206, -1, -1);
func_8006E070(windowID, 0);
ShowTextWindow(windowID);
func_8004DBD4(windowID, D_800F7F00);
HideTextWindow(windowID);
func_8004F4D4(D_800F7F04, 2, 0);
func_8004F504(D_800F7F04);
func_800500A4();
PlaySound(0x44);
PlaySound(0x6D);
D_800F7DC0_29A2C0 = CreateObject(0x40U, NULL);
func_800A0D00(&D_800F7DC0_29A2C0->coords, D_800F7DD4_29A2D4.x, D_800F7DD4_29A2D4.y + 200.0f, D_800F7DD4_29A2D4.z);
func_800A0D00(&D_800F7DC0_29A2C0->xScale, 0.5f, 0.5f, 0.5f);
D_800F7DC4_29A2C4 = func_80042728(D_800F7DC0_29A2C0, 0);
for (i = 0; i < 0xB5; i += 5) {
func_800A0D00(&D_800F7DC0_29A2C0->coords, D_800F7DD4_29A2D4.x + (((D_800F7DE0_29A2E0.x - D_800F7DD4_29A2D4.x) * i) / 180.0f), D_800F7DD4_29A2D4.y + 200.0f + (sinf(i * 0.017453292519943295) * 100.0f), D_800F7DD4_29A2D4.z + (((D_800F7DE0_29A2E0.z - D_800F7DD4_29A2D4.z) * i) / 180.0));
Obj = D_800F7DC0_29A2C0;
Obj->unk_18.x = sinf((i * 0xA) * 0.017453292519943295);
Obj = D_800F7DC0_29A2C0;
Obj->unk_18.z = cosf((i * 0xA) * 0.017453292519943295);
SleepVProcess();
}
PlaySound(0x474);
func_80055994(D_800F7F00, 1);
func_800503B0(D_800F7F00, 4);
DestroyObject(D_800F7DC0_29A2C0);
D_800F7DC0_29A2C0 = NULL;
func_800427D4(D_800F7DC4_29A2C4);
D_800F7DC4_29A2C4 = NULL;
func_80021CDC(*D_800F7F08->unk_3C->unk_40, gPlayers[D_800F7F00].characterID, 0x81);
func_8004CCD0(&D_800F7F08->coords, &D_800F32A0->coords, &D_800F7F08->unk_18);
func_8003E81C(D_800F7F08, 4, 0U);
gPlayers[D_800F7F00].starAmount++;
D_800F7DD0_29A2D0 = func_8004D8A4();
SleepProcess(0x24);
func_80060468(0x443, gPlayers[D_800F7F00].characterID);
SleepProcess(0x30);
func_80050160();
D_800F7DCC_29A2CC = 1;
return;
}
if (gPlayers[D_800F7F00].starAmount == 0) {
windowID = CreateTextWindow(0x50, 0x3C, 0xE, 3);
LoadStringIntoWindow(windowID, (void* )0x204, -1, -1);
func_8006E070(windowID, 0);
ShowTextWindow(windowID);
func_8004DBD4(windowID, D_800F7F00);
HideTextWindow(windowID);
func_8004F4D4(D_800F7F04, 1, 2);
} else {
windowID = CreateTextWindow(0x50, 0x3C, 0xB, 3);
LoadStringIntoWindow(windowID, (void* )0x205, -1, -1);
func_8006E070(windowID, 0);
ShowTextWindow(windowID);
func_8004DBD4(windowID, D_800F7F00);
HideTextWindow(windowID);
}
func_8004F4D4(D_800F7F08, 5, 0);
func_8004F504(D_800F7F08);
if (gPlayers[D_800F7F00].starAmount != 0) {
func_800500A4();
PlaySound(0x44);
PlaySound(0x6D);
gPlayers[D_800F7F00].starAmount--;
func_800503B0((s32) D_800F7F00, 6);
D_800F7DC0_29A2C0 = CreateObject(0x40U, NULL);
func_800A0D00(&D_800F7DC0_29A2C0->coords, D_800F7DE0_29A2E0.x, D_800F7DE0_29A2E0.y + 200.0f, D_800F7DE0_29A2E0.z);
func_800A0D00(&D_800F7DC0_29A2C0->xScale, 0.5f, 0.5f, 0.5f);
D_800F7DC4_29A2C4 = func_80042728(D_800F7DC0_29A2C0, 0);
for (i = 0; i < 0xB5; i += 5) {
func_800A0D00(&D_800F7DC0_29A2C0->coords, D_800F7DE0_29A2E0.x + (((D_800F7DD4_29A2D4.x - D_800F7DE0_29A2E0.x) * i) / 180.0f), (D_800F7DE0_29A2E0.y + 200.0f) + (sinf(i * 0.017453292519943295) * 100.0f), D_800F7DE0_29A2E0.z + (((D_800F7DD4_29A2D4.z - D_800F7DE0_29A2E0.z) * i) / 180.0));
Obj = D_800F7DC0_29A2C0;
Obj->unk_18.x = sinf((i * 0xA * 0.017453292519943295));
Obj = D_800F7DC0_29A2C0;
Obj->unk_18.z = cosf((i * 0xA * 0.017453292519943295));
SleepVProcess();
}
PlaySound(0x474);
func_80055994(D_800F7F00, 2);
DestroyObject(D_800F7DC0_29A2C0);
D_800F7DC0_29A2C0 = NULL;
func_800427D4(D_800F7DC4_29A2C4);
D_800F7DC4_29A2C4 = NULL;
func_8004F4D4(D_800F7F04, 1, 0);
func_8004F40C(D_800F7F04, -1, 2);
SleepProcess(0x24);
SleepProcess(0x30);
func_80050160();
}
}
void func_800F76D4_299BD4(void) {
s32 windowID;
s32 temp_s0;
if (D_800C597A == 0) {
func_800421E0();
SleepProcess(0x10);
PlaySound(0xF0);
SleepProcess(10);
} else {
SleepProcess(8);
}
if (gPlayers[D_800F7F00].starAmount >= 99) {
windowID = CreateTextWindow(0x78, 0x3C, 0xC, 4);
LoadStringIntoWindow(windowID, (void*)0x207, -1, -1);
func_8006E070(windowID, 0);
ShowTextWindow(windowID);
func_8004DBD4(windowID, D_800F7F00);
HideTextWindow(windowID);
}
else if (gPlayers[D_800F7F00].coinAmount < 20) {
windowID = CreateTextWindow(0x78, 0x28, 0xC, 6);
LoadStringIntoWindow(windowID, (void*)0x200, -1, -1);
func_8006E070(windowID, 0);
ShowTextWindow(windowID);
func_8004DBD4(windowID, D_800F7F00);
HideTextWindow(windowID);
} else {
windowID = CreateTextWindow(0x6E, 0x28, 0xC, 7);
LoadStringIntoWindow(windowID, (void*)0x201, -1, -1);
func_8006E070(windowID, 0);
ShowTextWindow(windowID);
while ((func_8006FCC0(windowID)) != 0) {
SleepVProcess();
}
temp_s0 = func_800F66D8_298BD8(windowID);
HideTextWindow(windowID);
if (temp_s0 == 2) {
D_800F7DC8_29A2C8 = 1;
} else if (temp_s0 == 1) {
windowID = CreateTextWindow(0x78, 0x50, 9, 2);
LoadStringIntoWindow(windowID, (void*)0x202, -1, -1);
func_8006E070(windowID, 0);
ShowTextWindow(windowID);
func_8004DBD4(windowID, D_800F7F00);
HideTextWindow(windowID);
} else {
func_80055960(D_800F7F00, -0x14);
SleepProcess(0x1E);
windowID = CreateTextWindow(0x32, 0x3C, 0x13, 3);
LoadStringIntoWindow(windowID, (void*)0x203, -1, -1);
func_8006E070(windowID, 0);
ShowTextWindow(windowID);
func_8004DBD4(windowID, D_800F7F00);
HideTextWindow(windowID);
func_800F6898_298D98();
}
}
D_800F5144 = 1;
while (1) {
SleepVProcess();
}
}
void func_800F7978_299E78(void) {
if (func_80072718() == 0) {
@ -64,22 +455,22 @@ void func_800F7978_299E78(void) {
func_80070ED4();
func_80041370();
func_800405DC(D_800F7F00);
if (D_800F7DC8 == 0) {
if (D_800F7DC8_29A2C8 == 0) {
func_8005DFB8(1);
return;
}
func_8004F284();
func_8004F28C(0x5E, D_800F7DC8);
func_8004F28C(0x5E, D_800F7DC8_29A2C8);
}
}
void func_800F7A08_299F08(unkObjectStruct* arg0) {
if (D_800F5144 != 0) {
if (D_800F7DC8 != 0) {
if (D_800F7DC8_29A2C8 != 0) {
func_800726AC(6, 8);
} else {
if (D_800F7DCC != 0) {
if (D_800F7DD0 == 1) {
if (D_800F7DCC_29A2CC != 0) {
if (D_800F7DD0_29A2D0 == 1) {
func_800601D4(0x20);
}
}
@ -94,27 +485,49 @@ void func_800F7A90_299F90(void) {
func_8004F2AC();
func_8004F8DC();
D_800F7F0C = func_8004F954(0x26, 0x20);
D_800F7F04 = CreateObject(0x78, &D_800F7DF8);
D_800F7F04->coords.x = D_800F7DD4.x;
D_800F7F04->coords.y = D_800F7DD4.y;
D_800F7F04->coords.z = D_800F7DD4.z;
D_800F7F04 = CreateObject(0x78, &D_800F7DF8_29A2F8);
D_800F7F04->coords.x = D_800F7DD4_29A2D4.x;
D_800F7F04->coords.y = D_800F7DD4_29A2D4.y;
D_800F7F04->coords.z = D_800F7DD4_29A2D4.z;
D_800F7F04->xScale = D_800F7F04->yScale = D_800F7F04->zScale = 1.5f;
D_800F7F08 = CreateObject(func_80052F04(D_800F7F00), D_800F7EB4[gPlayers[D_800F7F00].characterID]);
D_800F7F08->coords.x = D_800F7DE0.x;
D_800F7F08->coords.y = D_800F7DE0.y;
D_800F7F08->coords.z = D_800F7DE0.z;
D_800F7F08 = CreateObject(func_80052F04(D_800F7F00), D_800F7EB4_29A3B4[gPlayers[D_800F7F00].characterID]);
D_800F7F08->coords.x = D_800F7DE0_29A2E0.x;
D_800F7F08->coords.y = D_800F7DE0_29A2E0.y;
D_800F7F08->coords.z = D_800F7DE0_29A2E0.z;
func_80021B14(*D_800F7F08->unk_3C->unk_40, gPlayers[D_800F7F00].characterID, 0x80);
func_8004CCD0(&D_800F7F08->coords, &D_800F7F04->coords, &D_800F7F08->unk_18);
func_8004CCD0(&D_800F7F04->coords, &D_800F7F08->coords, &D_800F7F04->unk_18);
func_80052E84(D_800F7F00);
func_8003E664(gPlayers[D_800F7F00].playerObj);
(gPlayers[D_800F7F00].playerObj)->coords.x = D_800F7DEC.x;
(gPlayers[D_800F7F00].playerObj)->coords.y = D_800F7DEC.y;
(gPlayers[D_800F7F00].playerObj)->coords.z = D_800F7DEC.z;
(gPlayers[D_800F7F00].playerObj)->coords.x = D_800F7DEC_29A2EC.x;
(gPlayers[D_800F7F00].playerObj)->coords.y = D_800F7DEC_29A2EC.y;
(gPlayers[D_800F7F00].playerObj)->coords.z = D_800F7DEC_29A2EC.z;
}
INCLUDE_ASM(s32, "ovl_5E_StarVisitEternalStar/298AE0", func_800F7C88_29A188);
void func_800F7C88_29A188(void) {
DestroyObject(D_800F7F08);
DestroyObject(D_800F7F04);
if (D_800F7DC0_29A2C0 != NULL) {
DestroyObject(D_800F7DC0_29A2C0);
}
if (D_800F7DC4_29A2C4 != NULL) {
func_800427D4(D_800F7DC4_29A2C4);
}
func_80052FD4(D_800F7F00);
func_8004F2EC();
}
INCLUDE_ASM(s32, "ovl_5E_StarVisitEternalStar/298AE0", func_800F7CF8_29A1F8);
void func_800F7CF8_29A1F8(void) {
func_800178A0(1);
func_80017660(0, 0.0f, 0.0f, 320.0f, 240.0f);
func_800176C4(0, 640.0f, 480.0f, 511.0f, 640.0f, 480.0f, 511.0f);
LoadBackgroundData(&D_FE2310);
LoadBackgroundIndex(0x47);
}
INCLUDE_ASM(s32, "ovl_5E_StarVisitEternalStar/298AE0", func_800F7D98_29A298);
void func_800F7D98_29A298(void) {
func_8004A140();
func_80049F0C();
}

View File

@ -6,11 +6,7 @@ typedef struct unk_ovl_5E {
/* 0x00 */ u8 unk_00[4];
} unk_ovl_5E;
extern Vec3f D_800F32D0;
extern Vec3f D_800F7DD4;
extern Vec3f D_800F7DE0;
extern Vec3f D_800F7DEC;
extern Vec3f D_800F7DF8;
extern unkObjectStruct* D_800F7EB4[];
extern u8 D_800F7F00;
extern Object* D_800F7F04;
@ -29,3 +25,21 @@ void func_800F7D98_29A298(void);
extern s32 D_800F7DC8;
extern unk_ovl_5E D_800F7ED0;
extern u8 D_800F7F00;
extern Object* D_800F7DC0;
extern Object* D_800F7DC4;
void SleepProcess(s32);
void func_8004DBD4(s32, u8);
s32 func_800F66D8_298BD8(s32);
void func_800F6898_298D98(void);
void SleepProcess(s32);
void func_80040780(u8);
void func_800415B0(u8, s32);
s8 func_800415E8(u8);
s32 func_8004D8A4(void);
void func_8004DBD4(s32, u8);
void func_80055994(u8, s32);
extern s32 D_800F3FF0;
extern u16 D_800F5460[];
extern Vec3f D_800F7DD4;
extern Vec3f D_800F7DE0;

View File

@ -13,6 +13,7 @@ Vec3f vec1;
Vec3f vec2;
} unkUserData;
void func_8005B860(s32);
extern testStruct2 D_800F6F00[];
void func_8005C3FC(s32, s32);
void func_8005CC3C(void);

View File

@ -13,6 +13,8 @@ Vec3f vec1;
Vec3f vec2;
} unkUserData;
void func_8005CC3C(void);
void func_8005C3FC(s32, s32);
extern s16 D_800ED154;
void func_8005B860(s32);
void func_800F67BC_2FA2FC(void);

View File

@ -469,6 +469,8 @@ sprintf = 0x8008C490;
proutSprintf = 0x8008C4E8;
osSyncPrintf = 0x8008C520;
overlay_table = 0x800C1C74;
aisetfreq_rodata_0000 = 0x800CC640;
osViClock = 0x800C7728;
__CartRomHandle = 0x800F2A80;

79
tools/asm_sizes.py Executable file
View File

@ -0,0 +1,79 @@
#! /usr/bin/python3
import json
import glob
import os
import argparse
from enum import IntEnum
script_dir = os.path.dirname(os.path.realpath(__file__))
asm_dir = script_dir + "/../asm/nonmatchings"
modes = [ "min", "max", "avg", "total", "size" ]
sizes = {}
funcs = {}
# Calculate the number of instructions in a .s file
def calc_insns(f_path):
ret = 0
with open(f_path) as f:
f_lines = f.readlines()
for line in f_lines:
if line.startswith("/* "):
ret += 1
funcs[f_path.split("/")[-1][:-2]] = ret
return ret
# Calculate different data points for each .c files and store them as a Tuple
def do_dir(root, dir):
max = 0
min = 0
total = 0
files = glob.glob(os.path.join(root, dir) + "/*.s")
for f in files:
amt = calc_insns(f)
if amt > max:
max = amt
if min == 0 or amt < min:
min = amt
total += amt
avg = 0 if len(files) == 0 else total / len(files)
sizes[root + "/" + dir] = ((min, max, total, avg, len(files)))
parser = argparse.ArgumentParser(description="A tool to receive information about the number of non-matching .s files "
+"per .c file, or the size of .s files, measured by their number of instructions. "
+"Option -p is used by default if no option is specified.")
group = parser.add_mutually_exclusive_group()
group.add_argument("-f", "--files", help="Default. Print the number of non-matching .s files per .c file, ordered by size.", action='store_true', required=False)
group.add_argument("-a", "--alphabetical", help="Print the size of .s files, ordered by name.", action='store_true', required=False)
group.add_argument("-s", "--size", help="Print the size of .s files, ordered by size.", action='store_true', required=False)
parser.add_argument("-l", "--limit", help="Only print the .c --files that are greater than or equal to the value.", type=int, default=0, required=False)
parser.add_argument("-m", "--mode", help="Switches between output modes for --files. Allowed values are: {min, max, avg, total, size}.", choices=modes, default="size", metavar='', required=False)
args = parser.parse_args()
if __name__ == "__main__":
for root, dirs, files in os.walk(asm_dir):
for asm_dir in dirs:
do_dir(root, asm_dir)
if args.alphabetical:
print(json.dumps(dict(sorted(funcs.items(), key=lambda f: f[0])), indent=4))
elif args.size:
print(json.dumps(dict(sorted(funcs.items(), key=lambda f: f[1])), indent=4))
else:
for thing in sorted(sizes.keys(), key=lambda x: sizes[x][modes.index(args.mode)]):
val = sizes[thing][modes.index(args.mode)]
if val > args.limit:
print(thing.split("nonmatchings/")[1].ljust(50) + str(val))

9
tools/find_duplicates.py Normal file → Executable file
View File

@ -11,12 +11,12 @@ import sys
script_dir = os.path.dirname(os.path.realpath(__file__))
root_dir = script_dir + "/../"
asm_dir = root_dir + "asm/"
asm_dir = root_dir + "asm/nonmatchings/"
build_dir = root_dir + "build/"
def read_rom():
with open(root_dir + "/baserom.us.z64", "rb") as f:
with open(root_dir + "baserom.us.z64", "rb") as f:
return f.read()
@ -205,11 +205,6 @@ def all_matches(all_funcs_flag):
i += 1
print("File matching progress: {:%}".format(i / (len(s_files) - iter_limit)), end='\r')
# symbol doesn't exists?
if file not in map_offsets:
to_match_files.remove(file)
continue
if get_symbol_length(file) < 16:
to_match_files.remove(file)
continue

View File

@ -99,6 +99,7 @@ def main(args):
"color": color.hex,
}))
else:
print (f" Matching Size:{matching_size}\n Nonmatching Size:{nonmatching_size}\n Calculated Size:{matching_size + nonmatching_size}\n Total Size:{total_size}\n")
if matching_size + nonmatching_size != total_size:
print("Warning: category/total size mismatch!\n")
print(f"{len(matching_funcs)} matched functions / {len(all_funcs)} total ({funcs_matching_ratio:.2f}%)")