#!/usr/bin/env bash
set -eu -o pipefail

#   Simple "visual" dump of an Apple 1 (Signetics 2513 or similar)
#   character ROM file. This is for emulator ROM dumps, which are not in
#   the format of the actual ROM. See:
#       https://github.com/0cjs/sedoc/blob/master/8bit/a1/charrom.md

#   xxd:
#     -c 1    print only one byte per line
#     -b      binary output
#   sed:
#     every eight lines, insert a blank line
#     remove leading addresses and (meaningless) trailing "ASCII" output
#     replace 0 with period and 1 with asterisk
#
xxd -c 1 -b "$@" | sed \
    -e '0~8 a\\' \
    -e 's/^[0-9a-f]*: //' -e 's/  *.$//' \
    -e 's/0/./g' -e 's/1/*/g'
