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

46 lines
1.0 KiB
C

#ifndef GW_HAL_H
#define GW_HAL_H
#include <stdint.h>
#include <stdbool.h>
/* Hardware Abstraction Layer vtable */
typedef struct hal_ops {
/* Terminal I/O */
void (*putch)(int ch);
void (*puts)(const char *s);
int (*getch)(void); /* blocking read */
bool (*kbhit)(void); /* key available? */
void (*locate)(int row, int col);
int (*get_cursor_row)(void);
int (*get_cursor_col)(void);
void (*cls)(void);
void (*set_width)(int cols);
/* Raw mode for INKEY$/INPUT$ */
void (*enable_raw)(void);
void (*disable_raw)(void);
/* Write raw bytes bypassing cursor tracking (for Sixel, etc.) */
void (*write_raw)(const char *data, int len);
/* Terminal properties */
int screen_width;
int screen_height;
bool is_tty;
/* Lifecycle */
void (*init)(void);
void (*shutdown)(void);
} hal_ops_t;
extern hal_ops_t *gw_hal;
/* Platform implementations */
hal_ops_t *hal_posix_create(void);
#ifdef __MSDOS__
hal_ops_t *hal_dos_create(void);
#endif
#endif