Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")

Expand Down
11 changes: 8 additions & 3 deletions genhooks
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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)"
Expand Down
3 changes: 2 additions & 1 deletion src/fp/debug/flags.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down