| Commit message (Collapse) | Author |
|
Typing commands is the main thing you do in the lab, so selecting a machine
now focuses its input instead of making you click twice. Clicking anywhere on
a card selects it; the input takes the caret.
The catch is that the console swallows the keyboard - 'z' and 'x' are letters
before they are A and B - so there are two ways back to the joypad: esc, or
clicking the Game Boy's screen (which is where you'd reach for it anyway).
Both are spelled out in the header and the input's placeholder.
Switching machines also releases any button still held on the one you left,
which previously could stick down across a focus change.
Also lands the page swap: the network lab is the landing page and the
single-Game-Boy player moved to /play.html, with /net.html 301'd in nginx.
Verified in headless Chrome: focus follows add and click, the screen and esc
both blur back, SELECT still opens the on-screen keyboard afterwards
(20 -> 491 lit pixels), and typing 'uptime' into a card still answers.
|
|
/net.html plugs Game Boys into a switch that leases them addresses and routes
between them: add one, add another, and they ping each other. Unplug either
and its address goes back to the pool for the next one.
web/gbhub.js is tools/gbhub (gbos) ported to the browser - SLIP framing, DHCP
OFFER/ACK, unicast routing, broadcast flooding and ICMP echo for the gateway.
It deliberately has no uplink: NAT needs a TUN device and a tab has no raw
sockets, so packets addressed off-net are dropped and logged as "no route"
rather than pretending.
web/gbcore.js wraps one wasm instantiation as a GameBoy object. Several Game
Boys are several instantiations of the same compiled Module - the core keeps
its machine in a static, so each gets its own linear memory and is isolated
for free. Measured 12.3x realtime per instance, so the page caps at 6.
Each card gets a text input, because unframed link bytes are console I/O: it
lands on the shell's stdin like tools/gbtype, so you can run `ping 10.0.0.3`
without the on-screen keyboard.
Verified headless (node, two Game Boys through the hub: 2/2 leases, ping
4/4 received) and in headless Chrome against the live site: 4 Game Boys at
60fps each, leases .2-.5, typing into a card's console pings another, unplug
frees the address and a replug reclaims it, no exceptions.
|
|
The page fetched nothing on its own, so a visitor met an empty canvas and a
file picker. It now loads roms/gbos.gb on arrival - gbos being a Unix-ish
microkernel for the GBC, which shows off rather more of the emulator than a
title screen - with a note pointing at SELECT for its on-screen keyboard and
warning that its networking rides a link cable a browser tab doesn't have.
Dropping your own ROM still replaces it (and hides the blurb).
web/deploy.sh builds the wasm, stages index + wasm + the demo ROM, rsyncs to
/opt/sl0p/gbc and curls the three URLs back. The ROM is a build artifact of
~/dev/gbos and deliberately not vendored here; if it's missing the page falls
back to "drop in a ROM" on the 404, so the deploy still works.
Also fixes a save-path bug that would have bitten the first 128KB cart:
String.fromCharCode(...sram) throws RangeError on a spread that big, killing
the autosave. Chunked, and the whole thing is wrapped for quota errors.
|
|
`make wasm` builds the core to WebAssembly (~44KB stripped) and web/ is a
front-end for it: drag-drop a ROM, pixelated canvas at any zoom, keyboard
mapped like the native build, battery saves in localStorage.
Built with zig cc, which carries its own wasm backend, linker and
wasi-libc - so no emscripten dependency, just zig on PATH. Only the
portable core goes in; render/kitty/control/main are terminal- and
POSIX-bound and stay out. src/wasm.c is the browser's whole host layer:
no terminal, no sockets, no files, and no frame pacing (the page's
requestAnimationFrame owns that). The machine is static, the RGB888 ->
RGBA conversion for putImageData happens in wasm, and nothing allocates
per frame.
The entire host interface is four WASI fd_* imports, pulled in by the
cart info banner's fprintf; the page shims them to console.log in ~20
lines. Cartridge RAM *is* the save file here, so it's exported for the
page to persist per cart title (every 5s and on unload).
Because both builds now advance on the same frame boundary, the port is
checked byte-for-byte against the native binary rather than by eyeballing
a canvas - tools/wasm_check.mjs runs N frames in node and diffs the
framebuffer against a --shot PPM:
cgb-acid2 @60, dmg-acid2 @60, cpu_instrs @600, mem_timing-2 @700,
pky.gbc @400 with an imported .sav, cgb-acid2 @120 through the full
CGB BIOS boot animation -> all pixel-identical
Also smoke-tested in headless chromium over CDP: core instantiates, ROM
loads through the file input, canvas animates (7 distinct frames over
5.6s), keyboard reaches the joypad, 60fps, and a 32KB save lands in
localStorage.
No audio: the APU is still stubbed.
|