From 5f04911e0098b073fb4ce5eca6905bf4ac92ead8 Mon Sep 17 00:00:00 2001 From: Roman971 Date: Sat, 21 Mar 2020 18:19:49 +0100 Subject: [PATCH] Add script to generate REG macros from GameInfo offsets Also removed `asmdiff-old.sh` that I believe is no longer used by anyone. --- tools/asmdiff-old.sh | 7 ------- tools/regconvert.py | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) delete mode 100644 tools/asmdiff-old.sh create mode 100644 tools/regconvert.py diff --git a/tools/asmdiff-old.sh b/tools/asmdiff-old.sh deleted file mode 100644 index 66b986662b..0000000000 --- a/tools/asmdiff-old.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -OBJDUMP="${MIPS_BINUTILS_PREFIX}objdump -D -bbinary -mmips -EB" -OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))" -$OBJDUMP $OPTIONS baserom.z64 > baserom.dump -$OBJDUMP $OPTIONS zelda_ocarina_mq_dbg.z64 > zelda_ocarina_mq_dbg.dump -diff baserom.dump zelda_ocarina_mq_dbg.dump | colordiff diff --git a/tools/regconvert.py b/tools/regconvert.py new file mode 100644 index 0000000000..fdc1090b67 --- /dev/null +++ b/tools/regconvert.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +import argparse + +GROUP_SIZE = 0x60 +DATA_OFFSET = 0x14 + +REGISTER_NAMES = " SOPQMYDUIZCNKXcsiWAVHGmnBdkb" + +def get_reg_macro(offset): + reg = (offset - DATA_OFFSET) // 2 + group = reg // GROUP_SIZE + reg_in_group = reg % GROUP_SIZE + return "%cREG(%d)\n" % (REGISTER_NAMES[group], reg_in_group) + +def main(): + parser = argparse.ArgumentParser(description="Converts a GameInfo offset to a REG macro.") + parser.add_argument("offset", help="offset to GameInfo in hexadecimal") + args = parser.parse_args() + print(get_reg_macro(int(args.offset, 16))) + +if __name__ == "__main__": + main()