The 4KB screen buffer (80x25x2 bytes) was allocated from near heap via
calloc(), which exhausted the 64KB data segment on 16-bit DOS. Now uses
_fcalloc()/_ffree() from OpenWatcom's far heap on 16-bit, keeping the
buffer outside DGROUP.
The TUI now works fully on 16-bit FreeDOS: full-screen editor, F-key
bar, cursor positioning, and scroll -- all via BIOS INT 10h through the
DOS HAL, with the screen buffer in far memory.
Changes:
- tui.h: GW_FAR macro (expands to __far on 16-bit, nothing elsewhere),
tui.screen declared as tui_cell_t GW_FAR *
- tui.c: _fcalloc/_ffree for 16-bit, _fmemmove for scroll_up()
- TUI_CELL() macro works unchanged (far pointer dereference is
transparent)
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.
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.
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.