6 Commits

Author SHA1 Message Date
Eremey Valetov
70ffd39562 v0.17.0: BIOS-routed TUI on DOS, version banner, compiler PulseAudio link
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.
2026-05-03 12:25:41 -04:00
Eremey Valetov
71ff44828d Add 16-bit real-mode DOS target -- 127KB standalone, no extender
New Makefile.dos16 builds with OpenWatcom wcc (16-bit, MEDIUM model)
producing a standard MZ executable that runs on any DOS without DOS/4GW.
All 24 source files compile clean; tested on FreeDOS 1.4 via QEMU.

Changes for 16-bit compatibility:
- hal_dos.c: INTX macro selects int86() vs int386() based on _M_I86
- sound.c: reduce stack buffer from 8192 to 512 samples on 16-bit
- tui.c: gracefully disable TUI if screen buffer allocation fails
  (near heap exhaustion common on 16-bit), batch mode still works
- .gitignore: add .obj/.exe/.err/.lib for OpenWatcom build artifacts

Size comparison:
- 32-bit DOS/4GW: 175KB + 265KB extender = 440KB total
- 16-bit real-mode: 127KB standalone

The 32-bit build (Makefile.dos) and Linux build are unaffected.
72/72 interpreter tests pass.
2026-04-10 06:32:47 -04:00
Eremey Valetov
8ff9ff22bf Cross-compile to DOS with OpenWatcom -- 24/24 files, 154KB executable
All 24 source files compile and link for DOS/4GW 32-bit target using
OpenWatcom V2 cross-compiler (wcc386 -bt=dos -mf -za99 -D__MSDOS__).

Platform portability fixes:
- hal_dos.c: use int386() instead of int86() for 32-bit DOS
- interp.c: mkdir() 1-arg on DOS, _dos_findfirst/findnext for FILES,
  monotonic_time() portable wrapper for clock_gettime/clock()
- virmem.c: replace clock_gettime with portable time()/localtime()
- graphics.c: define M_PI, avoid non-constant aggregate initializers
- tui.c: guard sys/ioctl.h and sigaction, use signal() on DOS,
  use HAL screen size instead of TIOCGWINSZ

Produces: gwbasic.exe (154KB LE executable, requires DOS4GW.EXE)
Linux build and all 72+14+69 tests unaffected.
2026-03-30 19:42:45 -04:00
Eremey Valetov
d1a58876e7 Add DOS HAL backend and OpenWatcom build for FreeDOS
platform/hal_dos.c: DOS HAL implementation using BIOS INT 10h for
screen/cursor, INT 16h for keyboard, direct character output via
BIOS write-char. Compile-time selection via __MSDOS__ define.
Linux HAL (hal_posix.c) unchanged -- full backward compatibility.

hal.h: add hal_dos_create() declaration under __MSDOS__ guard.
main.c, gwrt.c: select HAL at compile time via #ifdef __MSDOS__.

Makefile.dos: OpenWatcom wmake build file targeting DOS/4GW 32-bit.
Builds GWBASIC.EXE (interpreter), GWBASCOM.EXE (compiler),
GWRT.LIB (runtime library for compiled programs).

All 72 interpreter, 14 kernel, and 69 compiler tests continue to
pass on Linux (no regression).
2026-03-30 18:12:24 -04:00
Eremey Valetov
1f4c460f4f Phase 5: CI, terminal I/O, Sixel graphics, classic programs
Add GitHub Actions CI with automated build and test. Implement real
terminal I/O with raw mode (enable_raw/disable_raw, proper INKEY$
polling via VMIN=0/VTIME=0, INPUT$ function). Add Sixel graphics
engine with virtual framebuffer (SCREEN 1: 320x200, SCREEN 2:
640x200), Bresenham line drawing, midpoint circle, flood fill PAINT,
DRAW mini-language parser, and Sixel encoder with RLE. Replace all
graphics stubs with real implementations (PSET, LINE, CIRCLE, DRAW,
PAINT, COLOR, SCREEN, POINT). Fix AND/OR/XOR operator precedence
to be lower than relational operators. Add 13 classic test programs
(39 total). Bump version to 0.5.0.
2026-02-10 16:46:34 -05:00
Eremey Valetov
d8e8375366 Phase 1: expression calculator with direct mode
GW-BASIC reimplementation in C11, using Microsoft's open-sourced 8088
assembly as the authoritative reference.

Tokenizer (CRUNCH/LIST), expression evaluator with operator precedence,
all math functions (SIN, COS, TAN, ATN, SQR, LOG, EXP, RND, etc.),
string functions (LEFT$, RIGHT$, MID$, CHR$, ASC, VAL, STR$, etc.),
PRINT statement with comma/semicolon zones, TAB(), SPC().

Handles integer/single/double types with correct promotion, D exponent
for double-precision literals, type suffixes (%, !, #), &H hex/&O octal
literals, MBF conversion routines, and GW-BASIC-compatible number
formatting.

Platform-independent via HAL vtable; POSIX backend included.
2026-02-10 10:25:08 -05:00