<feed xmlns='http://www.w3.org/2005/Atom'>
<title>sl0pboy.git/web/gbcore.js, branch master</title>
<subtitle>sl0pboy - a Game Boy Color emulator (companion to the gbos OS)</subtitle>
<id>https://git.sl0p.foo/sl0pboy.git/atom/web/gbcore.js?h=master</id>
<link rel='self' href='https://git.sl0p.foo/sl0pboy.git/atom/web/gbcore.js?h=master'/>
<link rel='alternate' type='text/html' href='https://git.sl0p.foo/sl0pboy.git/'/>
<updated>2026-09-22T18:48:09Z</updated>
<entry>
<title>wasm: cap the stack at 256KB - 16.25MB -&gt; 0.5MB per Game Boy</title>
<updated>2026-09-22T18:48:09Z</updated>
<author>
<name>gbc dev</name>
<email>gbc@localhost</email>
</author>
<published>2026-09-22T18:48:09Z</published>
<link rel='alternate' type='text/html' href='https://git.sl0p.foo/sl0pboy.git/commit/?id=a2aa8fbb20cab296d44bcdd23c63c0f76ec52869'/>
<id>urn:sha1:a2aa8fbb20cab296d44bcdd23c63c0f76ec52869</id>
<content type='text'>
zig defaults the wasm stack to 16MB, and that lands in the module's *initial*
memory, so every instance allocated 16.25MB before executing an instruction.
With several Game Boys on one page that was the dominant cost: 123MB for six.
The machine is a static and nothing here recurses deeply, so 256KB is plenty.

Per instance: 20.5MB -&gt; 4.8MB of linear memory (six: 123MB -&gt; 29MB). Note the
spelling - zig cc rejects -Wl,--stack-size and -zstack-size, and wants
-Wl,-z,stack-size=N.

With memory no longer the constraint, the page cap goes 6 -&gt; 8 on measurement
rather than guesswork. Emulation-only, one thread: 12.5x realtime at 1, 3.1x
at 4, 1.5x at 8, and exactly 1.0x at 12 - i.e. ~12 is where a thread runs out
of road with nothing left for rendering. 8 holds a verified 60fps each in a
real browser with all eight leased.

Golden frames are still pixel-exact on cgb-acid2, dmg-acid2, cpu_instrs@600
and pky@400 with its .sav, and two Game Boys still lease and ping 4/4.
</content>
</entry>
<entry>
<title>web: network lab - several Game Boys on a virtual switch, in the page</title>
<updated>2026-09-22T17:50:10Z</updated>
<author>
<name>gbc dev</name>
<email>gbc@localhost</email>
</author>
<published>2026-09-22T17:50:10Z</published>
<link rel='alternate' type='text/html' href='https://git.sl0p.foo/sl0pboy.git/commit/?id=c1ce018c20c8b9f10b849c1b10c6862b666ea2f6'/>
<id>urn:sha1:c1ce018c20c8b9f10b849c1b10c6862b666ea2f6</id>
<content type='text'>
/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.
</content>
</entry>
</feed>
