diff options
author | mid-kid <esteve.varela@gmail.com> | 2020-09-12 23:58:44 +0200 |
---|---|---|
committer | mid-kid <esteve.varela@gmail.com> | 2020-09-12 23:58:44 +0200 |
commit | c8d5687ac4fa64396104da4f3f04f0594c38dc6c (patch) | |
tree | 7df330f23a1f8a7225e2820dccec24239ce23c40 /tools/dump_string.py | |
parent | 247b904a6bb10c7fdd5689c8380a4a0bdb30385c (diff) |
Dump strings, write tooling around them
Diffstat (limited to 'tools/dump_string.py')
-rwxr-xr-x | tools/dump_string.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/dump_string.py b/tools/dump_string.py new file mode 100755 index 0000000..42fd347 --- /dev/null +++ b/tools/dump_string.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +from sys import argv +from charmap import parse_charmap + +file = open("DMGAKVJ0.1", "rb").read() + +bank = int(argv[1], 16) +addr = int(argv[2], 16) + +offset = addr +if bank > 0: + offset += 0x4000 * (bank - 1) + +o_charmap, constants = parse_charmap("data/charmap.txt") +charmap = {} +for char in o_charmap: + if o_charmap[char] not in charmap: + charmap[o_charmap[char]] = char + +while True: + value = file[offset] | (file[offset + 1] << 8) + offset += 2 + + if value == 0xffff: + print() + break + elif value == 0xfffe: + print() + continue + + if value in charmap: + print(charmap[value], end="") + else: + print("<%02x>" % value, end="") |