diff options
author | Rangi <remy.oukaour+rangi@gmail.com> | 2020-08-09 13:49:34 -0400 |
---|---|---|
committer | Rangi <remy.oukaour+rangi@gmail.com> | 2020-08-09 13:49:34 -0400 |
commit | b7da8dbb0e2236f37e4b4c99b88598369da3a008 (patch) | |
tree | 7dd6391629d3c80572ed2af73205851d4122d72b /tools/dump_names.py | |
parent | faa37936780b8e04733310024bd621a8f2c635cb (diff) |
tools/ contains what's needed to build the ROMs; utils/ contains disassembly utilites
Diffstat (limited to 'tools/dump_names.py')
-rw-r--r-- | tools/dump_names.py | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/tools/dump_names.py b/tools/dump_names.py deleted file mode 100644 index 81f357a..0000000 --- a/tools/dump_names.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python - -import sys, os, io -from read_charmap import read_charmap - -def calc_bank(p): - return p // 0x4000 - -def calc_address(p): - b = calc_bank(p) - o = b * 0x4000 - return 0x4000 + p - o - -def get_sym_loc(p): - b, a = calc_bank(p), calc_address(p) - return '%02x:%04x' % (b, a) - -def get_project_dir(): - script_path = os.path.realpath(__file__) - script_dir = os.path.dirname(script_path) - project_dir = os.path.join(script_dir, '..') - return os.path.normpath(project_dir) - -def get_baserom_path(): - project_dir = get_project_dir() - return os.path.join(project_dir, 'baserom.gb') - -def dump_strings(data): - charmap = read_charmap() - ss = [] - chars = [] - for v in data: - if v in charmap: - c = charmap[v] - chars.append(c) - else: - if chars: - ss.append('"%s"' % ''.join(chars)) - chars = [] - ss.append('$%02x' % v) - if v == 0x50: - if chars: - ss.append('"%s"' % ''.join(chars)) - chars = [] - print '\tdb %s' % ', '.join(ss) - ss = [] - if ss: - print '\tdb %s' % ', '.join(ss) - -def read_data(bank, address, n): - offset = bank * 0x4000 + address - 0x4000 - baserom_path = get_baserom_path() - with open(baserom_path, 'rb') as f: - f.seek(offset) - data = [] - i = 0 - while i < n: - c = f.read(1) - v = ord(c) - if v == 0x50: - i += 1 - data.append(v) - return data - -p = 0xfcaaf # Landmarks -print get_sym_loc(p) -data = read_data(calc_bank(p), calc_address(p), 45) -dump_strings(data) |