A fantasy console is an imaginary retro computer that runs as a program, like PICO-8. This one is a 32-bit machine: 16 registers, a stack and one address space. The display, input and storage are mapped into memory, so you use them by reading and writing addresses. Programs are written in the console's own assembly. Other languages (Forth, Lisp, something C-like) can be built on top of the machine.
Try it: press F5 in the IDE above to run the example. Click the screen, move the square with the arrow keys, and press Z to change its color.
Design principles
- Easy to compile for. All registers work the same way, branches compare values directly (no flags register), and the calling convention (ABI) is documented.
- Modular hardware. The CPU only knows about memory and a bus. Displays, input and other devices are plugins placed in the address space. Want two screens? Plug in two.
- Deterministic. Integer math only, and time counted in ticks and cycles: the same inputs always give the same frames.
- The host never crashes. Program errors become machine faults, and an infinite loop only uses up that tick's cycles.
- Limits make it fun. Each tick has a fixed cycle budget.
The IDE
The IDE runs natively and in the browser. It has:
- an editor with a debugger: breakpoints, stepping by instruction or by tick, stack, registers and disassembly;
- a Memory page that shows the whole address space as named blocks (program, variables, screen, stack, font ROM, devices);
- a Hardware page where you build the machine by dragging parts onto it (CPU, RAM, displays, controllers, disks, ROM chips);
- a ROM editor for fonts and sprite sheets.
main:
LI r9, INPUT
LI r10, DISPLAY
LD.W r11, [r10+0] ; framebuffer address
LD.HU r7, [r10+4] ; width
LD.HU r8, [r10+6] ; height
