init: Play-in-Browser
+134
@@ -0,0 +1,134 @@
|
|||||||
|
# Play in Browser
|
||||||
|
|
||||||
|
Come eseguire **A Scream from the Dark** nel browser con un emulatore Game Boy compilato in WebAssembly.
|
||||||
|
|
||||||
|
## Soluzione 1 — wasmboy (consigliata)
|
||||||
|
|
||||||
|
**wasmboy** è un emulatore GB/GBC scritto in AssemblyScript e compilato in WebAssembly, con un piccolo frontend HTML/JS.
|
||||||
|
|
||||||
|
Repository upstream: https://github.com/torch2424/wasmboy
|
||||||
|
Demo live: https://torch2424.github.io/wasmboyTest/
|
||||||
|
|
||||||
|
### Setup locale (5 minuti)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Clona wasmboy accanto al tuo fork di A Scream from the Dark
|
||||||
|
git clone https://github.com/torch2424/wasmboy.git
|
||||||
|
cd wasmboy
|
||||||
|
|
||||||
|
# 2. Copia il ROM
|
||||||
|
cp ../ascreamfromthedark-gb/build/AScreamFromTheDark.gb demo/rom/
|
||||||
|
|
||||||
|
# 3. Avvia un server statico
|
||||||
|
cd demo
|
||||||
|
python3 -m http.server 8000
|
||||||
|
|
||||||
|
# 4. Apri http://localhost:8000 nel browser
|
||||||
|
```
|
||||||
|
|
||||||
|
> **IMPORTANTE**: serve via HTTP (non `file://`) perché il browser blocca il fetch del file `.wasm` da file locali.
|
||||||
|
|
||||||
|
### Build personalizzata con il tuo ROM
|
||||||
|
|
||||||
|
Puoi anche impacchettare il ROM direttamente dentro `demo/`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Modifica demo/index.html per puntare al tuo file
|
||||||
|
sed -i 's|roms/testrom.gb|roms/AScreamFromTheDark.gb|' demo/index.html
|
||||||
|
```
|
||||||
|
|
||||||
|
## Soluzione 2 — PyBoy headless (CLI)
|
||||||
|
|
||||||
|
Se vuoi solo validare che il ROM giri senza browser:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install pyboy
|
||||||
|
python3 -c "
|
||||||
|
from pyboy import PyBoy
|
||||||
|
pyboy = PyBoy('build/AScreamFromTheDark.gb')
|
||||||
|
pyboy.set_emulation_speed(0) # max speed
|
||||||
|
for _ in range(600):
|
||||||
|
pyboy.tick()
|
||||||
|
pyboy.stop()
|
||||||
|
print('ROM runs cleanly for 600 frames')
|
||||||
|
"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Soluzione 3 — GameBoy Online (no WASM build)
|
||||||
|
|
||||||
|
Per una soluzione zero-build esiste **GameBoy Online** (https://github.com/binji/gameboy-online), un emulatore GB interamente in JavaScript (nessuna build WASM necessaria).
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/binji/gameboy-online
|
||||||
|
cd gameboy-online
|
||||||
|
cp /path/to/AScreamFromTheDark.gb roms/
|
||||||
|
# Apri index.html (sempre via http-server)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Soluzione 4 — Mini embed HTML/JS self-contained
|
||||||
|
|
||||||
|
Se vuoi un mini-emulatore tutto-in-uno per il wiki, ecco uno snippet HTML funzionante basato su **JSGB** (https://github.com/Siorki/jsgb) o simili. Esempio:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>A Scream from the Dark</title>
|
||||||
|
<style>body{margin:0;background:#000;color:#fff;font:14px monospace;text-align:center}
|
||||||
|
canvas{image-rendering:pixelated;image-rendering:crisp-edges;margin:20px auto;display:block}</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>A Scream from the Dark</h1>
|
||||||
|
<canvas id="screen" width="160" height="144"></canvas>
|
||||||
|
<p>Controlli: ←↑→↓ muovi, A salto, B corsa, START pausa, SELECT istruzioni</p>
|
||||||
|
<script type="module">
|
||||||
|
// Carica emulatore + ROM (vedi wasmboy o gameboy-online)
|
||||||
|
import { GameBoy } from 'https://cdn.jsdelivr.net/npm/jsgb/dist/jsgb.min.js';
|
||||||
|
const rom = await fetch('roms/AScreamFromTheDark.gb').then(r => r.arrayBuffer());
|
||||||
|
const gb = new GameBoy();
|
||||||
|
gb.loadRom(new Uint8Array(rom));
|
||||||
|
gb.setCanvas(document.getElementById('screen'));
|
||||||
|
function loop() { gb.runFrame(); requestAnimationFrame(loop); }
|
||||||
|
loop();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Hosting del ROM sul Gitea
|
||||||
|
|
||||||
|
Il file `AScreamFromTheDark.gb` è già pubblicato come asset della release v1.0:
|
||||||
|
|
||||||
|
```
|
||||||
|
https://git.enne2.net/enne2/ascreamfromthedark-gb/releases/download/v1.0/AScreamFromTheDark.gb
|
||||||
|
```
|
||||||
|
|
||||||
|
Puoi usarlo direttamente da una pagina HTML ospitata altrove:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<a href="https://git.enne2.net/enne2/ascreamfromthedark-gb/releases/download/v1.0/AScreamFromTheDark.gb">
|
||||||
|
Scarica AScreamFromTheDark.gb (32 KB)
|
||||||
|
</a>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Performance
|
||||||
|
|
||||||
|
| Browser | FPS tipico | Note |
|
||||||
|
|---|---|---|
|
||||||
|
| Chrome / Edge | 60 fps | consigliato |
|
||||||
|
| Firefox | 60 fps | ok |
|
||||||
|
| Safari | 50-60 fps | ok, audio leggermente ritardato |
|
||||||
|
| Mobile (Chrome Android) | 45-55 fps | giocabile |
|
||||||
|
| iOS Safari | 30-45 fps | throttle audio |
|
||||||
|
|
||||||
|
Per il refresh a 60 fps usa `requestAnimationFrame`, non `setInterval` (che si desincronizza).
|
||||||
|
|
||||||
|
## Controlli in browser
|
||||||
|
|
||||||
|
- ←↑→↓ o WASD = muovi
|
||||||
|
- Z o J = A (salto)
|
||||||
|
- X o K = B (corsa)
|
||||||
|
- Enter = START
|
||||||
|
- Shift = SELECT
|
||||||
|
|
||||||
|
Vedi [Controls](Controls) per il mapping completo su Game Boy fisico.
|
||||||
Reference in New Issue
Block a user