Skip to content

Instantly share code, notes, and snippets.

@dogtopus
Last active May 3, 2019 06:12
Show Gist options
  • Save dogtopus/778fd6afe85249ad38d84375369236cf to your computer and use it in GitHub Desktop.
Save dogtopus/778fd6afe85249ad38d84375369236cf to your computer and use it in GitHub Desktop.
Monon Color (Moonoon Color) save dumper/injector
#!/bin/bash
# Old code, published as-is. Should work on most 64Mbit games. Not sure about others.
SAVE_OFFSET=$((0x50000))
SAVE_SIZE=$((0x20000))
save_read() {
dd if="$1" of="$2" \
iflag=skip_bytes,count_bytes count=$SAVE_SIZE skip=$SAVE_OFFSET
}
save_write() {
dd if="$2" of="$1" \
iflag=count_bytes oflag=seek_bytes conv=nocreat,notrunc \
count=$SAVE_SIZE seek=$SAVE_OFFSET
}
save_erase() {
tr "\000" "\377" < /dev/zero | \
dd of="$1" iflag=count_bytes oflag=seek_bytes conv=nocreat,notrunc \
count=$SAVE_SIZE seek=$SAVE_OFFSET
}
_die() {
if [[ ! -z "$2" ]]; then
echo "$2" 1>&2
fi
exit $1
}
if [[ $# -lt 2 ]]; then
_die 1 "Usage: $0 r|w|e <rom> [save]"
fi
case "$1" in
e|erase)
save_erase "$2"
;;
r|read)
if [[ $# -lt 3 ]]; then _die 1 "Save file not specified"; fi
save_read "$2" "$3"
;;
w|write)
if [[ $# -lt 3 ]]; then _die 1 "Save file not specified"; fi
save_write "$2" "$3"
;;
*)
_die 1 "Usage: $0 r|w|e <rom> [save]"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment