mirror of
https://github.com/pmret/papermario.git
synced 2024-11-08 12:02:30 +01:00
add NON_MATCHING
This commit is contained in:
parent
c52ad332cc
commit
fbbbf83d22
@ -54,9 +54,12 @@ INCLUDE_ASM(code_6000, collision_heap_create);
|
||||
|
||||
INCLUDE_ASM(code_6000, collision_heap_malloc);
|
||||
|
||||
INCLUDE_ASM(code_6000, collision_heap_free);
|
||||
/*s32 collision_heap_free(s32 size) {
|
||||
#ifdef NON_MATCHING
|
||||
s32 collision_heap_free(s32 size) {
|
||||
s32 isBattle = (*gGameStatusPtr)->isBattle;
|
||||
|
||||
return _heap_free((isBattle == 0) ? (&D_80268000) : (&D_803DA800), size);
|
||||
}*/
|
||||
}
|
||||
#else
|
||||
INCLUDE_ASM(code_6000, collision_heap_free);
|
||||
#endif
|
||||
|
@ -716,10 +716,10 @@ void reset_status_menu(void) {
|
||||
func_801452B4(uiStatus->iconIndexC, uiStatus->iconIndexC);
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
// uses a jumptable, which we need .rodata support for.
|
||||
s32 INCLUDE_ASM(code_80850_len_3060, is_ability_active, s32 arg0);
|
||||
// Somewhat close. Needs work.
|
||||
/*s32 is_ability_active(s32 arg0) {
|
||||
s32 is_ability_active(s32 arg0) {
|
||||
s32 iVar2;
|
||||
u32 uVar3;
|
||||
s32 iVar5;
|
||||
@ -965,7 +965,10 @@ s32 INCLUDE_ASM(code_80850_len_3060, is_ability_active, s32 arg0);
|
||||
}
|
||||
return iVar7;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
#else
|
||||
s32 INCLUDE_ASM(code_80850_len_3060, is_ability_active, s32 arg0);
|
||||
#endif
|
||||
|
||||
s32 is_partner_ability_active(void) {
|
||||
return 0;
|
||||
|
@ -41,8 +41,8 @@ Trigger* get_trigger_by_id(s32 triggerID) {
|
||||
return (*gCurrentTriggerListPtr)[triggerID];
|
||||
}
|
||||
|
||||
INCLUDE_ASM(code_dbd70_len_700, func_80145CE8);
|
||||
/*s32 func_80145CE8(s32 arg0) {
|
||||
#ifdef NON_MATCHING
|
||||
s32 func_80145CE8(s32 arg0) {
|
||||
s32 i;
|
||||
s32 ret;
|
||||
|
||||
@ -60,4 +60,7 @@ INCLUDE_ASM(code_dbd70_len_700, func_80145CE8);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}*/
|
||||
}
|
||||
#else
|
||||
INCLUDE_ASM(code_dbd70_len_700, func_80145CE8);
|
||||
#endif
|
||||
|
@ -18,8 +18,7 @@ INCLUDE_ASM(code_e79b0_len_1920, start_child_script);
|
||||
|
||||
INCLUDE_ASM(code_e79b0_len_1920, func_802C39F8);
|
||||
|
||||
INCLUDE_ASM(code_e79b0_len_1920, restart_script);
|
||||
/*
|
||||
#ifdef NON_MATCHING
|
||||
ScriptInstance* restart_script(ScriptInstance* script) {
|
||||
script->loopDepth = -1;
|
||||
script->switchDepth = -1;
|
||||
@ -39,7 +38,9 @@ ScriptInstance* restart_script(ScriptInstance* script) {
|
||||
|
||||
return script;
|
||||
}
|
||||
*/
|
||||
#else
|
||||
INCLUDE_ASM(code_e79b0_len_1920, restart_script);
|
||||
#endif
|
||||
|
||||
INCLUDE_ASM(code_e79b0_len_1920, update_scripts);
|
||||
|
||||
@ -104,22 +105,23 @@ void set_script_timescale(ScriptInstance* script, f32 timeScale) {
|
||||
script->timeScale = timeScale * gGlobalTimeSpace;
|
||||
}
|
||||
|
||||
INCLUDE_ASM(code_e79b0_len_1920, set_global_timespace);
|
||||
/*
|
||||
#ifdef NON_MATCHING
|
||||
// TODO: figure out why compiler/assembler isn't putting SWC1 in delay slot
|
||||
void set_global_timespace(f32 timeScale) {
|
||||
//gGlobalTimeSpace = timeScale;
|
||||
}
|
||||
*/
|
||||
#else
|
||||
INCLUDE_ASM(code_e79b0_len_1920, set_global_timespace);
|
||||
#endif
|
||||
|
||||
|
||||
INCLUDE_ASM(code_e79b0_len_1920, get_global_timespace);
|
||||
/*
|
||||
#ifdef NON_MATCHING
|
||||
// TODO: figure out why compiler/assembler isn't putting LWC1 in delay slot
|
||||
f32 get_global_timespace(void) {
|
||||
//return gGlobalTimeSpace;
|
||||
}
|
||||
*/
|
||||
#else
|
||||
INCLUDE_ASM(code_e79b0_len_1920, get_global_timespace);
|
||||
#endif
|
||||
|
||||
void set_script_group(ScriptInstance* script, s8 groupFlags) {
|
||||
script->groupFlags = groupFlags;
|
||||
@ -305,8 +307,7 @@ void set_script_flags(ScriptInstance* script, s32 flags) {
|
||||
}
|
||||
}
|
||||
|
||||
INCLUDE_ASM(code_e79b0_len_1920, clear_script_flags);
|
||||
/*
|
||||
#ifdef NON_MATCHING
|
||||
// TODO: Really close but some weirdness is going on
|
||||
void clear_script_flags(ScriptInstance* script, s32 flags) {
|
||||
int i;
|
||||
@ -325,4 +326,6 @@ void clear_script_flags(ScriptInstance* script, s32 flags) {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
#else
|
||||
INCLUDE_ASM(code_e79b0_len_1920, clear_script_flags);
|
||||
#endif
|
||||
|
@ -66,10 +66,9 @@ ApiStatus SetMessageString(ScriptInstance* script, s32 isInitialCall) {
|
||||
return ApiStatus_DONE2;
|
||||
}
|
||||
|
||||
INCLUDE_API_ASM(code_f4c60_len_4300, SetMessageValue);
|
||||
#ifdef NON_MATCHING
|
||||
// TODO: Figure out why there's an extra NOP after this function
|
||||
// It's probably because of a file split issue
|
||||
/*
|
||||
ApiStatus SetMessageValue(ScriptInstance* script, s32 initialCall) {
|
||||
Bytecode* ptrReadPos = script->ptrReadPos;
|
||||
Bytecode value = get_variable(script, *ptrReadPos++);
|
||||
@ -78,7 +77,9 @@ ApiStatus SetMessageValue(ScriptInstance* script, s32 initialCall) {
|
||||
set_message_value(value, index);
|
||||
return ApiStatus_DONE2;
|
||||
}
|
||||
*/
|
||||
#else
|
||||
INCLUDE_API_ASM(code_f4c60_len_4300, SetMessageValue);
|
||||
#endif
|
||||
|
||||
INCLUDE_API_ASM(code_f4c60_len_4300, HidePlayerShadow);
|
||||
|
||||
|
@ -335,8 +335,7 @@ ApiStatus AddStarPieces(ScriptInstance* script, s32 isInitialCall) {
|
||||
return ApiStatus_DONE2;
|
||||
}
|
||||
|
||||
INCLUDE_API_ASM(code_fa4c0_len_3bf0, GetItemPower);
|
||||
/*
|
||||
#ifdef NON_MATCHING
|
||||
// Close to working
|
||||
ApiStatus GetItemPower(ScriptInstance* script, s32 isInitialCall) {
|
||||
Bytecode* ptrReadPos = script->ptrReadPos;
|
||||
@ -349,7 +348,9 @@ ApiStatus GetItemPower(ScriptInstance* script, s32 isInitialCall) {
|
||||
set_variable(script, ptrNextPos++, item->potencyB);
|
||||
return ApiStatus_DONE2;
|
||||
}
|
||||
*/
|
||||
#else
|
||||
INCLUDE_API_ASM(code_fa4c0_len_3bf0, GetItemPower);
|
||||
#endif
|
||||
|
||||
INCLUDE_API_ASM(code_fa4c0_len_3bf0, ShowGotItem);
|
||||
|
||||
@ -359,8 +360,7 @@ INCLUDE_ASM(code_fa4c0_len_3bf0, func_802D74C0);
|
||||
|
||||
INCLUDE_API_ASM(code_fa4c0_len_3bf0, ShowEmote);
|
||||
|
||||
INCLUDE_API_ASM(code_fa4c0_len_3bf0, RemoveEffect);
|
||||
/*
|
||||
#ifdef NON_MATCHING
|
||||
// Works
|
||||
ApiStatus RemoveEffect(ScriptInstance* script, s32 isInitialCall) {
|
||||
Bytecode* ptrReadPos = script->ptrReadPos;
|
||||
@ -398,8 +398,10 @@ ApiStatus func_802D7B74(ScriptInstance* script, s32 isInitialCall) {
|
||||
return ApiStatus_DONE2;
|
||||
}
|
||||
|
||||
// More functions still in RemoveEffect.s but the ones above are matching properly
|
||||
*/
|
||||
// TODO: More functions still in RemoveEffect.s but the ones above are matching properly
|
||||
#else
|
||||
INCLUDE_API_ASM(code_fa4c0_len_3bf0, RemoveEffect);
|
||||
#endif
|
||||
|
||||
INCLUDE_API_ASM(code_fa4c0_len_3bf0, ShowSleepBubble);
|
||||
|
||||
|
@ -28,16 +28,28 @@ c_func_pattern = re.compile(
|
||||
re.MULTILINE
|
||||
)
|
||||
def funcs_in_c(text):
|
||||
text = strip_c_comments(text)
|
||||
return [match.group(1) for match in c_func_pattern.finditer(text)]
|
||||
return (match.group(1) for match in c_func_pattern.finditer(text))
|
||||
|
||||
asm_func_pattern = re.compile(
|
||||
r"INCLUDE_(?:API_)?ASM\([^,]+, ([^,)]+)",
|
||||
re.MULTILINE
|
||||
)
|
||||
def include_asms_in_c(text):
|
||||
return (match.group(1) for match in asm_func_pattern.finditer(text))
|
||||
|
||||
matched = []
|
||||
asm = []
|
||||
for filename in C_FILES:
|
||||
with open(filename, "r") as file:
|
||||
matched += funcs_in_c(file.read())
|
||||
text = strip_c_comments(file.read())
|
||||
matched.extend((m for m in funcs_in_c(text) if not m in matched))
|
||||
asm.extend((m for m in include_asms_in_c(text) if not m in asm))
|
||||
|
||||
non_matched = [path.splitext(path.basename(filename))[0] for filename in ASM_FILES]
|
||||
matched_but_undeleted_asm = [f for f in matched if f in non_matched]
|
||||
|
||||
partial_matched = [f for f in matched if f in asm]
|
||||
matched = [f for f in matched if not f in partial_matched]
|
||||
matched_but_undeleted_asm = [f for f in matched if f in non_matched and not f in partial_matched]
|
||||
|
||||
if __name__ == "__main__":
|
||||
if "--help" in argv:
|
||||
@ -46,7 +58,7 @@ if __name__ == "__main__":
|
||||
exit()
|
||||
|
||||
total = len(matched) + len(non_matched)
|
||||
print(f"{len(matched)}/{total} ({(len(matched) / total) * 100:.2f}%)")
|
||||
print(f"{len(matched)}+{len(partial_matched)} / {total} functions ({(len(matched) / total) * 100:.2f}% matched)")
|
||||
|
||||
if len(matched_but_undeleted_asm) > 0:
|
||||
print(f"The following functions have been matched but still exist in asm/nonmatchings/: {' '.join(matched_but_undeleted_asm)}")
|
||||
@ -59,3 +71,5 @@ if __name__ == "__main__":
|
||||
for func in matched_but_undeleted_asm:
|
||||
file = glob(path.join(DIR, f"../asm/nonmatchings/*/{func}.s"))[0]
|
||||
remove(file)
|
||||
elif len(asm) != len(non_matched):
|
||||
print(f"warning: number of INCLUDE_ASM macros ({len(asm)}) != number of asm files ({len(non_matched)})")
|
||||
|
Loading…
Reference in New Issue
Block a user