I'm not as positive about the name of some undefined symbols anymore. Also slightly better stack pointer code

This commit is contained in:
Ryan Myers
2021-09-30 14:46:38 -04:00
parent ed87ea82f0
commit 7c7376bc7b
6 changed files with 24 additions and 27 deletions
+1 -1
View File
@@ -141,7 +141,7 @@ TEXBUILDER = $(TOOLS_DIR)/dkr_texbuilder
COMPRESS = $(TOOLS_DIR)/dkr_decompressor -c
LIB_DIRS := lib/
ASM_DIRS := asm/ asm/boot/ asm/assets/ lib/asm/
ASM_DIRS := asm/ asm/boot/ asm/assets/ lib/asm/ lib/asm/non_decompilable
SRC_DIRS := $(sort $(dir $(wildcard src/* src/**/*))) $(sort $(dir $(wildcard lib/src/* lib/src/**/* lib/src/**/**/*)))
GLOBAL_ASM_C_FILES != grep -rl 'GLOBAL_ASM(' $(SRC_DIRS)
@@ -159,11 +159,11 @@ glabel func_80024D54
/* 025BA0 80024FA0 A3A00083 */ sb $zero, 0x83($sp)
/* 025BA4 80024FA4 304B0004 */ andi $t3, $v0, 4
/* 025BA8 80024FA8 11600003 */ beqz $t3, .L80024FB8
/* 025BAC 80024FAC 3C0FA000 */ lui $t7, %hi(THREAD_S6) # $t7, 0xa000
/* 025BAC 80024FAC 3C0FA000 */ lui $t7, %hi(D_A0000200) # $t7, 0xa000
/* 025BB0 80024FB0 240C0001 */ li $t4, 1
/* 025BB4 80024FB4 A3AC0083 */ sb $t4, 0x83($sp)
.L80024FB8:
/* 025BB8 80024FB8 8DED0200 */ lw $t5, %lo(THREAD_S6)($t7)
/* 025BB8 80024FB8 8DED0200 */ lw $t5, %lo(D_A0000200)($t7)
/* 025BBC 80024FBC 3C01AC29 */ lui $at, 0xac29
/* 025BC0 80024FC0 11A10002 */ beq $t5, $at, .L80024FCC
/* 025BC4 80024FC4 240E0001 */ li $t6, 1
@@ -23,8 +23,8 @@ glabel func_8003B4BC
/* 03C0FC 8003B4FC 46283282 */ mul.d $f10, $f6, $f8
/* 03C100 8003B500 462050A0 */ cvt.s.d $f2, $f10
.L8003B504:
/* 03C104 8003B504 3C18A000 */ lui $t8, %hi(THREAD_PC) # $t8, 0xa000
/* 03C108 8003B508 8F190284 */ lw $t9, %lo(THREAD_PC)($t8)
/* 03C104 8003B504 3C18A000 */ lui $t8, %hi(D_A0000284) # $t8, 0xa000
/* 03C108 8003B508 8F190284 */ lw $t9, %lo(D_A0000284)($t8)
/* 03C10C 8003B50C 3C01240B */ lui $at, (0x240B17D7 >> 16) # lui $at, 0x240b
/* 03C110 8003B510 342117D7 */ ori $at, (0x240B17D7 & 0xFFFF) # ori $at, $at, 0x17d7
/* 03C114 8003B514 13210002 */ beq $t9, $at, .L8003B520
+2 -2
View File
@@ -121,11 +121,11 @@ GLOBAL_ASM("asm/non_matchings/memory/new_memory_pool.s")
void *allocate_from_main_pool_safe(s32 size, u32 colorTag) {
void *temp_v0;
if (size == 0) {
func_800B7460(*(s32 *)((u8 *)get_stack_pointer() + 0x14), size, colorTag);
func_800B7460((s32 *)((u8 *)get_stack_pointer()->unk14), size, colorTag);
}
temp_v0 = allocate_from_memory_pool(0, size, colorTag);
if (temp_v0 == (void *)NULL) {
func_800B7460(*(s32 *)((u8 *)get_stack_pointer() + 0x14), size, colorTag);
func_800B7460((s32 *)((u8 *)get_stack_pointer()->unk14), size, colorTag);
}
return temp_v0;
}
+15 -18
View File
@@ -20,8 +20,6 @@ LOWER_INSTR_LS_REGEX_TMPL = r'(/\* %s[^\n#]*[ls][bhwd](u|c1)?\s+' + REG_REGEX +
LOWER_INSTR_ADDU_REGEX_TMPL = r'(/\* %s[^\n#]*addiu\s+' + REG_REGEX + r',\s+' + REG_REGEX + r',\s+)-?0x[0-9a-f]{3,4}'
LOWER_INSTR_ADDU_SAME_REGEX_TMPL = r'(/\* %s[^\n#]*)(addiu\s+' + REG_REGEX + r',\s+\3,\s+-?0x[0-9a-f]{3,4})'
IGNORE_GLABELS = ['D_800E389E', 'D_801264A1', 'D_800E1B84']
def _find_glabels(asm):
glabels = []
for file in FileUtil.get_filenames_from_directory_recursive('.', '.s'):
@@ -38,22 +36,21 @@ def _find_glabels(asm):
if glabel_lower & 0x8000:
glabel_upper -= 1
glabel = 'D_%08X' % (glabel_upper << 16 | glabel_lower)
if glabel not in IGNORE_GLABELS:
glabels.append((glabel, *offsets))
# replace upper instruction
contents = re.sub(UPPER_INSTR_REGEX_TMPL % offsets[0],
r'\1%s, %%hi(%s) # \2' % (reg, glabel),
contents)
# replace lower instruction
contents = re.sub(LOWER_INSTR_LS_REGEX_TMPL % offsets[1],
r'\1%%lo(%s)\5' % glabel,
contents)
contents = re.sub(LOWER_INSTR_ADDU_SAME_REGEX_TMPL % offsets[1],
r'\1addiu \3, %%lo(%s) # \2' % glabel,
contents)
contents = re.sub(LOWER_INSTR_ADDU_REGEX_TMPL % offsets[1],
r'\1%%lo(%s)' % glabel,
contents)
glabels.append((glabel, *offsets))
# replace upper instruction
contents = re.sub(UPPER_INSTR_REGEX_TMPL % offsets[0],
r'\1%s, %%hi(%s) # \2' % (reg, glabel),
contents)
# replace lower instruction
contents = re.sub(LOWER_INSTR_LS_REGEX_TMPL % offsets[1],
r'\1%%lo(%s)\5' % glabel,
contents)
contents = re.sub(LOWER_INSTR_ADDU_SAME_REGEX_TMPL % offsets[1],
r'\1addiu \3, %%lo(%s) # \2' % glabel,
contents)
contents = re.sub(LOWER_INSTR_ADDU_REGEX_TMPL % offsets[1],
r'\1%%lo(%s)' % glabel,
contents)
if len(matches):
FileUtil.write_text_to_file(file, contents)
return glabels
+2 -2
View File
@@ -4,8 +4,8 @@ osResetType = 0x8000030C;
osCicId = 0x80000310;
osAppNMIBuffer = 0x8000031C;
THREAD_S6 = 0xA0000200;
THREAD_PC = 0xA0000284;
D_A0000200 = 0xA0000200;
D_A0000284 = 0xA0000284;
SP_DRAM_ADDR_REG = 0xA4040004;
SP_RD_LEN_REG = 0xA4040008;
SP_WR_LEN_REG = 0xA404000C;