From 97739a54d693574f02482bfc6b081c040b16e94b Mon Sep 17 00:00:00 2001 From: RodrigoDornelles Date: Sun, 29 Oct 2023 17:47:37 -0300 Subject: [PATCH] feat: change emulator to fceux (wasm) --- .github/workflows/build.yml | 4 +- build-pwa.py | 32 ---------- fake_npm_build.sh | 4 ++ fake_npm_install.sh | 6 ++ res/index.html | 120 ++++++++++++++++++++++++++++++------ 5 files changed, 112 insertions(+), 54 deletions(-) delete mode 100755 build-pwa.py create mode 100755 fake_npm_build.sh create mode 100755 fake_npm_install.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 04bc916..6c98d59 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,8 +60,8 @@ jobs: name: Build project (Makefile) run: make - - name: Build page (Python) - run: ./build-pwa.py --download && ./build-pwa.py --jap + name: Build website + run: ./fake_npm_install.sh && ./fake_npm_build.sh - name: Setup Pages uses: actions/configure-pages@v3 diff --git a/build-pwa.py b/build-pwa.py deleted file mode 100755 index ac95c58..0000000 --- a/build-pwa.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python3 -from base64 import b64encode as b64 -import requests -import sys -import os - -title = 'Coco Battle Royale II' -input = './bin/cocobattleroyale.nes' -output = './html/usa.html' - - -if not os.path.exists('html'): - os.mkdir('html') - -if '--jap' in sys.argv: - title = 'Kokobatoru 2' - input = './bin/kokobatoru.nes' - output = './html/jap.html' - -if '--download' in sys.argv: - for file_name in ['nes.min.js']: - cdn = 'https://cdn.jsdelivr.net/gh/takahirox/nes-js@v0.0.1/build' - with requests.get(f'{cdn}/{file_name}', stream=True) as download: - file_name = file_name.replace(r'.min.js', '.js') - open(f'./html/{file_name}', "w+").write(download.text) - -rom = b64(open(input, "rb").read()).decode() -html = open("./res/index.html", "r").read() -html = html.replace(r'{{game}}', title).replace(r'{{rom}}', rom) -open(output, "w").write(html) - -print(title) diff --git a/fake_npm_build.sh b/fake_npm_build.sh new file mode 100755 index 0000000..084e315 --- /dev/null +++ b/fake_npm_build.sh @@ -0,0 +1,4 @@ +#!/usr/bin/sh +mkdir -p html +cp ./bin/kokobatoru.nes ./html +cp ./bin/cocobattleroyale.nes ./html diff --git a/fake_npm_install.sh b/fake_npm_install.sh new file mode 100755 index 0000000..7541d2c --- /dev/null +++ b/fake_npm_install.sh @@ -0,0 +1,6 @@ +#!/usr/bin/sh +mkdir -p html +URL_FCEUX_JS=https://cdn.jsdelivr.net/npm/em-fceux@2.2.0/dist/fceux.min.js +URL_FCEUX_WASM=https://cdn.jsdelivr.net/npm/em-fceux@2.2.0/dist/fceux.wasm +(curl -fsSL $URL_FCEUX_JS || wget -qO- $URL_FCEUX_JS) > html/fceux.js +(curl -fsSL $URL_FCEUX_WASM || wget -qO- $URL_FCEUX_WASM) > html/fceux.wasm diff --git a/res/index.html b/res/index.html index 8bf542b..7ec1c51 100644 --- a/res/index.html +++ b/res/index.html @@ -1,10 +1,24 @@ - - {{game}} - + + + + Coco Battle Royale 2 + + + + + + + + + + + + - - + - - - - + FCEUX().then((fceux_) => { + fceux = fceux_; + loading.style.display = 'none'; + buttons.forEach(button => button.style.display = 'block'); + }); + }) + + +