Browser-based COR24 BASIC v1 sandbox. Write and run 1970s-style line-numbered BASIC programs on the COR24 p-code virtual machine, directly in your browser. Zero install.
Live demo: https://sw-embed.github.io/web-sw-cor24-basic/
Part of the Software Wrighter COR24 Tools Project.
web-sw-cor24-basic is a zero-install browser sandbox for the
COR24 BASIC v1 interpreter.
Pick a bundled demo from the dropdown — or paste your own BASIC program into
the editor — and run it in a p-code VM compiled to WebAssembly. The UI
supports INPUT-driven interactive programs, so REPL-style and turn-based
games like startrek work out of the box.
The BASIC interpreter is Pascal compiled to COR24 p-code (.p24). In this
project the p-code runs on an in-browser p-code interpreter
(pv24t ported to Rust/WASM — see
src/runner.rs) rather than on the COR24 hardware emulator,
so the only thing shipped to the browser is the .p24 image and a small
loader.
Build time (sibling repo):
sw-cor24-basic/src/basic.pas --[p24p compiler]--> build/basic.p24
Build time (this repo):
../sw-cor24-basic/build/basic.p24 --copy--> assets/basic.p24
examples/*.bas --embed--> Rust string table
Browser runtime:
basic.p24 -> loaded by pa24r into a Rust p-code interpreter
BASIC source -> fed as stdin; auto-appended `RUN` for line-numbered progs
INPUT -> pauses execution; host resumes when user submits a line
stdout bytes -> streamed into the output panel (auto-scrolls)
- Frontend: Yew 0.21 (CSR), WASM
- P-code loader:
pa24r - P-code interpreter: in-tree port of
pv24t - BASIC interpreter:
sw-cor24-basic(Pascal -> p-code)
# 1. Build the BASIC interpreter p-code in the sibling repo
cd ../sw-cor24-basic && ./scripts/build-basic.sh
# 2. Copy the interpreter binary into this project
cp ../sw-cor24-basic/build/basic.p24 assets/
# 3. Dev server (http://localhost:9072/)
./scripts/serve.sh
# 4. Build the release bundle for GitHub Pages
./scripts/build-pages.shbuild-pages.sh holds an exclusive dist/ lock (same lock as serve.sh) so
a running dev server cannot race the wasm-bindgen pipeline and leave empty
artifacts that manifest as SRI failures in the browser.
- Open the app (locally or the live demo link above).
- Pick a demo from the demo dropdown (or paste your own BASIC into the source panel on the left).
- Click Run. Output streams into the right-hand panel and auto-scrolls to the bottom.
- If the program uses
INPUT, an input row appears below the output — type your line and press Enter (or click Send). For long-running interactive programs (likestartrek) there is no instruction budget: play as long as you like. - Reset reloads the current demo's source. Clear wipes the output panel. Stop halts a running program.
Keyboard shortcuts:
- Ctrl/Cmd+Enter — Run from the source panel
- Esc — Stop the running program
- Enter (in the input row) — submit an input line
Bundled in examples/ and registered in
src/demos.rs. Full write-ups in
docs/demos.md.
| Name | Interactive | Summary |
|---|---|---|
bitwise-demo |
BAND/BOR/BXOR/SHL/SHR plus tagged-int helpers and byte packing. |
|
calc |
Arithmetic, variables, ABS. |
|
cont-demo |
STOP mid-program, then CONT from the REPL to resume. |
|
count |
Minimal FOR/NEXT loop, 1..10. |
|
data-demo |
DATA/READ/RESTORE, including RESTORE <line> and negative values. |
|
dim-demo |
DIM integer arrays, scalar/array namespace separation, expression subscripts. |
|
factorial |
Iterative factorial with FOR/NEXT. |
|
fibonacci |
First 10 Fibonacci numbers. | |
fizzbuzz |
IF/GOTO branching, 1..15. |
|
guess |
✓ | Guess-the-number game with INPUT and IF/GOTO. |
hello |
"HELLO WORLD" one-liner. | |
memdump |
POKE a short message, read it back with PEEK. |
|
mod-demo |
MOD operator — clean FizzBuzz without (I/N)*N=I. |
|
on-demo |
ON expr GOSUB for O(1) bytecode-style dispatch. |
|
robot-chase |
✓ | Turn-based 16x16 robot chase on a POKE/PEEK grid. Numpad-style movement, teleport, LRS, and robot-vs-robot collision logic. |
startrek |
✓ | Classic Star Trek game across an 8x8 galaxy. Uses INPUT, GOSUB/RETURN, PEEK/POKE as arrays, and a home-rolled PRNG. |
trek-adventure |
✓ | Numeric-menu text adventure: save the Enterprise before orbit decays. Uses IF/AND, GOSUB/RETURN, room/item state across ~380 lines. |
To add a new demo, see docs/adding-demos.md.
| Repo | Role |
|---|---|
| sw-cor24-basic | BASIC interpreter source |
| sw-cor24-emulator | COR24 hardware emulator |
| sw-cor24-pcode | P-code VM, assembler, linker |
| web-sw-cor24-pcode | Browser p-code debugger (same pattern) |
| web-sw-cor24-snobol4 | Browser SNOBOL4 sandbox (GH Pages pattern) |
- Blog: Software Wrighter Lab
- Discord: Join the community
- YouTube: Software Wrighter
Copyright (c) 2026 Michael A. Wright
MIT -- see LICENSE for details.
