#!/bin/bash # Produce a per-instruction TMS34010 trace of Mortal Kombat (Midway T-unit) # from MAME 0.285. # # usage: scripts/mame/trace_mk.sh [start-frame] [stop-frame] # TRACE_REGS=short cuts the register line from 33 fields to 7 # MACHINE=smashtv trace a different TMS34010 board (Y-unit, 34010 @ 40 MHz) # # Output: /error.log (one register line per instruction, state # BEFORE the instruction) and /trace_disasm.txt (the # matching disassembly, line for line). # # error.log is opened in the process's current working directory, so the # script cd's into first. ROMs are read in place from the MAME # set directory with -rompath; nothing is copied. Traces and ROMs are # gitignored -- never commit either. See docs/mame-oracle.md. set -euo pipefail out=${1:?output directory}; start=${2:-0}; stop=${3:-2} mame=${MAME:-/usr/games/mame} machine=${MACHINE:-mk} rompath="${ROMPATH:-${MAME_ROMPATH:?set MAME_ROMPATH (or ROMPATH) to the MAME non-merged ROM folder}}" here=$(cd "$(dirname "$0")" && pwd) mkdir -p "$out/cfg" "$out/nvram" out=$(cd "$out" && pwd) cd "$out" TRACE_START_FRAME=$start TRACE_STOP_FRAME=$stop TRACE_DISASM_FILE=trace_disasm.txt \ TRACE_REGS=${TRACE_REGS:-full} \ "$mame" "$machine" -rompath "$rompath" -homepath "$out" \ -cfg_directory "$out/cfg" -nvram_directory "$out/nvram" \ -video none -sound none -nothrottle -noreadconfig -skip_gameinfo \ -debug -debugger none -log -autoboot_script "$here/trace_mk.lua" 2>&1 \ | grep -vE '^(ALSA|Warning: -video)' || true wc -l "$out/error.log" "$out/trace_disasm.txt"