TB THOREAU BASIC

THOREAU BASIC 2.5.2 · WINDOWS x64 · UEFI x64

Thoreau BASIC

A free 64-bit BASIC interpreter for Windows x64 and bootable x64 UEFI. Write GW-BASIC-style line-numbered programs, run them on Windows or directly from firmware without an operating system, package them as standalone EXE/EFI applications, and use international keyboard layouts on bare-metal UEFI.

V2.5.2 keeps PARFOR workers alive across repeated loops, removes major UEFI firmware-launch overhead, hardens JIT cache lifetime and input cleanup, and adds Island3D as a mouse-only first-person terrain showcase.

V2.5.2

Keep the cores awake.

Version 2.5.2 is a runtime-performance and robustness update for programs that hit the JIT and PARFOR continuously. Compiled PARFOR source regions are reused instead of consuming code-cache space on every invocation, and RUN now forms a clean token/JIT cache boundary before variables are recreated.

Windows already used persistent PARFOR workers. UEFI now does too: application processors are started through EFI MP Services only when the pool grows, then remain parked inside Thoreau and receive later jobs through shared work counters while the BSP participates. This removes firmware AP-launch/event overhead from frame-by-frame parallel loops.

On supported bare-metal x64 systems Thoreau can enable AVX/YMM state itself when firmware leaves it disabled, reports framebuffer write-combining status, and uses a faster bulk path for PUT ...,PSET. Both platforms also discard queued gameplay keystrokes when RUN or CONT returns to Ready., so old movement keys do not reappear later in the editor or LIST pager.

PARFOR X=0 TO 639 reuse the same native worker graph frame after frame OPTION PARTHREADS 0 let Thoreau tune the persistent worker pool RUN "ISLAND3D" 1024×1024 fractal terrain, mouse-only controls

V2.5

BASIC, now with a native engine under the floorboards.

Thoreau BASIC 2.5 turns the experimental compiler work into a normal execution path on both Windows x64 and x64 UEFI. Stored programs can compile hot numeric and hypercomplex expressions, scalar and numeric/@ array work, assignments, IF/ELSE, FOR/NEXT, WHILE/WEND, DEF FN and large cross-line regions into native x64 code. Unsupported syntax simply drops back to the classic interpreter.

Classic line-numbered control flow is not treated as embarrassing luggage. Literal GOSUB/RETURN can stay native across compiled regions, including calls made from hot loops. The JIT preserves BASIC return points and single-line IF/ELSE context when a call has to fall back to the interpreter. JIT OFF disables both bytecode and native acceleration for a clean correctness A/B test; JIT ON restores it.

PROFILE now knows which engine executed each line. JIT sampling modes report RUNS, JITRUNS, INTRUNS and MODE, while PROFILE INTERPRETER gives an exact classic-engine comparison. The new GorseGlass demo puts the machinery under load with a 1024×768 raytracer using nested loops, arrays, many GOSUBs, reflections, true Snell refraction and Schlick Fresnel blending.

JIT OFF : RUN force the classic interpreter for an A/B correctness test JIT ON : PROFILE JIT : RUN run compiled and see which lines stayed native PROFILE INTERPRETER : RUN exact interpreter-only timing for comparison

V2.4.1

Sharper tools for the program you are already inside.

V2.4.1 added FIND NEXT/PREV/WORD, source REPLACE, syntax-aware XREF and AUDIT, the first line profiler, REDIM, FOR END/WHILE END, POLYFILL, graphics-slot introspection and several control-flow and input refinements.

V2.4

More input. More pixels. An actual network stack.

Games can now ask what is held right now with KEYDOWN(), so movement and firing no longer fight over INKEY$. Mouse support is shared across Windows and UEFI, with position, buttons, wheel, ON MOUSEMOVE and ON MOUSECLICK. UEFI draws its own software pointer, probes both Simple and Absolute Pointer protocols, and can fall back to a raw PS/2 mouse when firmware publishes pointer protocols that never deliver motion. MOUSEINFO shows which backend is active.

Windows SCREEN width,height now accepts arbitrary logical framebuffer sizes and scales them cleanly into windows or fullscreen with preserved aspect ratio. UEFI exposes its real GOP modes through SCREEN MODES, VIDEOMODES(), VIDEOMODE and SCREEN MODE.

Networking is now a BASIC feature rather than wishful thinking: eight TCP/IPv4 client slots, DNS, HTTPGET$(), HTTP status and network-error reporting use Winsock/WinHTTP on Windows. UEFI first uses firmware DNS4/TCP4/HTTP, but can now drop to EFI_SIMPLE_NETWORK_PROTOCOL and run Thoreau's own ARP, DHCPv4, IPv4, UDP, DNS and TCP stack. It probes real packet I/O even when firmware reports a stale media-present flag. NETINFO exposes exactly which path is active. Plain HTTP works on the raw fallback; authenticated HTTPS still uses the firmware HTTP/TLS stack.

Classic compatibility also gets quieter but important fixes: INPUT ; keeps the cursor on the current line, NEXT K,J,I closes several nested loops, and DEFxxx defaults now make an unsuffixed variable and its matching explicit suffix the same variable, as in GW-BASIC.

IF KEYDOWN("LEFT") AND KEYDOWN("SPACE") THEN GOSUB 9000 move and fire in one frame ON MOUSECLICK GOSUB 8000 event-driven pointer input MOUSEINFO show UEFI pointer protocols, PS/2 fallback and active backend NETINFO show firmware protocols, raw-stack DHCP and active backend J$=HTTPGET$("http://api.open-notify.org/iss-now.json") live ISS data even through the raw UEFI fallback

WHAT IT IS

Old-school BASIC. Modern machine.

GW-BASIC-shaped on the surface, but built for 64-bit systems, real framebuffers and bare firmware.

01

Windows + bare UEFI

Run as a native Windows x64 application or boot straight into BASIC on x64 UEFI hardware.

02

Standalone apps

CREATEEXE and CREATEEFI turn the loaded BASIC program into a self-contained application.

03

64-bit BASIC

64-bit integers, 64-bit addresses, wide PEEK/POKE operations and a large modern memory arena.

04

24-bit GW-BASIC graphics

Classic PSET, LINE, CIRCLE, PAINT, COLOR, GET/PUT and DRAW run on a 24-bit framebuffer with direct RGB colors, plus LOADBMP, BITBLT and SAVEBMP.

05

Machine Explorer

Inspect memory, disks, sectors, partitions, filesystems, boot entries and machine landmarks from inside BASIC.

06

International UEFI keyboards

KEYB and THOREAU.CFG select from 23 layouts. On supported bare metal, raw USB HID input avoids firmware key-mapping problems.

07

Clean SYSTEM exit

SYSTEM returns a UEFI build to firmware so boot can continue, while the Windows build simply exits.

08

Software sprites

65,536 image slots and 65,536 persistent instances, transparent-color masks, movement, visibility, text layering and pixel-perfect collision.

09

Hypercomplex mathematics

The @ type brings complex numbers, quaternions and octonions into ordinary BASIC expressions, arrays, powers and transcendental functions.

10

Game-loop controls

KEYDOWN reads simultaneous held-key state, KEYREPEAT controls typematic behavior and WAITREL provides relative frame pacing.

11

Memory that stays sane

Automatic string GC and reusable array/bitmap blocks keep long-running programs from leaking the BASIC arena away.

12

External-editor friendly

LOAD and MERGE accept literal TAB characters in ASCII source and expand them to 4-column tab stops.

13

Mouse input

Position, buttons, wheel and non-preemptive move/click handlers work on Windows and UEFI. UEFI can use Simple/Absolute Pointer or fall back to raw PS/2, with MOUSEINFO diagnostics.

14

Flexible video modes

Use arbitrary logical raster sizes on Windows or enumerate and select physical/GOP modes with VIDEOMODES, VIDEOMODE and SCREEN MODE.

15

TCP/IP + raw UEFI fallback

Eight TCP/IPv4 clients, DNS and HTTPGET$ work through Windows networking, firmware UEFI protocols, or Thoreau's own SNP-based ARP/DHCP/IPv4/UDP/DNS/TCP stack. NETINFO shows protocols, DHCP state, addressing, media report and active backend.

16

Classic compatibility polish

INPUT ; cursor retention, multi-variable NEXT and GW-BASIC-compatible DEFxxx variable identity close several subtle language gaps.

17

Native x64 JIT

Windows and UEFI can compile supported stored BASIC into native x64 code, including numeric/@ arrays, loops, IF/ELSE and GOSUB-heavy program regions. Unsupported statements fall back automatically, and JIT OFF restores the classic interpreter completely.

THE PROOF

Pixel Prose

A complete Thoreau BASIC game released three ways: editable BASIC source, a Windows executable, and an EFI application that can boot directly into the game. The Pixel Prose .BAS source is included with the Thoreau BASIC example programs.

UEFI BOOT \EFI\BOOT\BOOTX64.EFI

The UEFI ZIP contains the EFI application and its assets. Put the EFI application at this path on a suitable x64 UEFI boot volume and the firmware launches the game directly.

V2.5.2 SHOWCASE

Raytracing, voxel islands, sprites and bare-metal trouble.

The examples are meant to exercise real features hard enough to be useful starting points, not just sit politely beside the syntax reference.

GorseGlass

A 1024×768 analytic raytracer and JIT stress test with checkerboard floor, hard shadows, Phong highlights, reflective materials and a glass sphere using explicit entry/exit Snell refraction with Schlick Fresnel blending.

Island3D

A first-person fractal terrain renderer with a 1024×1024 heightfield, fog, directional lighting, trees, double buffering and a PARFOR column renderer. The running demo is mouse-only: move to look, hold left to walk forward, right to walk backward, and both buttons to quit.

SpriteInvaders

A compact Space-Invaders-style sprite demo with persistent instances, transparency, collision detection and projectiles. KEYDOWN now allows movement and firing simultaneously.

NeonDescent

A 1024×768 vertically scrolling shooter with many simultaneous sprites, HUD text, WAITREL pacing and continuous BITBLT scrolling.

ISS tracker

A keyless live ISS demo using the public Open Notify HTTP endpoint, so it also exercises Thoreau's raw UEFI network fallback while plotting an orbital trail across the world map.

Mouse Paint

A small paint program demonstrating pointer position, buttons, wheel-controlled brush size and ON MOUSEMOVE / ON MOUSECLICK handlers across the Windows, UEFI pointer and raw PS/2 backends.

Multi-key demo

Shows the difference between queued INKEY$ events and current held-state input by moving and firing at the same time with KEYDOWN.

Video modes demo

Enumerates physical/display modes with VIDEOMODES and VIDEOMODE and demonstrates SCREEN MODE selection on both platforms.

complex-demo

A 2D Mandelbrot renderer using native complex syntax: C@=CPLX(CR,CI) and Z@=Z@*Z@+C@.

quaternion-demo

A ray-marched three-dimensional slice of a four-dimensional quaternion Julia set using QUAT(), NORM, LOG and 24-bit graphics.

DOWNLOADS

Thoreau BASIC 2.5.2

Pick your floor. Windows, or the firmware beneath it.

CONTACT / SUPPORT

Thoreau BASIC is free to use.

Questions, bug reports, compatibility notes or feedback? Get in touch.

If you want to support development, you can make a voluntary PayPal contribution.

QUICK START

Hello, machine.

10 CLS
20 PRINT "HELLO FROM THOREAU BASIC"
30 FOR I=1 TO 5
40 PRINT I
50 NEXT I
60 END
RUN
“I make myself rich by making my wants few.”
Henry David Thoreau