Commit Graph

17 Commits

Author SHA1 Message Date
Eremey Valetov
0bacfcef6c Implement VIEW/WINDOW/PALETTE, PMAP, fix MBF float format, update to v0.13.0
Graphics viewport and coordinate mapping:
- VIEW [[SCREEN] (x1,y1)-(x2,y2) [,[fill][,border]]] with clipping
- WINDOW [[SCREEN] (x1,y1)-(x2,y2)] with Cartesian/screen modes
- PALETTE [attribute, color] with CGA 16-color remapping
- PMAP(coord, func) for logical/physical coordinate conversion
- All graphics statements (PSET, LINE, CIRCLE, PAINT, GET/PUT) respect
  viewport clipping and WINDOW coordinate mapping

MBF (Microsoft Binary Format) float support:
- CVS/CVD now interpret bytes as MBF format (compatible with real GW-BASIC)
- MKS$/MKD$ now produce MBF-encoded bytes
- Fixed shift errors in MBF↔IEEE conversion routines (single: 1→0, double: 4→3)
- Random-access file I/O now byte-compatible with original GWBASIC.EXE

66 tests (2 new), 61 compat matches (up from 58).
2026-03-10 22:20:58 -04:00
Eremey Valetov
4551c88a50 Implement BSAVE/BLOAD, TUI color, extended PEEK/POKE, update to v0.12.0
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.
2026-03-01 13:37:05 -05:00
Eremey Valetov
0743757029 Implement DEF SEG/PEEK/POKE, GET/PUT sprites, fix PRINT USING, update to v0.11.0 2026-03-01 13:07:28 -05:00
Eremey Valetov
e7f35c21ff Implement binary SAVE/LOAD, INKEY$ extended keys, golden tests, update to v0.10.0
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.
2026-03-01 12:25:47 -05:00
Eremey Valetov
3fa8c6f034 Implement EDIT statement and ON TIMER/ON KEY event trapping, update to v0.9.0
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.
2026-02-27 17:29:09 -05:00
Eremey Valetov
35e4b12131 Implement LPRINT and LLIST with configurable printer output
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.
2026-02-22 13:55:27 -05:00
Eremey Valetov
da6b513b07 Add AUTO, RENUM, DELETE, COMMON; fix LIST range parsing
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.
2026-02-22 12:58:47 -05:00
Eremey Valetov
ece018d06a Implement DATE$/TIME$/TIMER, FILES, SHELL, CHDIR, MKDIR, RMDIR
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.
2026-02-22 12:40:18 -05:00
Eremey Valetov
691031a7f9 Fix RESTORE with line number, add 8 Rosetta Code test programs
RESTORE n now correctly positions past the DATA token so the next
READ gets actual values instead of the token byte.

New tests: Roman numerals, Luhn validator, Towers of Hanoi, 100 Doors,
Pascal's triangle, type declarations, Hailstone sequence, multiplication
table.  50 tests now pass.
2026-02-15 16:22:55 -05:00
Eremey Valetov
169f16d465 Implement SOUND, BEEP, and PLAY with PulseAudio backend 2026-02-15 16:14:36 -05:00
Eremey Valetov
9ca23e5d10 Fix variable names with digits, ERL, update docs
- 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
2026-02-10 17:01:50 -05: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
df5c3083b1 Add README, implement KILL/NAME, use relative paths in tests
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.
2026-02-10 15:53:57 -05:00
Eremey Valetov
66479b5d6e Phase 4: CHAIN, RUN "file", random-access I/O, MBF conversions
Add CHAIN statement for loading and running chained programs with
optional ALL flag to preserve variables. Extend RUN to accept a
filename string argument. Implement random-access file I/O with
FIELD, LSET, RSET, PUT#, GET# and the MBF conversion functions
CVI/CVS/CVD/MKI$/MKS$/MKD$. Add COMMON statement (parse and skip).
Five new test programs covering all new features (27 total).
2026-02-10 12:11:25 -05:00
Eremey Valetov
c2d73e9c24 Phase 3: file I/O, PRINT USING, SAVE/LOAD, MID$ assignment, graphics stubs
Add OPEN/CLOSE with both modern (OPEN "f" FOR OUTPUT AS #n) and compact
(OPEN "O",#n,"f") syntaxes. PRINT#, WRITE#, INPUT#, LINE INPUT# for
sequential file access. EOF() now returns real file status with peek-ahead.
LOC/LOF return approximate values.

PRINT USING with numeric (#, ., +, -, $$, **, ^^^^, comma grouping) and
string (!, &, \ \) format specifiers. Shared by PRINT USING and PRINT# USING.

SAVE (ASCII), LOAD (with ,R auto-run), and MERGE for program persistence.

MID$ assignment (MID$(var$, start [,len]) = expr) for in-place string
modification. Works with both scalar variables and array elements.

Graphics stubs for SCREEN, PSET, PRESET, LINE, CIRCLE, DRAW, PAINT,
VIEW, WINDOW, PALETTE - parse and discard arguments so graphics-heavy
programs don't crash.

SYSTEM and NEW/CLEAR now close all open files. Version bumped to 0.3.0.
22 tests pass (16 existing + 6 new).
2026-02-10 11:53:28 -05:00
Eremey Valetov
616259537a Phase 2: variables, arrays, program execution, and control flow
Add variable storage (scalar and array), program line storage with
RUN/LIST/NEW, and full control flow: FOR/NEXT, GOTO, GOSUB/RETURN,
IF/THEN/ELSE, WHILE/WEND, ON GOTO/GOSUB, DATA/READ/RESTORE.

New modules: interp.c (1445 lines - execution loop and statement
dispatcher), vars.c, arrays.c, input.c. Version bumped to 0.2.0.
16 test programs pass including Leibniz pi and prime sieve.
2026-02-10 11:16:58 -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