diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3f32236e..c27099a1 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -16,7 +16,7 @@ jobs: matrix: include: - name: Linux - os: ubuntu-latest + os: ubuntu-20.04 - name: Mac os: macos-latest steps: @@ -35,3 +35,15 @@ jobs: brew install sdl2 coreutils - name: Build run: make -j$(nproc) zelda3 + + - name: Package AppImage + if: ${{ matrix.name == 'Linux' }} + run: | + platform/appimage/appimage.sh + + - name: Upload AppImage + if: ${{ matrix.name == 'Linux' }} + uses: actions/upload-artifact@v3 + with: + name: Zelda3 + path: uploads/ diff --git a/platform/appimage/AppRun b/platform/appimage/AppRun new file mode 100755 index 00000000..6164832f --- /dev/null +++ b/platform/appimage/AppRun @@ -0,0 +1,86 @@ +#!/bin/bash + +SCRIPT_PATH=`dirname $(realpath $0)`/usr +export LD_LIBRARY_PATH=${SCRIPT_PATH}/lib +export LC_NUMERIC=en_US.UTF-8 +export ZELDA_ROM=$(shasum *.s[mf]c | grep -i 6D4F10A8B10E10DBE624CB23CF03B88BB8252973 | awk '{ print $2 }') +export LANG_ROM=$(shasum *.s[mf]c | awk ' { print $2 }' | sed '/zelda3.sfc/ d') +export LANG_ROM_HASH=$(shasum *.s[mf]c | awk '{ print toupper($1) }' | sed '/6D4F10A8B10E10DBE624CB23CF03B88BB8252973/I d') + +extract_language () { + sed -i 's/# Language/Language/g' "$ASSETDIR"/zelda3.ini + sed -i "s/Language = .*/Language = $1/g" "$ASSETDIR"/zelda3.ini + "${SCRIPT_PATH}"/bin/notify-send -i "${SCRIPT_PATH}"/../zelda3.png "Translating..." + "${SCRIPT_PATH}"/bin/python3 restool.py --extract-dialogue -r translate.sfc + "${SCRIPT_PATH}"/bin/python3 restool.py --languages="$1" +} + +if [ ! -e zelda3_assets.dat ]; then + if [ ! -e "$ZELDA_ROM" ]; then + "${SCRIPT_PATH}"/bin/notify-send -i "${SCRIPT_PATH}"/../zelda3.png "Missing ROM file" + exit + else + export ASSETDIR="$(mktemp -d /tmp/assets-XXXXX)" + cp -r "${SCRIPT_PATH}"/assets/* "$ASSETDIR" + ln -s "$PWD"/"$ZELDA_ROM" "$ASSETDIR"/tables/zelda3.sfc + if [ -e "$LANG_ROM" ]; then + ln -s "$PWD"/"$LANG_ROM" "$ASSETDIR"/tables/translate.sfc + fi + cd "$ASSETDIR"/tables + "${SCRIPT_PATH}"/bin/notify-send -i "${SCRIPT_PATH}"/../zelda3.png "Extracting Assets" + "${SCRIPT_PATH}"/bin/python3 restool.py --extract-from-rom -r zelda3.sfc + if [ -e "translate.sfc" ]; then + case "$LANG_ROM_HASH" in + 2E62494967FB0AFDF5DA1635607F9641DF7C6559) + extract_language "de" + ;; + 229364A1B92A05167CD38609B1AA98F7041987CC) + extract_language "fr" + ;; + C1C6C7F76FFF936C534FF11F87A54162FC0AA100) + extract_language "fr-c" + ;; + 7C073A222569B9B8E8CA5FCB5DFEC3B5E31DA895) + extract_language "en" + ;; + 461FCBD700D1332009C0E85A7A136E2A8E4B111E) + extract_language "es" + ;; + 3C4D605EEFDA1D76F101965138F238476655B11D) + extract_language "pl" + ;; + D0D09ED41F9C373FE6AFDCCAFBF0DA8C88D3D90D) + extract_language "pt" + ;; + B2A07A59E64C498BC1B2F28728F9BF4014C8D582) + extract_language "redux" + ;; + 9325C22EB0A2A1F0017157C8B620BC3A605CEDE1) + extract_language "redux" + ;; + FA8ADFDBA2697C9A54D583A1284A22AC764C7637) + extract_language "nl" + ;; + 43CD3438469B2C3FE879EA2F410B3EF3CB3F1CA4) + extract_language "sv" + ;; + *) + "${SCRIPT_PATH}"/bin/notify-send -i "${SCRIPT_PATH}"/../zelda3.png "Unknown ROM file" + exit + ;; + esac + fi + cd - + cp "$ASSETDIR"/tables/zelda3_assets.dat . + cp "$ASSETDIR"/zelda3.ini . + rm -r "$ASSETDIR" + fi +fi + +if [ ! -e zelda3.ini ]; then + cp "${SCRIPT_PATH}"/assets/zelda3.ini . +fi + +"${SCRIPT_PATH}"/bin/zelda3 $@ + +exit diff --git a/platform/appimage/appimage.sh b/platform/appimage/appimage.sh new file mode 100755 index 00000000..848ed7af --- /dev/null +++ b/platform/appimage/appimage.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +export LINUXDEPLOY="./linuxdeploy-x86_64.AppImage --appimage-extract-and-run" +export CONDA_PACKAGES="pyyaml;pillow" +curl -sSfLO https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage +curl -sSfLO https://raw.githubusercontent.com/linuxdeploy/linuxdeploy-plugin-conda/master/linuxdeploy-plugin-conda.sh +chmod +x linuxdeploy-x86_64.AppImage +chmod +x linuxdeploy-plugin-conda.sh +$LINUXDEPLOY --appdir=AppDir +cp zelda3 AppDir/usr/bin/ +cp platform/appimage/{AppRun,zelda3.desktop,zelda3.png} AppDir +chmod +x AppDir/AppRun +chmod +x AppDir/usr/bin/zelda3 +mkdir -p AppDir/usr/assets +cp -r {tables,other} AppDir/usr/assets/ +cp zelda3.ini AppDir/usr/assets/ +cp /usr/bin/notify-send AppDir/usr/bin/ +$LINUXDEPLOY --appdir=AppDir --plugin conda --output appimage +mkdir uploads +mv Zelda*.AppImage uploads diff --git a/platform/appimage/zelda3.desktop b/platform/appimage/zelda3.desktop new file mode 100644 index 00000000..9a62a5b0 --- /dev/null +++ b/platform/appimage/zelda3.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=Zelda3 +Exec=zelda3 +Terminal=false +Type=Application +Icon=zelda3 +Comment=Zelda3 port +Categories=Game; +StartupWMClass=zelda3; diff --git a/platform/appimage/zelda3.png b/platform/appimage/zelda3.png new file mode 100644 index 00000000..c9b43911 Binary files /dev/null and b/platform/appimage/zelda3.png differ