summaryrefslogtreecommitdiff
path: root/tools/script_disassembler/script_disassembler.py
diff options
context:
space:
mode:
authoroctorock <79596758+octorock@users.noreply.github.com>2021-03-05 01:00:45 +0100
committeroctorock <79596758+octorock@users.noreply.github.com>2021-03-06 14:53:33 +0100
commit6dce46458cb4011e824e16d19a6ae129f61481ca (patch)
tree6703926fdc3dd2adb0919cb6218a7c2a85abaa56 /tools/script_disassembler/script_disassembler.py
parent37d03d13824fc8a6f1da88e77176e4d5d7e95c5e (diff)
Split scripts into separate files
Diffstat (limited to 'tools/script_disassembler/script_disassembler.py')
-rw-r--r--tools/script_disassembler/script_disassembler.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/script_disassembler/script_disassembler.py b/tools/script_disassembler/script_disassembler.py
index f0926e68..330d2a7d 100644
--- a/tools/script_disassembler/script_disassembler.py
+++ b/tools/script_disassembler/script_disassembler.py
@@ -5,6 +5,8 @@ import struct
# Input 'macros' to generate the macros for the script commands
# Input the script bytes as hex to disassemble the script
+# Build macros: echo "macros" | python script_disassembler.py > ~/git/tmc/github/asm/macros/script.inc
+
@dataclass
class Context:
ptr: int
@@ -225,9 +227,10 @@ parameters = {
},
}
-def build_script_command(name: str):
+# Remove the ScriptCommand_ prefix for the asm macros
+def build_script_command(name: str):
name = name.replace("ScriptCommand_", "")
- if name[0].isdigit():
+ if name[0].isdigit(): # asm macros cannot start with an _
return '_' + name
return name
@@ -294,7 +297,7 @@ def disassemble_script(input_bytes):
# Print rest (did not manage to get there)
if ctx.ptr < len(ctx.data):
if (len(ctx.data) - ctx.ptr) % 2 != 0:
- print(ctx.data[ctx.ptr:])
+ print('\n'.join(['.byte ' + hex(x) for x in ctx.data[ctx.ptr:]]))
# TODO error
return
print('\n'.join(['.short ' + x for x in barray_to_u16_hex(ctx.data[ctx.ptr:])]))