Files
snark13 c71e249a4e Add full compiler toolchain, libc, examples and reference docs
First substantive commit: the entire Sprinter C compiler tree on top of
the bare README+gitignore initial commit.

What's in here:
  bin/sprinter-cc        — driver script invoking SDCC + linker + mkexe
  libc/                  — Sprinter-specific libc layer over ESTEX/BIOS
                           (conio, gfx, io, mem, stdio + headers)
  runtime/               — crt0 variants (default/small/banked/minimal)
                           + heap + bank trampolines
  toolchain/             — mkexe (SprintEXE packer, C + tests)
  examples/              — 30 demo programs (gfx, file I/O, env, time, …)
  lib/Makefile           — builds the libc archive (sprinter.lib)
  docs/                  — converted Sprinter manuals + asm reference samples
  third_party/           — solid-c reference compiler dump + sdcc setup script
  release_docs/          — packaging / release notes

gitignore overhaul:
  • Drop dangerous blanket patterns: *.asm (would hide docs/samples/*.asm)
    and *.exe (case-insensitive match was hiding third_party/solid-c/*.EXE
    on macOS APFS).  Replaced with examples/*/*.{asm,exe,…} and lib/*.lib.
  • Restore tracking of toolchain/mkexe/tests/{one,big}.bin — those are
    INPUT fixtures, not build outputs.
  • Collapse the duplicated SDCC/C/Sdcc sections into one section per
    concern (build outputs / vendored / OS-junk).
  • Add .sprinter-cc-*/, build/ (catches lib/build/ too), .claude/.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-03 16:13:21 +03:00

69 lines
1.8 KiB
C

/*
* ffirst / fnext — directory iteration via ESTEX $19 / $1A.
*
* ESTEX F_FIRST ($19):
* HL = pattern, DE = buffer, A = attribute mask, B = format (0/1)
* CF = err / A = error code
* ESTEX F_NEXT ($1A):
* DE = same buffer
* CF = err / A = error code
*
* We always use format B=1 — 256-byte buffer with NUL-terminated DOS
* "name.ext" name at offset 33.
*
* ABI note: ffirst takes uint8_t as its 3rd arg. SDCC pushes a *single*
* byte for that (via `push af; inc sp`), not two — so the callee must
* pop ret-addr (2 bytes) AND consume the attr byte (`inc sp`) on the way
* out. Naively `pop bc` would over-eat into the caller's frame.
*/
#include <dir.h>
int ffirst(const char *pattern, ffblk_t *buf, uint8_t attrib) __naked
{
(void)pattern; (void)buf; (void)attrib;
__asm
;; On entry: HL = pattern, DE = buf, [SP+0..1] = ret, [SP+2] = attr.
ld iy, #2
add iy, sp
ld a, 0 (iy) ; A = attr (read without disturbing SP)
push ix
ld bc, #0x0119 ; ESTEX F_FIRST; format: 1 = DOS "name.ext" layout
rst #0x10
pop ix
pop hl ; HL = return address
inc sp ; consume the 1-byte attr
jr c, _ff_err
ld de, #0
jp (hl)
_ff_err:
call __errno_set
ld de, #-1
jp (hl)
__endasm;
}
int fnext(ffblk_t *buf) __naked
{
(void)buf;
__asm
;; HL = buf on entry; ESTEX F_NEXT wants buf in DE.
push ix
ex de, hl
ld c, #0x1A ; ESTEX F_NEXT
rst #0x10
pop ix
jr c, _fnext_err
ld de, #0
ret
_fnext_err:
call __errno_set
ld de, #-1
ret
__endasm;
}