general cleanup

This commit is contained in:
angie 2024-01-10 20:30:03 -03:00
parent 94dab60235
commit a9a3ef4376
8 changed files with 107 additions and 69 deletions

View File

@ -1,4 +1,34 @@
Checks: 'readability-*,-readability-magic-numbers,-readability-uppercase-literal-suffix,-readability-non-const-parameter,-readability-else-after-return,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-security.insecureAPI.*,-clang-analyzer-deadcode.DeadStores,-clang-analyzer-core.uninitialized.ArraySubscript,-clang-analyzer-core.UndefinedBinaryOperatorResult,bugprone*,-bugprone-macro-parentheses,-bugprone-reserved-identifier,-bugprone-narrowing-conversions,-bugprone-too-small-loop-variable,-bugprone-integer-division,-bugprone-sizeof-expression,-bugprone-suspicious-include,modernize*,-bugprone-branch-clone,-bugprone-signed-char-misuse,-bugprone-incorrect-roundings,performance*,portability*,diagnostic-*,analyzer-*,misc*,-misc-no-recursion'
Checks: >
readability-*,
-readability-magic-numbers,
-readability-uppercase-literal-suffix,
-readability-non-const-parameter,
-readability-else-after-return,
clang-diagnostic-*,
clang-analyzer-*,
-clang-analyzer-security.insecureAPI.*,
-clang-analyzer-deadcode.DeadStores,
-clang-analyzer-core.uninitialized.ArraySubscript,
-clang-analyzer-core.UndefinedBinaryOperatorResult,
-clang-analyzer-core.CallAndMessage, # Checks for unset variables passed to functions
bugprone*,
-bugprone-macro-parentheses,
-bugprone-reserved-identifier,
-bugprone-narrowing-conversions,
-bugprone-too-small-loop-variable,
-bugprone-integer-division,
-bugprone-sizeof-expression,
-bugprone-suspicious-include,
modernize*,
-bugprone-branch-clone,
-bugprone-signed-char-misuse,
-bugprone-incorrect-roundings,
performance*,
portability*,
diagnostic-*,
analyzer-*,
misc*,
-misc-no-recursion
WarningsAsErrors: ''
HeaderFilterRegex: '^(src|include)\/.*\.h$'
FormatStyle: 'file'

View File

@ -310,7 +310,7 @@ format:
clang-format-11 -i -style=file $(C_FILES)
tidy:
clang-tidy-11 -p . --fix --fix-errors $(C_FILES) -- $(CC_CHECK_FLAGS) $(IINC) $(CHECK_WARNINGS) $(BUILD_DEFINES) $(COMMON_DEFINES) $(RELEASE_DEFINES) $(GBI_DEFINES) $(C_DEFINES) $(MIPS_BUILTIN_DEFS)
clang-tidy-11 -p . --fix --fix-errors $(filter-out %libgcc2.c, $(C_FILES)) -- $(CC_CHECK_FLAGS) $(IINC) $(CHECK_WARNINGS) $(BUILD_DEFINES) $(COMMON_DEFINES) $(RELEASE_DEFINES) $(GBI_DEFINES) $(C_DEFINES) $(MIPS_BUILTIN_DEFS)
.PHONY: all compressed uncompressed clean distclean setup extract lib diff-init init format tidy
.DEFAULT_GOAL := all

View File

@ -11,6 +11,7 @@
#define CTYPE_ISCONTROL 0x20 /* 0x0~0x1f , 0x7f */
#define CTYPE_ISPUNCTUATION 0x40 /* punctuation */
#define CTYPE_ISKANJI 0x80 /* SJIS 1st BYTE */
#define CTYPE_ISXDIGIT 0
extern unsigned char __ctype_map[0x100];
@ -42,6 +43,9 @@ extern unsigned char __MojiStat[0x101];
#define CTYPE_ISUPPER 0x08 /* 'A'~'Z' */
#define CTYPE_ISXDIGIT 0x10 /* 'A'~'F', 'a'~'f', '0'~'9' */
#define CTYPE_ISSPACE 0x20 /* 0x09~0x0D, 0x20 */
#define CTYPE_ISHEX 0
#define CTYPE_ISPUNCTUATION 0
#define CTYPE_ISKANJI 0
#define iscntrl(c) ((__MojiStat+1)[c] & CTYPE_ISCONTROL)

View File

@ -31,8 +31,6 @@
#endif
#define CLAMP(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x))
#define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x))
#define CLAMP_MIN(x, min) ((x) < (min) ? (min) : (x))
#define SQ(x) ((x) * (x))
@ -45,6 +43,7 @@
#define ANY_BUTTON (A_BUTTON | B_BUTTON | L_TRIG | R_TRIG | Z_TRIG | START_BUTTON | U_JPAD | L_JPAD | R_JPAD | D_JPAD | U_CBUTTONS | L_CBUTTONS | R_CBUTTONS | D_CBUTTONS)
#define RELOCATE_SEGMENTED(ptr, baseAddr) ((void *)(SEGMENT_OFFSET((ptr)) + (uintptr_t)(baseAddr)))
#define saved_reg_s0 0

View File

@ -9496,6 +9496,7 @@ s32 dm_game_main2(void) {
break;
default:
UNREACHABLE;
break;
}

View File

@ -56,10 +56,10 @@ s32 lws_anim(Gfx **gfxP, Mtx *mtx, struct_lws_scene *arg2, s32 arg3, void *arg4)
s32 a5;
s32 a6;
temp_s5 = (void *)(((uintptr_t)arg2->unk_10 & 0x00FFFFFF) + (uintptr_t)arg4);
temp_s5 = RELOCATE_SEGMENTED(arg2->unk_10, arg4);
temp_s5 = &temp_s5[i];
temp = (void *)(((uintptr_t)arg2->unk_14 & 0x00FFFFFF) + (uintptr_t)arg4);
temp = RELOCATE_SEGMENTED(arg2->unk_14, arg4);
temp = &temp[temp_s5->unk_0C];
var_a1 = var_a2 = temp;

View File

@ -25,8 +25,6 @@
#include "joy.h"
#endif
#define STORY_BUFFER_OFFSET(addr) ((void *)(((uintptr_t)(addr)&0xFFFFFF) + (uintptr_t)story_buffer))
extern struct_lws_scene *lws_scene;
extern struct_wakuGraphic *wakuGraphic;
@ -458,12 +456,12 @@ void draw_coffee_break(Gfx **gfxP, s32 arg1, s32 arg2, s32 arg3) {
lws_data = (void **)bgGraphic;
if (arg2 != 0) {
gDPSetEnvColor(sp60++, 183, 127, 95, 255);
var_s0 = (void *)(((uintptr_t)lws_data[1] & 0x00FFFFFF) + (uintptr_t)bgGraphic);
var_v0 = (void *)(((uintptr_t)lws_data[6] & 0x00FFFFFF) + (uintptr_t)bgGraphic);
var_s0 = RELOCATE_SEGMENTED(lws_data[1], bgGraphic);
var_v0 = RELOCATE_SEGMENTED(lws_data[6], bgGraphic);
} else {
gDPSetEnvColor(sp60++, 255, 255, 255, 255);
var_s0 = (void *)(((uintptr_t)lws_data[0] & 0x00FFFFFF) + (uintptr_t)bgGraphic);
var_v0 = (void *)(((uintptr_t)lws_data[5] & 0x00FFFFFF) + (uintptr_t)bgGraphic);
var_s0 = RELOCATE_SEGMENTED(lws_data[0], bgGraphic);
var_v0 = RELOCATE_SEGMENTED(lws_data[5], bgGraphic);
}
makeTransrateMatrix(&sp20, 0U, 0xFFC40000U, 0xFC4A0000U);
@ -474,15 +472,15 @@ void draw_coffee_break(Gfx **gfxP, s32 arg1, s32 arg2, s32 arg3) {
bgtime += 1;
switch (story_seq_step) {
case 0:
var_s0 = (void *)(((uintptr_t)lws_data[2] & 0x00FFFFFF) + (uintptr_t)bgGraphic);
var_s0 = RELOCATE_SEGMENTED(lws_data[2], bgGraphic);
break;
case 1:
var_s0 = (void *)(((uintptr_t)lws_data[3] & 0x00FFFFFF) + (uintptr_t)bgGraphic);
var_s0 = RELOCATE_SEGMENTED(lws_data[3], bgGraphic);
break;
case 2:
var_s0 = (void *)(((uintptr_t)lws_data[4] & 0x00FFFFFF) + (uintptr_t)bgGraphic);
var_s0 = RELOCATE_SEGMENTED(lws_data[4], bgGraphic);
break;
default:
@ -660,11 +658,11 @@ s32 demo_title(Gfx **gfxP, bool arg1) {
if (arg1) {
gDPSetEnvColor(gfx++, 183, 127, 95, 255);
lws_scene = (void *)(((uintptr_t)lws_data[0x21] & 0xFFFFFF) + (uintptr_t)title_data);
lws_scene = RELOCATE_SEGMENTED(lws_data[0x21], title_data);
} else {
gDPSetEnvColor(gfx++, 255, 255, 255, 255);
lws_scene = (void *)(((uintptr_t)lws_data[0] & 0xFFFFFF) + (uintptr_t)title_data);
lws_scene = RELOCATE_SEGMENTED(lws_data[0], title_data);
}
makeTransrateMatrix(&sp60, 0, 0xFFC4 << 16, 0xFC4A << 16);
@ -825,8 +823,7 @@ void story_st_new_op(Gfx **gfxP, s32 arg1) {
var_s0 = 0x1B;
}
func_800773F0();
lws_anim(&gfx, &sp20, (void *)(((uintptr_t)lws_data[var_s0] & 0xFFFFFF) + (uintptr_t)story_buffer), 0,
story_buffer);
lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[var_s0], story_buffer), 0, story_buffer);
framecont = 0;
fin_frame_440 = 0;
fin_demo_441 = var_s0;
@ -855,8 +852,8 @@ void story_st_new_op(Gfx **gfxP, s32 arg1) {
framecont += 3;
}
func_8007865C();
if (lws_anim(&gfx, &sp20, (void *)(((uintptr_t)lws_data[var_s0] & 0xFFFFFF) + (uintptr_t)story_buffer),
story_time_cnt, story_buffer) == 1) {
if (lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[var_s0], story_buffer), story_time_cnt,
story_buffer) == 1) {
if (msgWnd_isEnd(&mess_st) != false) {
framecont = 0;
story_time_cnt = 0;
@ -882,8 +879,8 @@ void story_st_new_op(Gfx **gfxP, s32 arg1) {
framecont += 3;
}
func_8007865C();
if ((lws_anim(&gfx, &sp20, (void *)(((uintptr_t)lws_data[0x1C] & 0xFFFFFF) + (uintptr_t)story_buffer),
story_time_cnt, story_buffer) == 1) &&
if ((lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[0x1C], story_buffer), story_time_cnt,
story_buffer) == 1) &&
(msgWnd_isEnd(&mess_st) != false)) {
framecont = 0;
story_time_cnt = 0;
@ -917,8 +914,8 @@ void story_st_new_op(Gfx **gfxP, s32 arg1) {
}
func_8007865C();
if ((lws_anim(&gfx, &sp20, (void *)(((uintptr_t)lws_data[0x1D] & 0xFFFFFF) + (uintptr_t)story_buffer),
story_time_cnt, story_buffer) == 1) &&
if ((lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[0x1D], story_buffer), story_time_cnt,
story_buffer) == 1) &&
(msgWnd_isEnd(&mess_st) != false)) {
framecont = 0;
story_time_cnt = 0;
@ -954,8 +951,8 @@ void story_st_new_op(Gfx **gfxP, s32 arg1) {
story_time_cnt += 3;
}
func_8007865C();
if ((lws_anim(&gfx, &sp20, (void *)(((uintptr_t)lws_data[0x4] & 0xFFFFFF) + (uintptr_t)story_buffer),
story_time_cnt, story_buffer) == 1) &&
if ((lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[0x4], story_buffer), story_time_cnt, story_buffer) ==
1) &&
(msgWnd_isEnd(&mess_st) != false)) {
story_time_cnt = 0;
story_seq_step += 1;
@ -969,8 +966,8 @@ void story_st_new_op(Gfx **gfxP, s32 arg1) {
default:
func_8007744C();
lws_anim(&gfx, &sp20, (void *)(((uintptr_t)lws_data[fin_demo_441] & 0xFFFFFF) + (uintptr_t)story_buffer),
fin_frame_440, story_buffer);
lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[fin_demo_441], story_buffer), fin_frame_440,
story_buffer);
break;
}
@ -997,7 +994,7 @@ void story_st_new(Gfx **gfxP, s32 arg1, s32 arg2) {
makeTransrateMatrix(&mtx, 0, 0x1FFE7 << 0xF, 0x1F894 << 0xF);
temp_s1 = (void *)(((uintptr_t)lws_data[arg1] & 0xFFFFFF) + (uintptr_t)story_buffer);
temp_s1 = RELOCATE_SEGMENTED(lws_data[arg1], story_buffer);
switch (story_seq_step) {
case 0:
@ -1059,13 +1056,12 @@ void story_st_new2_f(Gfx **gfxP, s32 arg1, s32 arg2, s32 arg3, s32 arg4) {
makeTransrateMatrix(&sp20, 0U, 0xFFF38000U, 0xFC4A0000U);
lws_scene = (void *)(((uintptr_t)lws_data[arg1] & 0xFFFFFF) + (uintptr_t)story_buffer);
lws_scene = RELOCATE_SEGMENTED(lws_data[arg1], story_buffer);
switch (story_seq_step) {
case 0x0:
func_800773F0();
lws_anim(&gfx, &sp20, (void *)(((uintptr_t)lws_data[arg1] & 0xFFFFFF) + (uintptr_t)story_buffer), 0,
story_buffer);
lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[arg1], story_buffer), 0, story_buffer);
framecont = 0;
fin_frame_568 = 0;
fin_demo_569 = arg1;
@ -1087,8 +1083,8 @@ void story_st_new2_f(Gfx **gfxP, s32 arg1, s32 arg2, s32 arg3, s32 arg4) {
framecont += 3;
}
func_8007865C();
if ((lws_anim(&gfx, &sp20, (void *)(((uintptr_t)lws_data[arg1] & 0xFFFFFF) + (uintptr_t)story_buffer),
story_time_cnt, story_buffer) == 1) &&
if ((lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[arg1], story_buffer), story_time_cnt,
story_buffer) == 1) &&
msgWnd_isEnd(&mess_st)) {
framecont = 0;
story_time_cnt = 0;
@ -1119,8 +1115,8 @@ void story_st_new2_f(Gfx **gfxP, s32 arg1, s32 arg2, s32 arg3, s32 arg4) {
story_time_cnt += 3;
}
func_8007865C();
if ((lws_anim(&gfx, &sp20, (void *)(((uintptr_t)lws_data[arg3] & 0xFFFFFF) + (uintptr_t)story_buffer),
story_time_cnt, story_buffer) == 1) &&
if ((lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[arg3], story_buffer), story_time_cnt,
story_buffer) == 1) &&
(msgWnd_isEnd(&mess_st) != false)) {
story_time_cnt = 0;
story_seq_step += 1;
@ -1137,8 +1133,8 @@ void story_st_new2_f(Gfx **gfxP, s32 arg1, s32 arg2, s32 arg3, s32 arg4) {
default:
func_8007744C();
lws_anim(&gfx, &sp20, (void *)(((uintptr_t)lws_data[fin_demo_569] & 0xFFFFFF) + (uintptr_t)story_buffer),
fin_frame_568, story_buffer);
lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[fin_demo_569], story_buffer), fin_frame_568,
story_buffer);
break;
}
@ -1167,8 +1163,7 @@ void story_st_new2(Gfx **gfxP, s32 arg1, s32 arg2, s32 arg3, s32 arg4) {
switch (story_seq_step) {
case 0x0:
func_800773F0();
lws_anim(&gfx, &sp20, (void *)(((uintptr_t)lws_data[arg1] & 0xFFFFFF) + (uintptr_t)story_buffer), 0,
story_buffer);
lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[arg1], story_buffer), 0, story_buffer);
framecont = 0;
fin_frame_623 = 0;
fin_demo_624 = arg1;
@ -1190,8 +1185,8 @@ void story_st_new2(Gfx **gfxP, s32 arg1, s32 arg2, s32 arg3, s32 arg4) {
framecont += 3;
}
func_8007865C();
if ((lws_anim(&gfx, &sp20, (void *)(((uintptr_t)lws_data[arg1] & 0xFFFFFF) + (uintptr_t)story_buffer),
story_time_cnt, story_buffer) == 1) &&
if ((lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[arg1], story_buffer), story_time_cnt,
story_buffer) == 1) &&
(msgWnd_isEnd(&mess_st) != false)) {
framecont = 0;
story_time_cnt = 0;
@ -1215,8 +1210,8 @@ void story_st_new2(Gfx **gfxP, s32 arg1, s32 arg2, s32 arg3, s32 arg4) {
}
func_8007865C();
if ((lws_anim(&gfx, &sp20, (void *)(((uintptr_t)lws_data[arg3] & 0xFFFFFF) + (uintptr_t)story_buffer),
story_time_cnt, story_buffer) == 1) &&
if ((lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[arg3], story_buffer), story_time_cnt,
story_buffer) == 1) &&
(msgWnd_isEnd(&mess_st) != false)) {
story_time_cnt = 0;
story_seq_step++;
@ -1225,8 +1220,8 @@ void story_st_new2(Gfx **gfxP, s32 arg1, s32 arg2, s32 arg3, s32 arg4) {
default:
func_8007744C();
lws_anim(&gfx, &sp20, (void *)(((uintptr_t)lws_data[fin_demo_624] & 0xFFFFFF) + (uintptr_t)story_buffer),
fin_frame_623, story_buffer);
lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[fin_demo_624], story_buffer), fin_frame_623,
story_buffer);
break;
}
@ -1259,8 +1254,7 @@ void story_m_end(Gfx **gfxP, s32 arg1, s32 arg2) {
switch (story_seq_step) {
case 0:
func_800773F0();
lws_anim(&gfx, &sp20, (void *)(((uintptr_t)lws_data[arg1] & 0xFFFFFF) + (uintptr_t)story_buffer), 0,
story_buffer);
lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[arg1], story_buffer), 0, story_buffer);
framecont = 0;
story_spot_cnt = 0x100;
st_mes_ptr = mes_data[arg2];
@ -1278,8 +1272,8 @@ void story_m_end(Gfx **gfxP, s32 arg1, s32 arg2) {
story_seq_step += 1;
}
if (lws_anim(&gfx, &sp20, (void *)(((uintptr_t)lws_data[arg1] & 0xFFFFFF) + (uintptr_t)story_buffer),
story_time_cnt, story_buffer) == 1) {
if (lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[arg1], story_buffer), story_time_cnt, story_buffer) ==
1) {
framecont = 0;
story_time_cnt = 0;
st_message_count = 0;
@ -1343,8 +1337,8 @@ void story_m_end(Gfx **gfxP, s32 arg1, s32 arg2) {
}
}
if (lws_anim(&gfx, &sp20, (void *)(((uintptr_t)lws_data[0x15] & 0xFFFFFF) + (uintptr_t)story_buffer),
story_time_cnt, story_buffer) == 1) {
if (lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[0x15], story_buffer), story_time_cnt, story_buffer) ==
1) {
framecont = 0x117;
story_time_cnt = 0x117U;
}
@ -1399,7 +1393,7 @@ void story_st_new_w9(Gfx **gfxP, s32 arg1, s32 arg2) {
makeTransrateMatrix(&mtx, 0, 0xFFF38000, 0xFC4A0000);
temp_s0 = (void *)(((uintptr_t)lws_data[arg1] & 0xFFFFFF) + (uintptr_t)story_buffer);
temp_s0 = RELOCATE_SEGMENTED(lws_data[arg1], story_buffer);
switch (story_seq_step) {
case 0:
@ -1478,7 +1472,7 @@ void story_w_end(Gfx **gfxP, s32 arg1) {
switch (story_seq_step) {
case 0:
func_800773F0();
lws_anim(&gfx, &sp20, STORY_BUFFER_OFFSET(lws_data[arg1]), 0, story_buffer);
lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[arg1], story_buffer), 0, story_buffer);
framecont = 0;
story_spot_cnt = 0x100;
st_mes_ptr = mes_data[0x17];
@ -1494,7 +1488,8 @@ void story_w_end(Gfx **gfxP, s32 arg1) {
st_message_count = 0;
story_seq_step += 1;
}
if (lws_anim(&gfx, &sp20, STORY_BUFFER_OFFSET(lws_data[arg1]), story_time_cnt, story_buffer) == 1) {
if (lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[arg1], story_buffer), story_time_cnt, story_buffer) ==
1) {
framecont = 0;
story_time_cnt = 0;
st_message_count = 0;
@ -1539,7 +1534,8 @@ void story_w_end(Gfx **gfxP, s32 arg1) {
func_8007865C();
}
}
if (lws_anim(&gfx, &sp20, STORY_BUFFER_OFFSET(lws_data[0x18]), story_time_cnt, story_buffer) == 1) {
if (lws_anim(&gfx, &sp20, RELOCATE_SEGMENTED(lws_data[0x18], story_buffer), story_time_cnt, story_buffer) ==
1) {
framecont = 0x6D;
story_time_cnt = (s32)0x6DU;
}

View File

@ -11,21 +11,24 @@ from pathlib import Path
ASMPATH = Path("asm")
NONMATCHINGS = "nonmatchings"
def getProgressFromMapFile(mapFile: mapfile_parser.MapFile, asmPath: Path, nonmatchings: Path, aliases: dict[str, str]=dict(), pathIndex: int=2) -> tuple[mapfile_parser.ProgressStats, dict[str, mapfile_parser.ProgressStats]]:
def getProgressFromMapFile(mapFile: mapfile_parser.MapFile, asmPath: Path, aliases: dict[str, str]=dict(), pathIndex: int=2, folderIndex: int|None=None) -> tuple[mapfile_parser.ProgressStats, dict[str, mapfile_parser.ProgressStats]]:
totalStats = mapfile_parser.ProgressStats()
progressPerFolder: dict[str, mapfile_parser.ProgressStats] = dict()
if folderIndex is None:
folderIndex = pathIndex
for segment in mapFile:
for file in segment:
if len(file) == 0:
continue
folder = file.filepath.parts[pathIndex]
if folder in aliases:
folder = aliases[folder]
folderParts = list(file.filepath.parts[pathIndex:folderIndex+1])
if folderParts[0] in aliases:
folderParts[0] = aliases[folderParts[0]]
folder = "/".join(folderParts)
if folder not in progressPerFolder:
progressPerFolder[folder] = mapfile_parser.ProgressStats()
@ -78,13 +81,11 @@ def getProgress(mapPath: Path, version: str, subpaths: bool=False) -> tuple[mapf
realSym.size = sym.size
sym.size = 0
nonMatchingsPath = ASMPATH / version / NONMATCHINGS
pathIndex = 2
folderIndex = None
if subpaths:
pathIndex += 1
folderIndex = 3
return getProgressFromMapFile(mapFile.filterBySectionType(".text"), ASMPATH / version, nonMatchingsPath, aliases={"ultralib": "libultra"}, pathIndex=pathIndex)
return getProgressFromMapFile(mapFile.filterBySectionType(".text"), ASMPATH / version, aliases={"ultralib": "libultra"}, folderIndex=folderIndex)
def progressMain():
@ -92,9 +93,12 @@ def progressMain():
parser.add_argument("-v", "--version", help="version to process", default="us")
parser.add_argument("-p", "--subpaths", help="Make a summary for one level deeper in the path tree", action="store_true")
parser.add_argument("-s", "--sort", help="Sort by decomped size instead of the ROM sorting", action="store_true")
parser.add_argument("-r", "--remaining", help="Print an extra column indicating the remaining percentage to match of each entry", action="store_true")
args = parser.parse_args()
remaining: bool = args.remaining
mapPath = Path("build") / f"drmario64.{args.version}.map"
totalStats, progressPerFolder = getProgress(mapPath, args.version, args.subpaths)
@ -105,9 +109,13 @@ def progressMain():
progressesList = list(progressPerFolder.items())
if args.sort:
progressesList.sort(key=lambda x: (x[1].decompedSize / x[1].total, x[1].total), reverse=True)
progressesList.sort(key=lambda x: (x[1].decompedSize / x[1].total, x[1].total, x[0]), reverse=True)
for folder, statsEntry in progressesList:
statsEntry.print(folder, totalStats)
print(statsEntry.getEntryAsStr(folder, totalStats), end="")
if remaining and statsEntry.undecompedSize != 0:
remainingPercentage = statsEntry.total / totalStats.total * 100 - statsEntry.decompedPercentageTotal(totalStats)
print(f"{remainingPercentage:>8.4f}%", end="")
print()
if __name__ == "__main__":