From faee4586d2230789c55e03c8657a8083a5c73e71 Mon Sep 17 00:00:00 2001 From: Elliot Nunn Date: Sat, 23 Mar 2019 17:26:43 +0800 Subject: [PATCH] Allow to print raw tokens --- patch_rip.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/patch_rip.py b/patch_rip.py index fb87744..35dc0d4 100755 --- a/patch_rip.py +++ b/patch_rip.py @@ -64,6 +64,7 @@ parser = argparse.ArgumentParser(description=''' parser.add_argument('src', nargs='+', action='store', help='Source file (.rdump) or files (numbered)') parser.add_argument('-roms', nargs='+', default=['Plus', 'SE', 'II', 'Portable', 'IIci', 'SuperMario']) +parser.add_argument('-pt', action='store_true', help='Print raw module tokens') parser.add_argument('-pm', action='store_true', help='Print information about modules and code references') parser.add_argument('-pr', action='store_true', help='Print information about ROM references') parser.add_argument('-oo', action='store', help='Base destination path to dump resources as raw files') @@ -211,15 +212,16 @@ for num, data, annotations in lpch_list: tokens.append(tok) if tok[0] == 'end': break - # daccum = 0 - # for i, (a, b) in enumerate(tokens): - # if a == 'distance': - # daccum += b - # print('%02d'%i, a, hex(b), '='+hex(daccum)) - # elif b is None: - # print('%02d'%i, a) - # else: - # print('%02d'%i, a, hex(b)) + if args.pt: + daccum = 0 + for i, (a, b) in enumerate(tokens): + if a == 'distance': + daccum += b + print('%02d'%i, a, hex(b), '='+hex(daccum)) + elif b is None: + print('%02d'%i, a) + else: + print('%02d'%i, a, hex(b)) jt_offset = 0