Various improvements

This commit is contained in:
Elliot Nunn 2020-09-12 14:48:16 +08:00
parent 4b0f72856f
commit 6007b23086
4 changed files with 37814 additions and 25 deletions

View File

@ -6,28 +6,20 @@ VANILLA=~/Documents/mac/primary/Sys710x.rdump
SUPERMARIO=~/Documents/mac/supermario/worktree/cube-e
BUILT=$SUPERMARIO/BuildResults/System/System.rdump
WIDTHS="16 32 64"
MODE=-pj
RH="-rh $SUPERMARIO/BuildResults/System/Lib/LinkedPatches.lib"
SH="-sh $SUPERMARIO/BuildResults/System/Text/LinkPatchJumpTbl"
COMMON="-w 16 $RH $SH"
for WIDTH in $WIDTHS; do
DEST=lpchdmp$WIDTH.txt
COLUMN=$((10 + $WIDTH*5/4 + 4))
for MODE in pt pm pr pj pjh pp; do
(
paste \
<(./patch_rip.py $VANILLA $MODE -w $WIDTH $RH $SH | cut -c -$(($COLUMN-1)) ) \
<(./patch_rip.py $BUILT $MODE -w $WIDTH $RH $SH ) \
| expand -t $COLUMN
)>/tmp/$DEST &
./patch_rip.py -$MODE $COMMON $BUILT >/tmp/elliot-$MODE-lpch
./patch_rip.py -$MODE $COMMON $VANILLA >/tmp/apple-$MODE-lpch; echo >>/tmp/apple-$MODE-lpch
git diff --no-index -U999999999 /tmp/elliot-$MODE-lpch /tmp/apple-$MODE-lpch >lpch-$MODE.patch
true
) &
done
for job in `jobs -p`; do
wait $job
done
for WIDTH in $WIDTHS; do
DEST=lpchdmp$WIDTH.txt
mv /tmp/$DEST $DEST
wait $job
done

37740
definitive.txt Normal file

File diff suppressed because it is too large Load Diff

50
order_rom_refs.py Executable file
View File

@ -0,0 +1,50 @@
#!/usr/bin/env python3
import argparse
import re
from os import path
parser = argparse.ArgumentParser(description='''
Determine the order in which various object files make jmpROM, jsrROM etc calls.
This is relevant to matching up the link order with the linkedpatch ROM bind order
''')
parser.add_argument('src', action='store', nargs='+', help='Object files')
parser.add_argument('-1', action='store_true', dest='onlyonce', help='Mention each rom reference only once')
parser.add_argument('-f', '--filter', action='store', dest='filter', help='List of truly included ROM reference names (one per line)')
parser.add_argument('-n', '--number', action='store', dest='number', type=int, help='lpch resource number (helps sub-filter -f)')
args = parser.parse_args()
every = None
right_number = True
if args.number: right_number = False
if args.filter:
every = set()
for l in open(args.filter):
if args.number:
if 'lpch %d' % args.number in l:
right_number = True
elif 'lpch ' in l:
right_number = False
l = l.partition(';')[0].split()
if len(l) == 1:
if right_number:
name = l[0]
every.add(name)
already = set()
for src_path in args.src:
if not args.onlyonce: already = set()
obj_file = open(src_path, 'rb').read()
if obj_file.startswith(b'\x01'):
didprint = False
for m in re.finditer(rb'ROM\$([_A-Za-z][_A-Za-z0-9@%]*)\$', obj_file):
rom_name = m.group(1).decode('mac_roman')
if (every is None or rom_name in every) and rom_name not in already:
if not didprint:
print(path.basename(src_path))
didprint = True
already.add(rom_name)
print(' ' + rom_name)

View File

@ -17,10 +17,10 @@ COND_NAMES = ['Plus', 'SE', 'II', 'Portable', 'IIci', 'SuperMario',
global_sym_names = {}
def name(jt_offset):
retval = 'R%03X' % jt_offset
retval = '%03X' % jt_offset
betterval = global_sym_names.get(jt_offset, None)
if betterval:
return retval + '/' + betterval
return retval + ' ' + betterval
else:
return retval
@ -147,6 +147,7 @@ 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('-pj', action='store_true', help='Print jump table')
parser.add_argument('-pjh', action='store_true', help='Print jump table (hex)')
parser.add_argument('-pp', action='store_true', help='Print patch names')
parser.add_argument('-rh', action='store', help='LinkedPatches.lib, so we know how to name ROM references')
parser.add_argument('-sh', action='store', help='output of LinkedPatch -l, so we know how to name symbols')
@ -265,7 +266,8 @@ for num, data in lpch_list:
rom_table.append(romofs_pairs)
if args.pr:
print(','.join('(%s,$%x)' % (k, v) for k, v in romofs_pairs))
rom_lookup_name = ','.join('(%s,$%x)' % (k, v) for k, v in romofs_pairs)
print(global_romref_names.get(rom_lookup_name, rom_lookup_name))
if the_int & 0x800000:
break
@ -474,14 +476,16 @@ for el in large_rom_table:
if args.pp:
for jt, v in patches.items():
for jt, v in sorted(patches.items()):
for trap, cond_names in v:
print(f' MakePatch {name(jt)}, _{trap:04X}, ({cond_names})')
if args.pj:
if args.pj or args.pjh:
nums = [num for num, data in lpch_list]
CHARWID = 2.5 if args.pjh else 1 # for hex
def render_line(ofs, line):
return '%05x: %s' % (ofs, line)
@ -494,15 +498,18 @@ if args.pj:
if not line:
print('expected', stop, 'got', len(code))
raise ValueError()
line = bytes(x if (32 < x and x != 127 and x != 0xF0 and x < 127) else 46 for x in line).decode('mac_roman')
line = ' ' * (ofs % args.width) + line
if args.pjh:
line = ' '.join(line[o:o+2].hex() for o in range(0, len(line), 2))
else:
line = bytes(x if (32 < x and x != 127 and x != 0xF0 and x < 127) else 46 for x in line).decode('mac_roman')
line = ' ' * int(CHARWID * (ofs % args.width)) + line
yield render_line(ofs, line)
ofs = ofs2
def render_offset(ofs, line):
return '%05x: %s%s' % (ofs, ' ' * (ofs % args.width), line)
return '%05x: %s%s' % (ofs, ' ' * int(CHARWID * (ofs % args.width)), line)
def render_sep(ofs):
return '%05x: %s' % (ofs, '=' * args.width)