#!/bin/sh # Regenerate prg.s from the ROM and the Mesen CDL capture. # # The pass order is the one the repo uses: # 1. Pass 1 - banked_dis.py traces every MMC3 bank separately, seeded from # the Mesen Code Data Logger capture, and writes prg.s. # 2. Pass 2 - derive_branch_names.py adds the mechanical branch-target names # to the hand-written routine map, apply_pass2_map.py renames the file. # 3. The audit comments are re-aligned, because the rename makes the # operands longer. # # The CDL capture is not kept in the repository: it is 64 KB of emulator # state. Re-take it with Mesen (see README.md) if the split has to be # re-derived. set -e PROJ="$(dirname "$0")" TOOLS="$PROJ/../../_tools" CDL="${CDL:-/tmp/opencode/mermaids_union.cdl}" python3 "$TOOLS/banked_dis.py" \ --prg "$PROJ/prg.bin" \ --cdl "$CDL" \ --project "Mermaids of Atlantis (U)" \ --out "$PROJ/prg.s" \ --symbols "$PROJ/symbols.inc" \ --undocumented \ --banks "0:8000,2000:A000,4000:C000,6000:E000,8000:8000,A000:A000,C000:C000,E000:E000" \ --prefix "8000:Bank4,A000:Bank5,C000:Bank6,E000:Bank7" \ --label "4000:C00E" python3 "$TOOLS/derive_branch_names.py" "$PROJ" "$PROJ/routinemap.tsv" \ "0:,8000:Bank4,A000:Bank5,C000:Bank6,E000:Bank7" "$PROJ/labelmap.tsv" python3 "$TOOLS/apply_pass2_map.py" "$PROJ" "$PROJ/labelmap.tsv" \ --bank-prefix "0:,8000:Bank4,A000:Bank5,C000:Bank6,E000:Bank7" --write # The semantic zero-page names, the routine descriptions and the audit # comment column are the last three passes. python3 "$TOOLS/apply_zp_aliases.py" "$PROJ" --write \ --alias ButtonState1=Zp26 --alias ButtonState2=Zp27 \ --alias PrevButton1=Zp28 --alias PrevButton2=Zp29 \ --alias NewButton1=Zp2A --alias NewButton2=Zp2B \ --alias PrgBankNumber=Zp2C --alias HandlerIndex=Zp2D \ --alias IdleCounter=Zp2F --alias FrameCounter=Zp31 \ --alias ControllerBits=Zp05 --alias ControllerByte=Zp07 \ --alias GameMode=Zp6A python3 "$TOOLS/describe_routines.py" "$PROJ/prg.s" "$PROJ/routinedesc.tsv" python3 "$TOOLS/align_audit_comments.py" "$PROJ" --write