60373930fb
- <dos.h>: getdate/gettime/setdate/settime (структуры Turbo-C, обёртки над getdatetime), getdisk/setdisk (ESTEX $02/$01), absread/abswrite (BIOS $55/$56, rst 8 — номера найдены в solid-c DOS.ASM; сектор 0 = boot логического диска) - scanf/fscanf/sscanf: своё C-ядро _scanf_core (%d %u %x %o %c %s, модификатор l, ширина, подавление '*', %%); в SDCC z80 scanf нет, asm solid-c не портируем из-за чужого ABI; 22 хост-теста ядра - хвост П2: fdopen/freopen/fclosall/fgetpos/fsetpos поверх таблицы FILE; парсер режима и выдача слота вынесены в _file_mode/_file_slot - rename() — ESTEX RENAME $10; isatty(fd) = fd <= 0 (tty только псевдо-fd 0/-1/-2: из CLI DSS манипуляторы идут с 1 — verified, fd 1 не резерв, под Flex Navigator его держит навигатор) - errno.h: Solid-C имена ошибок (EZERO/EINVFNC/ENOFILE/...) как алиасы - <sprinter_solid.h> — зонтичный заголовок для портирования; ltell/_setargv в sprinter_compat.h; div/ldiv — из SDCC (проверено) - tests/solidt — smoke всех П3/П4 API, зелёный в MAME (вкл. absread boot-сектора с сигнатурой 55AA) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
112 lines
3.0 KiB
C
112 lines
3.0 KiB
C
/*
|
|
* sprinter_compat.h — Solid-C compatibility shims.
|
|
*
|
|
* Pulls in standard headers and adds aliases/macros that Solid-C
|
|
* programs expect. Programs targeting Sprinter from Solid-C source
|
|
* can `#include <sprinter_compat.h>` and most names "just work".
|
|
*/
|
|
|
|
#ifndef SPRINTER_COMPAT_H
|
|
#define SPRINTER_COMPAT_H
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <conio.h>
|
|
#include <mouse.h>
|
|
#include <errno.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <dir.h>
|
|
#include <dos.h> /* getdate/gettime, getdisk, absread */
|
|
#include <sprinter_exit.h> /* _exit, atexit */
|
|
|
|
/* ---- Solid-C types ----------------------------------------------- */
|
|
typedef uint8_t BYTE;
|
|
typedef uint8_t TINY;
|
|
typedef uint8_t BOOL;
|
|
typedef uint8_t STATUS;
|
|
typedef uint16_t WORD;
|
|
typedef int FD;
|
|
|
|
#ifndef TRUE
|
|
#define TRUE 1
|
|
#define FALSE 0
|
|
#define YES 1
|
|
#define NO 0
|
|
#endif
|
|
|
|
#ifndef OK
|
|
#define OK 0
|
|
#endif
|
|
|
|
#ifndef ERROR
|
|
#define ERROR (-1)
|
|
#endif
|
|
|
|
#ifndef EXIT_SUCCESS
|
|
#define EXIT_SUCCESS 0
|
|
#define EXIT_FAILURE 1
|
|
#endif
|
|
|
|
/* Solid-C's uint typedef (we expose it explicitly). Note `uint` may
|
|
* already be defined in some environments; guard. */
|
|
#ifndef _SOLID_UINT_DEFINED
|
|
#define _SOLID_UINT_DEFINED
|
|
typedef unsigned uint;
|
|
#endif
|
|
|
|
/* fpoint — 32-bit split file position (used by lseek/tell). */
|
|
typedef struct fpoint {
|
|
uint16_t low;
|
|
uint16_t high;
|
|
} f_point;
|
|
|
|
/* ---- string.h aliases -------------------------------------------- */
|
|
/* setmem(ptr, n, byte) → memset(ptr, byte, n) — arg order swapped */
|
|
#define setmem(p, n, b) memset((p), (b), (n))
|
|
/* movmem(src, dst, n) → memcpy(dst, src, n) — arg order swapped */
|
|
#define movmem(s, d, n) memcpy((d), (s), (n))
|
|
|
|
/* In-place case conversion. */
|
|
char *strlwr(char *s);
|
|
char *strupr(char *s);
|
|
|
|
/* Solid-C calls perror's table 'strerr'. */
|
|
#define strerr(n) strerror((n))
|
|
|
|
/* ---- stdlib.h additions ------------------------------------------ */
|
|
#define abort() _exit(0xFF)
|
|
|
|
#ifndef min
|
|
#define min(a, b) ((a) < (b) ? (a) : (b))
|
|
#endif
|
|
#ifndef max
|
|
#define max(a, b) ((a) > (b) ? (a) : (b))
|
|
#endif
|
|
|
|
/* div() and div_t come from SDCC's <stdlib.h> (already included above). */
|
|
|
|
/* sysenv() is now a real function (libc/io/env.c) that returns the WHOLE
|
|
* environment into a caller-provided buffer. Declared in <sprinter.h>. */
|
|
|
|
/* ---- ctype.h additions ------------------------------------------- */
|
|
#define isascii(c) (((unsigned)(c)) < 128)
|
|
|
|
/* ---- io.h aliases (Solid-C fd shortcuts) ------------------------- */
|
|
#define seek(fd, off) lseek((fd), (long)(off), SEEK_SET)
|
|
#define tell(fd) ((uint16_t)lseek((fd), 0, SEEK_CUR))
|
|
#define ltell(fd) lseek((fd), 0L, SEEK_CUR)
|
|
#define remove(name) unlink(name)
|
|
|
|
/* crt0 разбирает argv сам — заглушка для портируемого кода. */
|
|
#define _setargv() 0
|
|
|
|
/* ---- dir.h alias ------------------------------------------------- */
|
|
#define _ffirst ffirst
|
|
|
|
#endif
|