Web, Commodore, Windows version, Linux standalone, Windows Screensaver complete.

This commit is contained in:
The Dust Council 2026-06-05 00:39:31 -07:00
parent 47730936de
commit 9257f21598
19 changed files with 794 additions and 18 deletions

View file

@ -157,6 +157,99 @@ To install on Windows: right-click `vectorgons.scr` → **Install** (or copy it
`C:\Windows\System32` and choose it under *Settings → Personalization → Lock
screen → Screen saver*). Like the `.exe`, it needs only Windows system DLLs.
## Browser (WebAssembly)
The same source compiles to WebAssembly with [Emscripten](https://emscripten.org),
which maps the GLFW3 windowing and the legacy/immediate-mode OpenGL onto WebGL
(`-sLEGACY_GL_EMULATION`). The retained-mode VBO geometry, the FBO bloom, and the
frustum culling all run unchanged; the browser-specific bits (GLU helpers, the
`requestAnimationFrame` main loop, and the WebGL-incompatible `double`/`glReadBuffer`
calls) are guarded behind `#ifdef __EMSCRIPTEN__`.
```sh
source /path/to/emsdk/emsdk_env.sh # put emcc on PATH
make web # -> web/vectorgons.js + web/vectorgons.wasm
```
Serve the `web/` directory over HTTP (WebAssembly will **not** load from a
`file://` URL) and open `index.html`:
```sh
cd web && python3 -m http.server 8000 # then visit http://localhost:8000/
```
`web/index.html` is a ready-made page. To embed in your own page, drop a focusable
canvas with `id="canvas"`, point Emscripten's `Module` at it, and load the script:
```html
<canvas id="canvas" width="1100" height="760" tabindex="0"></canvas>
<script>
var Module = { canvas: document.getElementById('canvas') };
</script>
<script src="vectorgons.js"></script>
```
Serve `vectorgons.js`, `vectorgons.wasm`, and `vectorgons-boot.js` from the same
directory. Click the canvas to give it keyboard focus; all the usual controls
then work, and `F` requests browser fullscreen. (Settings are not persisted in
the browser.)
### Content-Security-Policy
WebAssembly needs a couple of CSP allowances. If your server sends a strict CSP
(symptom: the canvas appears but nothing runs, and the console shows
`both async and sync fetching of the wasm failed`), the page's `script-src` must
include **`'wasm-unsafe-eval'`** (required to instantiate any WASM — there is no
nonce/hash alternative) and **`connect-src`** must allow fetching the `.wasm`
(e.g. `'self'`). Loading the `Module` config from `vectorgons-boot.js` (rather
than an inline `<script>`) means `'unsafe-inline'` is *not* required. A working
policy for the Vectorgons path:
```
script-src 'self' 'wasm-unsafe-eval'; connect-src 'self';
```
## Commodore 64 (`c64/`)
A bonus port for the original 1982 hardware lives in [`c64/`](c64/). The 1 MHz
6510 has no floating-point unit and a 1-bit, 320×200 hi-res bitmap, so this is a
ground-up reimplementation rather than the OpenGL engine recompiled — but it
keeps the heart of Vectorgons: **tumbling wireframe polytopes**, cycling through
a small shape library (cube, octahedron, tetrahedron, stellated star, pyramid,
and a 4-D tesseract shadow) in classic monochrome vector-graphics style.
Per the brief, the glass / metal / mirror objects are dropped — there is no
shading on a 1-bit bitmap. The compromises that make it fit a C64:
- **Integer fixed-point everywhere** — a 256-entry signed sine table (scale 128)
drives the 3-D rotation; points are perspective-projected with integer divide.
- **One object at a time**, drawn with a Bresenham line routine straight into the
VIC-II hi-res bitmap; each frame erases the previous edges and draws the new
ones (no full-screen clear) so it stays flicker-free without double buffering.
- Precomputed bitmap row/column/bit-mask address tables for fast plotting.
- A custom cc65 linker config keeps program code below `$2000`, reserves
`$2000$3FFF` for the bitmap, and puts BSS/heap/stack above it.
Build it with [cc65](https://cc65.github.io/) and pack it onto a disk image with
VICE's `c1541`:
```sh
cd c64
make d64 # -> vectorgons.prg and vectorgons.d64
make run # build + launch in the VICE x64sc emulator
```
If `cl65`/`c1541` aren't on your `PATH`, point the Makefile at them, e.g.
`make d64 CL65=/path/to/cl65 CC65_HOME=/path/to/share/cc65`. On real hardware (or
an emulator) load it the usual way and it autostarts:
```
LOAD"VECTORGONS",8,1
RUN
```
Press any key to return to BASIC.
## Settings persistence
Your settings are saved automatically on exit to `~/.vectorgons` (a plain