2022-01-01 23:26:11 +11:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e # Fail if any command fails
|
|
|
|
set -x # print every command before it runs
|
|
|
|
|
|
|
|
# Requires gbafix and arm-none-eabi-objcopy to already be installed
|
|
|
|
|
|
|
|
function build_rom() {
|
2022-01-02 09:46:37 +11:00
|
|
|
local GAME_FOLDER="$1"
|
2022-01-01 23:26:11 +11:00
|
|
|
local INTERNAL_NAME="$2"
|
|
|
|
|
2022-01-02 09:46:37 +11:00
|
|
|
local GAME_NAME
|
|
|
|
GAME_NAME="$(basename "$GAME_FOLDER")"
|
|
|
|
|
|
|
|
local TARGET_FOLDER="${CARGO_TARGET_DIR:-$GAME_FOLDER/target}"
|
2022-01-02 06:27:31 +11:00
|
|
|
local GBA_FILE="$TARGET_FOLDER/$GAME_NAME.gba"
|
2022-01-01 23:26:11 +11:00
|
|
|
|
2022-01-02 09:46:37 +11:00
|
|
|
(cd "$GAME_FOLDER" && cargo build --release --verbose --target thumbv4t-none-eabi)
|
2022-01-01 23:26:11 +11:00
|
|
|
|
2022-01-13 09:57:47 +11:00
|
|
|
mkdir -p examples/target/examples
|
|
|
|
|
2022-01-02 06:27:31 +11:00
|
|
|
arm-none-eabi-objcopy -O binary "$TARGET_FOLDER/thumbv4t-none-eabi/release/$GAME_NAME" "$GBA_FILE"
|
2022-01-01 23:26:11 +11:00
|
|
|
gbafix -p "-t${INTERNAL_NAME:0:12}" "-c${INTERNAL_NAME:0:4}" -mGC "$GBA_FILE"
|
|
|
|
|
2022-01-13 09:57:47 +11:00
|
|
|
cp -v "$GBA_FILE" "examples/target/examples/$GAME_NAME.gba"
|
2022-01-01 23:26:11 +11:00
|
|
|
}
|
|
|
|
|
2022-01-02 07:17:56 +11:00
|
|
|
mkdir -p examples/target
|
|
|
|
|
2022-01-02 09:46:37 +11:00
|
|
|
build_rom "examples/the-purple-night" "PURPLENIGHT"
|
|
|
|
build_rom "examples/the-hat-chooses-the-wizard" "HATWIZARD"
|
|
|
|
|
|
|
|
build_rom "book/games/pong" "PONG"
|
2022-01-02 07:17:56 +11:00
|
|
|
|
2022-01-13 09:57:47 +11:00
|
|
|
(cd examples/target && zip examples.zip examples/*.gba)
|