Files
gw-basic-2026/include/gwbasic.h
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

101 lines
2.5 KiB
C

#ifndef GWBASIC_H
#define GWBASIC_H
#include "types.h"
#include "tokens.h"
#include "error.h"
#include "hal.h"
#include "interp.h"
#include "eval.h"
#include "gw_math.h"
#include "strings.h"
#define GW_VERSION "0.17.0"
#define GW_BANNER "GW-BASIC " GW_VERSION
/* Tokenizer */
int gw_crunch(const char *text, uint8_t *out, int outsize);
void gw_list_line(uint8_t *tokens, int len, char *out, int outsize);
/* PRINT statement */
void gw_stmt_print(void);
void gw_print_value(gw_value_t *v);
void gw_print_newline(void);
/* LPRINT / LLIST (print.c) */
void gw_stmt_lprint(void);
void gw_stmt_llist(void);
void gw_lpt_set_path(const char *path);
void gw_lpt_close(void);
/* Line number parsing helper (interp.c) */
bool read_linenum(uint16_t *out);
/* Variables (vars.c) */
gw_valtype_t gw_parse_varname(char name_out[2]);
var_entry_t *gw_var_find_or_create(const char name[2], gw_valtype_t type);
void gw_var_assign(var_entry_t *var, gw_value_t *val);
void gw_vars_clear(void);
void gw_stmt_deftype(gw_valtype_t type);
void gw_stmt_swap(void);
/* Arrays (arrays.c) */
void gw_stmt_dim(void);
gw_value_t *gw_array_element(const char name[2], gw_valtype_t type);
void gw_stmt_erase(void);
void gw_stmt_option(void);
void gw_arrays_clear(void);
/* Input (input.c) */
void gw_stmt_input(void);
void gw_stmt_line_input(void);
/* DEF FN evaluation (interp.c) */
gw_value_t gw_eval_fn_call(void);
/* File I/O (fileio.c) */
file_entry_t *gw_file_get(int num);
void gw_file_close_all(void);
void gw_stmt_open(void);
void gw_stmt_close(void);
void gw_stmt_print_file(void);
void gw_stmt_write_file(void);
void gw_stmt_input_file(void);
void gw_stmt_line_input_file(void);
int gw_file_eof(int num);
/* Program I/O (program_io.c) */
void gw_stmt_save(void);
void gw_stmt_load(void);
void gw_stmt_merge(void);
void gw_stmt_load_internal(const char *filename, bool clear);
/* PRINT USING (print_using.c) */
void gw_print_using(FILE *fp);
/* MID$ assignment (interp.c) */
void gw_stmt_mid_assign(void);
/* Random-access file I/O (fileio.c) */
void gw_stmt_field(void);
void gw_stmt_lset(void);
void gw_stmt_rset(void);
void gw_stmt_put(void);
void gw_stmt_get(void);
/* MBF conversion functions (fileio.c) */
gw_value_t gw_fn_cvi(gw_value_t *s);
gw_value_t gw_fn_cvs(gw_value_t *s);
gw_value_t gw_fn_cvd(gw_value_t *s);
gw_value_t gw_fn_mki(int16_t n);
gw_value_t gw_fn_mks(float f);
gw_value_t gw_fn_mkd(double d);
/* CHAIN (interp.c) */
void gw_stmt_chain(void);
/* Error recovery for run loop */
extern jmp_buf gw_run_jmp;
#endif