diff --git a/configure.py b/configure.py index 0391f230..29477679 100755 --- a/configure.py +++ b/configure.py @@ -20,12 +20,16 @@ def run(cmd: str) -> str: args = parser.parse_args() -VERSIONS = ["us", "jp"] +if run("type mips64-ultra-elf-gcc >/dev/null 2>&1; echo $?").rstrip() == "0": + MIPS = "mips64-ultra-elf" +else: + MIPS = "mips64" -CC = "mips64-gcc" -LD = "mips64-g++" -AS = "mips64-gcc -x assembler-with-cpp" -OBJCOPY = "mips64-objcopy" +VERSIONS = ["us", "jp"] +CC = f"{MIPS}-gcc" +LD = f"{MIPS}-g++" +AS = f"{MIPS}-gcc -x assembler-with-cpp" +OBJCOPY = f"{MIPS}-objcopy" GRC = "grc" GENHOOKS = "./genhooks" SRCDIR = "src" @@ -89,13 +93,14 @@ def run(cmd: str) -> str: description="LD $out", ) -n.rule("grc", command="$grc $in -d $resdesc -o $out", description="GRC $in") +# grc directly looks for an AS environment variable to check which mips command to use +n.rule("grc", command=f"export AS=\"{MIPS}-as\"; $grc $in -d $resdesc -o $out", description="GRC $in") n.rule("as", command=f"$as {CPPFLAGS} $ldflags $in -o $out", description="AS $in") n.rule("objcopy", command="$objcopy -S -O binary $in $out", description="OBJCOPY $in -> $out") -n.rule("genhooks", command="$genhooks $in > $out", description="GENHOOKS $in") +n.rule("genhooks", command=f"$genhooks $in {MIPS} > $out", description="GENHOOKS $in") n.rule("sys_cc", command="gcc -O2 $in -o $out", description="GCC $in") diff --git a/genhooks b/genhooks index f96bc043..9bbe22f2 100755 --- a/genhooks +++ b/genhooks @@ -6,8 +6,13 @@ if [ -z "$elf" ]; then exit fi +mips="$2" +if [ -z "$mips" ]; then + mips="mips64" +fi + symtbl="$(mktemp)" -mips64-nm "$elf" | awk '(/^[0-9A-Za-z_ ]*$/) {printf "sym_%s=0x%s\n",$3,substr($1,length($1)-7)}' >"$symtbl" +$mips-nm "$elf" | awk '(/^[0-9A-Za-z_ ]*$/) {printf "sym_%s=0x%s\n",$3,substr($1,length($1)-7)}' >"$symtbl" . "$symtbl" rm -f "$symtbl" @@ -24,8 +29,8 @@ genhook() { addr="$(printf "%d" "$1")" tmp="$(mktemp)" - echo ".set noreorder; .set noat; $2" | mips64-as - -o "$tmp" - mips64-readelf -x .text "$tmp" | grep "0x[0-9A-Fa-f]\{8\}" | grep -o " [0-9A-Fa-f]\{8\}" | + echo ".set noreorder; .set noat; $2" | $mips-as - -o "$tmp" + $mips-readelf -x .text "$tmp" | grep "0x[0-9A-Fa-f]\{8\}" | grep -o " [0-9A-Fa-f]\{8\}" | while read -r line; do gsc16 "$addr" "0x`echo "$line" | sed -e "s/\(....\)..../\1/"`" addr="$(expr "$addr" + 2)" diff --git a/src/fp/debug/flags.c b/src/fp/debug/flags.c index 4d576cff..0b3416b2 100644 --- a/src/fp/debug/flags.c +++ b/src/fp/debug/flags.c @@ -60,7 +60,8 @@ static void addEvent(s32 recordIndex, s32 flagIndex, bool value) { e->recordIndex = recordIndex; e->flagIndex = flagIndex; e->value = value; - snprintf(e->description, sizeof(e->description), "%s[0x%0*lx] := %i", r->name, r->indexLength, flagIndex, value); + snprintf(e->description, sizeof(e->description), "%s[0x%0*lx] := %i", r->name, r->indexLength % 10, flagIndex, + value); } static u32 getFlagWord(void *data, size_t wordSize, s32 index) {