* tests: automated headless FreeDOS QEMU smoke
Fully-automated counterpart to the manual run_freedos_qemu.sh: overlays the
FreeDOS image (no mutation), stages the interpreter and a SYSTEM-terminated
smoke on C:, injects the run plus poweroff into the image's startup batch,
boots headless, and diffs OUT.TXT against the golden file. Local-dev only
(needs qemu, a FreeDOS qcow2, mtools, nbd, and passwordless sudo); CI keeps
using the DOSBox-X path. Exercises the binary on a real FreeDOS install
rather than DOSBox-X emulation.
* Release 0.18.0
Cross-language linking (link BASIC into C/Fortran, call C from BASIC via
'$EXTERN), the v0.18 codegen/perf batch (paren string-comparison fix,
--no-gc-check/--fast-math, larger 32-bit caps, process-local DATE$/TIME$),
and the automated FreeDOS QEMU smoke. Bumps GW_VERSION and updates the
banners, CHANGES.TXT, and the development history table.
---------
Co-authored-by: Eremey Valetov <evvaletov@users.noreply.github.com>
Three fixes that lift seven test programs from skipped to passing,
bringing the AOT compiler harness from 56/56 to 63/63.
- Unnumbered programs (compiler_main.c): src/compiler_main.c skipped
any line that didn't start with a digit, so direct-mode .bas files
like hello.bas, math_ops.bas, string_ops.bas (no line numbers)
failed with "No program lines found". load_file now auto-assigns
line numbers (last_num + 10) to unnumbered lines, with overflow
protection at line 65520.
- String concatenation in PRINT (codegen.c): emit_str_atom had a
broken concat loop that emitted "; _cat = gw_str_concat(&...
_cat.sval ...)" — _cat was never declared, so any program with a
string-literal concat in PRINT (like PRINT "ABC" + "DEF") failed
to link. Concat is properly handled by emit_str_expr's outer
loop; remove the dead/broken code in the atom. Fixes
string_ops.bas.
- Transcendental result type (codegen.c): peek_expr_type returned
VT_DBL for ATN/LOG/EXP/VAL, so PRINT formatted them with 15-digit
double precision (e.g. 3.141592653589793) while real GW-BASIC and
the interpreter format the single-precision result as 3.141593.
Real GW-BASIC's transcendentals are single-precision; only CDBL
forces double. Demote ATN/LOG/EXP/VAL to VT_SNG; CDBL stays
VT_DBL. Fixes math_ops.bas.
Also: tests/run_compiler_tests.sh now runs the compiled binary from
the project root rather than the tempdir where it was built, so
test programs that reference tests/programs/ via relative paths
(chain_test, common_test, run_file, misc_stmts) resolve their
targets. Earlier I'd misdiagnosed those failures as ON ERROR
divergence — they were just CWD-dependent path lookups.
Doc/test counts: 56 → 63 in README, docs/index.md, docs/development.md,
docs/roadmap.md. Roadmap updated to note the compiler now accepts
unnumbered programs.
QA findings from a multi-round review of the FreeDOS submission prep work:
- TUI rendering refactor: src/tui.c emitted ANSI escape sequences via
printf, which displays as raw text on bare FreeDOS (no ANSI.SYS).
Add four HAL ops (tui_enter, tui_leave, render_run, set_cursor_shape)
and route per-cell rendering through them. POSIX backend keeps the
ANSI path; DOS backend drives BIOS INT 10h via the existing
bios_set_cursor / bios_write_char helpers. The TUI's logical cursor
goes through the saved orig_locate to avoid recursing through the
swapped-in gw_hal->locate.
- DOS extended-key mapping: dos_getch returns 0x100 | scancode for
arrows / F-keys; tui_read_key wasn't translating those to its TK_*
constants, so the editor never saw arrow keys or F1-F10 on DOS.
Add a __MSDOS__-conditional translation table in tui_read_key.
- Version banner: GW_VERSION was still 0.16.0 even though the v0.17.0
release prep was already in CHANGES.TXT. Bump.
- Compiler PulseAudio link: gwbasic-compile -c hardcoded
'-lgwrt -lm -lpthread' on the gcc command line. When libgwrt was
built against libpulse-simple (the default on any host with the
PulseAudio dev headers installed), the compile workflow failed with
'undefined reference to pa_simple_drain'. CMake now passes
GWRT_HAS_PULSEAUDIO to gwbasic-compile when libpulse is present, and
the compiler appends -lpulse-simple to the link line.
- FRE("") garbage collection: the interpreter skipped strpool_gc with a
comment 'unsafe during expression eval', but that's exactly what real
GW-BASIC's FRE("") does (and the AOT compiler path already did). Add
the GC call; strpool_pin/unpin is the existing escape hatch if a
caller has live pool pointers on the C stack. Fixes the string_gc
compat test.
- Test harness normalization: run_tests.sh stripped trailing whitespace
on the actual output but not the expected file, causing spurious
mismatches against golden files captured from real GWBASIC.EXE.
Normalize both sides identically. Fixes the peek_gfx mismatch.
- Print_using: snprintf into mantissa[32] with %.*f and an unbounded
dec triggered a -Wformat-truncation warning. Clamp dec to 20 (IEEE
double has at most ~17 significant decimal digits).
- Doc/version consistency: 16-bit binary size reported as 127KB in one
place and 128KB in three; standardize on 128KB. HAL backend count
said '1 file' but is now 2. CI test count said 'all 66 test
programs' but is 72. Add a v0.17.0 row to the development.md table.
Update getting-started.md DOS section to match the BIOS-rendering
reality and add a manual TUI verification checklist.
- dos_init now writes back BIOS-reported cols/rows to dos_hal struct
fields (forward-declared so dos_init can reference it).
After these changes: 72/72 interpreter tests pass, compat 68/68
matched, no warnings on the Linux build.
- Add CHANGES.TXT with full version history (DOS-friendly format)
- Add DOS/FreeDOS section to README.md
- Move compiler memory safety and DOS target to Completed in roadmap
- Add hal_dos.c to architecture.md module map
- Add .tab-color to .gitignore
Remove Unicode em dashes (U+2014) and en dashes (U+2013) from all
Markdown files. Use ASCII -- for parenthetical breaks and - for
hyphenation, matching standard plain-text conventions.
README.md: rewrite with v0.16.0 version, compiler section, Jupyter
kernel section, hardware I/O in statement table, accurate test counts
(72 interpreter + 14 kernel + 69 compiler), build instructions for
all three targets.
docs/roadmap.md: clean up Phase 2 accumulation into single coherent
compiler description. List all language coverage, operators, functions,
and optimizations. Remove stale intermediate progress markers.
docs/development.md: update test counts (72 programs, 68 golden files),
add kernel and compiler test commands.
Binary tokenized SAVE/LOAD now stores float constants in Microsoft Binary
Format (MBF) on disk, matching original GWBASIC.EXE. A token-walking function
(convert_floats) converts IEEE↔MBF at the save_binary()/load_binary() boundary.
Also fixes a latent bug where load_binary() scanned for 0x00 to find the end
of each token line — this fails when float bytes contain null (e.g. MBF for
100.5 is 00 00 49 87). The loader now uses the next-line pointer to compute
token data length, matching the original's approach.
BSAVE/BLOAD: save and load virtual memory blocks with 0xFD-header
binary format, operating on the current DEF SEG segment.
TUI color: tui_refresh emits ANSI SGR codes from cell attributes;
COLOR statement sets tui.current_attr when TUI is active.
Extended PEEK/POKE: CGA graphics framebuffer (interlaced layout) via
gfx_cga_peek/poke routed through virmem when gfx_active(); BIOS
keyboard shift flags (offset 0x17 bit 7 = insert mode).
Add bibliography to language reference. 64 tests, all passing.
Binary SAVE/LOAD: SAVE now writes tokenized binary by default (0xFF header
format), matching original GW-BASIC behavior. SAVE "file",A for ASCII.
LOAD auto-detects binary vs ASCII from the first byte. Command-line file
loading also auto-detects, so binary .BAS files just work.
INKEY$ extended keys: arrow keys, Home/End/PgUp/PgDn, Insert/Delete, and
F1-F10 now return the correct CHR$(0) + scan_code two-byte sequences per
the IBM PC convention. Refactored event trap key parsing to use tui_read_key()
instead of duplicating escape sequence parsing.
Golden-file regression tests: generated .expected output files for 55 of 58
test programs (3 timing-dependent tests excluded). The test runner now
reports compat match status alongside pass/fail.
Classic programs: added Hamurabi, Lunar Lander, Gunner, and Diamond from
David Ahl's BASIC Computer Games (1978) in tests/classic/ for manual
compatibility testing.
Docs updated with compiler roadmap item and hardware I/O simulator plan.
Add event-driven programming: ON TIMER(n) GOSUB with TIMER ON/OFF/STOP,
ON KEY(n) GOSUB with KEY(n) ON/OFF/STOP for F1-F10. Fix F-key escape
sequence parser (F9/F10 detection, push back consumed bytes on unmatched
sequences). Add EDIT statement for TUI line editing. Guard key trap
polling so keystrokes aren't consumed when no traps are configured.
LPRINT and LLIST now output to a printer device or file instead of the
screen. By default, output is appended to LPT1.TXT in the current
directory. Use --lpt to redirect to a real printer device (/dev/lp0,
LPT1 on FreeDOS) or a custom file path.
Includes full PRINT format support (semicolons, commas, TAB, SPC,
PRINT USING) and LLIST with line number range parsing.
The TUI screen buffer is now dynamically allocated instead of using a
fixed 25x80 array. When launched with --full/-f, the editor queries the
terminal size via ioctl(TIOCGWINSZ) and adapts accordingly. The default
remains the authentic 25x80.
AUTO generates line numbers during interactive editing, RENUM
renumbers program lines and patches all GOTO/GOSUB/ON references,
DELETE removes line ranges. COMMON declares variables preserved
across CHAIN. Also fixed LIST/DELETE range parsing (was broken by
expression evaluator consuming the dash as subtraction).
Bump to v0.7.0, 53 tests.
DATE$, TIME$, and TIMER now return real system date/time instead of
hardcoded values. Added directory and shell access statements with
proper GW-BASIC error codes (Path not found 76, File already exists 60).
Bump to v0.6.0, 52 tests.
Authentic GW-BASIC screen editor with 25x80 buffer, free cursor movement,
enter-on-any-line, F1-F10 function keys, Insert/Overwrite toggle, KEY
ON/OFF/LIST statement, and Ctrl+Break handling. HAL pointer swap routes
all PRINT/LIST/error output through the TUI automatically. Piped mode
unchanged (50/50 tests pass).
Adds automated compatibility testing infrastructure: DOSBox-X headless
config, PRINT-to-file transform script, and run_compat.sh with --generate
and --compare modes for verifying output against real GWBASIC.EXE.
Project renamed from gwbasic-c to GW-BASIC 2026.
- Tokenizer now copies entire identifier (letters+digits) when no
keyword matches, fixing variables like K2, V1, AB3%
- ERL returns actual error line number instead of 0
- Update README and Sphinx docs for v0.5.0
Add README.md for public release. Implement KILL and NAME statements
for file management. Change test programs to use relative paths
instead of /tmp/ and clean up temp files with KILL. Update .gitignore
for test artifacts.