262588213843476 · Gist

#!/bin/sh
# Convert a GBA multiboot binary into a GBA ROM, by including a pre-assembled bootstrap
# This can be used to play multiboot games using a flash cartridge.
# Example usage:
# ./mb2gba.sh < game.mb > game.gba
# Back up game header from the multiboot rom
header="$(dd bs=1 count=192 | base64)"
# Set the start address to 0x080000c0
echo LgAA6g== | base64 -d
# Copy the rest of the header from the multiboot rom
echo "$header" | base64 -d | dd bs=1 skip=4
# Add the bootstrap binary with padding up to 0x140
echo AQOg43QQj+LUEIDlAhSg49gQgOUhE6Dj3BCA5QMEoOMCCYDiARCg4wYQQOUAAADvAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= | base64 -d
# Append the entire multiboot binary
echo "$header" | base64 -d
dd

Read the original on gist.github.com ↗