diff options
author | mid-kid <esteve.varela@gmail.com> | 2020-09-13 01:01:15 +0200 |
---|---|---|
committer | mid-kid <esteve.varela@gmail.com> | 2020-09-13 01:01:15 +0200 |
commit | 38315f0c65e4a512386b3ffd3e914b4a54edda92 (patch) | |
tree | 5ada4b53e89558da13ac8c9c23de404884039622 /tools/dump_string.py | |
parent | 54b050210a5a01930ebb3b3d098467d5f0eada1b (diff) |
Dump remaining strings in bank 2
Diffstat (limited to 'tools/dump_string.py')
-rwxr-xr-x | tools/dump_string.py | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/tools/dump_string.py b/tools/dump_string.py index 42fd347..1641944 100755 --- a/tools/dump_string.py +++ b/tools/dump_string.py @@ -7,6 +7,9 @@ file = open("DMGAKVJ0.1", "rb").read() bank = int(argv[1], 16) addr = int(argv[2], 16) +count = 1 +if len(argv) > 3: + count = int(argv[3], 0) offset = addr if bank > 0: @@ -18,18 +21,26 @@ 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="") +print(".org %02x:%04x" % (bank, addr)) +for x in range(count): + bank = offset // 0x4000 + addr = offset % 0x4000 + if bank > 0: + addr += 0x4000 + + print("[message_%02x_%04x]" % (bank, addr)) + while True: + value = file[offset] | (file[offset + 1] << 8) + offset += 2 + + if value == 0xffff: + print("\n") + break + elif value == 0xfffe: + print() + continue + + if value in charmap: + print(charmap[value], end="") + else: + print("<%02x>" % value, end="") |