From a43b4d6703e07cf3a03fe492a2c54c843fd99419 Mon Sep 17 00:00:00 2001 From: Alexander Petrov Date: Tue, 30 Jun 2026 22:13:36 +0300 Subject: [PATCH] =?UTF-8?q?mdview2=20testfiles:=20LINES.MD=20~250=20=D0=9A?= =?UTF-8?q?=D0=91=20(=D0=BB=D0=B8=D0=BC=D0=B8=D1=82=2018432)=20+=20HUGE.MD?= =?UTF-8?q?=20>256=20=D0=9A=D0=91=20(=D0=BA=D0=BB=D0=B0=D0=BC=D0=BF)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - LINES.MD: 22000->25000 строк (~250 КБ -> 16 страниц -> max_lines 18432), чтобы обрыв был ровно на заявленном лимите. - HUGE.MD: ~340 КБ (проза ×4) для проверки клампа файлов >256 КБ. - floppy кладёт HUGE.MD на диск. Co-Authored-By: Claude Opus 4.8 --- examples/mdview2/Makefile | 7 +- examples/mdview2/testfiles/HUGE.MD | 6556 +++++++++++++++++++ examples/mdview2/testfiles/LINES.MD | 3000 +++++++++ examples/mdview2/testfiles/gen_testfiles.py | 19 +- 4 files changed, 9571 insertions(+), 11 deletions(-) create mode 100644 examples/mdview2/testfiles/HUGE.MD diff --git a/examples/mdview2/Makefile b/examples/mdview2/Makefile index a52e25c..33ccb29 100644 --- a/examples/mdview2/Makefile +++ b/examples/mdview2/Makefile @@ -41,15 +41,16 @@ $(README_DISK): README.MD | $(DISK_TMP) # iconv не нужен, make_disk берёт имя по basename): # TABLES.MD — пробивает кап контент-кэша (сообщение Content cache exhausted) # LINES.MD — пробивает лимит строк 18432 (сообщение Line limit reached) +# HUGE.MD — >256 КБ, кламп (сообщение File too large - truncated at 256 KB) # Убрать вместе с возвратом к обычному README-диску. TESTDIR := testfiles # UTF8TEST.MD кладётся на диск КАК ЕСТЬ (в UTF-8, без перекодировки) — # это тестовый вход для проверки UTF-8 рендеринга (Фаза 2 кодировок). -floppy: $(EXAMPLE).exe $(README_DISK) $(TESTDIR)/TABLES.MD $(TESTDIR)/LINES.MD - python3 $(MAKE_DISK) $(FLOPPY_IMG) $(EXAMPLE).exe $(README_DISK) $(TESTDIR)/TABLES.MD $(TESTDIR)/LINES.MD UTF8TEST.MD +floppy: $(EXAMPLE).exe $(README_DISK) $(TESTDIR)/TABLES.MD $(TESTDIR)/LINES.MD $(TESTDIR)/HUGE.MD + python3 $(MAKE_DISK) $(FLOPPY_IMG) $(EXAMPLE).exe $(README_DISK) $(TESTDIR)/TABLES.MD $(TESTDIR)/LINES.MD $(TESTDIR)/HUGE.MD UTF8TEST.MD @echo - @echo "Floppy ready: $(FLOPPY_IMG) (mdview2.exe + README.MD + TABLES.MD + LINES.MD + UTF8TEST.MD)" + @echo "Floppy ready: $(FLOPPY_IMG) (mdview2.exe + README.MD + TABLES.MD + LINES.MD + HUGE.MD + UTF8TEST.MD)" @echo "Run: cd $(MAME_DIR) && ./run_mame.sh" clean: diff --git a/examples/mdview2/testfiles/HUGE.MD b/examples/mdview2/testfiles/HUGE.MD new file mode 100644 index 0000000..cdfc5b7 --- /dev/null +++ b/examples/mdview2/testfiles/HUGE.MD @@ -0,0 +1,6556 @@ +# MDView ? ᬮ騪 Markdown Sprinter + +**MDView** ? ணࠬ ᬮ 㬥⮢ ଠ *Markdown* +Sprinter ( Z80). 㬥 ࠭ ⤥쭮 W3 +᭮ RAM ணࠬ. + +## + +- 㬥 **128 ** (8 ࠭ EMM 16 ) +- **16 384** ࠭ ப +- ⮬᪨ ७ ᫮ ਭ ࠭ (80 ⮫殢) +- ਧ⠫ ᤢ ப ப ( , ⠡) +- -: 䠩, ப, 業 ப⪨ +- ப ﭨ ६ 㧪 樨 +- প ?? ᪫ ப + +## + +``` +mdview [_䠩.md] +``` + +᫨ 䠩 , 㦠 `README.MD`. + +## ࠢ + +``` + ⢨ + +Up Down ப⪠ ப / +PgUp PgDn ப⪠ ࠭ (30 ப) +Home 砫 㬥 +End 㬥 +Left Right ਧ⠫ ᤢ (⮫쪮 nowrap-ப) +F1 ࠢ +F8 ஢: CP866 ? CP1251 ? KOI8-R ? UTF-8 ? ... +F10 / Esc 室 ணࠬ +``` + +஢ । ⮬᪨ ⨨ (BOM + ⨪ + 4 ); `F8` ४砥 , ᫨ ⥪ 訡. +8- ஢ (CP866/CP1251/KOI8-R) ४ (६ +ᮢ). ன / (ਬ UTF-8) ந ? +ࢮ ४祭 (⪠ 㧠 ᯨ஬), . + +## ⠪ Markdown + +### + +ন ஢ H1?H4. ஢ H5 H6 ⮡ࠦ H4. + + # ࢮ ஢ + ## ண ஢ + ### 쥣 ஢ + #### ⮣ ஢ + +### ⮢ ଠ஢ + +** ⥪** 뤥 묨 񧤮窠: `**⥪**` + +*ᨢ* 뤥 묨 񧤮窠 `*⥪*` ન `_⥪_` + +`஥ ` 砥 묨 窠 + +~~ભ ⥪~~ ? ⨫: `~~⥪~~` + +### 㬥஢ ᯨ᮪ + +થ `-`, `*` `+`: + +- 㭪 ᯨ᪠ +- ன 㭪 ᯨ᪠ +- ⨩ 㭪 筮 ⥪⮬, 室 + 㤥 ७ ᫥ ப ࠭ 㯠 + +### 㬥஢ ᯨ᮪ + +1. +2. ன +3. ⨩ + +### + +> 稭 ᨬ `>`. ᪮쪮 ᫥⥫ +> ப ᪫ ⮬᪨ +> ७ᮬ ᫮. + +### (verbatim) + + 砥 ன 窨. +⥪ ⮡ࠦ ? ? ࠧ Markdown: + +``` +#include +#include + +int main(void) { + puts("Hello, Sprinter!"); + return 0; +} +``` + +### ਧ⠫쭠 + + ᨬ `---`, `***` `___` ⤥쭮 ப: + +--- + +## 孨᪨ ࠪ⨪ + +- **ଠ:** Sprinter, Z80 @ 21 +- **஢:** CP866 / CP1251 / KOI8-R / UTF-8 (⮮।, `F8`) +- **ᨬ ࠧ 䠩:** 128 +- **ᨬ쭮 ᫮ ப :** 16 384 +- **ᨬ쭠 ப ७-:** 255 祥 (. ࠭祭 ) +- ** :** small + - ணࠬ, c⥪, , ? a W1-W2 (32 , 0x4000?0xBFFF). + - 䠩 ? ࠭ EMM, ⮡ࠦ W3 (0xC000?0xFFFF) + +## ࠭祭 + +### ப MD-० ? 255 祥 + +- ࠭ ப ** 255 (ᨬ, ਡ)** +? ⠭ `MAX_CACHE_LINE_LEN`. ⨯: `g_ncells` +`cache_rec_t.len` ? `uint8_t`. ᠥ ப, ⭥ ᥣ +**ਧ⠫쭮 ஫㥬** ப ( ப ⠡, 䫠 +`IF_HSCROLL`), MD-० ࠢ. + +** ந室 ப:** 樨 `gc_put()` +뢠 祩 ᫥ 255- (`if (g_ncells < MAX_CACHE_LINE_LEN)`). + ⮫쪮 255 祥, ⮪ **** ? +஫ ** થ १** 255- 樨 (થ `>` 砥 +? । ?). ९ ? `gc_put` ஢ ࠭. + +: ?255 祥? ? **७७ ਭ**, 室. + ࠧ稢 ஡ ( `TAB_STOP`), 祩 ⠡ +஡ ਭ + ࠬ `` ? ⮬ ⨣ ࠭, 祬 +255 ?? ᨬ. + +> **RAW-० (`F2`) ⮣ ** ? אַ 䠩 +> ⮢, ப 楫 (१ wrap `F3` ਧ. ஫). + +** ** (業, ॠ) ? `uint16_t`: +- `cache_rec_t.len` `uint8_t?uint16_t` ? **஢ 8 ** + (len ꥤ pad-), `idx<<3` . ᯫ⭮. +- `g_ncells` / `g_ncells_at_space` ? `uint16_t` ? 業 **/᪮**: + 16-⭠ 䬥⨪ Z80 祬 `gc_put` (맮 祩) + scan-横. ਥ: **+0.2?0.4 ** + 樨. +- `g_cells[MAX_CACHE_LINE_LEN*2]` near-RAM (W2) ? 業 + ****: `2 ? ` . 510 ; 512 ? +0.5 , 1024 ? +1.5 . + EMM- ⥭ (1 ) ப ﭥ ? 㧪 near. +- `viewport_x` ( `docset_t`) + ⮫ `max_vx` (ᥩ 248) ? `uint16_t`, + ࠭ >255 , ஫ . `widths[]`/`ccx` ⠡/. + + ஬ ? 512?1023: 墠 ᥬ ⨭/⠡栬, + 業 ~+0.3 +0.5?1.5 near-RAM. ** 㬥 `uint16_t`** ? + ⠢ થ १ 255- 樨, ⮡ 뫠 . + +## TODO + +1. **祭 ࠧ 㬥⮢.** 128 : 筮 + ࠧ ࠡ 訬 - ࠭ , ஢ + ࠡ 8- ࠭栬 16. + +: ଠ஢ ⠡ ࠬ; প ஢ +CP866 / CP1251 / KOI8-R / UTF-8 ⮮। ४祭 `F8` +(ன ந , ࢮ ४祭). + +4. **᪮७ ७ਭ.** ப ࠭. ⨬ 横 뢮 + ᨬ १ BIOS WRCHAR ( 뢮, DMA). + +--- + +*MDView v0.2 (c) 2026 ஢ ..* + + +--- + +# Sprinter C Compiler ? v1.0 + +C toolchain for **Sprinter** ? the Z80-based home computer by Peters Plus, running +ESTEX DSS. Host: macOS / Linux. Target: `.EXE` files in SprintEXE format. + +Built on top of **SDCC 4.5** (vendored in `third_party/sdcc/`). This repository adds +everything Sprinter-specific: crt0, linker integration, libc wrappers over ESTEX, +banked-call trampolines, graphics & accelerator API, mouse driver wrappers, and the +`mkexe` utility for producing SprintEXE images. + +## What you get + +* **`bin/sprinter-cc`** ? one-line driver: `sprinter-cc -o foo.exe foo.c` +* **Memory modes**: `tiny`, `small`, `big`, `huge`, `manual` ? see below. +* **stdio + conio**: printf, puts, putchar, getchar, fopen/fread/..., cprintf, cputs, putch, textcolor/textbackground/textattr, gotoxy, kbhit/getch. +* **Graphics**: 320?256?256 and 640?256?16 modes, accelerator-backed primitives (hline / vline / rect / fill_rect / line via Bresenham, plus clear), bitmap-font text in both modes via BIOS character generator. +* **File I/O**: POSIX (`open`/`read`/`write`/`close`/`lseek`/`unlink`/`creat`), FILE\* streams (`fopen`/`fgets`/`fwrite`/...), directory listing (`ffirst`/`fnext`), `chdir`/`getcwd`/`mkdir`/`rmdir`, `stat`/`fstat`. +* **Memory**: 32 KB heap (W2-resident), banking-aware page allocator (`mem_alloc_pages`/`bank_read`/`bank_write`), explicit memory modes for sub-16 KB programs. +* **Mouse**: full Sprinter driver wrapper (14 functions including custom cursor bitmaps). +* **Environment**: `getenv`/`putenv`/`sysenv` over ESTEX `$46`. +* **Time**: `getdatetime`/`setdatetime` + POSIX `time`/`localtime`/`mktime`/`asctime`/`ctime`. +* **Misc**: `errno`/`strerror`/`perror`, `atexit`, `setjmp`/`longjmp`, `sleep`, full argv parsing in crt0. + +## Quick start + +```sh +git clone sprinter-c +cd sprinter-c +make sdcc # one-time: fetch SDCC 4.5 binary (~25 MB) +make all # build mkexe + libsprinter.lib + 27 examples +make floppy # pack everything into mame/v306/IMG/mc.img +cd mame/v306 && ./run_mame.sh # boot Sprinter in MAME +``` + +Compile a single program: + +```sh +cat > hello.c < +int main(void) { puts("Hello, Sprinter!"); return 0; } +EOF + +bin/sprinter-cc -o hello.exe hello.c +``` + +That's it ? `hello.exe` is now a valid SprintEXE you can `RUN HELLO` from the ESTEX shell. + +## Memory modes + +Sprinter's address space is four 16 KB windows (W0 / W1 / W2 / W3). DSS allocates +pages by program size ? small programs get only one page. Pick a memory mode based +on what your program needs: + +| Mode | Code lives in | Banking | Use when | Note | +|---|---|---|---|---| +| `tiny` (default) | W2 (0x8100+) | no | code+data < 14 KB | | +| `small` | W1-W2 (0x4100+) | no | code+data < 30 KB | | +| `big` | W2 + W1 banking | yes (W1) | tiny + extra code modules | | +| `huge` | W1-W2 + W3 banking | yes (W3) | small + extra code modules | | +| `manual` | user-specified | optional | special layouts | Not implemented | + +```sh +sprinter-cc --memory small -o big.exe bigprog.c +sprinter-cc --memory huge -o app.exe main.c --bank 1=engine.c --bank 2=ai.c +``` + +Banked functions are declared with `__banked`: + +```c +void engine_tick(int dt) __banked; // lives in BANK1, automatically swapped +``` + +## Examples (27 total) + +| Example | What it demonstrates | +|---|---| +| `hello` | Hello world with stdio + conio Turbo-C-style colors | +| `argv` | argv parsing in crt0 | +| `cat` | File I/O ? read & print TEST.TXT | +| `seek` | 32-bit lseek over a 100 KB file | +| `ls` | Directory listing via ffirst/fnext | +| `filetest` | FILE\* streams (fopen/fread/...) | +| `stattest` | `stat`/`fstat` on files and directories | +| `errno` | errno / strerror / perror | +| `mem_test` | Page allocator + bank\_read/bank\_write | +| `malloc` | Heap stress test (200+ allocations) | +| `banked` | Banked code in W3 (huge mode) | +| `bankedbg` | Banked code in W1 (big mode) | +| `banklocl` | Bank-local static data and BSS | +| `mouse` | Mouse driver in text mode | +| `gfx_mous` | Mouse with custom bitmap cursor in graphics mode | +| `gfx_demo` | 320?256?256 lines / rects / accelerator | +| `gfx_d16` | 640?256?16 same primitives | +| `gfx_text` | Bitmap-font text on graphics screen | +| `timedir` | Date/time + directory listing | +| `ptime` | POSIX time API | +| `openenv` | open() flags + environment vars | +| `conio` | conio API smoke test | +| `attrprob` | Probe Sprinter text attribute byte layout | +| `strtest` | string.h test (from SDCC's z80.lib) | +| `stdlib` | stdlib.h test (qsort / rand / strtol / etc.) | +| `assrtest` | assert() | +| `rt_test` | Runtime helpers (sleep, setjmp, atexit) | + +## Headers + +Standard: +* `` ? puts / printf / FILE\* + Sprinter-specific dec/hex helpers +* `` ? atoi / atof / malloc / qsort / ... (from SDCC z80.lib) +* `` / `` / `` ? from SDCC z80.lib +* `` ? read / write / close / lseek / unlink +* `` ? open / creat + O\_RDONLY / O\_CREAT / ... +* `` ? errno + error names + strerror +* `` ? stat / fstat +* `` / `` ? from SDCC + +Sprinter-specific: +* `` ? putch / cputs / cprintf, textcolor / textbackground / textattr, kbhit / getch, clrscr, gotoxy, wherex/y +* `` ? gfx_init/done, palette, putpixel, hline/vline/rect/fill_rect/line, text ? for both 320 and 640 modes (gfx_\*16 variants) +* `` ? full 14-function driver wrapper + mouse_cursor_t with bitmap support +* `` ? chdir / getcwd / mkdir / rmdir / ffirst / fnext / ffblk +* `` ? getdatetime / setdatetime + POSIX time / localtime / etc. +* `` ? raw ports, ESTEX/BIOS function numbers, env API +* `` ? exit / \_exit / atexit +* `` ? mem\_alloc\_pages / mem\_free\_block / bank\_read / bank\_write +* `` ? Solid-C compatibility layer (aliases + BOOL/WORD/uint types) + +## Toolchain commands + +```sh +make all # build mkexe + lib + every example +make floppy # repack mame/v306/IMG/mc.img with all .exe files +make check # 17 mkexe unit-tests +make clean # remove all build artefacts +make sdcc # one-time: fetch SDCC 4.5 binary +``` + +### sprinter-cc options + +``` +sprinter-cc -o foo.exe foo.c [more.c ...] [options] + + --memory MODE tiny | small | big | huge | manual (default: tiny) + --memory-manual SPEC explicit placement (CODE=W1|W2,DATA=W1|W2|SAME,BANKED=W1|W3) + --stack-size N bytes reserved for the stack (default ~1278) + --crt0=TYPE default | minimal | banked | small + --bank N=FILE.c compile FILE.c into bank N (repeatable, max 15) + --debug enable runtime diagnostics (defines DEBUG_RT) + -I PATH extra include path + -L 0xADDR / -E / -S override load / entry / stack addresses + -Wl FLAG pass FLAG to sdldz80 + --mkexe FLAG pass FLAG to mkexe (e.g. --mkexe -p --mkexe 0 for bank padding) + -v verbose +``` + +## Status + +What works in v1.0: +* Compile / link / pack to SprintEXE ? verified on all 27 examples +* Four memory modes (tiny / small / big / huge) +* Graphics (both modes) with accelerator +* Mouse (text + graphics cursor) +* File I/O, directories, environment, time +* All headers listed above + +Deferred to v2.0 (see `docs/TODO.md`): +* **Turbo-C-style BGI graphics API** ? `initgraph` / `setcolor` / `circle` / + `getimage` / `putimage` / etc. on top of our `gfx_*` primitives +* Remaining Solid-C compatibility gaps (Phase 2/3) ? see `docs/solid_c_compatibility.md` +* Manual memory mode +* Rewrite FILE\* stream API (current implementation is very primitive and doesn't use buffers) + +Deferred to v3.0: +* **IM2 interrupt handlers** ? research complete (`docs/im2_isr_design.md`), + implementation scheduled for v3 +* **Audio API** (AY-3-8910 + COVOX) ? requires IM2 +* **ISA-8 slot drivers** ? requires IM2 (???) + +## Documentation + +* `docs/TODO.md` ? roadmap and open work items +* `docs/solid_c_compatibility.md` ? gap analysis vs Solid-C 2004 +* `docs/im2_isr_design.md` ? interrupt handler design (v2) +* `docs/converted/` ? source documentation (ESTEX, BIOS, architecture) + converted to plain text for `grep` +* `docs/reference/`, `docs/samples/`, `docs/memory management/` ? original + Russian docs and code samples from Peters Plus + +## Repository layout + +``` +bin/sprinter-cc one-line compiler driver (bash) +toolchain/mkexe/ host-side tool: .ihx -> .exe SprintEXE +toolchain/check_banks.py post-link bank size enforcer +runtime/ crt0 variants (default, minimal, small, banked) + bank trampolines, heap, heap_top +libc/include/ headers +libc/io|stdio|mem|gfx/ C and asm sources for libsprinter.lib +lib/ Makefile that archives libsprinter.lib via sdar +examples/ 27 example programs +mame/v306/ MAME binary + Sprinter ROM/HDD images + floppy script +third_party/sdcc/ vendored SDCC 4.5 (fetched via `make sdcc`) +third_party/solid-c/ reference: original Sprinter native C (for compat target) +docs/ documentation +``` + +## License + +This repository contains: +* Original code in `bin/`, `toolchain/`, `runtime/`, `libc/`, `lib/`, `examples/` ? + MIT-licensed. +* `third_party/sdcc/` ? SDCC 4.5 under GPLv2 with linking exception + (see `third_party/sdcc/COPYING.txt`) +* `third_party/solid-c/` ? original Sprinter Solid C, used only as a reference + +## Credits + +* **Sprinter / Peters Plus** ? , ਩ ਭ and the original team +* **SDCC** ? for the underlying Z80 compiler +* **MAME** ? for the Sprinter Sp2000 emulation + +--- + +For questions / patches: see CONTRIBUTING.md (TBD) or open an issue. + +--- + +# TODO / Roadmap + + 浪 뢠 ਮ.  ॠ ணࠬ ? ਮ ᬥ. + +## ⠯ 5 ? malloc / free + banking-aware page allocator ? + +- [x] SDCC's `malloc`/`free` + `runtime/heap.s` ( library heap.rel, 14000- heap 2) +- [x] `libc/mem/mem_alloc.c` ? page allocator: `mem_alloc_pages`/`mem_free_block`/`mem_get_page`/`mem_info` १ ESTEX `$3C/$3D/$3E` + BIOS `$C4` +- [x] `libc/mem/bank_io.c` ? HOME-१ `bank_read`/`bank_write`/`bank_load_byte`/`bank_store_byte` ᢮ W3 +- [x] `examples/malloc_test/` ? ஢ઠ SDCC's malloc (~210 64- allocations १ heap) +- [x] `examples/mem_test/` ? ஢ઠ page allocator: 3 ࠭, ࠧ १ bank_write, 䨪 १ bank_read + +## ⠯ 6 ? argv parsing + sprinter-cc wrapper ? + +- [x] crt0 ESTEX command-line IX-prefix (inline asm `runtime/crt0.s`) +- [x] Strip leading CP/M-style space (DSS quirk) +- [x] । `argc`/`argv` main() १ HL/DE (SDCC __sdcccall(1) ABI) +- [x] argv[0] = basename .EXE १ ESTEX APPINFO ($47 subfn 2) +- [x] `runtime/crt0_minimal.s` ? opt-out 祭 쪨 ணࠬ +- [x] `runtime/crt0_banked.s` ? ⥯ ⮦ argv (parse_argv + get_progname ᪮஢ crt0.s; 㤥 factored argv.s libsprinter.lib) +- [x] Bash-⪠ `bin/sprinter-cc`: `sprinter-cc -o foo.exe foo.c` ப +- [x] প 権: `--memory`, `--memory-manual`, `--stack-size`, `--crt0=`, `--bank N=FILE.c`, `--debug`, `-I`, `-L`/`-E`/`-S`, `-Wl`, `--mkexe` + +## ⠯ 8 ? 䨪 (320?256?256 + 640?256?16 + accel + bitmap font) ? + +- [x] **8a** Graphics core: `gfx_init`/`gfx_done`/`gfx_clear`/`gfx_putpixel`/`gfx_pal_load`/`gfx_pal_set` (libc/gfx/gfx_core.c). १ BIOS PIC_SET_PAL ($A4). Verified 320?256?256. +- [x] **8b** /אַ㣮쭨/fill १ accelerator (libc/gfx/gfx_lines.c): `gfx_hline`/`gfx_vline` १ accel Fill (LD C,C / LD E,E + SMC block-size), `gfx_rect`/`gfx_fill_rect` heuristic 롮஬ ਥ樨 (h/v bursts count), `gfx_line` Bresenham . `gfx_clear` ⮦ ९ᠭ column-major accel (~4? ॥). +- [x] **8c** 640?256?16 mode (libc/gfx/gfx_16.c): `gfx_*16` API, HIGH nibble = LEFT pixel (㬥 misleading), per-row RMW vline ( = 2 ਧ⠫ ᥫ). +- [x] **8d** Bitmap font + gfx_text (libc/gfx/gfx_text.c): १ BIOS WIN_GET_ZG ($B8), interleaved layout `font[row*256+char]`, `gfx_text`/`gfx_putchar` 320 mode, `gfx_text16`/`gfx_putchar16` 640 mode pair-table lookup. + +. memory/sprinter_graphics.md, sprinter_accelerator.md, sprinter_graphics_16.md, sprinter_font_format.md. + + ( ): +- [ ] -quad 640: per-cell (mode 0x82 ࠧ蠥 1 4 per 16?8 cell) ? १ אַ area-ᠭ ࠭ 0x0300..0x039F + +## Auto-banking (. `memory/banking_roadmap.md` ⠫) + +Phase 1 ? file-level bin-packing ? ॠ뢠 ஥ ~30 KB . + +- [ ] `toolchain/auto_bank.py`: + - ࠧ `.rel`-䠩 ( .map ᫥ dry-run link') + - First-fit-decreasing bin-packing + - `#pragma codeseg BANKn` manual override + - ५뢠 묨 `-Wl-b_BANKn=...` ࠬࠬ + - ⠥ । + +Phase 2-5: incremental rebalance, declarative `banks.toml`, function-level, call-graph-aware. 쪮 ᫨/ . + +## Bank-local static data (mutable data ⮬ ) ? ? + +- [x] ਬ `examples/bank_local_data/` ? 㭪 BANK1 ᢮ writable BSS array + const table + malloc- +- [x] `mkexe -p 0` 㫥 padding (BSS-storage 㧪) +- [x] ᪨ 楯: `--codeseg BANK1 --constseg BANK1 --dataseg BANK1` bank1.c + `-Wl-b_BANK1=0x1C000` . **`--dataseg BANK1` ** ? ࠭ ⭮ - trampoline bug ᪨஢ १. +- [x] ** 䨪 trampoline'a runtime/bank.s** ? `pop af; out (n), a` ਫ A ? banked-㭪樨 騥 uint8_t 頫 . `pop bc; out (c), b` ࠭ A. +- [x] **malloc banked-㭪樨 ࠡ⠥ ஧筮** ? heap W2 (HOME), W2 ᢠ trampoline', pointer  ⥪. . memory/bank_local_data_pattern.md. +- [x] 㬥 memory: `memory/bank_local_data_pattern.md` ( 楯 + malloc + nuances), `memory/sdcc_banking.md` (trampoline fix) +- [ ] 樮쭮 ? `check_banks.py` ⮡ 뢠 ࠧ size = code + const + bss per bank (cosmetic) + +祬: 㫥 訬 private state (level loader, audio engine, scene data). W2 heap , ⨪ . + +## ᪠ solid-c (⨢ Sprinter C ? `third_party/solid-c/`) + +᫥ solid-c'᪮ libc (. `memory/solid_c_findings.md`)  ⮢ ᫥ 㭪権. ਮ **᮪** : + +### High-priority gaps ( ஢, 짠) +- [x] **`errno` + `strerror`/`perror`** ? ⠡窠 32 訡 (libc/io/errno.c) +- [x] **७ `open()`** O_CREAT/O_TRUNC/O_APPEND/O_EXCL state machine +- [x] **`atexit`** ? 8-callback LIFO + `exit()` + `_exit()` (libc/io/atexit.c) +- [x] **`setjmp`/`longjmp`** ? 6- jmp_buf={sp,ix,pc} (libc/io/setjmp.c) +- [x] **`sleep(seconds)`** ? 50Hz halt-loop (libc/io/sleep.c) +- [x] **ESTEX ENV API** ($46, getenv/putenv) ? libc/io/env.c. 竨 doc-bug: ॠ쭮 A=0 NOT FOUND + +### Medium-priority (㦭 shell-like ⨫) +- [ ] **Mouse driver** ? `rst $30h`, 17 㭪権. **砫 ࠡ⠥ MAME**. +- [x] **`ffirst`/`fnext` + ffblk_t struct** directory listing ? ॠ, demo: ls.exe +- [x] **`getdatetime`/`setdatetime`** १ ESTEX $21/$22 ? libc/io/time.c, demo: time_dir_test +- [x] **`chdir`/`getcwd`/`mkdir`/`rmdir`** ? wrappers ESTEX $1B-$1E ? libc/io/fsdir.c +- [x] **conio: `kbhit`/`getch`/`getche`/`cputs`/`clrscr`/`gotoxy`** ? ॠ +- [x] **conio extras**: `wherex`/`wherey` ($53), `wrchar`/`rdchar` ($58/$57), `textmode_get/set` ($50/$51), `clrscr_attr` ($56) + COLOR macros + +### Low-priority ? ? FILE* stack + +- [x] ** unbuffered FILE\*** ? `libc/stdio/file.c` + `libc/include/stdio.h`. fopen/fclose/fputs/fgets/fread/fwrite/fseek/ftell/rewind/feof/ferror/clearerr/fflush + stdin/stdout/stderr pseudo-streams. . `memory/file_star_design.md` `examples/filetest`. +- [ ] fprintf / fscanf ? 㦭 printf-१-callback machinery. 짮⥫ `sprintf(buf, ...) + fputs(buf, fp)`. +- [ ] 樮 buffered mode (setvbuf, line/block buffering) ? ᫨ - . + +### POSIX time API ? ? +- [x] `libc/io/posix_time.c` ? time/localtime/gmtime/mktime/asctime/ctime getdatetime. SDCC's time.rel ( override _RtcRead). . `examples/ptime`. + +### sys/stat ? ? +- [x] `libc/io/stat.c` ? POSIX stat/fstat. ਤ open+fstat 䠩, ffirst+iter ( "."/".."). . `examples/stattest` `memory/estex_ffirst_dotdot.md`. + +### assert ? ? (ᯮ㥬 SDCC's __assert १ fallback include path) + +## libc/stdlib ? ? 㦭 (. memory/sdcc_stdlib_works.md) + +஢७ १ `examples/stdlib_test/`: SDCC z80.lib ᮤন ࠡ騥 ॠ樨: +- `atoi/atol/atof, strtol/strtoul, rand/srand, qsort/bsearch, abs/labs, div/ldiv` +- `` (memchr/cmp/set/cpy, strcat/cmp/cpy/len/chr/spn/etc.) +- `` (toupper/tolower) +- `` (sinf/cosf/sqrtf/etc.) + + ⮬᪨ ﭥ z80.lib 㦭. ** ९뢠**. + + Sprinter-specific 易⥫ 㫨 : atexit, env, errno, setjmp, putchar/puts/getchar, conio, fsdir, time, mouse, open/read/lseek/close. + +## Build-system: libsprinter.lib + sprinter-cc ? ? + +- [x] `lib/Makefile` ? ᮡࠥ libc/*.c `.rel`, 娢 १ sdar `lib/sprinter.lib` +- [x] 砥 runtime/bank.s runtime/heap.s (auto-pulled __banked/malloc) +- [x] `bin/sprinter-cc` ? bash-wrapper: `sprinter-cc -o foo.exe foo.c` ப +- [x] প 権 `--crt0=default|minimal|banked`, `--bank N=FILE.c`, `-I`, `-L`/`-E`/`-S`, `-Wl`, `--mkexe` +- [x] `examples/hello_sccc/` ? : `hello.c` ᮡࠥ shell-맮, ࠧ ᮢ Makefile (925 ) +- [x] Split `putchar.c` ? `putchar.c` + `puts.c` per-function granularity (puts override SDCC's z80.lib version) +- [x] `make all` (ᨬ `lib` । `examples`) + + 襭 (樮쭮): +- [ ] ஢ ⠫ examples sprinter-cc Makefile (ᬥ⨪) +- [ ] 쭥 libc/*.c per-function ( ⥪ granularity 㦥 㦭 ࠧ ? .rel 楫, 設⢠ 䠩 㭪) + +## ⠯ 9 ? memory modes sprinter-cc + +DSS 뤥 ࠭ ࠧ ਫ: < 16 KB ? ࠭, ⠫ 砥 ?࠭ #FF? (read=0xFF, write ). - ⮣ CODE--W1 + DATA--W2 쪮 ணࠬ . . [memory/sprinter_memory_modes.md](../../.claude/projects/-Volumes-SAM8-Projects-DIY-Z80-Sprinter-C-Compiler/memory/sprinter_memory_modes.md). + +- [x] **`tiny`**: (CODE+DATA+⥪) W2. Default. Verified hello/argv/conio/malloc/file/etc. +- [x] **`--memory MODE` 䫠 sprinter-cc**: parser + per-mode 䮫 CODE_LOC/DATA_LOC, override १  `--code-loc`/`--data-loc`. tiny ࠡ⠥; small/big/huge warning' (runtime ⮢). 2026-05-30. +- [x] **`--memory-manual SPEC`**: `CODE=W1|W2,DATA=W1|W2|SAME,BANKED=W1|W3`. 2026-05-30. +- [x] **`small` runtime**: `runtime/crt0_small.s` ᯮ ESTEX `$3D GETMEM` + `$3A SETWIN2` ⮡ 뤥 W2-࠭ gsinit. **** BIOS `$C4` ? ⥪ ⮬ ⠯ W1 (boot_stack HOME), BIOS ॡ ⥪ W2. ᫥ SP ४砥 0xBFFE, ⠭ flow. 2026-05-30, verified hello.exe. +- [x] **`small` auto-detect >16 KB ணࠬ**: `crt0_small.s` ⠥ `0xC2` (⥪ ࠭ W2 ? `0xA2`! W1). ᫨ 0xFF ? 뤥 page; DSS 㦥 ᤥ (ணࠬ ᠬ 뫥 W2). crt0 뢠 0..30 KB. mkexe ⠪ ࠧ蠥 HOME span W1+W2 (0x4000..0xBFFF). Verified hello: small (5 KB 䠩, SETWIN2 path) + 32 KB 䠩 (auto-skip). 2026-05-30. +- [x] **`big` runtime** (tiny + banked code W1): ࠬਧ `crt0_banked.s` + `bank.s` १ `.ifdef BANK_W1` ? 㣮 banking port (0xA2 vs 0xE2), 㣮 load-addr (0x4000 vs 0xC000). sprinter-cc prepend' `BANK_W1 = 1` `--memory big`, । `mkexe -B 0x4000`. ਬ `examples/banked_big/`. 2026-05-30. +- [x] **`huge` runtime** (small + banked code W3): merge W2-detect `crt0_small.s` `crt0_banked.s`. 騩 ਬ `examples/banked/` ⥯ ᯮ MEMORY=huge. 2026-05-30. +- [x] **`--debug` 䫠**: prepend `DEBUG_RT = 1` crt0 + `-DDEBUG_RT` sdcc. 뢠 symbol `_w2_self_allocated` (uint8_t) ? runtime diagnostic ஢ W2. 2026-05-30. + +### -襭 libc crt0 + +** `sprinter.lib`** ࠡ⠥ memory mode ? `.rel`-童 relocatable, SDLD dead-code elimination per-member ( 䨪  `gfx_core.rel` ..). Verified hello vs malloc_test १ map-䠩. + +**`gfx.lib` ⤥쭮 ? 㦥**: dead-code elimination 㦥 ࠡ⠥. + +**`libc_banked` (libc bank HOME)** ? ⮬, HOME (16 KB) user- + libc `huge` mode. १ `--codeseg BANK0` 樨 libc; trade-off: trampoline ~30 横 libc-맮. ਣ: ॠ쭠 ணࠬ HOME budget. + +**HW-ᨬ 㫨 ? `sprinter_home.lib` ⤥쭮.** libc 䨧᪨ W3, ⮬ W3: +- `gfx_*` ? `0xC000+` ᫥ swap W3 video page +- `bank_io` (mem_alloc_pages/bank_read/bank_write) ? swap' W3 १ `OUT (0xE2)` +- 騥 ISR ? 뢠 ਩ W3 㣮 + + huge mode 㫨 HOME (W1). 㤥 `libc_banked`, **६** 뤥塞 `sprinter_home.lib` (HOME-only) `sprinter.lib` (bankable). 쭠 奬: +``` +sprinter_home.lib HOME-only: gfx, bank_io, ISR shims +sprinter.lib bankable: printf, malloc, string, conio, stdio, env, ... +sprinter_banked.lib sprinter.lib --codeseg BANK0 ( huge) +``` +ਣ: ॠ `--memory huge` runtime. + +**crt0 ? mode:** +- `crt0.s` ? ⥪騩, **tiny/big**: SP=0xBFFE, argv (W2- 㦥 뤥 DSS). +- `crt0_minimal.s` ? ⥪騩, tiny argv. +- `crt0_small.s` ? **, step 3**: **small/huge**, W2 १ `mem_alloc_pages` gsinit, `0xA2`, ⮬ ⠭ flow. +- `crt0_banked.s` ? ⥪騩, **big**: trampoline-⠡ W3 , CODE W2. +- `crt0_banked_small.s` ? ****: huge = small (W2-alloc) + banked (W3 trampolines). + +sprinter-cc ࠥ crt0 `--memory` mode (ᥩ `--crt0=` override). +- [x] **ࠨ ࠧ ⥪**: 䫠 `sprinter-cc --stack-size BYTES`. Wrapper `heap_top.s` `___sdcc_heap_end = stack_top + 1 - stack_size`, ⤥ .rel per-program. Default ?1278 (heap_top=0xBB00) `runtime/heap_top.s`. 2026-05-30. + +䥩: `sprinter-cc --memory [tiny|small|big|huge|manual] [--memory-manual SPEC] [--stack-size N] foo.c`. `--memory-manual` ⮫쪮 `--memory manual`. + +## Known issues / quirks + +- **ESTEX $46 ENV API**: ? ࠡ⠥. - `DiskSyscalls.txt v1.6` 訡筮 뢠 return-status ? A=0 NOT FOUND, FOUND. 䨪஢ `memory/sprinter_platform.md`. + +## V2 (᫥ ५ v1) + +### Turbo-C-style graphics API (BGI-like) ? **MUST v2** + + `gfx_*` API ஢ **Turbo-C ``** (BGI) MS-DOS. +ணࠬ ਢ訥 Turbo-C ७ ᪨ 1--1. + +** ** ( ᭮ Borland BGI): + +Setup/teardown: +- `initgraph()` / `closegraph()` ? ᥩ `gfx_init`/`gfx_done`, alias +- `getmaxx()` / `getmaxy()` ? GFX_WIDTH-1 / GFX_HEIGHT-1 +- `cleardevice()` ? alias to gfx_clear +- `getgraphmode()` / `setgraphmode()` ? get_videomode/set_videomode + +Color/palette: +- `setcolor(c)`, `getcolor()` ? current draw color +- `setbkcolor(c)`, `getbkcolor()` ? background color +- `setpalette(idx, c)` ? entry +- `getpalette(&info)` ? read all palette + +Primitives ( 㦥 ? BGI- aliases): +- `putpixel(x, y, c)` ? gfx_putpixel +- `getpixel(x, y)` ? 㦭 ॠ (RMW ⭮ ? IN) +- `moveto(x, y)`, `lineto(x, y)`, `linerel(dx, dy)` ? current point + line drawing +- `line(x1, y1, x2, y2)` ? gfx_line +- `rectangle(x1, y1, x2, y2)` ? gfx_rect ( 㣮 API: x1,y1,x2,y2 vs x,y,w,h!) +- `bar(x1, y1, x2, y2)` ? gfx_fill_rect +- `bar3d(x1, y1, x2, y2, depth, topflag)` ? : rect + 3d edges +- `circle(x, y, r)`, `arc(...)`, `ellipse(...)`, `pieslice(...)` ? primitives +- `fillpoly()`, `drawpoly()` ? +- `floodfill(x, y, border_color)` ? + +Text on graphics screen: +- `outtext(s)` / `outtextxy(x, y, s)` ? gfx_text (alias) +- `settextstyle(font, dir, size)` ? multiple bitmap fonts +- `gettextsettings(&info)` +- `textwidth(s)` / `textheight(s)` ? measure + +Image manipulation: +- `imagesize(x1, y1, x2, y2)` ? bytes needed for getimage +- `getimage(x1, y1, x2, y2, buf)` ? save rect to buffer +- `putimage(x, y, buf, op)` ? paste back with COPY_PUT/XOR_PUT/AND_PUT/OR_PUT/NOT_PUT + +Clipping/viewport: +- `setviewport(x1, y1, x2, y2, clip)` ? drawing clip rect +- `getviewsettings(&info)` +- `clearviewport()` +- `setactivepage(p)` / `setvisualpage(p)` ? ਧ (Sprinter 2 screen) + +Line style: +- `setlinestyle(style, pattern, thickness)` ? SOLID_LINE / DOTTED_LINE / etc. +- `getlinesettings(&info)` + +**Acceptance:** ७ ⨯筮 Turbo-C BGI ணࠬ (饩 ᯮ짮 +moveto/lineto/circle/bar/setcolor) ࠡ ⢥ ࠢ. + +**Notes:** +- BGI fonts (TRIPLEX/SANS_SERIF/GOTHIC) ? BIOS font, ⠫ 㦭 + ( bitmap data lib) +- imagesize/getimage/putimage ? ᠬ ॡ game/animation +- Active/visual page ( ਧ) ? Sprinter ন 2 graphics pages, + 㦥 API switching + +. ⠪ `examples/` Turbo C 2.x BGIDEMO reference 㦭. + +### IM2 Interrupt Handlers ? **MUST v2** + +User- ISR १ Z80 IM 2 mode. 㦭 : +- Timer ticks (50 Hz frame counter, ) +- Music playback (AY, COVOX) +- Real-time games (input + game logic + render interrupt-driven) +- Async keyboard / mouse handling + +**Status:** v2. research + design `docs/im2_isr_design.md`. + +**襭 ⥪:** ॠ ⤥ memory mode `--memory im2` +( ⮣ ⮡ 騥 crt0). Detail' design-doc. + +** research'** ( ⥪ `docs/im2_isr_design.md`): +- Vector 0xFF ? frame + keyboard + CBL. Disambiguation ⠬ 0x19 / 0xFE +- Mouse hardware-IRQ 室 ( ⥪饩 ) +- Vector table / ISR / stack W2 (0x8000..0xBFFF) +- DSS ᢮ IM 2 handler ? 㦭 chain' ( / SYSTIME ) + +### 稥 㯭 㭪 v2 + +- [ ] **FILE API rewrite ? buffered streams** ? ⥪ ॠ + `libc/stdio/file.c` provisional unbuffered shim ( fputc/fgetc + = read/write syscall). 㦭 業 buffered ᥬ⨪ + Solid-C: + + ```c + typedef struct { + uint flags; // +0..1 file status flags + int level; // +2..3 empty/fill level of buffer + char *curp; // +4..5 current active pointer + int fd; // +6..7 underlying low-level fd + char *buffer; // +8..9 data transfer buffer + char hold; // +10 ungetc byte if no buffer + short token; // +11..12 reserved + char dummy; // +13 reserved + } FILE; + ``` + + stdin/stdout/stderr ? fd-થ `0 / -1 / -2`. ⥫ + stdout/stderr ࠭ ७: ESTEX OPEN positive + small fd (1, 2, ?) 筮 䠩 ? ᫨ stdout=1, ॠ + fd=1 ⠫ 䨪஬. fd=0 stdin ᭮ + (ESTEX 0 頥). fd । syscall' ? + ᯥਧ 䫠 `_F_CONIN/_F_CONOUT`. + + ਭ-⮪ (stdaux/stdprn) ॠ㥬 ? Sprinter ਭ୮ + API . + + ୠ⨢ ? ॠ third_party/solid-c (sources + `SRC/CLIB/`); ⠬ ⮢ buffered FILE + fopen/fread/fwrite/ + fseek/setvbuf .. ஢ 訬 open/read/write/lseek. + + rewrite deferred issues stdio-review: + - `fwrite` short-write ⠢ `_F_ERROR` + - `fgets(buf, 1, fp)` ? ⠭ "empty string", 㫨 NULL + - `mode_to_flags` ? break-out '+' (cosmetic) + +- [ ] **Audio API** ? AY-3-8910 + COVOX १ 뢠 (ॡ IM2) +- [ ] **ISA-8 slot support** ? ZX-Bus (sound, network, etc.) ? ॡ IM2 + ⥭ port + +## 稥 (v1 backlog, 騥) + +- [x] **#9: text I/O split (Turbo-C style)** ? stdio (puts/printf/putchar) ⥯ fast no-attr १ PCHARS/PUTCHAR. conio (cputs/cprintf/putch) ਬ attr १ textcolor/textbackground/textattr. KEEP_EXIST_ATTR ? conio fallback fast path. Verified hello.exe. . `memory/text_output_api_split.md`. 2026-05-31. +- [x] **Mouse API ** (१ driver, RST 30h) ? 14 㭪権 (init/show/hide/refresh/read/goto/bounds/text_cursor/load_cursor/get_cursor/get/set_sensitivity/video_mode_changed). . `memory/mouse_api.md`. Verified MAME 2026-05-31. Sensitivity = divider ( = ॥). +- [ ] Interrupt handlers ? IM 2 vector table HOME user ISR' +- [ ] প `restore SP on EXIT` ( z88dk +pps) ? ஢ 㦭 +- [ ] CI: ⮬᪨ ᪠ MAME `-aviwrite` screenshot-ࠢ, ⮡ ਬ஢ 室 祫 + +## ⮬ + +- প `` ( SDCC stdlib ? 㦭 ஢ crt0 ᮢ⨬) +- `` १ ESTEX SYSTIME (`$21`) CMOS BIOS-㭪樨 +- ZX Spectrum-ᮢ⨬ ० ⤥ target ( ஢ ᯥ㬮᪨ ணࠬ) +- প ZX-Bus (sound, network, etc.) ? 㦭 ࠩ +- Profile-guided optimization tools (hot/cold detection) 㯭 ணࠬ + +## Linker duplicate-symbol warnings (, 䨫஢) + + ᮧ⥫쭮 overrides' SDCC z80.lib 㭪樨 ᮡ⢥ ᨥ `sprinter.lib`, `sdldz80` `?ASlink-Warning-Definition of public symbol '...' found more than once`. ࢮ । (), ⮬ ४⭮ ? warning ⮫쪮 noise. + +騥 overrides: +- `_puts` ? १ PCHARS+\r\n vs SDCC posix puts +- `___sdcc_heap` ? heap W2 vs SDCC's ⠭ +- `_asctime`, `_localtime` ( 㣨 time) ? `posix_time.c` १ ESTEX SYSTIME vs SDCC's `time.rel` `_RtcRead` + +**饥 襭:** `bin/sprinter-cc` 䨫஢뢠 warning- (warning + 2 follow-up `Library:` ப) 뢮 `sdcc`. १ `-v` (verbose) 뢠. १ awk-pipe. + +** 襭:** +- ३ explicit `--nostdlib` + 筮 ᯨ᮪ 㦭 㫥 z80.lib (string, math, stdlib override') ? warning', ᪨஢ +- : २ `_puts` ? `_puts_sprinter` + alias १ linker flag ( 㢥७ SDCC ন) +- : ⠢ ᥩ (ࠡ祥 benign) ? ਮ + +## TODO: ஢ ॠ쭮 + +- [ ] **Port_Y banking trick** (`docs/part2/SprinterGraphics programming.txt`): + ⢥ত ᫥ `OUT (0x89), Y` 0xC000+0x400*N W3 + ப Y..Y+15 ( ணࠬ஢ ? 16 ப). + Empirical 2026-06-01 MAME 0.283 trick ** ࠡ⠥** ? ᥫ + ᠬ 0xC000+row_width 室 . ᪨ + `docs/samples/plasma2.asm` ⮦ ᯮ banking, ⠭ + Port_Y per row. + : + 1. ॠ쭮 Sprinter + 2. dual-write (`_gfx_putpixel_raw` + ன write `0xD000+x`) + 3. ᫨ ? MAME, issue + ९ + 4. ᫨ ⮦ ? 㬥 , 㤠 㯮 + ⠢ ⥪ ॠ (Port_Y per pixel) + 5. ᫨ banking ࠡ⠥ ? ஢ Port_Y + `_gfx_putpixel_raw` (sentinel out-of-range, . memory/gfx_port_y_banking.md) + + 易 먣 Bresenham (60-pixel ) ? 8? + OUT (0x89) 権, `gfx_fill_rect 320x256` ? 16? . + release v1. + +## GFX: ७ `docs/part2/accelerator_doc.txt` + +᫥ ⥭ ⠫쭮 accelerator doc  ࠢ. + ᯮ ⮫쪮 ਧ⠫/⨪ Fill mode. + +### Quick wins ⥪ primitives + +- [ ] ** SMC `LD A, (var)` block-size**. 㬥  + ࠧ蠥 `LD A, (HL)`, `LD A, (BC)`, `LD A, (DE)` ( `LD A, r`). + 㡥 SMC complexity `gfx_lines.c:hfill_chunk/vfill_chunk` + `gfx_16.c:g16_hfill_chunk`. 饭 ⮫쪮 register-to-register. +- [ ] **஢ block-size**. 㬥 뢠 accel + block size bursts (. `Horizontal_Line_Fill`: ⠭ + size + `LD B,B` ⪫祭, ⮬ Fill mode ᯮ + ࠭ size). `gfx_fill_rect` 100 묨 + ப ? ⠭ size 1 ࠧ, 100. + +### Bank-prefix modes (port 0xE2 bits) + +㬥 뢠 ਠ ࠭ ⠭⭮ 0x50: + +| Bank byte | Effect | +|---|---| +| 0x50 | Normal write ? shadow + | +| 0x54 | "no copy in main shadow RAM" | +| 0x58 | **"FF is transparent"** ? 0xFF write ⠢ background | +| 0x5C | both | + +Bank 0x58 祬 mouse cursor 0xFF-஧筮. + **sprite-blending १ accel block copy**: + +- [ ] **`gfx_set_bank_transparent(on)`** 䫠 `gfx_set_bank` + 롮 0x50/0x58 ᮢ sprite' +- [ ] ᯮ짮 `gfx_blit()` ⮡ 䠪 + transparent sprites १ accel- + +### Block copy mode (sprite blit') + +`LD L,L` (horizontal) `LD A,A` (vertical) ? ० ஢ १ +256- accel memory. blit'. + +- [ ] **`gfx_blit(src_data, x, y, w, h)`** ? ஢ sprite' + (ந ࠧ, १ accel) +- [ ] **`gfx_blit_transparent(src, x, y, w, h)`** ? ᯮ짮 bank 0x58 + +. `Draw_Restangle_Data` accelerator_doc.txt ७. + +### AND / OR / XOR operations १ accel + +㬥 뢠 accel ন ᪨ 樨 +. ਬ: +- XOR ? (뤥 selection UI) +- OR / AND ? masking, alpha-style blending +- . ਬ accelerator_doc.txt: "256 bytes block coding via XOR" + +- [ ] **`gfx_xor_rect`** / **`gfx_or_rect`** / **`gfx_and_rect`** ? + ਬ⨢ ᪨ 権 אַ㣮쭨 +- [ ] **`gfx_invert_rect(x, y, w, h)`** ? alias xor 0xFF + +### Bitmap fonts ࠧ ࠧ஢ + + `gfx_text` / `gfx_putchar` प ࠡ 8?8 ⮬ +(BIOS WIN_GET_ZG 頥 256?8 ). UI / 쭨 +㦭: +- [ ] **`gfx_set_font_size(w, h)`** ? ४ ਭ/ glyph' +- [ ] **`gfx_set_font_data(ptr, w, h, advance)`** ? 㪠⥫ + 짮⥫᪨ + ࠧ +- [ ] প **proportional** (advance != w) ⮢ ? + array advance[256] ਭ glyph' +- [ ] **Big-font ०**: 8?16, 16?16, 16?8 ( 쭨) +- [ ] ⤥ API `gfx_text_ex(x, y, str, font_id)` + font_id 롨ࠥ 㦥 ⮢ +- [ ] **Anti-alias 2-bit ** ( 䮭 / ࠭ / 2- alpha?) + ? far future, smooth UI + +## ⠯ ⨬権 ( ᥩ) + +- **`gfx_line` १ accel ** ? Bresenham |dy| << |dx| ( ) 뤠 runs Y ( X): ᥫ, ᥫ, ᥫ, 蠣 Y, ᥫ, ᥫ... ⠪ run ? ⮢ 㬥 `gfx_hline` ( `vline`). + ᫥: runs 㭪 ; run length, ஬ 룮 accel hline 祬 N?putpixel (overhead accel ~20?s, putpixel ~5?s ? accel 룮 run ? 4-5 px); (dx ? dy) ⠢ Bresenham, ? run-length-based fill. + `gfx_line` orthogonal cases 㦥 १ accel ? ⨬஢ ⮫쪮 . + +- **`gfx_fill_rect` W3-swap ** ? ᥩ ७ `gfx_hline`/`gfx_vline` ᢮ DI/save-W3/restore-W3/EI. ᤥ internal `_fill_rect_inner` ন W3 DI 横; ~20?s ? ⢮ ப/⮫殢 . ਬ ᥬ ਬ⨢. +# MDView ? ᬮ騪 Markdown Sprinter + +**MDView** ? ணࠬ ᬮ 㬥⮢ ଠ *Markdown* +Sprinter ( Z80). 㬥 ࠭ ⤥쭮 W3 +᭮ RAM ணࠬ. + +## + +- 㬥 **128 ** (8 ࠭ EMM 16 ) +- **16 384** ࠭ ப +- ⮬᪨ ७ ᫮ ਭ ࠭ (80 ⮫殢) +- ਧ⠫ ᤢ ப ப ( , ⠡) +- -: 䠩, ப, 業 ப⪨ +- ப ﭨ ६ 㧪 樨 +- প ?? ᪫ ப + +## + +``` +mdview [_䠩.md] +``` + +᫨ 䠩 , 㦠 `README.MD`. + +## ࠢ + +``` + ⢨ + +Up Down ப⪠ ப / +PgUp PgDn ப⪠ ࠭ (30 ப) +Home 砫 㬥 +End 㬥 +Left Right ਧ⠫ ᤢ (⮫쪮 nowrap-ப) +F1 ࠢ +F8 ஢: CP866 ? CP1251 ? KOI8-R ? UTF-8 ? ... +F10 / Esc 室 ணࠬ +``` + +஢ । ⮬᪨ ⨨ (BOM + ⨪ + 4 ); `F8` ४砥 , ᫨ ⥪ 訡. +8- ஢ (CP866/CP1251/KOI8-R) ४ (६ +ᮢ). ன / (ਬ UTF-8) ந ? +ࢮ ४祭 (⪠ 㧠 ᯨ஬), . + +## ⠪ Markdown + +### + +ন ஢ H1?H4. ஢ H5 H6 ⮡ࠦ H4. + + # ࢮ ஢ + ## ண ஢ + ### 쥣 ஢ + #### ⮣ ஢ + +### ⮢ ଠ஢ + +** ⥪** 뤥 묨 񧤮窠: `**⥪**` + +*ᨢ* 뤥 묨 񧤮窠 `*⥪*` ન `_⥪_` + +`஥ ` 砥 묨 窠 + +~~ભ ⥪~~ ? ⨫: `~~⥪~~` + +### 㬥஢ ᯨ᮪ + +થ `-`, `*` `+`: + +- 㭪 ᯨ᪠ +- ன 㭪 ᯨ᪠ +- ⨩ 㭪 筮 ⥪⮬, 室 + 㤥 ७ ᫥ ப ࠭ 㯠 + +### 㬥஢ ᯨ᮪ + +1. +2. ன +3. ⨩ + +### + +> 稭 ᨬ `>`. ᪮쪮 ᫥⥫ +> ப ᪫ ⮬᪨ +> ७ᮬ ᫮. + +### (verbatim) + + 砥 ன 窨. +⥪ ⮡ࠦ ? ? ࠧ Markdown: + +``` +#include +#include + +int main(void) { + puts("Hello, Sprinter!"); + return 0; +} +``` + +### ਧ⠫쭠 + + ᨬ `---`, `***` `___` ⤥쭮 ப: + +--- + +## 孨᪨ ࠪ⨪ + +- **ଠ:** Sprinter, Z80 @ 21 +- **஢:** CP866 / CP1251 / KOI8-R / UTF-8 (⮮।, `F8`) +- **ᨬ ࠧ 䠩:** 128 +- **ᨬ쭮 ᫮ ப :** 16 384 +- ** :** small + - ணࠬ, c⥪, , ? a W1-W2 (32 , 0x4000?0xBFFF). + - 䠩 ? ࠭ EMM, ⮡ࠦ W3 (0xC000?0xFFFF) + +## TODO + +1. **祭 ࠧ 㬥⮢.** 128 : 筮 + ࠧ ࠡ 訬 - ࠭ , ஢ + ࠡ 8- ࠭栬 16. + +: ଠ஢ ⠡ ࠬ; প ஢ +CP866 / CP1251 / KOI8-R / UTF-8 ⮮। ४祭 `F8` +(ன ந , ࢮ ४祭). + +4. **᪮७ ७ਭ.** ப ࠭. ⨬ 横 뢮 + ᨬ १ BIOS WRCHAR ( 뢮, DMA). + +--- + +*MDView v0.2 (c) 2026 ஢ ..* + + +--- + +# Sprinter C Compiler ? v1.0 + +C toolchain for **Sprinter** ? the Z80-based home computer by Peters Plus, running +ESTEX DSS. Host: macOS / Linux. Target: `.EXE` files in SprintEXE format. + +Built on top of **SDCC 4.5** (vendored in `third_party/sdcc/`). This repository adds +everything Sprinter-specific: crt0, linker integration, libc wrappers over ESTEX, +banked-call trampolines, graphics & accelerator API, mouse driver wrappers, and the +`mkexe` utility for producing SprintEXE images. + +## What you get + +* **`bin/sprinter-cc`** ? one-line driver: `sprinter-cc -o foo.exe foo.c` +* **Memory modes**: `tiny`, `small`, `big`, `huge`, `manual` ? see below. +* **stdio + conio**: printf, puts, putchar, getchar, fopen/fread/..., cprintf, cputs, putch, textcolor/textbackground/textattr, gotoxy, kbhit/getch. +* **Graphics**: 320?256?256 and 640?256?16 modes, accelerator-backed primitives (hline / vline / rect / fill_rect / line via Bresenham, plus clear), bitmap-font text in both modes via BIOS character generator. +* **File I/O**: POSIX (`open`/`read`/`write`/`close`/`lseek`/`unlink`/`creat`), FILE\* streams (`fopen`/`fgets`/`fwrite`/...), directory listing (`ffirst`/`fnext`), `chdir`/`getcwd`/`mkdir`/`rmdir`, `stat`/`fstat`. +* **Memory**: 32 KB heap (W2-resident), banking-aware page allocator (`mem_alloc_pages`/`bank_read`/`bank_write`), explicit memory modes for sub-16 KB programs. +* **Mouse**: full Sprinter driver wrapper (14 functions including custom cursor bitmaps). +* **Environment**: `getenv`/`putenv`/`sysenv` over ESTEX `$46`. +* **Time**: `getdatetime`/`setdatetime` + POSIX `time`/`localtime`/`mktime`/`asctime`/`ctime`. +* **Misc**: `errno`/`strerror`/`perror`, `atexit`, `setjmp`/`longjmp`, `sleep`, full argv parsing in crt0. + +## Quick start + +```sh +git clone sprinter-c +cd sprinter-c +make sdcc # one-time: fetch SDCC 4.5 binary (~25 MB) +make all # build mkexe + libsprinter.lib + 27 examples +make floppy # pack everything into mame/v306/IMG/mc.img +cd mame/v306 && ./run_mame.sh # boot Sprinter in MAME +``` + +Compile a single program: + +```sh +cat > hello.c < +int main(void) { puts("Hello, Sprinter!"); return 0; } +EOF + +bin/sprinter-cc -o hello.exe hello.c +``` + +That's it ? `hello.exe` is now a valid SprintEXE you can `RUN HELLO` from the ESTEX shell. + +## Memory modes + +Sprinter's address space is four 16 KB windows (W0 / W1 / W2 / W3). DSS allocates +pages by program size ? small programs get only one page. Pick a memory mode based +on what your program needs: + +| Mode | Code lives in | Banking | Use when | Note | +|---|---|---|---|---| +| `tiny` (default) | W2 (0x8100+) | no | code+data < 14 KB | | +| `small` | W1-W2 (0x4100+) | no | code+data < 30 KB | | +| `big` | W2 + W1 banking | yes (W1) | tiny + extra code modules | | +| `huge` | W1-W2 + W3 banking | yes (W3) | small + extra code modules | | +| `manual` | user-specified | optional | special layouts | Not implemented | + +```sh +sprinter-cc --memory small -o big.exe bigprog.c +sprinter-cc --memory huge -o app.exe main.c --bank 1=engine.c --bank 2=ai.c +``` + +Banked functions are declared with `__banked`: + +```c +void engine_tick(int dt) __banked; // lives in BANK1, automatically swapped +``` + +## Examples (27 total) + +| Example | What it demonstrates | +|---|---| +| `hello` | Hello world with stdio + conio Turbo-C-style colors | +| `argv` | argv parsing in crt0 | +| `cat` | File I/O ? read & print TEST.TXT | +| `seek` | 32-bit lseek over a 100 KB file | +| `ls` | Directory listing via ffirst/fnext | +| `filetest` | FILE\* streams (fopen/fread/...) | +| `stattest` | `stat`/`fstat` on files and directories | +| `errno` | errno / strerror / perror | +| `mem_test` | Page allocator + bank\_read/bank\_write | +| `malloc` | Heap stress test (200+ allocations) | +| `banked` | Banked code in W3 (huge mode) | +| `bankedbg` | Banked code in W1 (big mode) | +| `banklocl` | Bank-local static data and BSS | +| `mouse` | Mouse driver in text mode | +| `gfx_mous` | Mouse with custom bitmap cursor in graphics mode | +| `gfx_demo` | 320?256?256 lines / rects / accelerator | +| `gfx_d16` | 640?256?16 same primitives | +| `gfx_text` | Bitmap-font text on graphics screen | +| `timedir` | Date/time + directory listing | +| `ptime` | POSIX time API | +| `openenv` | open() flags + environment vars | +| `conio` | conio API smoke test | +| `attrprob` | Probe Sprinter text attribute byte layout | +| `strtest` | string.h test (from SDCC's z80.lib) | +| `stdlib` | stdlib.h test (qsort / rand / strtol / etc.) | +| `assrtest` | assert() | +| `rt_test` | Runtime helpers (sleep, setjmp, atexit) | + +## Headers + +Standard: +* `` ? puts / printf / FILE\* + Sprinter-specific dec/hex helpers +* `` ? atoi / atof / malloc / qsort / ... (from SDCC z80.lib) +* `` / `` / `` ? from SDCC z80.lib +* `` ? read / write / close / lseek / unlink +* `` ? open / creat + O\_RDONLY / O\_CREAT / ... +* `` ? errno + error names + strerror +* `` ? stat / fstat +* `` / `` ? from SDCC + +Sprinter-specific: +* `` ? putch / cputs / cprintf, textcolor / textbackground / textattr, kbhit / getch, clrscr, gotoxy, wherex/y +* `` ? gfx_init/done, palette, putpixel, hline/vline/rect/fill_rect/line, text ? for both 320 and 640 modes (gfx_\*16 variants) +* `` ? full 14-function driver wrapper + mouse_cursor_t with bitmap support +* `` ? chdir / getcwd / mkdir / rmdir / ffirst / fnext / ffblk +* `` ? getdatetime / setdatetime + POSIX time / localtime / etc. +* `` ? raw ports, ESTEX/BIOS function numbers, env API +* `` ? exit / \_exit / atexit +* `` ? mem\_alloc\_pages / mem\_free\_block / bank\_read / bank\_write +* `` ? Solid-C compatibility layer (aliases + BOOL/WORD/uint types) + +## Toolchain commands + +```sh +make all # build mkexe + lib + every example +make floppy # repack mame/v306/IMG/mc.img with all .exe files +make check # 17 mkexe unit-tests +make clean # remove all build artefacts +make sdcc # one-time: fetch SDCC 4.5 binary +``` + +### sprinter-cc options + +``` +sprinter-cc -o foo.exe foo.c [more.c ...] [options] + + --memory MODE tiny | small | big | huge | manual (default: tiny) + --memory-manual SPEC explicit placement (CODE=W1|W2,DATA=W1|W2|SAME,BANKED=W1|W3) + --stack-size N bytes reserved for the stack (default ~1278) + --crt0=TYPE default | minimal | banked | small + --bank N=FILE.c compile FILE.c into bank N (repeatable, max 15) + --debug enable runtime diagnostics (defines DEBUG_RT) + -I PATH extra include path + -L 0xADDR / -E / -S override load / entry / stack addresses + -Wl FLAG pass FLAG to sdldz80 + --mkexe FLAG pass FLAG to mkexe (e.g. --mkexe -p --mkexe 0 for bank padding) + -v verbose +``` + +## Status + +What works in v1.0: +* Compile / link / pack to SprintEXE ? verified on all 27 examples +* Four memory modes (tiny / small / big / huge) +* Graphics (both modes) with accelerator +* Mouse (text + graphics cursor) +* File I/O, directories, environment, time +* All headers listed above + +Deferred to v2.0 (see `docs/TODO.md`): +* **Turbo-C-style BGI graphics API** ? `initgraph` / `setcolor` / `circle` / + `getimage` / `putimage` / etc. on top of our `gfx_*` primitives +* Remaining Solid-C compatibility gaps (Phase 2/3) ? see `docs/solid_c_compatibility.md` +* Manual memory mode +* Rewrite FILE\* stream API (current implementation is very primitive and doesn't use buffers) + +Deferred to v3.0: +* **IM2 interrupt handlers** ? research complete (`docs/im2_isr_design.md`), + implementation scheduled for v3 +* **Audio API** (AY-3-8910 + COVOX) ? requires IM2 +* **ISA-8 slot drivers** ? requires IM2 (???) + +## Documentation + +* `docs/TODO.md` ? roadmap and open work items +* `docs/solid_c_compatibility.md` ? gap analysis vs Solid-C 2004 +* `docs/im2_isr_design.md` ? interrupt handler design (v2) +* `docs/converted/` ? source documentation (ESTEX, BIOS, architecture) + converted to plain text for `grep` +* `docs/reference/`, `docs/samples/`, `docs/memory management/` ? original + Russian docs and code samples from Peters Plus + +## Repository layout + +``` +bin/sprinter-cc one-line compiler driver (bash) +toolchain/mkexe/ host-side tool: .ihx -> .exe SprintEXE +toolchain/check_banks.py post-link bank size enforcer +runtime/ crt0 variants (default, minimal, small, banked) + bank trampolines, heap, heap_top +libc/include/ headers +libc/io|stdio|mem|gfx/ C and asm sources for libsprinter.lib +lib/ Makefile that archives libsprinter.lib via sdar +examples/ 27 example programs +mame/v306/ MAME binary + Sprinter ROM/HDD images + floppy script +third_party/sdcc/ vendored SDCC 4.5 (fetched via `make sdcc`) +third_party/solid-c/ reference: original Sprinter native C (for compat target) +docs/ documentation +``` + +## License + +This repository contains: +* Original code in `bin/`, `toolchain/`, `runtime/`, `libc/`, `lib/`, `examples/` ? + MIT-licensed. +* `third_party/sdcc/` ? SDCC 4.5 under GPLv2 with linking exception + (see `third_party/sdcc/COPYING.txt`) +* `third_party/solid-c/` ? original Sprinter Solid C, used only as a reference + +## Credits + +* **Sprinter / Peters Plus** ? , ਩ ਭ and the original team +* **SDCC** ? for the underlying Z80 compiler +* **MAME** ? for the Sprinter Sp2000 emulation + +--- + +For questions / patches: see CONTRIBUTING.md (TBD) or open an issue. + +--- + +# TODO / Roadmap + + 浪 뢠 ਮ.  ॠ ணࠬ ? ਮ ᬥ. + +## ⠯ 5 ? malloc / free + banking-aware page allocator ? + +- [x] SDCC's `malloc`/`free` + `runtime/heap.s` ( library heap.rel, 14000- heap 2) +- [x] `libc/mem/mem_alloc.c` ? page allocator: `mem_alloc_pages`/`mem_free_block`/`mem_get_page`/`mem_info` १ ESTEX `$3C/$3D/$3E` + BIOS `$C4` +- [x] `libc/mem/bank_io.c` ? HOME-१ `bank_read`/`bank_write`/`bank_load_byte`/`bank_store_byte` ᢮ W3 +- [x] `examples/malloc_test/` ? ஢ઠ SDCC's malloc (~210 64- allocations १ heap) +- [x] `examples/mem_test/` ? ஢ઠ page allocator: 3 ࠭, ࠧ १ bank_write, 䨪 १ bank_read + +## ⠯ 6 ? argv parsing + sprinter-cc wrapper ? + +- [x] crt0 ESTEX command-line IX-prefix (inline asm `runtime/crt0.s`) +- [x] Strip leading CP/M-style space (DSS quirk) +- [x] । `argc`/`argv` main() १ HL/DE (SDCC __sdcccall(1) ABI) +- [x] argv[0] = basename .EXE १ ESTEX APPINFO ($47 subfn 2) +- [x] `runtime/crt0_minimal.s` ? opt-out 祭 쪨 ணࠬ +- [x] `runtime/crt0_banked.s` ? ⥯ ⮦ argv (parse_argv + get_progname ᪮஢ crt0.s; 㤥 factored argv.s libsprinter.lib) +- [x] Bash-⪠ `bin/sprinter-cc`: `sprinter-cc -o foo.exe foo.c` ப +- [x] প 権: `--memory`, `--memory-manual`, `--stack-size`, `--crt0=`, `--bank N=FILE.c`, `--debug`, `-I`, `-L`/`-E`/`-S`, `-Wl`, `--mkexe` + +## ⠯ 8 ? 䨪 (320?256?256 + 640?256?16 + accel + bitmap font) ? + +- [x] **8a** Graphics core: `gfx_init`/`gfx_done`/`gfx_clear`/`gfx_putpixel`/`gfx_pal_load`/`gfx_pal_set` (libc/gfx/gfx_core.c). १ BIOS PIC_SET_PAL ($A4). Verified 320?256?256. +- [x] **8b** /אַ㣮쭨/fill १ accelerator (libc/gfx/gfx_lines.c): `gfx_hline`/`gfx_vline` १ accel Fill (LD C,C / LD E,E + SMC block-size), `gfx_rect`/`gfx_fill_rect` heuristic 롮஬ ਥ樨 (h/v bursts count), `gfx_line` Bresenham . `gfx_clear` ⮦ ९ᠭ column-major accel (~4? ॥). +- [x] **8c** 640?256?16 mode (libc/gfx/gfx_16.c): `gfx_*16` API, HIGH nibble = LEFT pixel (㬥 misleading), per-row RMW vline ( = 2 ਧ⠫ ᥫ). +- [x] **8d** Bitmap font + gfx_text (libc/gfx/gfx_text.c): १ BIOS WIN_GET_ZG ($B8), interleaved layout `font[row*256+char]`, `gfx_text`/`gfx_putchar` 320 mode, `gfx_text16`/`gfx_putchar16` 640 mode pair-table lookup. + +. memory/sprinter_graphics.md, sprinter_accelerator.md, sprinter_graphics_16.md, sprinter_font_format.md. + + ( ): +- [ ] -quad 640: per-cell (mode 0x82 ࠧ蠥 1 4 per 16?8 cell) ? १ אַ area-ᠭ ࠭ 0x0300..0x039F + +## Auto-banking (. `memory/banking_roadmap.md` ⠫) + +Phase 1 ? file-level bin-packing ? ॠ뢠 ஥ ~30 KB . + +- [ ] `toolchain/auto_bank.py`: + - ࠧ `.rel`-䠩 ( .map ᫥ dry-run link') + - First-fit-decreasing bin-packing + - `#pragma codeseg BANKn` manual override + - ५뢠 묨 `-Wl-b_BANKn=...` ࠬࠬ + - ⠥ । + +Phase 2-5: incremental rebalance, declarative `banks.toml`, function-level, call-graph-aware. 쪮 ᫨/ . + +## Bank-local static data (mutable data ⮬ ) ? ? + +- [x] ਬ `examples/bank_local_data/` ? 㭪 BANK1 ᢮ writable BSS array + const table + malloc- +- [x] `mkexe -p 0` 㫥 padding (BSS-storage 㧪) +- [x] ᪨ 楯: `--codeseg BANK1 --constseg BANK1 --dataseg BANK1` bank1.c + `-Wl-b_BANK1=0x1C000` . **`--dataseg BANK1` ** ? ࠭ ⭮ - trampoline bug ᪨஢ १. +- [x] ** 䨪 trampoline'a runtime/bank.s** ? `pop af; out (n), a` ਫ A ? banked-㭪樨 騥 uint8_t 頫 . `pop bc; out (c), b` ࠭ A. +- [x] **malloc banked-㭪樨 ࠡ⠥ ஧筮** ? heap W2 (HOME), W2 ᢠ trampoline', pointer  ⥪. . memory/bank_local_data_pattern.md. +- [x] 㬥 memory: `memory/bank_local_data_pattern.md` ( 楯 + malloc + nuances), `memory/sdcc_banking.md` (trampoline fix) +- [ ] 樮쭮 ? `check_banks.py` ⮡ 뢠 ࠧ size = code + const + bss per bank (cosmetic) + +祬: 㫥 訬 private state (level loader, audio engine, scene data). W2 heap , ⨪ . + +## ᪠ solid-c (⨢ Sprinter C ? `third_party/solid-c/`) + +᫥ solid-c'᪮ libc (. `memory/solid_c_findings.md`)  ⮢ ᫥ 㭪権. ਮ **᮪** : + +### High-priority gaps ( ஢, 짠) +- [x] **`errno` + `strerror`/`perror`** ? ⠡窠 32 訡 (libc/io/errno.c) +- [x] **७ `open()`** O_CREAT/O_TRUNC/O_APPEND/O_EXCL state machine +- [x] **`atexit`** ? 8-callback LIFO + `exit()` + `_exit()` (libc/io/atexit.c) +- [x] **`setjmp`/`longjmp`** ? 6- jmp_buf={sp,ix,pc} (libc/io/setjmp.c) +- [x] **`sleep(seconds)`** ? 50Hz halt-loop (libc/io/sleep.c) +- [x] **ESTEX ENV API** ($46, getenv/putenv) ? libc/io/env.c. 竨 doc-bug: ॠ쭮 A=0 NOT FOUND + +### Medium-priority (㦭 shell-like ⨫) +- [ ] **Mouse driver** ? `rst $30h`, 17 㭪権. **砫 ࠡ⠥ MAME**. +- [x] **`ffirst`/`fnext` + ffblk_t struct** directory listing ? ॠ, demo: ls.exe +- [x] **`getdatetime`/`setdatetime`** १ ESTEX $21/$22 ? libc/io/time.c, demo: time_dir_test +- [x] **`chdir`/`getcwd`/`mkdir`/`rmdir`** ? wrappers ESTEX $1B-$1E ? libc/io/fsdir.c +- [x] **conio: `kbhit`/`getch`/`getche`/`cputs`/`clrscr`/`gotoxy`** ? ॠ +- [x] **conio extras**: `wherex`/`wherey` ($53), `wrchar`/`rdchar` ($58/$57), `textmode_get/set` ($50/$51), `clrscr_attr` ($56) + COLOR macros + +### Low-priority ? ? FILE* stack + +- [x] ** unbuffered FILE\*** ? `libc/stdio/file.c` + `libc/include/stdio.h`. fopen/fclose/fputs/fgets/fread/fwrite/fseek/ftell/rewind/feof/ferror/clearerr/fflush + stdin/stdout/stderr pseudo-streams. . `memory/file_star_design.md` `examples/filetest`. +- [ ] fprintf / fscanf ? 㦭 printf-१-callback machinery. 짮⥫ `sprintf(buf, ...) + fputs(buf, fp)`. +- [ ] 樮 buffered mode (setvbuf, line/block buffering) ? ᫨ - . + +### POSIX time API ? ? +- [x] `libc/io/posix_time.c` ? time/localtime/gmtime/mktime/asctime/ctime getdatetime. SDCC's time.rel ( override _RtcRead). . `examples/ptime`. + +### sys/stat ? ? +- [x] `libc/io/stat.c` ? POSIX stat/fstat. ਤ open+fstat 䠩, ffirst+iter ( "."/".."). . `examples/stattest` `memory/estex_ffirst_dotdot.md`. + +### assert ? ? (ᯮ㥬 SDCC's __assert १ fallback include path) + +## libc/stdlib ? ? 㦭 (. memory/sdcc_stdlib_works.md) + +஢७ १ `examples/stdlib_test/`: SDCC z80.lib ᮤন ࠡ騥 ॠ樨: +- `atoi/atol/atof, strtol/strtoul, rand/srand, qsort/bsearch, abs/labs, div/ldiv` +- `` (memchr/cmp/set/cpy, strcat/cmp/cpy/len/chr/spn/etc.) +- `` (toupper/tolower) +- `` (sinf/cosf/sqrtf/etc.) + + ⮬᪨ ﭥ z80.lib 㦭. ** ९뢠**. + + Sprinter-specific 易⥫ 㫨 : atexit, env, errno, setjmp, putchar/puts/getchar, conio, fsdir, time, mouse, open/read/lseek/close. + +## Build-system: libsprinter.lib + sprinter-cc ? ? + +- [x] `lib/Makefile` ? ᮡࠥ libc/*.c `.rel`, 娢 १ sdar `lib/sprinter.lib` +- [x] 砥 runtime/bank.s runtime/heap.s (auto-pulled __banked/malloc) +- [x] `bin/sprinter-cc` ? bash-wrapper: `sprinter-cc -o foo.exe foo.c` ப +- [x] প 権 `--crt0=default|minimal|banked`, `--bank N=FILE.c`, `-I`, `-L`/`-E`/`-S`, `-Wl`, `--mkexe` +- [x] `examples/hello_sccc/` ? : `hello.c` ᮡࠥ shell-맮, ࠧ ᮢ Makefile (925 ) +- [x] Split `putchar.c` ? `putchar.c` + `puts.c` per-function granularity (puts override SDCC's z80.lib version) +- [x] `make all` (ᨬ `lib` । `examples`) + + 襭 (樮쭮): +- [ ] ஢ ⠫ examples sprinter-cc Makefile (ᬥ⨪) +- [ ] 쭥 libc/*.c per-function ( ⥪ granularity 㦥 㦭 ࠧ ? .rel 楫, 設⢠ 䠩 㭪) + +## ⠯ 9 ? memory modes sprinter-cc + +DSS 뤥 ࠭ ࠧ ਫ: < 16 KB ? ࠭, ⠫ 砥 ?࠭ #FF? (read=0xFF, write ). - ⮣ CODE--W1 + DATA--W2 쪮 ணࠬ . . [memory/sprinter_memory_modes.md](../../.claude/projects/-Volumes-SAM8-Projects-DIY-Z80-Sprinter-C-Compiler/memory/sprinter_memory_modes.md). + +- [x] **`tiny`**: (CODE+DATA+⥪) W2. Default. Verified hello/argv/conio/malloc/file/etc. +- [x] **`--memory MODE` 䫠 sprinter-cc**: parser + per-mode 䮫 CODE_LOC/DATA_LOC, override १  `--code-loc`/`--data-loc`. tiny ࠡ⠥; small/big/huge warning' (runtime ⮢). 2026-05-30. +- [x] **`--memory-manual SPEC`**: `CODE=W1|W2,DATA=W1|W2|SAME,BANKED=W1|W3`. 2026-05-30. +- [x] **`small` runtime**: `runtime/crt0_small.s` ᯮ ESTEX `$3D GETMEM` + `$3A SETWIN2` ⮡ 뤥 W2-࠭ gsinit. **** BIOS `$C4` ? ⥪ ⮬ ⠯ W1 (boot_stack HOME), BIOS ॡ ⥪ W2. ᫥ SP ४砥 0xBFFE, ⠭ flow. 2026-05-30, verified hello.exe. +- [x] **`small` auto-detect >16 KB ணࠬ**: `crt0_small.s` ⠥ `0xC2` (⥪ ࠭ W2 ? `0xA2`! W1). ᫨ 0xFF ? 뤥 page; DSS 㦥 ᤥ (ணࠬ ᠬ 뫥 W2). crt0 뢠 0..30 KB. mkexe ⠪ ࠧ蠥 HOME span W1+W2 (0x4000..0xBFFF). Verified hello: small (5 KB 䠩, SETWIN2 path) + 32 KB 䠩 (auto-skip). 2026-05-30. +- [x] **`big` runtime** (tiny + banked code W1): ࠬਧ `crt0_banked.s` + `bank.s` १ `.ifdef BANK_W1` ? 㣮 banking port (0xA2 vs 0xE2), 㣮 load-addr (0x4000 vs 0xC000). sprinter-cc prepend' `BANK_W1 = 1` `--memory big`, । `mkexe -B 0x4000`. ਬ `examples/banked_big/`. 2026-05-30. +- [x] **`huge` runtime** (small + banked code W3): merge W2-detect `crt0_small.s` `crt0_banked.s`. 騩 ਬ `examples/banked/` ⥯ ᯮ MEMORY=huge. 2026-05-30. +- [x] **`--debug` 䫠**: prepend `DEBUG_RT = 1` crt0 + `-DDEBUG_RT` sdcc. 뢠 symbol `_w2_self_allocated` (uint8_t) ? runtime diagnostic ஢ W2. 2026-05-30. + +### -襭 libc crt0 + +** `sprinter.lib`** ࠡ⠥ memory mode ? `.rel`-童 relocatable, SDLD dead-code elimination per-member ( 䨪  `gfx_core.rel` ..). Verified hello vs malloc_test १ map-䠩. + +**`gfx.lib` ⤥쭮 ? 㦥**: dead-code elimination 㦥 ࠡ⠥. + +**`libc_banked` (libc bank HOME)** ? ⮬, HOME (16 KB) user- + libc `huge` mode. १ `--codeseg BANK0` 樨 libc; trade-off: trampoline ~30 横 libc-맮. ਣ: ॠ쭠 ணࠬ HOME budget. + +**HW-ᨬ 㫨 ? `sprinter_home.lib` ⤥쭮.** libc 䨧᪨ W3, ⮬ W3: +- `gfx_*` ? `0xC000+` ᫥ swap W3 video page +- `bank_io` (mem_alloc_pages/bank_read/bank_write) ? swap' W3 १ `OUT (0xE2)` +- 騥 ISR ? 뢠 ਩ W3 㣮 + + huge mode 㫨 HOME (W1). 㤥 `libc_banked`, **६** 뤥塞 `sprinter_home.lib` (HOME-only) `sprinter.lib` (bankable). 쭠 奬: +``` +sprinter_home.lib HOME-only: gfx, bank_io, ISR shims +sprinter.lib bankable: printf, malloc, string, conio, stdio, env, ... +sprinter_banked.lib sprinter.lib --codeseg BANK0 ( huge) +``` +ਣ: ॠ `--memory huge` runtime. + +**crt0 ? mode:** +- `crt0.s` ? ⥪騩, **tiny/big**: SP=0xBFFE, argv (W2- 㦥 뤥 DSS). +- `crt0_minimal.s` ? ⥪騩, tiny argv. +- `crt0_small.s` ? **, step 3**: **small/huge**, W2 १ `mem_alloc_pages` gsinit, `0xA2`, ⮬ ⠭ flow. +- `crt0_banked.s` ? ⥪騩, **big**: trampoline-⠡ W3 , CODE W2. +- `crt0_banked_small.s` ? ****: huge = small (W2-alloc) + banked (W3 trampolines). + +sprinter-cc ࠥ crt0 `--memory` mode (ᥩ `--crt0=` override). +- [x] **ࠨ ࠧ ⥪**: 䫠 `sprinter-cc --stack-size BYTES`. Wrapper `heap_top.s` `___sdcc_heap_end = stack_top + 1 - stack_size`, ⤥ .rel per-program. Default ?1278 (heap_top=0xBB00) `runtime/heap_top.s`. 2026-05-30. + +䥩: `sprinter-cc --memory [tiny|small|big|huge|manual] [--memory-manual SPEC] [--stack-size N] foo.c`. `--memory-manual` ⮫쪮 `--memory manual`. + +## Known issues / quirks + +- **ESTEX $46 ENV API**: ? ࠡ⠥. - `DiskSyscalls.txt v1.6` 訡筮 뢠 return-status ? A=0 NOT FOUND, FOUND. 䨪஢ `memory/sprinter_platform.md`. + +## V2 (᫥ ५ v1) + +### Turbo-C-style graphics API (BGI-like) ? **MUST v2** + + `gfx_*` API ஢ **Turbo-C ``** (BGI) MS-DOS. +ணࠬ ਢ訥 Turbo-C ७ ᪨ 1--1. + +** ** ( ᭮ Borland BGI): + +Setup/teardown: +- `initgraph()` / `closegraph()` ? ᥩ `gfx_init`/`gfx_done`, alias +- `getmaxx()` / `getmaxy()` ? GFX_WIDTH-1 / GFX_HEIGHT-1 +- `cleardevice()` ? alias to gfx_clear +- `getgraphmode()` / `setgraphmode()` ? get_videomode/set_videomode + +Color/palette: +- `setcolor(c)`, `getcolor()` ? current draw color +- `setbkcolor(c)`, `getbkcolor()` ? background color +- `setpalette(idx, c)` ? entry +- `getpalette(&info)` ? read all palette + +Primitives ( 㦥 ? BGI- aliases): +- `putpixel(x, y, c)` ? gfx_putpixel +- `getpixel(x, y)` ? 㦭 ॠ (RMW ⭮ ? IN) +- `moveto(x, y)`, `lineto(x, y)`, `linerel(dx, dy)` ? current point + line drawing +- `line(x1, y1, x2, y2)` ? gfx_line +- `rectangle(x1, y1, x2, y2)` ? gfx_rect ( 㣮 API: x1,y1,x2,y2 vs x,y,w,h!) +- `bar(x1, y1, x2, y2)` ? gfx_fill_rect +- `bar3d(x1, y1, x2, y2, depth, topflag)` ? : rect + 3d edges +- `circle(x, y, r)`, `arc(...)`, `ellipse(...)`, `pieslice(...)` ? primitives +- `fillpoly()`, `drawpoly()` ? +- `floodfill(x, y, border_color)` ? + +Text on graphics screen: +- `outtext(s)` / `outtextxy(x, y, s)` ? gfx_text (alias) +- `settextstyle(font, dir, size)` ? multiple bitmap fonts +- `gettextsettings(&info)` +- `textwidth(s)` / `textheight(s)` ? measure + +Image manipulation: +- `imagesize(x1, y1, x2, y2)` ? bytes needed for getimage +- `getimage(x1, y1, x2, y2, buf)` ? save rect to buffer +- `putimage(x, y, buf, op)` ? paste back with COPY_PUT/XOR_PUT/AND_PUT/OR_PUT/NOT_PUT + +Clipping/viewport: +- `setviewport(x1, y1, x2, y2, clip)` ? drawing clip rect +- `getviewsettings(&info)` +- `clearviewport()` +- `setactivepage(p)` / `setvisualpage(p)` ? ਧ (Sprinter 2 screen) + +Line style: +- `setlinestyle(style, pattern, thickness)` ? SOLID_LINE / DOTTED_LINE / etc. +- `getlinesettings(&info)` + +**Acceptance:** ७ ⨯筮 Turbo-C BGI ணࠬ (饩 ᯮ짮 +moveto/lineto/circle/bar/setcolor) ࠡ ⢥ ࠢ. + +**Notes:** +- BGI fonts (TRIPLEX/SANS_SERIF/GOTHIC) ? BIOS font, ⠫ 㦭 + ( bitmap data lib) +- imagesize/getimage/putimage ? ᠬ ॡ game/animation +- Active/visual page ( ਧ) ? Sprinter ন 2 graphics pages, + 㦥 API switching + +. ⠪ `examples/` Turbo C 2.x BGIDEMO reference 㦭. + +### IM2 Interrupt Handlers ? **MUST v2** + +User- ISR १ Z80 IM 2 mode. 㦭 : +- Timer ticks (50 Hz frame counter, ) +- Music playback (AY, COVOX) +- Real-time games (input + game logic + render interrupt-driven) +- Async keyboard / mouse handling + +**Status:** v2. research + design `docs/im2_isr_design.md`. + +**襭 ⥪:** ॠ ⤥ memory mode `--memory im2` +( ⮣ ⮡ 騥 crt0). Detail' design-doc. + +** research'** ( ⥪ `docs/im2_isr_design.md`): +- Vector 0xFF ? frame + keyboard + CBL. Disambiguation ⠬ 0x19 / 0xFE +- Mouse hardware-IRQ 室 ( ⥪饩 ) +- Vector table / ISR / stack W2 (0x8000..0xBFFF) +- DSS ᢮ IM 2 handler ? 㦭 chain' ( / SYSTIME ) + +### 稥 㯭 㭪 v2 + +- [ ] **FILE API rewrite ? buffered streams** ? ⥪ ॠ + `libc/stdio/file.c` provisional unbuffered shim ( fputc/fgetc + = read/write syscall). 㦭 業 buffered ᥬ⨪ + Solid-C: + + ```c + typedef struct { + uint flags; // +0..1 file status flags + int level; // +2..3 empty/fill level of buffer + char *curp; // +4..5 current active pointer + int fd; // +6..7 underlying low-level fd + char *buffer; // +8..9 data transfer buffer + char hold; // +10 ungetc byte if no buffer + short token; // +11..12 reserved + char dummy; // +13 reserved + } FILE; + ``` + + stdin/stdout/stderr ? fd-થ `0 / -1 / -2`. ⥫ + stdout/stderr ࠭ ७: ESTEX OPEN positive + small fd (1, 2, ?) 筮 䠩 ? ᫨ stdout=1, ॠ + fd=1 ⠫ 䨪஬. fd=0 stdin ᭮ + (ESTEX 0 頥). fd । syscall' ? + ᯥਧ 䫠 `_F_CONIN/_F_CONOUT`. + + ਭ-⮪ (stdaux/stdprn) ॠ㥬 ? Sprinter ਭ୮ + API . + + ୠ⨢ ? ॠ third_party/solid-c (sources + `SRC/CLIB/`); ⠬ ⮢ buffered FILE + fopen/fread/fwrite/ + fseek/setvbuf .. ஢ 訬 open/read/write/lseek. + + rewrite deferred issues stdio-review: + - `fwrite` short-write ⠢ `_F_ERROR` + - `fgets(buf, 1, fp)` ? ⠭ "empty string", 㫨 NULL + - `mode_to_flags` ? break-out '+' (cosmetic) + +- [ ] **Audio API** ? AY-3-8910 + COVOX १ 뢠 (ॡ IM2) +- [ ] **ISA-8 slot support** ? ZX-Bus (sound, network, etc.) ? ॡ IM2 + ⥭ port + +## 稥 (v1 backlog, 騥) + +- [x] **#9: text I/O split (Turbo-C style)** ? stdio (puts/printf/putchar) ⥯ fast no-attr १ PCHARS/PUTCHAR. conio (cputs/cprintf/putch) ਬ attr १ textcolor/textbackground/textattr. KEEP_EXIST_ATTR ? conio fallback fast path. Verified hello.exe. . `memory/text_output_api_split.md`. 2026-05-31. +- [x] **Mouse API ** (१ driver, RST 30h) ? 14 㭪権 (init/show/hide/refresh/read/goto/bounds/text_cursor/load_cursor/get_cursor/get/set_sensitivity/video_mode_changed). . `memory/mouse_api.md`. Verified MAME 2026-05-31. Sensitivity = divider ( = ॥). +- [ ] Interrupt handlers ? IM 2 vector table HOME user ISR' +- [ ] প `restore SP on EXIT` ( z88dk +pps) ? ஢ 㦭 +- [ ] CI: ⮬᪨ ᪠ MAME `-aviwrite` screenshot-ࠢ, ⮡ ਬ஢ 室 祫 + +## ⮬ + +- প `` ( SDCC stdlib ? 㦭 ஢ crt0 ᮢ⨬) +- `` १ ESTEX SYSTIME (`$21`) CMOS BIOS-㭪樨 +- ZX Spectrum-ᮢ⨬ ० ⤥ target ( ஢ ᯥ㬮᪨ ணࠬ) +- প ZX-Bus (sound, network, etc.) ? 㦭 ࠩ +- Profile-guided optimization tools (hot/cold detection) 㯭 ணࠬ + +## Linker duplicate-symbol warnings (, 䨫஢) + + ᮧ⥫쭮 overrides' SDCC z80.lib 㭪樨 ᮡ⢥ ᨥ `sprinter.lib`, `sdldz80` `?ASlink-Warning-Definition of public symbol '...' found more than once`. ࢮ । (), ⮬ ४⭮ ? warning ⮫쪮 noise. + +騥 overrides: +- `_puts` ? १ PCHARS+\r\n vs SDCC posix puts +- `___sdcc_heap` ? heap W2 vs SDCC's ⠭ +- `_asctime`, `_localtime` ( 㣨 time) ? `posix_time.c` १ ESTEX SYSTIME vs SDCC's `time.rel` `_RtcRead` + +**饥 襭:** `bin/sprinter-cc` 䨫஢뢠 warning- (warning + 2 follow-up `Library:` ப) 뢮 `sdcc`. १ `-v` (verbose) 뢠. १ awk-pipe. + +** 襭:** +- ३ explicit `--nostdlib` + 筮 ᯨ᮪ 㦭 㫥 z80.lib (string, math, stdlib override') ? warning', ᪨஢ +- : २ `_puts` ? `_puts_sprinter` + alias १ linker flag ( 㢥७ SDCC ন) +- : ⠢ ᥩ (ࠡ祥 benign) ? ਮ + +## TODO: ஢ ॠ쭮 + +- [ ] **Port_Y banking trick** (`docs/part2/SprinterGraphics programming.txt`): + ⢥ত ᫥ `OUT (0x89), Y` 0xC000+0x400*N W3 + ப Y..Y+15 ( ணࠬ஢ ? 16 ப). + Empirical 2026-06-01 MAME 0.283 trick ** ࠡ⠥** ? ᥫ + ᠬ 0xC000+row_width 室 . ᪨ + `docs/samples/plasma2.asm` ⮦ ᯮ banking, ⠭ + Port_Y per row. + : + 1. ॠ쭮 Sprinter + 2. dual-write (`_gfx_putpixel_raw` + ன write `0xD000+x`) + 3. ᫨ ? MAME, issue + ९ + 4. ᫨ ⮦ ? 㬥 , 㤠 㯮 + ⠢ ⥪ ॠ (Port_Y per pixel) + 5. ᫨ banking ࠡ⠥ ? ஢ Port_Y + `_gfx_putpixel_raw` (sentinel out-of-range, . memory/gfx_port_y_banking.md) + + 易 먣 Bresenham (60-pixel ) ? 8? + OUT (0x89) 権, `gfx_fill_rect 320x256` ? 16? . + release v1. + +## GFX: ७ `docs/part2/accelerator_doc.txt` + +᫥ ⥭ ⠫쭮 accelerator doc  ࠢ. + ᯮ ⮫쪮 ਧ⠫/⨪ Fill mode. + +### Quick wins ⥪ primitives + +- [ ] ** SMC `LD A, (var)` block-size**. 㬥  + ࠧ蠥 `LD A, (HL)`, `LD A, (BC)`, `LD A, (DE)` ( `LD A, r`). + 㡥 SMC complexity `gfx_lines.c:hfill_chunk/vfill_chunk` + `gfx_16.c:g16_hfill_chunk`. 饭 ⮫쪮 register-to-register. +- [ ] **஢ block-size**. 㬥 뢠 accel + block size bursts (. `Horizontal_Line_Fill`: ⠭ + size + `LD B,B` ⪫祭, ⮬ Fill mode ᯮ + ࠭ size). `gfx_fill_rect` 100 묨 + ப ? ⠭ size 1 ࠧ, 100. + +### Bank-prefix modes (port 0xE2 bits) + +㬥 뢠 ਠ ࠭ ⠭⭮ 0x50: + +| Bank byte | Effect | +|---|---| +| 0x50 | Normal write ? shadow + | +| 0x54 | "no copy in main shadow RAM" | +| 0x58 | **"FF is transparent"** ? 0xFF write ⠢ background | +| 0x5C | both | + +Bank 0x58 祬 mouse cursor 0xFF-஧筮. + **sprite-blending १ accel block copy**: + +- [ ] **`gfx_set_bank_transparent(on)`** 䫠 `gfx_set_bank` + 롮 0x50/0x58 ᮢ sprite' +- [ ] ᯮ짮 `gfx_blit()` ⮡ 䠪 + transparent sprites १ accel- + +### Block copy mode (sprite blit') + +`LD L,L` (horizontal) `LD A,A` (vertical) ? ० ஢ १ +256- accel memory. blit'. + +- [ ] **`gfx_blit(src_data, x, y, w, h)`** ? ஢ sprite' + (ந ࠧ, १ accel) +- [ ] **`gfx_blit_transparent(src, x, y, w, h)`** ? ᯮ짮 bank 0x58 + +. `Draw_Restangle_Data` accelerator_doc.txt ७. + +### AND / OR / XOR operations १ accel + +㬥 뢠 accel ন ᪨ 樨 +. ਬ: +- XOR ? (뤥 selection UI) +- OR / AND ? masking, alpha-style blending +- . ਬ accelerator_doc.txt: "256 bytes block coding via XOR" + +- [ ] **`gfx_xor_rect`** / **`gfx_or_rect`** / **`gfx_and_rect`** ? + ਬ⨢ ᪨ 権 אַ㣮쭨 +- [ ] **`gfx_invert_rect(x, y, w, h)`** ? alias xor 0xFF + +### Bitmap fonts ࠧ ࠧ஢ + + `gfx_text` / `gfx_putchar` प ࠡ 8?8 ⮬ +(BIOS WIN_GET_ZG 頥 256?8 ). UI / 쭨 +㦭: +- [ ] **`gfx_set_font_size(w, h)`** ? ४ ਭ/ glyph' +- [ ] **`gfx_set_font_data(ptr, w, h, advance)`** ? 㪠⥫ + 짮⥫᪨ + ࠧ +- [ ] প **proportional** (advance != w) ⮢ ? + array advance[256] ਭ glyph' +- [ ] **Big-font ०**: 8?16, 16?16, 16?8 ( 쭨) +- [ ] ⤥ API `gfx_text_ex(x, y, str, font_id)` + font_id 롨ࠥ 㦥 ⮢ +- [ ] **Anti-alias 2-bit ** ( 䮭 / ࠭ / 2- alpha?) + ? far future, smooth UI + +## ⠯ ⨬権 ( ᥩ) + +- **`gfx_line` १ accel ** ? Bresenham |dy| << |dx| ( ) 뤠 runs Y ( X): ᥫ, ᥫ, ᥫ, 蠣 Y, ᥫ, ᥫ... ⠪ run ? ⮢ 㬥 `gfx_hline` ( `vline`). + ᫥: runs 㭪 ; run length, ஬ 룮 accel hline 祬 N?putpixel (overhead accel ~20?s, putpixel ~5?s ? accel 룮 run ? 4-5 px); (dx ? dy) ⠢ Bresenham, ? run-length-based fill. + `gfx_line` orthogonal cases 㦥 १ accel ? ⨬஢ ⮫쪮 . + +- **`gfx_fill_rect` W3-swap ** ? ᥩ ७ `gfx_hline`/`gfx_vline` ᢮ DI/save-W3/restore-W3/EI. ᤥ internal `_fill_rect_inner` ন W3 DI 横; ~20?s ? ⢮ ப/⮫殢 . ਬ ᥬ ਬ⨢. +# MDView ? ᬮ騪 Markdown Sprinter + +**MDView** ? ணࠬ ᬮ 㬥⮢ ଠ *Markdown* +Sprinter ( Z80). 㬥 ࠭ ⤥쭮 W3 +᭮ RAM ணࠬ. + +## + +- 㬥 **128 ** (8 ࠭ EMM 16 ) +- **16 384** ࠭ ப +- ⮬᪨ ७ ᫮ ਭ ࠭ (80 ⮫殢) +- ਧ⠫ ᤢ ப ப ( , ⠡) +- -: 䠩, ப, 業 ப⪨ +- ப ﭨ ६ 㧪 樨 +- প ?? ᪫ ப + +## + +``` +mdview [_䠩.md] +``` + +᫨ 䠩 , 㦠 `README.MD`. + +## ࠢ + +``` + ⢨ + +Up Down ப⪠ ப / +PgUp PgDn ப⪠ ࠭ (30 ப) +Home 砫 㬥 +End 㬥 +Left Right ਧ⠫ ᤢ (⮫쪮 nowrap-ப) +F1 ࠢ +F8 ஢: CP866 ? CP1251 ? KOI8-R ? UTF-8 ? ... +F10 / Esc 室 ணࠬ +``` + +஢ । ⮬᪨ ⨨ (BOM + ⨪ + 4 ); `F8` ४砥 , ᫨ ⥪ 訡. +8- ஢ (CP866/CP1251/KOI8-R) ४ (६ +ᮢ). ன / (ਬ UTF-8) ந ? +ࢮ ४祭 (⪠ 㧠 ᯨ஬), . + +## ⠪ Markdown + +### + +ন ஢ H1?H4. ஢ H5 H6 ⮡ࠦ H4. + + # ࢮ ஢ + ## ண ஢ + ### 쥣 ஢ + #### ⮣ ஢ + +### ⮢ ଠ஢ + +** ⥪** 뤥 묨 񧤮窠: `**⥪**` + +*ᨢ* 뤥 묨 񧤮窠 `*⥪*` ન `_⥪_` + +`஥ ` 砥 묨 窠 + +~~ભ ⥪~~ ? ⨫: `~~⥪~~` + +### 㬥஢ ᯨ᮪ + +થ `-`, `*` `+`: + +- 㭪 ᯨ᪠ +- ன 㭪 ᯨ᪠ +- ⨩ 㭪 筮 ⥪⮬, 室 + 㤥 ७ ᫥ ப ࠭ 㯠 + +### 㬥஢ ᯨ᮪ + +1. +2. ன +3. ⨩ + +### + +> 稭 ᨬ `>`. ᪮쪮 ᫥⥫ +> ப ᪫ ⮬᪨ +> ७ᮬ ᫮. + +### (verbatim) + + 砥 ன 窨. +⥪ ⮡ࠦ ? ? ࠧ Markdown: + +``` +#include +#include + +int main(void) { + puts("Hello, Sprinter!"); + return 0; +} +``` + +### ਧ⠫쭠 + + ᨬ `---`, `***` `___` ⤥쭮 ப: + +--- + +## 孨᪨ ࠪ⨪ + +- **ଠ:** Sprinter, Z80 @ 21 +- **஢:** CP866 / CP1251 / KOI8-R / UTF-8 (⮮।, `F8`) +- **ᨬ ࠧ 䠩:** 128 +- **ᨬ쭮 ᫮ ப :** 16 384 +- **ᨬ쭠 ப ७-:** 255 祥 (. ࠭祭 ) +- ** :** small + - ணࠬ, c⥪, , ? a W1-W2 (32 , 0x4000?0xBFFF). + - 䠩 ? ࠭ EMM, ⮡ࠦ W3 (0xC000?0xFFFF) + +## ࠭祭 + +### ப MD-० ? 255 祥 + +- ࠭ ப ** 255 (ᨬ, ਡ)** +? ⠭ `MAX_CACHE_LINE_LEN`. ⨯: `g_ncells` +`cache_rec_t.len` ? `uint8_t`. ᠥ ப, ⭥ ᥣ +**ਧ⠫쭮 ஫㥬** ப ( ப ⠡, 䫠 +`IF_HSCROLL`), MD-० ࠢ. + +** ந室 ப:** 樨 `gc_put()` +뢠 祩 ᫥ 255- (`if (g_ncells < MAX_CACHE_LINE_LEN)`). + ⮫쪮 255 祥, ⮪ **** ? +஫ ** થ १** 255- 樨 (થ `>` 砥 +? । ?). ९ ? `gc_put` ஢ ࠭. + +: ?255 祥? ? **७७ ਭ**, 室. + ࠧ稢 ஡ ( `TAB_STOP`), 祩 ⠡ +஡ ਭ + ࠬ `` ? ⮬ ⨣ ࠭, 祬 +255 ?? ᨬ. + +> **RAW-० (`F2`) ⮣ ** ? אַ 䠩 +> ⮢, ப 楫 (१ wrap `F3` ਧ. ஫). + +** ** (業, ॠ) ? `uint16_t`: +- `cache_rec_t.len` `uint8_t?uint16_t` ? **஢ 8 ** + (len ꥤ pad-), `idx<<3` . ᯫ⭮. +- `g_ncells` / `g_ncells_at_space` ? `uint16_t` ? 業 **/᪮**: + 16-⭠ 䬥⨪ Z80 祬 `gc_put` (맮 祩) + scan-横. ਥ: **+0.2?0.4 ** + 樨. +- `g_cells[MAX_CACHE_LINE_LEN*2]` near-RAM (W2) ? 業 + ****: `2 ? ` . 510 ; 512 ? +0.5 , 1024 ? +1.5 . + EMM- ⥭ (1 ) ப ﭥ ? 㧪 near. +- `viewport_x` ( `docset_t`) + ⮫ `max_vx` (ᥩ 248) ? `uint16_t`, + ࠭ >255 , ஫ . `widths[]`/`ccx` ⠡/. + + ஬ ? 512?1023: 墠 ᥬ ⨭/⠡栬, + 業 ~+0.3 +0.5?1.5 near-RAM. ** 㬥 `uint16_t`** ? + ⠢ થ १ 255- 樨, ⮡ 뫠 . + +## TODO + +1. **祭 ࠧ 㬥⮢.** 128 : 筮 + ࠧ ࠡ 訬 - ࠭ , ஢ + ࠡ 8- ࠭栬 16. + +: ଠ஢ ⠡ ࠬ; প ஢ +CP866 / CP1251 / KOI8-R / UTF-8 ⮮। ४祭 `F8` +(ன ந , ࢮ ४祭). + +4. **᪮७ ७ਭ.** ப ࠭. ⨬ 横 뢮 + ᨬ १ BIOS WRCHAR ( 뢮, DMA). + +--- + +*MDView v0.2 (c) 2026 ஢ ..* + + +--- + +# Sprinter C Compiler ? v1.0 + +C toolchain for **Sprinter** ? the Z80-based home computer by Peters Plus, running +ESTEX DSS. Host: macOS / Linux. Target: `.EXE` files in SprintEXE format. + +Built on top of **SDCC 4.5** (vendored in `third_party/sdcc/`). This repository adds +everything Sprinter-specific: crt0, linker integration, libc wrappers over ESTEX, +banked-call trampolines, graphics & accelerator API, mouse driver wrappers, and the +`mkexe` utility for producing SprintEXE images. + +## What you get + +* **`bin/sprinter-cc`** ? one-line driver: `sprinter-cc -o foo.exe foo.c` +* **Memory modes**: `tiny`, `small`, `big`, `huge`, `manual` ? see below. +* **stdio + conio**: printf, puts, putchar, getchar, fopen/fread/..., cprintf, cputs, putch, textcolor/textbackground/textattr, gotoxy, kbhit/getch. +* **Graphics**: 320?256?256 and 640?256?16 modes, accelerator-backed primitives (hline / vline / rect / fill_rect / line via Bresenham, plus clear), bitmap-font text in both modes via BIOS character generator. +* **File I/O**: POSIX (`open`/`read`/`write`/`close`/`lseek`/`unlink`/`creat`), FILE\* streams (`fopen`/`fgets`/`fwrite`/...), directory listing (`ffirst`/`fnext`), `chdir`/`getcwd`/`mkdir`/`rmdir`, `stat`/`fstat`. +* **Memory**: 32 KB heap (W2-resident), banking-aware page allocator (`mem_alloc_pages`/`bank_read`/`bank_write`), explicit memory modes for sub-16 KB programs. +* **Mouse**: full Sprinter driver wrapper (14 functions including custom cursor bitmaps). +* **Environment**: `getenv`/`putenv`/`sysenv` over ESTEX `$46`. +* **Time**: `getdatetime`/`setdatetime` + POSIX `time`/`localtime`/`mktime`/`asctime`/`ctime`. +* **Misc**: `errno`/`strerror`/`perror`, `atexit`, `setjmp`/`longjmp`, `sleep`, full argv parsing in crt0. + +## Quick start + +```sh +git clone sprinter-c +cd sprinter-c +make sdcc # one-time: fetch SDCC 4.5 binary (~25 MB) +make all # build mkexe + libsprinter.lib + 27 examples +make floppy # pack everything into mame/v306/IMG/mc.img +cd mame/v306 && ./run_mame.sh # boot Sprinter in MAME +``` + +Compile a single program: + +```sh +cat > hello.c < +int main(void) { puts("Hello, Sprinter!"); return 0; } +EOF + +bin/sprinter-cc -o hello.exe hello.c +``` + +That's it ? `hello.exe` is now a valid SprintEXE you can `RUN HELLO` from the ESTEX shell. + +## Memory modes + +Sprinter's address space is four 16 KB windows (W0 / W1 / W2 / W3). DSS allocates +pages by program size ? small programs get only one page. Pick a memory mode based +on what your program needs: + +| Mode | Code lives in | Banking | Use when | Note | +|---|---|---|---|---| +| `tiny` (default) | W2 (0x8100+) | no | code+data < 14 KB | | +| `small` | W1-W2 (0x4100+) | no | code+data < 30 KB | | +| `big` | W2 + W1 banking | yes (W1) | tiny + extra code modules | | +| `huge` | W1-W2 + W3 banking | yes (W3) | small + extra code modules | | +| `manual` | user-specified | optional | special layouts | Not implemented | + +```sh +sprinter-cc --memory small -o big.exe bigprog.c +sprinter-cc --memory huge -o app.exe main.c --bank 1=engine.c --bank 2=ai.c +``` + +Banked functions are declared with `__banked`: + +```c +void engine_tick(int dt) __banked; // lives in BANK1, automatically swapped +``` + +## Examples (27 total) + +| Example | What it demonstrates | +|---|---| +| `hello` | Hello world with stdio + conio Turbo-C-style colors | +| `argv` | argv parsing in crt0 | +| `cat` | File I/O ? read & print TEST.TXT | +| `seek` | 32-bit lseek over a 100 KB file | +| `ls` | Directory listing via ffirst/fnext | +| `filetest` | FILE\* streams (fopen/fread/...) | +| `stattest` | `stat`/`fstat` on files and directories | +| `errno` | errno / strerror / perror | +| `mem_test` | Page allocator + bank\_read/bank\_write | +| `malloc` | Heap stress test (200+ allocations) | +| `banked` | Banked code in W3 (huge mode) | +| `bankedbg` | Banked code in W1 (big mode) | +| `banklocl` | Bank-local static data and BSS | +| `mouse` | Mouse driver in text mode | +| `gfx_mous` | Mouse with custom bitmap cursor in graphics mode | +| `gfx_demo` | 320?256?256 lines / rects / accelerator | +| `gfx_d16` | 640?256?16 same primitives | +| `gfx_text` | Bitmap-font text on graphics screen | +| `timedir` | Date/time + directory listing | +| `ptime` | POSIX time API | +| `openenv` | open() flags + environment vars | +| `conio` | conio API smoke test | +| `attrprob` | Probe Sprinter text attribute byte layout | +| `strtest` | string.h test (from SDCC's z80.lib) | +| `stdlib` | stdlib.h test (qsort / rand / strtol / etc.) | +| `assrtest` | assert() | +| `rt_test` | Runtime helpers (sleep, setjmp, atexit) | + +## Headers + +Standard: +* `` ? puts / printf / FILE\* + Sprinter-specific dec/hex helpers +* `` ? atoi / atof / malloc / qsort / ... (from SDCC z80.lib) +* `` / `` / `` ? from SDCC z80.lib +* `` ? read / write / close / lseek / unlink +* `` ? open / creat + O\_RDONLY / O\_CREAT / ... +* `` ? errno + error names + strerror +* `` ? stat / fstat +* `` / `` ? from SDCC + +Sprinter-specific: +* `` ? putch / cputs / cprintf, textcolor / textbackground / textattr, kbhit / getch, clrscr, gotoxy, wherex/y +* `` ? gfx_init/done, palette, putpixel, hline/vline/rect/fill_rect/line, text ? for both 320 and 640 modes (gfx_\*16 variants) +* `` ? full 14-function driver wrapper + mouse_cursor_t with bitmap support +* `` ? chdir / getcwd / mkdir / rmdir / ffirst / fnext / ffblk +* `` ? getdatetime / setdatetime + POSIX time / localtime / etc. +* `` ? raw ports, ESTEX/BIOS function numbers, env API +* `` ? exit / \_exit / atexit +* `` ? mem\_alloc\_pages / mem\_free\_block / bank\_read / bank\_write +* `` ? Solid-C compatibility layer (aliases + BOOL/WORD/uint types) + +## Toolchain commands + +```sh +make all # build mkexe + lib + every example +make floppy # repack mame/v306/IMG/mc.img with all .exe files +make check # 17 mkexe unit-tests +make clean # remove all build artefacts +make sdcc # one-time: fetch SDCC 4.5 binary +``` + +### sprinter-cc options + +``` +sprinter-cc -o foo.exe foo.c [more.c ...] [options] + + --memory MODE tiny | small | big | huge | manual (default: tiny) + --memory-manual SPEC explicit placement (CODE=W1|W2,DATA=W1|W2|SAME,BANKED=W1|W3) + --stack-size N bytes reserved for the stack (default ~1278) + --crt0=TYPE default | minimal | banked | small + --bank N=FILE.c compile FILE.c into bank N (repeatable, max 15) + --debug enable runtime diagnostics (defines DEBUG_RT) + -I PATH extra include path + -L 0xADDR / -E / -S override load / entry / stack addresses + -Wl FLAG pass FLAG to sdldz80 + --mkexe FLAG pass FLAG to mkexe (e.g. --mkexe -p --mkexe 0 for bank padding) + -v verbose +``` + +## Status + +What works in v1.0: +* Compile / link / pack to SprintEXE ? verified on all 27 examples +* Four memory modes (tiny / small / big / huge) +* Graphics (both modes) with accelerator +* Mouse (text + graphics cursor) +* File I/O, directories, environment, time +* All headers listed above + +Deferred to v2.0 (see `docs/TODO.md`): +* **Turbo-C-style BGI graphics API** ? `initgraph` / `setcolor` / `circle` / + `getimage` / `putimage` / etc. on top of our `gfx_*` primitives +* Remaining Solid-C compatibility gaps (Phase 2/3) ? see `docs/solid_c_compatibility.md` +* Manual memory mode +* Rewrite FILE\* stream API (current implementation is very primitive and doesn't use buffers) + +Deferred to v3.0: +* **IM2 interrupt handlers** ? research complete (`docs/im2_isr_design.md`), + implementation scheduled for v3 +* **Audio API** (AY-3-8910 + COVOX) ? requires IM2 +* **ISA-8 slot drivers** ? requires IM2 (???) + +## Documentation + +* `docs/TODO.md` ? roadmap and open work items +* `docs/solid_c_compatibility.md` ? gap analysis vs Solid-C 2004 +* `docs/im2_isr_design.md` ? interrupt handler design (v2) +* `docs/converted/` ? source documentation (ESTEX, BIOS, architecture) + converted to plain text for `grep` +* `docs/reference/`, `docs/samples/`, `docs/memory management/` ? original + Russian docs and code samples from Peters Plus + +## Repository layout + +``` +bin/sprinter-cc one-line compiler driver (bash) +toolchain/mkexe/ host-side tool: .ihx -> .exe SprintEXE +toolchain/check_banks.py post-link bank size enforcer +runtime/ crt0 variants (default, minimal, small, banked) + bank trampolines, heap, heap_top +libc/include/ headers +libc/io|stdio|mem|gfx/ C and asm sources for libsprinter.lib +lib/ Makefile that archives libsprinter.lib via sdar +examples/ 27 example programs +mame/v306/ MAME binary + Sprinter ROM/HDD images + floppy script +third_party/sdcc/ vendored SDCC 4.5 (fetched via `make sdcc`) +third_party/solid-c/ reference: original Sprinter native C (for compat target) +docs/ documentation +``` + +## License + +This repository contains: +* Original code in `bin/`, `toolchain/`, `runtime/`, `libc/`, `lib/`, `examples/` ? + MIT-licensed. +* `third_party/sdcc/` ? SDCC 4.5 under GPLv2 with linking exception + (see `third_party/sdcc/COPYING.txt`) +* `third_party/solid-c/` ? original Sprinter Solid C, used only as a reference + +## Credits + +* **Sprinter / Peters Plus** ? , ਩ ਭ and the original team +* **SDCC** ? for the underlying Z80 compiler +* **MAME** ? for the Sprinter Sp2000 emulation + +--- + +For questions / patches: see CONTRIBUTING.md (TBD) or open an issue. + +--- + +# TODO / Roadmap + + 浪 뢠 ਮ.  ॠ ணࠬ ? ਮ ᬥ. + +## ⠯ 5 ? malloc / free + banking-aware page allocator ? + +- [x] SDCC's `malloc`/`free` + `runtime/heap.s` ( library heap.rel, 14000- heap 2) +- [x] `libc/mem/mem_alloc.c` ? page allocator: `mem_alloc_pages`/`mem_free_block`/`mem_get_page`/`mem_info` १ ESTEX `$3C/$3D/$3E` + BIOS `$C4` +- [x] `libc/mem/bank_io.c` ? HOME-१ `bank_read`/`bank_write`/`bank_load_byte`/`bank_store_byte` ᢮ W3 +- [x] `examples/malloc_test/` ? ஢ઠ SDCC's malloc (~210 64- allocations १ heap) +- [x] `examples/mem_test/` ? ஢ઠ page allocator: 3 ࠭, ࠧ १ bank_write, 䨪 १ bank_read + +## ⠯ 6 ? argv parsing + sprinter-cc wrapper ? + +- [x] crt0 ESTEX command-line IX-prefix (inline asm `runtime/crt0.s`) +- [x] Strip leading CP/M-style space (DSS quirk) +- [x] । `argc`/`argv` main() १ HL/DE (SDCC __sdcccall(1) ABI) +- [x] argv[0] = basename .EXE १ ESTEX APPINFO ($47 subfn 2) +- [x] `runtime/crt0_minimal.s` ? opt-out 祭 쪨 ணࠬ +- [x] `runtime/crt0_banked.s` ? ⥯ ⮦ argv (parse_argv + get_progname ᪮஢ crt0.s; 㤥 factored argv.s libsprinter.lib) +- [x] Bash-⪠ `bin/sprinter-cc`: `sprinter-cc -o foo.exe foo.c` ப +- [x] প 権: `--memory`, `--memory-manual`, `--stack-size`, `--crt0=`, `--bank N=FILE.c`, `--debug`, `-I`, `-L`/`-E`/`-S`, `-Wl`, `--mkexe` + +## ⠯ 8 ? 䨪 (320?256?256 + 640?256?16 + accel + bitmap font) ? + +- [x] **8a** Graphics core: `gfx_init`/`gfx_done`/`gfx_clear`/`gfx_putpixel`/`gfx_pal_load`/`gfx_pal_set` (libc/gfx/gfx_core.c). १ BIOS PIC_SET_PAL ($A4). Verified 320?256?256. +- [x] **8b** /אַ㣮쭨/fill १ accelerator (libc/gfx/gfx_lines.c): `gfx_hline`/`gfx_vline` १ accel Fill (LD C,C / LD E,E + SMC block-size), `gfx_rect`/`gfx_fill_rect` heuristic 롮஬ ਥ樨 (h/v bursts count), `gfx_line` Bresenham . `gfx_clear` ⮦ ९ᠭ column-major accel (~4? ॥). +- [x] **8c** 640?256?16 mode (libc/gfx/gfx_16.c): `gfx_*16` API, HIGH nibble = LEFT pixel (㬥 misleading), per-row RMW vline ( = 2 ਧ⠫ ᥫ). +- [x] **8d** Bitmap font + gfx_text (libc/gfx/gfx_text.c): १ BIOS WIN_GET_ZG ($B8), interleaved layout `font[row*256+char]`, `gfx_text`/`gfx_putchar` 320 mode, `gfx_text16`/`gfx_putchar16` 640 mode pair-table lookup. + +. memory/sprinter_graphics.md, sprinter_accelerator.md, sprinter_graphics_16.md, sprinter_font_format.md. + + ( ): +- [ ] -quad 640: per-cell (mode 0x82 ࠧ蠥 1 4 per 16?8 cell) ? १ אַ area-ᠭ ࠭ 0x0300..0x039F + +## Auto-banking (. `memory/banking_roadmap.md` ⠫) + +Phase 1 ? file-level bin-packing ? ॠ뢠 ஥ ~30 KB . + +- [ ] `toolchain/auto_bank.py`: + - ࠧ `.rel`-䠩 ( .map ᫥ dry-run link') + - First-fit-decreasing bin-packing + - `#pragma codeseg BANKn` manual override + - ५뢠 묨 `-Wl-b_BANKn=...` ࠬࠬ + - ⠥ । + +Phase 2-5: incremental rebalance, declarative `banks.toml`, function-level, call-graph-aware. 쪮 ᫨/ . + +## Bank-local static data (mutable data ⮬ ) ? ? + +- [x] ਬ `examples/bank_local_data/` ? 㭪 BANK1 ᢮ writable BSS array + const table + malloc- +- [x] `mkexe -p 0` 㫥 padding (BSS-storage 㧪) +- [x] ᪨ 楯: `--codeseg BANK1 --constseg BANK1 --dataseg BANK1` bank1.c + `-Wl-b_BANK1=0x1C000` . **`--dataseg BANK1` ** ? ࠭ ⭮ - trampoline bug ᪨஢ १. +- [x] ** 䨪 trampoline'a runtime/bank.s** ? `pop af; out (n), a` ਫ A ? banked-㭪樨 騥 uint8_t 頫 . `pop bc; out (c), b` ࠭ A. +- [x] **malloc banked-㭪樨 ࠡ⠥ ஧筮** ? heap W2 (HOME), W2 ᢠ trampoline', pointer  ⥪. . memory/bank_local_data_pattern.md. +- [x] 㬥 memory: `memory/bank_local_data_pattern.md` ( 楯 + malloc + nuances), `memory/sdcc_banking.md` (trampoline fix) +- [ ] 樮쭮 ? `check_banks.py` ⮡ 뢠 ࠧ size = code + const + bss per bank (cosmetic) + +祬: 㫥 訬 private state (level loader, audio engine, scene data). W2 heap , ⨪ . + +## ᪠ solid-c (⨢ Sprinter C ? `third_party/solid-c/`) + +᫥ solid-c'᪮ libc (. `memory/solid_c_findings.md`)  ⮢ ᫥ 㭪権. ਮ **᮪** : + +### High-priority gaps ( ஢, 짠) +- [x] **`errno` + `strerror`/`perror`** ? ⠡窠 32 訡 (libc/io/errno.c) +- [x] **७ `open()`** O_CREAT/O_TRUNC/O_APPEND/O_EXCL state machine +- [x] **`atexit`** ? 8-callback LIFO + `exit()` + `_exit()` (libc/io/atexit.c) +- [x] **`setjmp`/`longjmp`** ? 6- jmp_buf={sp,ix,pc} (libc/io/setjmp.c) +- [x] **`sleep(seconds)`** ? 50Hz halt-loop (libc/io/sleep.c) +- [x] **ESTEX ENV API** ($46, getenv/putenv) ? libc/io/env.c. 竨 doc-bug: ॠ쭮 A=0 NOT FOUND + +### Medium-priority (㦭 shell-like ⨫) +- [ ] **Mouse driver** ? `rst $30h`, 17 㭪権. **砫 ࠡ⠥ MAME**. +- [x] **`ffirst`/`fnext` + ffblk_t struct** directory listing ? ॠ, demo: ls.exe +- [x] **`getdatetime`/`setdatetime`** १ ESTEX $21/$22 ? libc/io/time.c, demo: time_dir_test +- [x] **`chdir`/`getcwd`/`mkdir`/`rmdir`** ? wrappers ESTEX $1B-$1E ? libc/io/fsdir.c +- [x] **conio: `kbhit`/`getch`/`getche`/`cputs`/`clrscr`/`gotoxy`** ? ॠ +- [x] **conio extras**: `wherex`/`wherey` ($53), `wrchar`/`rdchar` ($58/$57), `textmode_get/set` ($50/$51), `clrscr_attr` ($56) + COLOR macros + +### Low-priority ? ? FILE* stack + +- [x] ** unbuffered FILE\*** ? `libc/stdio/file.c` + `libc/include/stdio.h`. fopen/fclose/fputs/fgets/fread/fwrite/fseek/ftell/rewind/feof/ferror/clearerr/fflush + stdin/stdout/stderr pseudo-streams. . `memory/file_star_design.md` `examples/filetest`. +- [ ] fprintf / fscanf ? 㦭 printf-१-callback machinery. 짮⥫ `sprintf(buf, ...) + fputs(buf, fp)`. +- [ ] 樮 buffered mode (setvbuf, line/block buffering) ? ᫨ - . + +### POSIX time API ? ? +- [x] `libc/io/posix_time.c` ? time/localtime/gmtime/mktime/asctime/ctime getdatetime. SDCC's time.rel ( override _RtcRead). . `examples/ptime`. + +### sys/stat ? ? +- [x] `libc/io/stat.c` ? POSIX stat/fstat. ਤ open+fstat 䠩, ffirst+iter ( "."/".."). . `examples/stattest` `memory/estex_ffirst_dotdot.md`. + +### assert ? ? (ᯮ㥬 SDCC's __assert १ fallback include path) + +## libc/stdlib ? ? 㦭 (. memory/sdcc_stdlib_works.md) + +஢७ १ `examples/stdlib_test/`: SDCC z80.lib ᮤন ࠡ騥 ॠ樨: +- `atoi/atol/atof, strtol/strtoul, rand/srand, qsort/bsearch, abs/labs, div/ldiv` +- `` (memchr/cmp/set/cpy, strcat/cmp/cpy/len/chr/spn/etc.) +- `` (toupper/tolower) +- `` (sinf/cosf/sqrtf/etc.) + + ⮬᪨ ﭥ z80.lib 㦭. ** ९뢠**. + + Sprinter-specific 易⥫ 㫨 : atexit, env, errno, setjmp, putchar/puts/getchar, conio, fsdir, time, mouse, open/read/lseek/close. + +## Build-system: libsprinter.lib + sprinter-cc ? ? + +- [x] `lib/Makefile` ? ᮡࠥ libc/*.c `.rel`, 娢 १ sdar `lib/sprinter.lib` +- [x] 砥 runtime/bank.s runtime/heap.s (auto-pulled __banked/malloc) +- [x] `bin/sprinter-cc` ? bash-wrapper: `sprinter-cc -o foo.exe foo.c` ப +- [x] প 権 `--crt0=default|minimal|banked`, `--bank N=FILE.c`, `-I`, `-L`/`-E`/`-S`, `-Wl`, `--mkexe` +- [x] `examples/hello_sccc/` ? : `hello.c` ᮡࠥ shell-맮, ࠧ ᮢ Makefile (925 ) +- [x] Split `putchar.c` ? `putchar.c` + `puts.c` per-function granularity (puts override SDCC's z80.lib version) +- [x] `make all` (ᨬ `lib` । `examples`) + + 襭 (樮쭮): +- [ ] ஢ ⠫ examples sprinter-cc Makefile (ᬥ⨪) +- [ ] 쭥 libc/*.c per-function ( ⥪ granularity 㦥 㦭 ࠧ ? .rel 楫, 設⢠ 䠩 㭪) + +## ⠯ 9 ? memory modes sprinter-cc + +DSS 뤥 ࠭ ࠧ ਫ: < 16 KB ? ࠭, ⠫ 砥 ?࠭ #FF? (read=0xFF, write ). - ⮣ CODE--W1 + DATA--W2 쪮 ணࠬ . . [memory/sprinter_memory_modes.md](../../.claude/projects/-Volumes-SAM8-Projects-DIY-Z80-Sprinter-C-Compiler/memory/sprinter_memory_modes.md). + +- [x] **`tiny`**: (CODE+DATA+⥪) W2. Default. Verified hello/argv/conio/malloc/file/etc. +- [x] **`--memory MODE` 䫠 sprinter-cc**: parser + per-mode 䮫 CODE_LOC/DATA_LOC, override १  `--code-loc`/`--data-loc`. tiny ࠡ⠥; small/big/huge warning' (runtime ⮢). 2026-05-30. +- [x] **`--memory-manual SPEC`**: `CODE=W1|W2,DATA=W1|W2|SAME,BANKED=W1|W3`. 2026-05-30. +- [x] **`small` runtime**: `runtime/crt0_small.s` ᯮ ESTEX `$3D GETMEM` + `$3A SETWIN2` ⮡ 뤥 W2-࠭ gsinit. **** BIOS `$C4` ? ⥪ ⮬ ⠯ W1 (boot_stack HOME), BIOS ॡ ⥪ W2. ᫥ SP ४砥 0xBFFE, ⠭ flow. 2026-05-30, verified hello.exe. +- [x] **`small` auto-detect >16 KB ணࠬ**: `crt0_small.s` ⠥ `0xC2` (⥪ ࠭ W2 ? `0xA2`! W1). ᫨ 0xFF ? 뤥 page; DSS 㦥 ᤥ (ணࠬ ᠬ 뫥 W2). crt0 뢠 0..30 KB. mkexe ⠪ ࠧ蠥 HOME span W1+W2 (0x4000..0xBFFF). Verified hello: small (5 KB 䠩, SETWIN2 path) + 32 KB 䠩 (auto-skip). 2026-05-30. +- [x] **`big` runtime** (tiny + banked code W1): ࠬਧ `crt0_banked.s` + `bank.s` १ `.ifdef BANK_W1` ? 㣮 banking port (0xA2 vs 0xE2), 㣮 load-addr (0x4000 vs 0xC000). sprinter-cc prepend' `BANK_W1 = 1` `--memory big`, । `mkexe -B 0x4000`. ਬ `examples/banked_big/`. 2026-05-30. +- [x] **`huge` runtime** (small + banked code W3): merge W2-detect `crt0_small.s` `crt0_banked.s`. 騩 ਬ `examples/banked/` ⥯ ᯮ MEMORY=huge. 2026-05-30. +- [x] **`--debug` 䫠**: prepend `DEBUG_RT = 1` crt0 + `-DDEBUG_RT` sdcc. 뢠 symbol `_w2_self_allocated` (uint8_t) ? runtime diagnostic ஢ W2. 2026-05-30. + +### -襭 libc crt0 + +** `sprinter.lib`** ࠡ⠥ memory mode ? `.rel`-童 relocatable, SDLD dead-code elimination per-member ( 䨪  `gfx_core.rel` ..). Verified hello vs malloc_test १ map-䠩. + +**`gfx.lib` ⤥쭮 ? 㦥**: dead-code elimination 㦥 ࠡ⠥. + +**`libc_banked` (libc bank HOME)** ? ⮬, HOME (16 KB) user- + libc `huge` mode. १ `--codeseg BANK0` 樨 libc; trade-off: trampoline ~30 横 libc-맮. ਣ: ॠ쭠 ணࠬ HOME budget. + +**HW-ᨬ 㫨 ? `sprinter_home.lib` ⤥쭮.** libc 䨧᪨ W3, ⮬ W3: +- `gfx_*` ? `0xC000+` ᫥ swap W3 video page +- `bank_io` (mem_alloc_pages/bank_read/bank_write) ? swap' W3 १ `OUT (0xE2)` +- 騥 ISR ? 뢠 ਩ W3 㣮 + + huge mode 㫨 HOME (W1). 㤥 `libc_banked`, **६** 뤥塞 `sprinter_home.lib` (HOME-only) `sprinter.lib` (bankable). 쭠 奬: +``` +sprinter_home.lib HOME-only: gfx, bank_io, ISR shims +sprinter.lib bankable: printf, malloc, string, conio, stdio, env, ... +sprinter_banked.lib sprinter.lib --codeseg BANK0 ( huge) +``` +ਣ: ॠ `--memory huge` runtime. + +**crt0 ? mode:** +- `crt0.s` ? ⥪騩, **tiny/big**: SP=0xBFFE, argv (W2- 㦥 뤥 DSS). +- `crt0_minimal.s` ? ⥪騩, tiny argv. +- `crt0_small.s` ? **, step 3**: **small/huge**, W2 १ `mem_alloc_pages` gsinit, `0xA2`, ⮬ ⠭ flow. +- `crt0_banked.s` ? ⥪騩, **big**: trampoline-⠡ W3 , CODE W2. +- `crt0_banked_small.s` ? ****: huge = small (W2-alloc) + banked (W3 trampolines). + +sprinter-cc ࠥ crt0 `--memory` mode (ᥩ `--crt0=` override). +- [x] **ࠨ ࠧ ⥪**: 䫠 `sprinter-cc --stack-size BYTES`. Wrapper `heap_top.s` `___sdcc_heap_end = stack_top + 1 - stack_size`, ⤥ .rel per-program. Default ?1278 (heap_top=0xBB00) `runtime/heap_top.s`. 2026-05-30. + +䥩: `sprinter-cc --memory [tiny|small|big|huge|manual] [--memory-manual SPEC] [--stack-size N] foo.c`. `--memory-manual` ⮫쪮 `--memory manual`. + +## Known issues / quirks + +- **ESTEX $46 ENV API**: ? ࠡ⠥. - `DiskSyscalls.txt v1.6` 訡筮 뢠 return-status ? A=0 NOT FOUND, FOUND. 䨪஢ `memory/sprinter_platform.md`. + +## V2 (᫥ ५ v1) + +### Turbo-C-style graphics API (BGI-like) ? **MUST v2** + + `gfx_*` API ஢ **Turbo-C ``** (BGI) MS-DOS. +ணࠬ ਢ訥 Turbo-C ७ ᪨ 1--1. + +** ** ( ᭮ Borland BGI): + +Setup/teardown: +- `initgraph()` / `closegraph()` ? ᥩ `gfx_init`/`gfx_done`, alias +- `getmaxx()` / `getmaxy()` ? GFX_WIDTH-1 / GFX_HEIGHT-1 +- `cleardevice()` ? alias to gfx_clear +- `getgraphmode()` / `setgraphmode()` ? get_videomode/set_videomode + +Color/palette: +- `setcolor(c)`, `getcolor()` ? current draw color +- `setbkcolor(c)`, `getbkcolor()` ? background color +- `setpalette(idx, c)` ? entry +- `getpalette(&info)` ? read all palette + +Primitives ( 㦥 ? BGI- aliases): +- `putpixel(x, y, c)` ? gfx_putpixel +- `getpixel(x, y)` ? 㦭 ॠ (RMW ⭮ ? IN) +- `moveto(x, y)`, `lineto(x, y)`, `linerel(dx, dy)` ? current point + line drawing +- `line(x1, y1, x2, y2)` ? gfx_line +- `rectangle(x1, y1, x2, y2)` ? gfx_rect ( 㣮 API: x1,y1,x2,y2 vs x,y,w,h!) +- `bar(x1, y1, x2, y2)` ? gfx_fill_rect +- `bar3d(x1, y1, x2, y2, depth, topflag)` ? : rect + 3d edges +- `circle(x, y, r)`, `arc(...)`, `ellipse(...)`, `pieslice(...)` ? primitives +- `fillpoly()`, `drawpoly()` ? +- `floodfill(x, y, border_color)` ? + +Text on graphics screen: +- `outtext(s)` / `outtextxy(x, y, s)` ? gfx_text (alias) +- `settextstyle(font, dir, size)` ? multiple bitmap fonts +- `gettextsettings(&info)` +- `textwidth(s)` / `textheight(s)` ? measure + +Image manipulation: +- `imagesize(x1, y1, x2, y2)` ? bytes needed for getimage +- `getimage(x1, y1, x2, y2, buf)` ? save rect to buffer +- `putimage(x, y, buf, op)` ? paste back with COPY_PUT/XOR_PUT/AND_PUT/OR_PUT/NOT_PUT + +Clipping/viewport: +- `setviewport(x1, y1, x2, y2, clip)` ? drawing clip rect +- `getviewsettings(&info)` +- `clearviewport()` +- `setactivepage(p)` / `setvisualpage(p)` ? ਧ (Sprinter 2 screen) + +Line style: +- `setlinestyle(style, pattern, thickness)` ? SOLID_LINE / DOTTED_LINE / etc. +- `getlinesettings(&info)` + +**Acceptance:** ७ ⨯筮 Turbo-C BGI ணࠬ (饩 ᯮ짮 +moveto/lineto/circle/bar/setcolor) ࠡ ⢥ ࠢ. + +**Notes:** +- BGI fonts (TRIPLEX/SANS_SERIF/GOTHIC) ? BIOS font, ⠫ 㦭 + ( bitmap data lib) +- imagesize/getimage/putimage ? ᠬ ॡ game/animation +- Active/visual page ( ਧ) ? Sprinter ন 2 graphics pages, + 㦥 API switching + +. ⠪ `examples/` Turbo C 2.x BGIDEMO reference 㦭. + +### IM2 Interrupt Handlers ? **MUST v2** + +User- ISR १ Z80 IM 2 mode. 㦭 : +- Timer ticks (50 Hz frame counter, ) +- Music playback (AY, COVOX) +- Real-time games (input + game logic + render interrupt-driven) +- Async keyboard / mouse handling + +**Status:** v2. research + design `docs/im2_isr_design.md`. + +**襭 ⥪:** ॠ ⤥ memory mode `--memory im2` +( ⮣ ⮡ 騥 crt0). Detail' design-doc. + +** research'** ( ⥪ `docs/im2_isr_design.md`): +- Vector 0xFF ? frame + keyboard + CBL. Disambiguation ⠬ 0x19 / 0xFE +- Mouse hardware-IRQ 室 ( ⥪饩 ) +- Vector table / ISR / stack W2 (0x8000..0xBFFF) +- DSS ᢮ IM 2 handler ? 㦭 chain' ( / SYSTIME ) + +### 稥 㯭 㭪 v2 + +- [ ] **FILE API rewrite ? buffered streams** ? ⥪ ॠ + `libc/stdio/file.c` provisional unbuffered shim ( fputc/fgetc + = read/write syscall). 㦭 業 buffered ᥬ⨪ + Solid-C: + + ```c + typedef struct { + uint flags; // +0..1 file status flags + int level; // +2..3 empty/fill level of buffer + char *curp; // +4..5 current active pointer + int fd; // +6..7 underlying low-level fd + char *buffer; // +8..9 data transfer buffer + char hold; // +10 ungetc byte if no buffer + short token; // +11..12 reserved + char dummy; // +13 reserved + } FILE; + ``` + + stdin/stdout/stderr ? fd-થ `0 / -1 / -2`. ⥫ + stdout/stderr ࠭ ७: ESTEX OPEN positive + small fd (1, 2, ?) 筮 䠩 ? ᫨ stdout=1, ॠ + fd=1 ⠫ 䨪஬. fd=0 stdin ᭮ + (ESTEX 0 頥). fd । syscall' ? + ᯥਧ 䫠 `_F_CONIN/_F_CONOUT`. + + ਭ-⮪ (stdaux/stdprn) ॠ㥬 ? Sprinter ਭ୮ + API . + + ୠ⨢ ? ॠ third_party/solid-c (sources + `SRC/CLIB/`); ⠬ ⮢ buffered FILE + fopen/fread/fwrite/ + fseek/setvbuf .. ஢ 訬 open/read/write/lseek. + + rewrite deferred issues stdio-review: + - `fwrite` short-write ⠢ `_F_ERROR` + - `fgets(buf, 1, fp)` ? ⠭ "empty string", 㫨 NULL + - `mode_to_flags` ? break-out '+' (cosmetic) + +- [ ] **Audio API** ? AY-3-8910 + COVOX १ 뢠 (ॡ IM2) +- [ ] **ISA-8 slot support** ? ZX-Bus (sound, network, etc.) ? ॡ IM2 + ⥭ port + +## 稥 (v1 backlog, 騥) + +- [x] **#9: text I/O split (Turbo-C style)** ? stdio (puts/printf/putchar) ⥯ fast no-attr १ PCHARS/PUTCHAR. conio (cputs/cprintf/putch) ਬ attr १ textcolor/textbackground/textattr. KEEP_EXIST_ATTR ? conio fallback fast path. Verified hello.exe. . `memory/text_output_api_split.md`. 2026-05-31. +- [x] **Mouse API ** (१ driver, RST 30h) ? 14 㭪権 (init/show/hide/refresh/read/goto/bounds/text_cursor/load_cursor/get_cursor/get/set_sensitivity/video_mode_changed). . `memory/mouse_api.md`. Verified MAME 2026-05-31. Sensitivity = divider ( = ॥). +- [ ] Interrupt handlers ? IM 2 vector table HOME user ISR' +- [ ] প `restore SP on EXIT` ( z88dk +pps) ? ஢ 㦭 +- [ ] CI: ⮬᪨ ᪠ MAME `-aviwrite` screenshot-ࠢ, ⮡ ਬ஢ 室 祫 + +## ⮬ + +- প `` ( SDCC stdlib ? 㦭 ஢ crt0 ᮢ⨬) +- `` १ ESTEX SYSTIME (`$21`) CMOS BIOS-㭪樨 +- ZX Spectrum-ᮢ⨬ ० ⤥ target ( ஢ ᯥ㬮᪨ ணࠬ) +- প ZX-Bus (sound, network, etc.) ? 㦭 ࠩ +- Profile-guided optimization tools (hot/cold detection) 㯭 ணࠬ + +## Linker duplicate-symbol warnings (, 䨫஢) + + ᮧ⥫쭮 overrides' SDCC z80.lib 㭪樨 ᮡ⢥ ᨥ `sprinter.lib`, `sdldz80` `?ASlink-Warning-Definition of public symbol '...' found more than once`. ࢮ । (), ⮬ ४⭮ ? warning ⮫쪮 noise. + +騥 overrides: +- `_puts` ? १ PCHARS+\r\n vs SDCC posix puts +- `___sdcc_heap` ? heap W2 vs SDCC's ⠭ +- `_asctime`, `_localtime` ( 㣨 time) ? `posix_time.c` १ ESTEX SYSTIME vs SDCC's `time.rel` `_RtcRead` + +**饥 襭:** `bin/sprinter-cc` 䨫஢뢠 warning- (warning + 2 follow-up `Library:` ப) 뢮 `sdcc`. १ `-v` (verbose) 뢠. १ awk-pipe. + +** 襭:** +- ३ explicit `--nostdlib` + 筮 ᯨ᮪ 㦭 㫥 z80.lib (string, math, stdlib override') ? warning', ᪨஢ +- : २ `_puts` ? `_puts_sprinter` + alias १ linker flag ( 㢥७ SDCC ন) +- : ⠢ ᥩ (ࠡ祥 benign) ? ਮ + +## TODO: ஢ ॠ쭮 + +- [ ] **Port_Y banking trick** (`docs/part2/SprinterGraphics programming.txt`): + ⢥ত ᫥ `OUT (0x89), Y` 0xC000+0x400*N W3 + ப Y..Y+15 ( ணࠬ஢ ? 16 ப). + Empirical 2026-06-01 MAME 0.283 trick ** ࠡ⠥** ? ᥫ + ᠬ 0xC000+row_width 室 . ᪨ + `docs/samples/plasma2.asm` ⮦ ᯮ banking, ⠭ + Port_Y per row. + : + 1. ॠ쭮 Sprinter + 2. dual-write (`_gfx_putpixel_raw` + ன write `0xD000+x`) + 3. ᫨ ? MAME, issue + ९ + 4. ᫨ ⮦ ? 㬥 , 㤠 㯮 + ⠢ ⥪ ॠ (Port_Y per pixel) + 5. ᫨ banking ࠡ⠥ ? ஢ Port_Y + `_gfx_putpixel_raw` (sentinel out-of-range, . memory/gfx_port_y_banking.md) + + 易 먣 Bresenham (60-pixel ) ? 8? + OUT (0x89) 権, `gfx_fill_rect 320x256` ? 16? . + release v1. + +## GFX: ७ `docs/part2/accelerator_doc.txt` + +᫥ ⥭ ⠫쭮 accelerator doc  ࠢ. + ᯮ ⮫쪮 ਧ⠫/⨪ Fill mode. + +### Quick wins ⥪ primitives + +- [ ] ** SMC `LD A, (var)` block-size**. 㬥  + ࠧ蠥 `LD A, (HL)`, `LD A, (BC)`, `LD A, (DE)` ( `LD A, r`). + 㡥 SMC complexity `gfx_lines.c:hfill_chunk/vfill_chunk` + `gfx_16.c:g16_hfill_chunk`. 饭 ⮫쪮 register-to-register. +- [ ] **஢ block-size**. 㬥 뢠 accel + block size bursts (. `Horizontal_Line_Fill`: ⠭ + size + `LD B,B` ⪫祭, ⮬ Fill mode ᯮ + ࠭ size). `gfx_fill_rect` 100 묨 + ப ? ⠭ size 1 ࠧ, 100. + +### Bank-prefix modes (port 0xE2 bits) + +㬥 뢠 ਠ ࠭ ⠭⭮ 0x50: + +| Bank byte | Effect | +|---|---| +| 0x50 | Normal write ? shadow + | +| 0x54 | "no copy in main shadow RAM" | +| 0x58 | **"FF is transparent"** ? 0xFF write ⠢ background | +| 0x5C | both | + +Bank 0x58 祬 mouse cursor 0xFF-஧筮. + **sprite-blending १ accel block copy**: + +- [ ] **`gfx_set_bank_transparent(on)`** 䫠 `gfx_set_bank` + 롮 0x50/0x58 ᮢ sprite' +- [ ] ᯮ짮 `gfx_blit()` ⮡ 䠪 + transparent sprites १ accel- + +### Block copy mode (sprite blit') + +`LD L,L` (horizontal) `LD A,A` (vertical) ? ० ஢ १ +256- accel memory. blit'. + +- [ ] **`gfx_blit(src_data, x, y, w, h)`** ? ஢ sprite' + (ந ࠧ, १ accel) +- [ ] **`gfx_blit_transparent(src, x, y, w, h)`** ? ᯮ짮 bank 0x58 + +. `Draw_Restangle_Data` accelerator_doc.txt ७. + +### AND / OR / XOR operations १ accel + +㬥 뢠 accel ন ᪨ 樨 +. ਬ: +- XOR ? (뤥 selection UI) +- OR / AND ? masking, alpha-style blending +- . ਬ accelerator_doc.txt: "256 bytes block coding via XOR" + +- [ ] **`gfx_xor_rect`** / **`gfx_or_rect`** / **`gfx_and_rect`** ? + ਬ⨢ ᪨ 権 אַ㣮쭨 +- [ ] **`gfx_invert_rect(x, y, w, h)`** ? alias xor 0xFF + +### Bitmap fonts ࠧ ࠧ஢ + + `gfx_text` / `gfx_putchar` प ࠡ 8?8 ⮬ +(BIOS WIN_GET_ZG 頥 256?8 ). UI / 쭨 +㦭: +- [ ] **`gfx_set_font_size(w, h)`** ? ४ ਭ/ glyph' +- [ ] **`gfx_set_font_data(ptr, w, h, advance)`** ? 㪠⥫ + 짮⥫᪨ + ࠧ +- [ ] প **proportional** (advance != w) ⮢ ? + array advance[256] ਭ glyph' +- [ ] **Big-font ०**: 8?16, 16?16, 16?8 ( 쭨) +- [ ] ⤥ API `gfx_text_ex(x, y, str, font_id)` + font_id 롨ࠥ 㦥 ⮢ +- [ ] **Anti-alias 2-bit ** ( 䮭 / ࠭ / 2- alpha?) + ? far future, smooth UI + +## ⠯ ⨬権 ( ᥩ) + +- **`gfx_line` १ accel ** ? Bresenham |dy| << |dx| ( ) 뤠 runs Y ( X): ᥫ, ᥫ, ᥫ, 蠣 Y, ᥫ, ᥫ... ⠪ run ? ⮢ 㬥 `gfx_hline` ( `vline`). + ᫥: runs 㭪 ; run length, ஬ 룮 accel hline 祬 N?putpixel (overhead accel ~20?s, putpixel ~5?s ? accel 룮 run ? 4-5 px); (dx ? dy) ⠢ Bresenham, ? run-length-based fill. + `gfx_line` orthogonal cases 㦥 १ accel ? ⨬஢ ⮫쪮 . + +- **`gfx_fill_rect` W3-swap ** ? ᥩ ७ `gfx_hline`/`gfx_vline` ᢮ DI/save-W3/restore-W3/EI. ᤥ internal `_fill_rect_inner` ন W3 DI 横; ~20?s ? ⢮ ப/⮫殢 . ਬ ᥬ ਬ⨢. +# MDView ? ᬮ騪 Markdown Sprinter + +**MDView** ? ணࠬ ᬮ 㬥⮢ ଠ *Markdown* +Sprinter ( Z80). 㬥 ࠭ ⤥쭮 W3 +᭮ RAM ணࠬ. + +## + +- 㬥 **128 ** (8 ࠭ EMM 16 ) +- **16 384** ࠭ ப +- ⮬᪨ ७ ᫮ ਭ ࠭ (80 ⮫殢) +- ਧ⠫ ᤢ ப ப ( , ⠡) +- -: 䠩, ப, 業 ப⪨ +- ப ﭨ ६ 㧪 樨 +- প ?? ᪫ ப + +## + +``` +mdview [_䠩.md] +``` + +᫨ 䠩 , 㦠 `README.MD`. + +## ࠢ + +``` + ⢨ + +Up Down ப⪠ ப / +PgUp PgDn ப⪠ ࠭ (30 ப) +Home 砫 㬥 +End 㬥 +Left Right ਧ⠫ ᤢ (⮫쪮 nowrap-ப) +F1 ࠢ +F8 ஢: CP866 ? CP1251 ? KOI8-R ? UTF-8 ? ... +F10 / Esc 室 ணࠬ +``` + +஢ । ⮬᪨ ⨨ (BOM + ⨪ + 4 ); `F8` ४砥 , ᫨ ⥪ 訡. +8- ஢ (CP866/CP1251/KOI8-R) ४ (६ +ᮢ). ன / (ਬ UTF-8) ந ? +ࢮ ४祭 (⪠ 㧠 ᯨ஬), . + +## ⠪ Markdown + +### + +ন ஢ H1?H4. ஢ H5 H6 ⮡ࠦ H4. + + # ࢮ ஢ + ## ண ஢ + ### 쥣 ஢ + #### ⮣ ஢ + +### ⮢ ଠ஢ + +** ⥪** 뤥 묨 񧤮窠: `**⥪**` + +*ᨢ* 뤥 묨 񧤮窠 `*⥪*` ન `_⥪_` + +`஥ ` 砥 묨 窠 + +~~ભ ⥪~~ ? ⨫: `~~⥪~~` + +### 㬥஢ ᯨ᮪ + +થ `-`, `*` `+`: + +- 㭪 ᯨ᪠ +- ன 㭪 ᯨ᪠ +- ⨩ 㭪 筮 ⥪⮬, 室 + 㤥 ७ ᫥ ப ࠭ 㯠 + +### 㬥஢ ᯨ᮪ + +1. +2. ன +3. ⨩ + +### + +> 稭 ᨬ `>`. ᪮쪮 ᫥⥫ +> ப ᪫ ⮬᪨ +> ७ᮬ ᫮. + +### (verbatim) + + 砥 ன 窨. +⥪ ⮡ࠦ ? ? ࠧ Markdown: + +``` +#include +#include + +int main(void) { + puts("Hello, Sprinter!"); + return 0; +} +``` + +### ਧ⠫쭠 + + ᨬ `---`, `***` `___` ⤥쭮 ப: + +--- + +## 孨᪨ ࠪ⨪ + +- **ଠ:** Sprinter, Z80 @ 21 +- **஢:** CP866 / CP1251 / KOI8-R / UTF-8 (⮮।, `F8`) +- **ᨬ ࠧ 䠩:** 128 +- **ᨬ쭮 ᫮ ப :** 16 384 +- ** :** small + - ணࠬ, c⥪, , ? a W1-W2 (32 , 0x4000?0xBFFF). + - 䠩 ? ࠭ EMM, ⮡ࠦ W3 (0xC000?0xFFFF) + +## TODO + +1. **祭 ࠧ 㬥⮢.** 128 : 筮 + ࠧ ࠡ 訬 - ࠭ , ஢ + ࠡ 8- ࠭栬 16. + +: ଠ஢ ⠡ ࠬ; প ஢ +CP866 / CP1251 / KOI8-R / UTF-8 ⮮। ४祭 `F8` +(ன ந , ࢮ ४祭). + +4. **᪮७ ७ਭ.** ப ࠭. ⨬ 横 뢮 + ᨬ १ BIOS WRCHAR ( 뢮, DMA). + +--- + +*MDView v0.2 (c) 2026 ஢ ..* + + +--- + +# Sprinter C Compiler ? v1.0 + +C toolchain for **Sprinter** ? the Z80-based home computer by Peters Plus, running +ESTEX DSS. Host: macOS / Linux. Target: `.EXE` files in SprintEXE format. + +Built on top of **SDCC 4.5** (vendored in `third_party/sdcc/`). This repository adds +everything Sprinter-specific: crt0, linker integration, libc wrappers over ESTEX, +banked-call trampolines, graphics & accelerator API, mouse driver wrappers, and the +`mkexe` utility for producing SprintEXE images. + +## What you get + +* **`bin/sprinter-cc`** ? one-line driver: `sprinter-cc -o foo.exe foo.c` +* **Memory modes**: `tiny`, `small`, `big`, `huge`, `manual` ? see below. +* **stdio + conio**: printf, puts, putchar, getchar, fopen/fread/..., cprintf, cputs, putch, textcolor/textbackground/textattr, gotoxy, kbhit/getch. +* **Graphics**: 320?256?256 and 640?256?16 modes, accelerator-backed primitives (hline / vline / rect / fill_rect / line via Bresenham, plus clear), bitmap-font text in both modes via BIOS character generator. +* **File I/O**: POSIX (`open`/`read`/`write`/`close`/`lseek`/`unlink`/`creat`), FILE\* streams (`fopen`/`fgets`/`fwrite`/...), directory listing (`ffirst`/`fnext`), `chdir`/`getcwd`/`mkdir`/`rmdir`, `stat`/`fstat`. +* **Memory**: 32 KB heap (W2-resident), banking-aware page allocator (`mem_alloc_pages`/`bank_read`/`bank_write`), explicit memory modes for sub-16 KB programs. +* **Mouse**: full Sprinter driver wrapper (14 functions including custom cursor bitmaps). +* **Environment**: `getenv`/`putenv`/`sysenv` over ESTEX `$46`. +* **Time**: `getdatetime`/`setdatetime` + POSIX `time`/`localtime`/`mktime`/`asctime`/`ctime`. +* **Misc**: `errno`/`strerror`/`perror`, `atexit`, `setjmp`/`longjmp`, `sleep`, full argv parsing in crt0. + +## Quick start + +```sh +git clone sprinter-c +cd sprinter-c +make sdcc # one-time: fetch SDCC 4.5 binary (~25 MB) +make all # build mkexe + libsprinter.lib + 27 examples +make floppy # pack everything into mame/v306/IMG/mc.img +cd mame/v306 && ./run_mame.sh # boot Sprinter in MAME +``` + +Compile a single program: + +```sh +cat > hello.c < +int main(void) { puts("Hello, Sprinter!"); return 0; } +EOF + +bin/sprinter-cc -o hello.exe hello.c +``` + +That's it ? `hello.exe` is now a valid SprintEXE you can `RUN HELLO` from the ESTEX shell. + +## Memory modes + +Sprinter's address space is four 16 KB windows (W0 / W1 / W2 / W3). DSS allocates +pages by program size ? small programs get only one page. Pick a memory mode based +on what your program needs: + +| Mode | Code lives in | Banking | Use when | Note | +|---|---|---|---|---| +| `tiny` (default) | W2 (0x8100+) | no | code+data < 14 KB | | +| `small` | W1-W2 (0x4100+) | no | code+data < 30 KB | | +| `big` | W2 + W1 banking | yes (W1) | tiny + extra code modules | | +| `huge` | W1-W2 + W3 banking | yes (W3) | small + extra code modules | | +| `manual` | user-specified | optional | special layouts | Not implemented | + +```sh +sprinter-cc --memory small -o big.exe bigprog.c +sprinter-cc --memory huge -o app.exe main.c --bank 1=engine.c --bank 2=ai.c +``` + +Banked functions are declared with `__banked`: + +```c +void engine_tick(int dt) __banked; // lives in BANK1, automatically swapped +``` + +## Examples (27 total) + +| Example | What it demonstrates | +|---|---| +| `hello` | Hello world with stdio + conio Turbo-C-style colors | +| `argv` | argv parsing in crt0 | +| `cat` | File I/O ? read & print TEST.TXT | +| `seek` | 32-bit lseek over a 100 KB file | +| `ls` | Directory listing via ffirst/fnext | +| `filetest` | FILE\* streams (fopen/fread/...) | +| `stattest` | `stat`/`fstat` on files and directories | +| `errno` | errno / strerror / perror | +| `mem_test` | Page allocator + bank\_read/bank\_write | +| `malloc` | Heap stress test (200+ allocations) | +| `banked` | Banked code in W3 (huge mode) | +| `bankedbg` | Banked code in W1 (big mode) | +| `banklocl` | Bank-local static data and BSS | +| `mouse` | Mouse driver in text mode | +| `gfx_mous` | Mouse with custom bitmap cursor in graphics mode | +| `gfx_demo` | 320?256?256 lines / rects / accelerator | +| `gfx_d16` | 640?256?16 same primitives | +| `gfx_text` | Bitmap-font text on graphics screen | +| `timedir` | Date/time + directory listing | +| `ptime` | POSIX time API | +| `openenv` | open() flags + environment vars | +| `conio` | conio API smoke test | +| `attrprob` | Probe Sprinter text attribute byte layout | +| `strtest` | string.h test (from SDCC's z80.lib) | +| `stdlib` | stdlib.h test (qsort / rand / strtol / etc.) | +| `assrtest` | assert() | +| `rt_test` | Runtime helpers (sleep, setjmp, atexit) | + +## Headers + +Standard: +* `` ? puts / printf / FILE\* + Sprinter-specific dec/hex helpers +* `` ? atoi / atof / malloc / qsort / ... (from SDCC z80.lib) +* `` / `` / `` ? from SDCC z80.lib +* `` ? read / write / close / lseek / unlink +* `` ? open / creat + O\_RDONLY / O\_CREAT / ... +* `` ? errno + error names + strerror +* `` ? stat / fstat +* `` / `` ? from SDCC + +Sprinter-specific: +* `` ? putch / cputs / cprintf, textcolor / textbackground / textattr, kbhit / getch, clrscr, gotoxy, wherex/y +* `` ? gfx_init/done, palette, putpixel, hline/vline/rect/fill_rect/line, text ? for both 320 and 640 modes (gfx_\*16 variants) +* `` ? full 14-function driver wrapper + mouse_cursor_t with bitmap support +* `` ? chdir / getcwd / mkdir / rmdir / ffirst / fnext / ffblk +* `` ? getdatetime / setdatetime + POSIX time / localtime / etc. +* `` ? raw ports, ESTEX/BIOS function numbers, env API +* `` ? exit / \_exit / atexit +* `` ? mem\_alloc\_pages / mem\_free\_block / bank\_read / bank\_write +* `` ? Solid-C compatibility layer (aliases + BOOL/WORD/uint types) + +## Toolchain commands + +```sh +make all # build mkexe + lib + every example +make floppy # repack mame/v306/IMG/mc.img with all .exe files +make check # 17 mkexe unit-tests +make clean # remove all build artefacts +make sdcc # one-time: fetch SDCC 4.5 binary +``` + +### sprinter-cc options + +``` +sprinter-cc -o foo.exe foo.c [more.c ...] [options] + + --memory MODE tiny | small | big | huge | manual (default: tiny) + --memory-manual SPEC explicit placement (CODE=W1|W2,DATA=W1|W2|SAME,BANKED=W1|W3) + --stack-size N bytes reserved for the stack (default ~1278) + --crt0=TYPE default | minimal | banked | small + --bank N=FILE.c compile FILE.c into bank N (repeatable, max 15) + --debug enable runtime diagnostics (defines DEBUG_RT) + -I PATH extra include path + -L 0xADDR / -E / -S override load / entry / stack addresses + -Wl FLAG pass FLAG to sdldz80 + --mkexe FLAG pass FLAG to mkexe (e.g. --mkexe -p --mkexe 0 for bank padding) + -v verbose +``` + +## Status + +What works in v1.0: +* Compile / link / pack to SprintEXE ? verified on all 27 examples +* Four memory modes (tiny / small / big / huge) +* Graphics (both modes) with accelerator +* Mouse (text + graphics cursor) +* File I/O, directories, environment, time +* All headers listed above + +Deferred to v2.0 (see `docs/TODO.md`): +* **Turbo-C-style BGI graphics API** ? `initgraph` / `setcolor` / `circle` / + `getimage` / `putimage` / etc. on top of our `gfx_*` primitives +* Remaining Solid-C compatibility gaps (Phase 2/3) ? see `docs/solid_c_compatibility.md` +* Manual memory mode +* Rewrite FILE\* stream API (current implementation is very primitive and doesn't use buffers) + +Deferred to v3.0: +* **IM2 interrupt handlers** ? research complete (`docs/im2_isr_design.md`), + implementation scheduled for v3 +* **Audio API** (AY-3-8910 + COVOX) ? requires IM2 +* **ISA-8 slot drivers** ? requires IM2 (???) + +## Documentation + +* `docs/TODO.md` ? roadmap and open work items +* `docs/solid_c_compatibility.md` ? gap analysis vs Solid-C 2004 +* `docs/im2_isr_design.md` ? interrupt handler design (v2) +* `docs/converted/` ? source documentation (ESTEX, BIOS, architecture) + converted to plain text for `grep` +* `docs/reference/`, `docs/samples/`, `docs/memory management/` ? original + Russian docs and code samples from Peters Plus + +## Repository layout + +``` +bin/sprinter-cc one-line compiler driver (bash) +toolchain/mkexe/ host-side tool: .ihx -> .exe SprintEXE +toolchain/check_banks.py post-link bank size enforcer +runtime/ crt0 variants (default, minimal, small, banked) + bank trampolines, heap, heap_top +libc/include/ headers +libc/io|stdio|mem|gfx/ C and asm sources for libsprinter.lib +lib/ Makefile that archives libsprinter.lib via sdar +examples/ 27 example programs +mame/v306/ MAME binary + Sprinter ROM/HDD images + floppy script +third_party/sdcc/ vendored SDCC 4.5 (fetched via `make sdcc`) +third_party/solid-c/ reference: original Sprinter native C (for compat target) +docs/ documentation +``` + +## License + +This repository contains: +* Original code in `bin/`, `toolchain/`, `runtime/`, `libc/`, `lib/`, `examples/` ? + MIT-licensed. +* `third_party/sdcc/` ? SDCC 4.5 under GPLv2 with linking exception + (see `third_party/sdcc/COPYING.txt`) +* `third_party/solid-c/` ? original Sprinter Solid C, used only as a reference + +## Credits + +* **Sprinter / Peters Plus** ? , ਩ ਭ and the original team +* **SDCC** ? for the underlying Z80 compiler +* **MAME** ? for the Sprinter Sp2000 emulation + +--- + +For questions / patches: see CONTRIBUTING.md (TBD) or open an issue. + +--- + +# TODO / Roadmap + + 浪 뢠 ਮ.  ॠ ணࠬ ? ਮ ᬥ. + +## ⠯ 5 ? malloc / free + banking-aware page allocator ? + +- [x] SDCC's `malloc`/`free` + `runtime/heap.s` ( library heap.rel, 14000- heap 2) +- [x] `libc/mem/mem_alloc.c` ? page allocator: `mem_alloc_pages`/`mem_free_block`/`mem_get_page`/`mem_info` १ ESTEX `$3C/$3D/$3E` + BIOS `$C4` +- [x] `libc/mem/bank_io.c` ? HOME-१ `bank_read`/`bank_write`/`bank_load_byte`/`bank_store_byte` ᢮ W3 +- [x] `examples/malloc_test/` ? ஢ઠ SDCC's malloc (~210 64- allocations १ heap) +- [x] `examples/mem_test/` ? ஢ઠ page allocator: 3 ࠭, ࠧ १ bank_write, 䨪 १ bank_read + +## ⠯ 6 ? argv parsing + sprinter-cc wrapper ? + +- [x] crt0 ESTEX command-line IX-prefix (inline asm `runtime/crt0.s`) +- [x] Strip leading CP/M-style space (DSS quirk) +- [x] । `argc`/`argv` main() १ HL/DE (SDCC __sdcccall(1) ABI) +- [x] argv[0] = basename .EXE १ ESTEX APPINFO ($47 subfn 2) +- [x] `runtime/crt0_minimal.s` ? opt-out 祭 쪨 ணࠬ +- [x] `runtime/crt0_banked.s` ? ⥯ ⮦ argv (parse_argv + get_progname ᪮஢ crt0.s; 㤥 factored argv.s libsprinter.lib) +- [x] Bash-⪠ `bin/sprinter-cc`: `sprinter-cc -o foo.exe foo.c` ப +- [x] প 権: `--memory`, `--memory-manual`, `--stack-size`, `--crt0=`, `--bank N=FILE.c`, `--debug`, `-I`, `-L`/`-E`/`-S`, `-Wl`, `--mkexe` + +## ⠯ 8 ? 䨪 (320?256?256 + 640?256?16 + accel + bitmap font) ? + +- [x] **8a** Graphics core: `gfx_init`/`gfx_done`/`gfx_clear`/`gfx_putpixel`/`gfx_pal_load`/`gfx_pal_set` (libc/gfx/gfx_core.c). १ BIOS PIC_SET_PAL ($A4). Verified 320?256?256. +- [x] **8b** /אַ㣮쭨/fill १ accelerator (libc/gfx/gfx_lines.c): `gfx_hline`/`gfx_vline` १ accel Fill (LD C,C / LD E,E + SMC block-size), `gfx_rect`/`gfx_fill_rect` heuristic 롮஬ ਥ樨 (h/v bursts count), `gfx_line` Bresenham . `gfx_clear` ⮦ ९ᠭ column-major accel (~4? ॥). +- [x] **8c** 640?256?16 mode (libc/gfx/gfx_16.c): `gfx_*16` API, HIGH nibble = LEFT pixel (㬥 misleading), per-row RMW vline ( = 2 ਧ⠫ ᥫ). +- [x] **8d** Bitmap font + gfx_text (libc/gfx/gfx_text.c): १ BIOS WIN_GET_ZG ($B8), interleaved layout `font[row*256+char]`, `gfx_text`/`gfx_putchar` 320 mode, `gfx_text16`/`gfx_putchar16` 640 mode pair-table lookup. + +. memory/sprinter_graphics.md, sprinter_accelerator.md, sprinter_graphics_16.md, sprinter_font_format.md. + + ( ): +- [ ] -quad 640: per-cell (mode 0x82 ࠧ蠥 1 4 per 16?8 cell) ? १ אַ area-ᠭ ࠭ 0x0300..0x039F + +## Auto-banking (. `memory/banking_roadmap.md` ⠫) + +Phase 1 ? file-level bin-packing ? ॠ뢠 ஥ ~30 KB . + +- [ ] `toolchain/auto_bank.py`: + - ࠧ `.rel`-䠩 ( .map ᫥ dry-run link') + - First-fit-decreasing bin-packing + - `#pragma codeseg BANKn` manual override + - ५뢠 묨 `-Wl-b_BANKn=...` ࠬࠬ + - ⠥ । + +Phase 2-5: incremental rebalance, declarative `banks.toml`, function-level, call-graph-aware. 쪮 ᫨/ . + +## Bank-local static data (mutable data ⮬ ) ? ? + +- [x] ਬ `examples/bank_local_data/` ? 㭪 BANK1 ᢮ writable BSS array + const table + malloc- +- [x] `mkexe -p 0` 㫥 padding (BSS-storage 㧪) +- [x] ᪨ 楯: `--codeseg BANK1 --constseg BANK1 --dataseg BANK1` bank1.c + `-Wl-b_BANK1=0x1C000` . **`--dataseg BANK1` ** ? ࠭ ⭮ - trampoline bug ᪨஢ १. +- [x] ** 䨪 trampoline'a runtime/bank.s** ? `pop af; out (n), a` ਫ A ? banked-㭪樨 騥 uint8_t 頫 . `pop bc; out (c), b` ࠭ A. +- [x] **malloc banked-㭪樨 ࠡ⠥ ஧筮** ? heap W2 (HOME), W2 ᢠ trampoline', pointer  ⥪. . memory/bank_local_data_pattern.md. +- [x] 㬥 memory: `memory/bank_local_data_pattern.md` ( 楯 + malloc + nuances), `memory/sdcc_banking.md` (trampoline fix) +- [ ] 樮쭮 ? `check_banks.py` ⮡ 뢠 ࠧ size = code + const + bss per bank (cosmetic) + +祬: 㫥 訬 private state (level loader, audio engine, scene data). W2 heap , ⨪ . + +## ᪠ solid-c (⨢ Sprinter C ? `third_party/solid-c/`) + +᫥ solid-c'᪮ libc (. `memory/solid_c_findings.md`)  ⮢ ᫥ 㭪権. ਮ **᮪** : + +### High-priority gaps ( ஢, 짠) +- [x] **`errno` + `strerror`/`perror`** ? ⠡窠 32 訡 (libc/io/errno.c) +- [x] **७ `open()`** O_CREAT/O_TRUNC/O_APPEND/O_EXCL state machine +- [x] **`atexit`** ? 8-callback LIFO + `exit()` + `_exit()` (libc/io/atexit.c) +- [x] **`setjmp`/`longjmp`** ? 6- jmp_buf={sp,ix,pc} (libc/io/setjmp.c) +- [x] **`sleep(seconds)`** ? 50Hz halt-loop (libc/io/sleep.c) +- [x] **ESTEX ENV API** ($46, getenv/putenv) ? libc/io/env.c. 竨 doc-bug: ॠ쭮 A=0 NOT FOUND + +### Medium-priority (㦭 shell-like ⨫) +- [ ] **Mouse driver** ? `rst $30h`, 17 㭪権. **砫 ࠡ⠥ MAME**. +- [x] **`ffirst`/`fnext` + ffblk_t struct** directory listing ? ॠ, demo: ls.exe +- [x] **`getdatetime`/`setdatetime`** १ ESTEX $21/$22 ? libc/io/time.c, demo: time_dir_test +- [x] **`chdir`/`getcwd`/`mkdir`/`rmdir`** ? wrappers ESTEX $1B-$1E ? libc/io/fsdir.c +- [x] **conio: `kbhit`/`getch`/`getche`/`cputs`/`clrscr`/`gotoxy`** ? ॠ +- [x] **conio extras**: `wherex`/`wherey` ($53), `wrchar`/`rdchar` ($58/$57), `textmode_get/set` ($50/$51), `clrscr_attr` ($56) + COLOR macros + +### Low-priority ? ? FILE* stack + +- [x] ** unbuffered FILE\*** ? `libc/stdio/file.c` + `libc/include/stdio.h`. fopen/fclose/fputs/fgets/fread/fwrite/fseek/ftell/rewind/feof/ferror/clearerr/fflush + stdin/stdout/stderr pseudo-streams. . `memory/file_star_design.md` `examples/filetest`. +- [ ] fprintf / fscanf ? 㦭 printf-१-callback machinery. 짮⥫ `sprintf(buf, ...) + fputs(buf, fp)`. +- [ ] 樮 buffered mode (setvbuf, line/block buffering) ? ᫨ - . + +### POSIX time API ? ? +- [x] `libc/io/posix_time.c` ? time/localtime/gmtime/mktime/asctime/ctime getdatetime. SDCC's time.rel ( override _RtcRead). . `examples/ptime`. + +### sys/stat ? ? +- [x] `libc/io/stat.c` ? POSIX stat/fstat. ਤ open+fstat 䠩, ffirst+iter ( "."/".."). . `examples/stattest` `memory/estex_ffirst_dotdot.md`. + +### assert ? ? (ᯮ㥬 SDCC's __assert १ fallback include path) + +## libc/stdlib ? ? 㦭 (. memory/sdcc_stdlib_works.md) + +஢७ १ `examples/stdlib_test/`: SDCC z80.lib ᮤন ࠡ騥 ॠ樨: +- `atoi/atol/atof, strtol/strtoul, rand/srand, qsort/bsearch, abs/labs, div/ldiv` +- `` (memchr/cmp/set/cpy, strcat/cmp/cpy/len/chr/spn/etc.) +- `` (toupper/tolower) +- `` (sinf/cosf/sqrtf/etc.) + + ⮬᪨ ﭥ z80.lib 㦭. ** ९뢠**. + + Sprinter-specific 易⥫ 㫨 : atexit, env, errno, setjmp, putchar/puts/getchar, conio, fsdir, time, mouse, open/read/lseek/close. + +## Build-system: libsprinter.lib + sprinter-cc ? ? + +- [x] `lib/Makefile` ? ᮡࠥ libc/*.c `.rel`, 娢 १ sdar `lib/sprinter.lib` +- [x] 砥 runtime/bank.s runtime/heap.s (auto-pulled __banked/malloc) +- [x] `bin/sprinter-cc` ? bash-wrapper: `sprinter-cc -o foo.exe foo.c` ப +- [x] প 権 `--crt0=default|minimal|banked`, `--bank N=FILE.c`, `-I`, `-L`/`-E`/`-S`, `-Wl`, `--mkexe` +- [x] `examples/hello_sccc/` ? : `hello.c` ᮡࠥ shell-맮, ࠧ ᮢ Makefile (925 ) +- [x] Split `putchar.c` ? `putchar.c` + `puts.c` per-function granularity (puts override SDCC's z80.lib version) +- [x] `make all` (ᨬ `lib` । `examples`) + + 襭 (樮쭮): +- [ ] ஢ ⠫ examples sprinter-cc Makefile (ᬥ⨪) +- [ ] 쭥 libc/*.c per-function ( ⥪ granularity 㦥 㦭 ࠧ ? .rel 楫, 設⢠ 䠩 㭪) + +## ⠯ 9 ? memory modes sprinter-cc + +DSS 뤥 ࠭ ࠧ ਫ: < 16 KB ? ࠭, ⠫ 砥 ?࠭ #FF? (read=0xFF, write ). - ⮣ CODE--W1 + DATA--W2 쪮 ணࠬ . . [memory/sprinter_memory_modes.md](../../.claude/projects/-Volumes-SAM8-Projects-DIY-Z80-Sprinter-C-Compiler/memory/sprinter_memory_modes.md). + +- [x] **`tiny`**: (CODE+DATA+⥪) W2. Default. Verified hello/argv/conio/malloc/file/etc. +- [x] **`--memory MODE` 䫠 sprinter-cc**: parser + per-mode 䮫 CODE_LOC/DATA_LOC, override १  `--code-loc`/`--data-loc`. tiny ࠡ⠥; small/big/huge warning' (runtime ⮢). 2026-05-30. +- [x] **`--memory-manual SPEC`**: `CODE=W1|W2,DATA=W1|W2|SAME,BANKED=W1|W3`. 2026-05-30. +- [x] **`small` runtime**: `runtime/crt0_small.s` ᯮ ESTEX `$3D GETMEM` + `$3A SETWIN2` ⮡ 뤥 W2-࠭ gsinit. **** BIOS `$C4` ? ⥪ ⮬ ⠯ W1 (boot_stack HOME), BIOS ॡ ⥪ W2. ᫥ SP ४砥 0xBFFE, ⠭ flow. 2026-05-30, verified hello.exe. +- [x] **`small` auto-detect >16 KB ணࠬ**: `crt0_small.s` ⠥ `0xC2` (⥪ ࠭ W2 ? `0xA2`! W1). ᫨ 0xFF ? 뤥 page; DSS 㦥 ᤥ (ணࠬ ᠬ 뫥 W2). crt0 뢠 0..30 KB. mkexe ⠪ ࠧ蠥 HOME span W1+W2 (0x4000..0xBFFF). Verified hello: small (5 KB 䠩, SETWIN2 path) + 32 KB 䠩 (auto-skip). 2026-05-30. +- [x] **`big` runtime** (tiny + banked code W1): ࠬਧ `crt0_banked.s` + `bank.s` १ `.ifdef BANK_W1` ? 㣮 banking port (0xA2 vs 0xE2), 㣮 load-addr (0x4000 vs 0xC000). sprinter-cc prepend' `BANK_W1 = 1` `--memory big`, । `mkexe -B 0x4000`. ਬ `examples/banked_big/`. 2026-05-30. +- [x] **`huge` runtime** (small + banked code W3): merge W2-detect `crt0_small.s` `crt0_banked.s`. 騩 ਬ `examples/banked/` ⥯ ᯮ MEMORY=huge. 2026-05-30. +- [x] **`--debug` 䫠**: prepend `DEBUG_RT = 1` crt0 + `-DDEBUG_RT` sdcc. 뢠 symbol `_w2_self_allocated` (uint8_t) ? runtime diagnostic ஢ W2. 2026-05-30. + +### -襭 libc crt0 + +** `sprinter.lib`** ࠡ⠥ memory mode ? `.rel`-童 relocatable, SDLD dead-code elimination per-member ( 䨪  `gfx_core.rel` ..). Verified hello vs malloc_test १ map-䠩. + +**`gfx.lib` ⤥쭮 ? 㦥**: dead-code elimination 㦥 ࠡ⠥. + +**`libc_banked` (libc bank HOME)** ? ⮬, HOME (16 KB) user- + libc `huge` mode. १ `--codeseg BANK0` 樨 libc; trade-off: trampoline ~30 横 libc-맮. ਣ: ॠ쭠 ணࠬ HOME budget. + +**HW-ᨬ 㫨 ? `sprinter_home.lib` ⤥쭮.** libc 䨧᪨ W3, ⮬ W3: +- `gfx_*` ? `0xC000+` ᫥ swap W3 video page +- `bank_io` (mem_alloc_pages/bank_read/bank_write) ? swap' W3 १ `OUT (0xE2)` +- 騥 ISR ? 뢠 ਩ W3 㣮 + + huge mode 㫨 HOME (W1). 㤥 `libc_banked`, **६** 뤥塞 `sprinter_home.lib` (HOME-only) `sprinter.lib` (bankable). 쭠 奬: +``` +sprinter_home.lib HOME-only: gfx, bank_io, ISR shims +sprinter.lib bankable: printf, malloc, string, conio, stdio, env, ... +sprinter_banked.lib sprinter.lib --codeseg BANK0 ( huge) +``` +ਣ: ॠ `--memory huge` runtime. + +**crt0 ? mode:** +- `crt0.s` ? ⥪騩, **tiny/big**: SP=0xBFFE, argv (W2- 㦥 뤥 DSS). +- `crt0_minimal.s` ? ⥪騩, tiny argv. +- `crt0_small.s` ? **, step 3**: **small/huge**, W2 १ `mem_alloc_pages` gsinit, `0xA2`, ⮬ ⠭ flow. +- `crt0_banked.s` ? ⥪騩, **big**: trampoline-⠡ W3 , CODE W2. +- `crt0_banked_small.s` ? ****: huge = small (W2-alloc) + banked (W3 trampolines). + +sprinter-cc ࠥ crt0 `--memory` mode (ᥩ `--crt0=` override). +- [x] **ࠨ ࠧ ⥪**: 䫠 `sprinter-cc --stack-size BYTES`. Wrapper `heap_top.s` `___sdcc_heap_end = stack_top + 1 - stack_size`, ⤥ .rel per-program. Default ?1278 (heap_top=0xBB00) `runtime/heap_top.s`. 2026-05-30. + +䥩: `sprinter-cc --memory [tiny|small|big|huge|manual] [--memory-manual SPEC] [--stack-size N] foo.c`. `--memory-manual` ⮫쪮 `--memory manual`. + +## Known issues / quirks + +- **ESTEX $46 ENV API**: ? ࠡ⠥. - `DiskSyscalls.txt v1.6` 訡筮 뢠 return-status ? A=0 NOT FOUND, FOUND. 䨪஢ `memory/sprinter_platform.md`. + +## V2 (᫥ ५ v1) + +### Turbo-C-style graphics API (BGI-like) ? **MUST v2** + + `gfx_*` API ஢ **Turbo-C ``** (BGI) MS-DOS. +ணࠬ ਢ訥 Turbo-C ७ ᪨ 1--1. + +** ** ( ᭮ Borland BGI): + +Setup/teardown: +- `initgraph()` / `closegraph()` ? ᥩ `gfx_init`/`gfx_done`, alias +- `getmaxx()` / `getmaxy()` ? GFX_WIDTH-1 / GFX_HEIGHT-1 +- `cleardevice()` ? alias to gfx_clear +- `getgraphmode()` / `setgraphmode()` ? get_videomode/set_videomode + +Color/palette: +- `setcolor(c)`, `getcolor()` ? current draw color +- `setbkcolor(c)`, `getbkcolor()` ? background color +- `setpalette(idx, c)` ? entry +- `getpalette(&info)` ? read all palette + +Primitives ( 㦥 ? BGI- aliases): +- `putpixel(x, y, c)` ? gfx_putpixel +- `getpixel(x, y)` ? 㦭 ॠ (RMW ⭮ ? IN) +- `moveto(x, y)`, `lineto(x, y)`, `linerel(dx, dy)` ? current point + line drawing +- `line(x1, y1, x2, y2)` ? gfx_line +- `rectangle(x1, y1, x2, y2)` ? gfx_rect ( 㣮 API: x1,y1,x2,y2 vs x,y,w,h!) +- `bar(x1, y1, x2, y2)` ? gfx_fill_rect +- `bar3d(x1, y1, x2, y2, depth, topflag)` ? : rect + 3d edges +- `circle(x, y, r)`, `arc(...)`, `ellipse(...)`, `pieslice(...)` ? primitives +- `fillpoly()`, `drawpoly()` ? +- `floodfill(x, y, border_color)` ? + +Text on graphics screen: +- `outtext(s)` / `outtextxy(x, y, s)` ? gfx_text (alias) +- `settextstyle(font, dir, size)` ? multiple bitmap fonts +- `gettextsettings(&info)` +- `textwidth(s)` / `textheight(s)` ? measure + +Image manipulation: +- `imagesize(x1, y1, x2, y2)` ? bytes needed for getimage +- `getimage(x1, y1, x2, y2, buf)` ? save rect to buffer +- `putimage(x, y, buf, op)` ? paste back with COPY_PUT/XOR_PUT/AND_PUT/OR_PUT/NOT_PUT + +Clipping/viewport: +- `setviewport(x1, y1, x2, y2, clip)` ? drawing clip rect +- `getviewsettings(&info)` +- `clearviewport()` +- `setactivepage(p)` / `setvisualpage(p)` ? ਧ (Sprinter 2 screen) + +Line style: +- `setlinestyle(style, pattern, thickness)` ? SOLID_LINE / DOTTED_LINE / etc. +- `getlinesettings(&info)` + +**Acceptance:** ७ ⨯筮 Turbo-C BGI ணࠬ (饩 ᯮ짮 +moveto/lineto/circle/bar/setcolor) ࠡ ⢥ ࠢ. + +**Notes:** +- BGI fonts (TRIPLEX/SANS_SERIF/GOTHIC) ? BIOS font, ⠫ 㦭 + ( bitmap data lib) +- imagesize/getimage/putimage ? ᠬ ॡ game/animation +- Active/visual page ( ਧ) ? Sprinter ন 2 graphics pages, + 㦥 API switching + +. ⠪ `examples/` Turbo C 2.x BGIDEMO reference 㦭. + +### IM2 Interrupt Handlers ? **MUST v2** + +User- ISR १ Z80 IM 2 mode. 㦭 : +- Timer ticks (50 Hz frame counter, ) +- Music playback (AY, COVOX) +- Real-time games (input + game logic + render interrupt-driven) +- Async keyboard / mouse handling + +**Status:** v2. research + design `docs/im2_isr_design.md`. + +**襭 ⥪:** ॠ ⤥ memory mode `--memory im2` +( ⮣ ⮡ 騥 crt0). Detail' design-doc. + +** research'** ( ⥪ `docs/im2_isr_design.md`): +- Vector 0xFF ? frame + keyboard + CBL. Disambiguation ⠬ 0x19 / 0xFE +- Mouse hardware-IRQ 室 ( ⥪饩 ) +- Vector table / ISR / stack W2 (0x8000..0xBFFF) +- DSS ᢮ IM 2 handler ? 㦭 chain' ( / SYSTIME ) + +### 稥 㯭 㭪 v2 + +- [ ] **FILE API rewrite ? buffered streams** ? ⥪ ॠ + `libc/stdio/file.c` provisional unbuffered shim ( fputc/fgetc + = read/write syscall). 㦭 業 buffered ᥬ⨪ + Solid-C: + + ```c + typedef struct { + uint flags; // +0..1 file status flags + int level; // +2..3 empty/fill level of buffer + char *curp; // +4..5 current active pointer + int fd; // +6..7 underlying low-level fd + char *buffer; // +8..9 data transfer buffer + char hold; // +10 ungetc byte if no buffer + short token; // +11..12 reserved + char dummy; // +13 reserved + } FILE; + ``` + + stdin/stdout/stderr ? fd-થ `0 / -1 / -2`. ⥫ + stdout/stderr ࠭ ७: ESTEX OPEN positive + small fd (1, 2, ?) 筮 䠩 ? ᫨ stdout=1, ॠ + fd=1 ⠫ 䨪஬. fd=0 stdin ᭮ + (ESTEX 0 頥). fd । syscall' ? + ᯥਧ 䫠 `_F_CONIN/_F_CONOUT`. + + ਭ-⮪ (stdaux/stdprn) ॠ㥬 ? Sprinter ਭ୮ + API . + + ୠ⨢ ? ॠ third_party/solid-c (sources + `SRC/CLIB/`); ⠬ ⮢ buffered FILE + fopen/fread/fwrite/ + fseek/setvbuf .. ஢ 訬 open/read/write/lseek. + + rewrite deferred issues stdio-review: + - `fwrite` short-write ⠢ `_F_ERROR` + - `fgets(buf, 1, fp)` ? ⠭ "empty string", 㫨 NULL + - `mode_to_flags` ? break-out '+' (cosmetic) + +- [ ] **Audio API** ? AY-3-8910 + COVOX १ 뢠 (ॡ IM2) +- [ ] **ISA-8 slot support** ? ZX-Bus (sound, network, etc.) ? ॡ IM2 + ⥭ port + +## 稥 (v1 backlog, 騥) + +- [x] **#9: text I/O split (Turbo-C style)** ? stdio (puts/printf/putchar) ⥯ fast no-attr १ PCHARS/PUTCHAR. conio (cputs/cprintf/putch) ਬ attr १ textcolor/textbackground/textattr. KEEP_EXIST_ATTR ? conio fallback fast path. Verified hello.exe. . `memory/text_output_api_split.md`. 2026-05-31. +- [x] **Mouse API ** (१ driver, RST 30h) ? 14 㭪権 (init/show/hide/refresh/read/goto/bounds/text_cursor/load_cursor/get_cursor/get/set_sensitivity/video_mode_changed). . `memory/mouse_api.md`. Verified MAME 2026-05-31. Sensitivity = divider ( = ॥). +- [ ] Interrupt handlers ? IM 2 vector table HOME user ISR' +- [ ] প `restore SP on EXIT` ( z88dk +pps) ? ஢ 㦭 +- [ ] CI: ⮬᪨ ᪠ MAME `-aviwrite` screenshot-ࠢ, ⮡ ਬ஢ 室 祫 + +## ⮬ + +- প `` ( SDCC stdlib ? 㦭 ஢ crt0 ᮢ⨬) +- `` १ ESTEX SYSTIME (`$21`) CMOS BIOS-㭪樨 +- ZX Spectrum-ᮢ⨬ ० ⤥ target ( ஢ ᯥ㬮᪨ ணࠬ) +- প ZX-Bus (sound, network, etc.) ? 㦭 ࠩ +- Profile-guided optimization tools (hot/cold detection) 㯭 ணࠬ + +## Linker duplicate-symbol warnings (, 䨫஢) + + ᮧ⥫쭮 overrides' SDCC z80.lib 㭪樨 ᮡ⢥ ᨥ `sprinter.lib`, `sdldz80` `?ASlink-Warning-Definition of public symbol '...' found more than once`. ࢮ । (), ⮬ ४⭮ ? warning ⮫쪮 noise. + +騥 overrides: +- `_puts` ? १ PCHARS+\r\n vs SDCC posix puts +- `___sdcc_heap` ? heap W2 vs SDCC's ⠭ +- `_asctime`, `_localtime` ( 㣨 time) ? `posix_time.c` १ ESTEX SYSTIME vs SDCC's `time.rel` `_RtcRead` + +**饥 襭:** `bin/sprinter-cc` 䨫஢뢠 warning- (warning + 2 follow-up `Library:` ப) 뢮 `sdcc`. १ `-v` (verbose) 뢠. १ awk-pipe. + +** 襭:** +- ३ explicit `--nostdlib` + 筮 ᯨ᮪ 㦭 㫥 z80.lib (string, math, stdlib override') ? warning', ᪨஢ +- : २ `_puts` ? `_puts_sprinter` + alias १ linker flag ( 㢥७ SDCC ন) +- : ⠢ ᥩ (ࠡ祥 benign) ? ਮ + +## TODO: ஢ ॠ쭮 + +- [ ] **Port_Y banking trick** (`docs/part2/SprinterGraphics programming.txt`): + ⢥ত ᫥ `OUT (0x89), Y` 0xC000+0x400*N W3 + ப Y..Y+15 ( ணࠬ஢ ? 16 ப). + Empirical 2026-06-01 MAME 0.283 trick ** ࠡ⠥** ? ᥫ + ᠬ 0xC000+row_width 室 . ᪨ + `docs/samples/plasma2.asm` ⮦ ᯮ banking, ⠭ + Port_Y per row. + : + 1. ॠ쭮 Sprinter + 2. dual-write (`_gfx_putpixel_raw` + ன write `0xD000+x`) + 3. ᫨ ? MAME, issue + ९ + 4. ᫨ ⮦ ? 㬥 , 㤠 㯮 + ⠢ ⥪ ॠ (Port_Y per pixel) + 5. ᫨ banking ࠡ⠥ ? ஢ Port_Y + `_gfx_putpixel_raw` (sentinel out-of-range, . memory/gfx_port_y_banking.md) + + 易 먣 Bresenham (60-pixel ) ? 8? + OUT (0x89) 権, `gfx_fill_rect 320x256` ? 16? . + release v1. + +## GFX: ७ `docs/part2/accelerator_doc.txt` + +᫥ ⥭ ⠫쭮 accelerator doc  ࠢ. + ᯮ ⮫쪮 ਧ⠫/⨪ Fill mode. + +### Quick wins ⥪ primitives + +- [ ] ** SMC `LD A, (var)` block-size**. 㬥  + ࠧ蠥 `LD A, (HL)`, `LD A, (BC)`, `LD A, (DE)` ( `LD A, r`). + 㡥 SMC complexity `gfx_lines.c:hfill_chunk/vfill_chunk` + `gfx_16.c:g16_hfill_chunk`. 饭 ⮫쪮 register-to-register. +- [ ] **஢ block-size**. 㬥 뢠 accel + block size bursts (. `Horizontal_Line_Fill`: ⠭ + size + `LD B,B` ⪫祭, ⮬ Fill mode ᯮ + ࠭ size). `gfx_fill_rect` 100 묨 + ப ? ⠭ size 1 ࠧ, 100. + +### Bank-prefix modes (port 0xE2 bits) + +㬥 뢠 ਠ ࠭ ⠭⭮ 0x50: + +| Bank byte | Effect | +|---|---| +| 0x50 | Normal write ? shadow + | +| 0x54 | "no copy in main shadow RAM" | +| 0x58 | **"FF is transparent"** ? 0xFF write ⠢ background | +| 0x5C | both | + +Bank 0x58 祬 mouse cursor 0xFF-஧筮. + **sprite-blending १ accel block copy**: + +- [ ] **`gfx_set_bank_transparent(on)`** 䫠 `gfx_set_bank` + 롮 0x50/0x58 ᮢ sprite' +- [ ] ᯮ짮 `gfx_blit()` ⮡ 䠪 + transparent sprites १ accel- + +### Block copy mode (sprite blit') + +`LD L,L` (horizontal) `LD A,A` (vertical) ? ० ஢ १ +256- accel memory. blit'. + +- [ ] **`gfx_blit(src_data, x, y, w, h)`** ? ஢ sprite' + (ந ࠧ, १ accel) +- [ ] **`gfx_blit_transparent(src, x, y, w, h)`** ? ᯮ짮 bank 0x58 + +. `Draw_Restangle_Data` accelerator_doc.txt ७. + +### AND / OR / XOR operations १ accel + +㬥 뢠 accel ন ᪨ 樨 +. ਬ: +- XOR ? (뤥 selection UI) +- OR / AND ? masking, alpha-style blending +- . ਬ accelerator_doc.txt: "256 bytes block coding via XOR" + +- [ ] **`gfx_xor_rect`** / **`gfx_or_rect`** / **`gfx_and_rect`** ? + ਬ⨢ ᪨ 権 אַ㣮쭨 +- [ ] **`gfx_invert_rect(x, y, w, h)`** ? alias xor 0xFF + +### Bitmap fonts ࠧ ࠧ஢ + + `gfx_text` / `gfx_putchar` प ࠡ 8?8 ⮬ +(BIOS WIN_GET_ZG 頥 256?8 ). UI / 쭨 +㦭: +- [ ] **`gfx_set_font_size(w, h)`** ? ४ ਭ/ glyph' +- [ ] **`gfx_set_font_data(ptr, w, h, advance)`** ? 㪠⥫ + 짮⥫᪨ + ࠧ +- [ ] প **proportional** (advance != w) ⮢ ? + array advance[256] ਭ glyph' +- [ ] **Big-font ०**: 8?16, 16?16, 16?8 ( 쭨) +- [ ] ⤥ API `gfx_text_ex(x, y, str, font_id)` + font_id 롨ࠥ 㦥 ⮢ +- [ ] **Anti-alias 2-bit ** ( 䮭 / ࠭ / 2- alpha?) + ? far future, smooth UI + +## ⠯ ⨬権 ( ᥩ) + +- **`gfx_line` १ accel ** ? Bresenham |dy| << |dx| ( ) 뤠 runs Y ( X): ᥫ, ᥫ, ᥫ, 蠣 Y, ᥫ, ᥫ... ⠪ run ? ⮢ 㬥 `gfx_hline` ( `vline`). + ᫥: runs 㭪 ; run length, ஬ 룮 accel hline 祬 N?putpixel (overhead accel ~20?s, putpixel ~5?s ? accel 룮 run ? 4-5 px); (dx ? dy) ⠢ Bresenham, ? run-length-based fill. + `gfx_line` orthogonal cases 㦥 १ accel ? ⨬஢ ⮫쪮 . + +- **`gfx_fill_rect` W3-swap ** ? ᥩ ७ `gfx_hline`/`gfx_vline` ᢮ DI/save-W3/restore-W3/EI. ᤥ internal `_fill_rect_inner` ন W3 DI 横; ~20?s ? ⢮ ப/⮫殢 . ਬ ᥬ ਬ⨢. +# MDView ? ᬮ騪 Markdown Sprinter + +**MDView** ? ணࠬ ᬮ 㬥⮢ ଠ *Markdown* +Sprinter ( Z80). 㬥 ࠭ ⤥쭮 W3 +᭮ RAM ணࠬ. + +## + +- 㬥 **128 ** (8 ࠭ EMM 16 ) +- **16 384** ࠭ ப +- ⮬᪨ ७ ᫮ ਭ ࠭ (80 ⮫殢) +- ਧ⠫ ᤢ ப ப ( , ⠡) +- -: 䠩, ப, 業 ப⪨ +- ப ﭨ ६ 㧪 樨 +- প ?? ᪫ ப + +## + +``` +mdview [_䠩.md] +``` + +᫨ 䠩 , 㦠 `README.MD`. + +## ࠢ + +``` + ⢨ + +Up Down ப⪠ ப / +PgUp PgDn ப⪠ ࠭ (30 ப) +Home 砫 㬥 +End 㬥 +Left Right ਧ⠫ ᤢ (⮫쪮 nowrap-ப) +F1 ࠢ +F8 ஢: CP866 ? CP1251 ? KOI8-R ? UTF-8 ? ... +F10 / Esc 室 ணࠬ +``` + +஢ । ⮬᪨ ⨨ (BOM + ⨪ + 4 ); `F8` ४砥 , ᫨ ⥪ 訡. +8- ஢ (CP866/CP1251/KOI8-R) ४ (६ +ᮢ). ன / (ਬ UTF-8) ந ? +ࢮ ४祭 (⪠ 㧠 ᯨ஬), . + +## ⠪ Markdown + +### + +ন ஢ H1?H4. ஢ H5 H6 ⮡ࠦ H4. + + # ࢮ ஢ + ## ண ஢ + ### 쥣 ஢ + #### ⮣ ஢ + +### ⮢ ଠ஢ + +** ⥪** 뤥 묨 񧤮窠: `**⥪**` + +*ᨢ* 뤥 묨 񧤮窠 `*⥪*` ન `_⥪_` + +`஥ ` 砥 묨 窠 + +~~ભ ⥪~~ ? ⨫: `~~⥪~~` + +### 㬥஢ ᯨ᮪ + +થ `-`, `*` `+`: + +- 㭪 ᯨ᪠ +- ன 㭪 ᯨ᪠ +- ⨩ 㭪 筮 ⥪⮬, 室 + 㤥 ७ ᫥ ப ࠭ 㯠 + +### 㬥஢ ᯨ᮪ + +1. +2. ன +3. ⨩ + +### + +> 稭 ᨬ `>`. ᪮쪮 ᫥⥫ +> ப ᪫ ⮬᪨ +> ७ᮬ ᫮. + +### (verbatim) + + 砥 ன 窨. +⥪ ⮡ࠦ ? ? ࠧ Markdown: + +``` +#include +#include + +int main(void) { + puts("Hello, Sprinter!"); + return 0; +} +``` + +### ਧ⠫쭠 + + ᨬ `---`, `***` `___` ⤥쭮 ப: + +--- + +## 孨᪨ ࠪ⨪ + +- **ଠ:** Sprinter, Z80 @ 21 +- **஢:** CP866 / CP1251 / KOI8-R / UTF-8 (⮮।, `F8`) +- **ᨬ ࠧ 䠩:** 128 +- **ᨬ쭮 ᫮ ப :** 16 384 +- **ᨬ쭠 ப ७-:** 255 祥 (. ࠭祭 ) +- ** :** small + - ணࠬ, c⥪, , ? a W1-W2 (32 , 0x4000?0xBFFF). + - 䠩 ? ࠭ EMM, ⮡ࠦ W3 (0xC000?0xFFFF) + +## ࠭祭 + +### ப MD-० ? 255 祥 + +- ࠭ ப ** 255 (ᨬ, ਡ)** +? ⠭ `MAX_CACHE_LINE_LEN`. ⨯: `g_ncells` +`cache_rec_t.len` ? `uint8_t`. ᠥ ப, ⭥ ᥣ +**ਧ⠫쭮 ஫㥬** ப ( ப ⠡, 䫠 +`IF_HSCROLL`), MD-० ࠢ. + +** ந室 ப:** 樨 `gc_put()` +뢠 祩 ᫥ 255- (`if (g_ncells < MAX_CACHE_LINE_LEN)`). + ⮫쪮 255 祥, ⮪ **** ? +஫ ** થ १** 255- 樨 (થ `>` 砥 +? । ?). ९ ? `gc_put` ஢ ࠭. + +: ?255 祥? ? **७७ ਭ**, 室. + ࠧ稢 ஡ ( `TAB_STOP`), 祩 ⠡ +஡ ਭ + ࠬ `` ? ⮬ ⨣ ࠭, 祬 +255 ?? ᨬ. + +> **RAW-० (`F2`) ⮣ ** ? אַ 䠩 +> ⮢, ப 楫 (१ wrap `F3` ਧ. ஫). + +** ** (業, ॠ) ? `uint16_t`: +- `cache_rec_t.len` `uint8_t?uint16_t` ? **஢ 8 ** + (len ꥤ pad-), `idx<<3` . ᯫ⭮. +- `g_ncells` / `g_ncells_at_space` ? `uint16_t` ? 業 **/᪮**: + 16-⭠ 䬥⨪ Z80 祬 `gc_put` (맮 祩) + scan-横. ਥ: **+0.2?0.4 ** + 樨. +- `g_cells[MAX_CACHE_LINE_LEN*2]` near-RAM (W2) ? 業 + ****: `2 ? ` . 510 ; 512 ? +0.5 , 1024 ? +1.5 . + EMM- ⥭ (1 ) ப ﭥ ? 㧪 near. +- `viewport_x` ( `docset_t`) + ⮫ `max_vx` (ᥩ 248) ? `uint16_t`, + ࠭ >255 , ஫ . `widths[]`/`ccx` ⠡/. + + ஬ ? 512?1023: 墠 ᥬ ⨭/⠡栬, + 業 ~+0.3 +0.5?1.5 near-RAM. ** 㬥 `uint16_t`** ? + ⠢ થ १ 255- 樨, ⮡ 뫠 . + +## TODO + +1. **祭 ࠧ 㬥⮢.** 128 : 筮 + ࠧ ࠡ 訬 - ࠭ , ஢ + ࠡ 8- ࠭栬 16. + +: ଠ஢ ⠡ ࠬ; প ஢ +CP866 / CP1251 / KOI8-R / UTF-8 ⮮। ४祭 `F8` +(ன ந , ࢮ ४祭). + +4. **᪮७ ७ਭ.** ப ࠭. ⨬ 横 뢮 + ᨬ १ BIOS WRCHAR ( 뢮, DMA). + +--- + +*MDView v0.2 (c) 2026 ஢ ..* + + +--- + +# Sprinter C Compiler ? v1.0 + +C toolchain for **Sprinter** ? the Z80-based home computer by Peters Plus, running +ESTEX DSS. Host: macOS / Linux. Target: `.EXE` files in SprintEXE format. + +Built on top of **SDCC 4.5** (vendored in `third_party/sdcc/`). This repository adds +everything Sprinter-specific: crt0, linker integration, libc wrappers over ESTEX, +banked-call trampolines, graphics & accelerator API, mouse driver wrappers, and the +`mkexe` utility for producing SprintEXE images. + +## What you get + +* **`bin/sprinter-cc`** ? one-line driver: `sprinter-cc -o foo.exe foo.c` +* **Memory modes**: `tiny`, `small`, `big`, `huge`, `manual` ? see below. +* **stdio + conio**: printf, puts, putchar, getchar, fopen/fread/..., cprintf, cputs, putch, textcolor/textbackground/textattr, gotoxy, kbhit/getch. +* **Graphics**: 320?256?256 and 640?256?16 modes, accelerator-backed primitives (hline / vline / rect / fill_rect / line via Bresenham, plus clear), bitmap-font text in both modes via BIOS character generator. +* **File I/O**: POSIX (`open`/`read`/`write`/`close`/`lseek`/`unlink`/`creat`), FILE\* streams (`fopen`/`fgets`/`fwrite`/...), directory listing (`ffirst`/`fnext`), `chdir`/`getcwd`/`mkdir`/`rmdir`, `stat`/`fstat`. +* **Memory**: 32 KB heap (W2-resident), banking-aware page allocator (`mem_alloc_pages`/`bank_read`/`bank_write`), explicit memory modes for sub-16 KB programs. +* **Mouse**: full Sprinter driver wrapper (14 functions including custom cursor bitmaps). +* **Environment**: `getenv`/`putenv`/`sysenv` over ESTEX `$46`. +* **Time**: `getdatetime`/`setdatetime` + POSIX `time`/`localtime`/`mktime`/`asctime`/`ctime`. +* **Misc**: `errno`/`strerror`/`perror`, `atexit`, `setjmp`/`longjmp`, `sleep`, full argv parsing in crt0. + +## Quick start + +```sh +git clone sprinter-c +cd sprinter-c +make sdcc # one-time: fetch SDCC 4.5 binary (~25 MB) +make all # build mkexe + libsprinter.lib + 27 examples +make floppy # pack everything into mame/v306/IMG/mc.img +cd mame/v306 && ./run_mame.sh # boot Sprinter in MAME +``` + +Compile a single program: + +```sh +cat > hello.c < +int main(void) { puts("Hello, Sprinter!"); return 0; } +EOF + +bin/sprinter-cc -o hello.exe hello.c +``` + +That's it ? `hello.exe` is now a valid SprintEXE you can `RUN HELLO` from the ESTEX shell. + +## Memory modes + +Sprinter's address space is four 16 KB windows (W0 / W1 / W2 / W3). DSS allocates +pages by program size ? small programs get only one page. Pick a memory mode based +on what your program needs: + +| Mode | Code lives in | Banking | Use when | Note | +|---|---|---|---|---| +| `tiny` (default) | W2 (0x8100+) | no | code+data < 14 KB | | +| `small` | W1-W2 (0x4100+) | no | code+data < 30 KB | | +| `big` | W2 + W1 banking | yes (W1) | tiny + extra code modules | | +| `huge` | W1-W2 + W3 banking | yes (W3) | small + extra code modules | | +| `manual` | user-specified | optional | special layouts | Not implemented | + +```sh +sprinter-cc --memory small -o big.exe bigprog.c +sprinter-cc --memory huge -o app.exe main.c --bank 1=engine.c --bank 2=ai.c +``` + +Banked functions are declared with `__banked`: + +```c +void engine_tick(int dt) __banked; // lives in BANK1, automatically swapped +``` + +## Examples (27 total) + +| Example | What it demonstrates | +|---|---| +| `hello` | Hello world with stdio + conio Turbo-C-style colors | +| `argv` | argv parsing in crt0 | +| `cat` | File I/O ? read & print TEST.TXT | +| `seek` | 32-bit lseek over a 100 KB file | +| `ls` | Directory listing via ffirst/fnext | +| `filetest` | FILE\* streams (fopen/fread/...) | +| `stattest` | `stat`/`fstat` on files and directories | +| `errno` | errno / strerror / perror | +| `mem_test` | Page allocator + bank\_read/bank\_write | +| `malloc` | Heap stress test (200+ allocations) | +| `banked` | Banked code in W3 (huge mode) | +| `bankedbg` | Banked code in W1 (big mode) | +| `banklocl` | Bank-local static data and BSS | +| `mouse` | Mouse driver in text mode | +| `gfx_mous` | Mouse with custom bitmap cursor in graphics mode | +| `gfx_demo` | 320?256?256 lines / rects / accelerator | +| `gfx_d16` | 640?256?16 same primitives | +| `gfx_text` | Bitmap-font text on graphics screen | +| `timedir` | Date/time + directory listing | +| `ptime` | POSIX time API | +| `openenv` | open() flags + environment vars | +| `conio` | conio API smoke test | +| `attrprob` | Probe Sprinter text attribute byte layout | +| `strtest` | string.h test (from SDCC's z80.lib) | +| `stdlib` | stdlib.h test (qsort / rand / strtol / etc.) | +| `assrtest` | assert() | +| `rt_test` | Runtime helpers (sleep, setjmp, atexit) | + +## Headers + +Standard: +* `` ? puts / printf / FILE\* + Sprinter-specific dec/hex helpers +* `` ? atoi / atof / malloc / qsort / ... (from SDCC z80.lib) +* `` / `` / `` ? from SDCC z80.lib +* `` ? read / write / close / lseek / unlink +* `` ? open / creat + O\_RDONLY / O\_CREAT / ... +* `` ? errno + error names + strerror +* `` ? stat / fstat +* `` / `` ? from SDCC + +Sprinter-specific: +* `` ? putch / cputs / cprintf, textcolor / textbackground / textattr, kbhit / getch, clrscr, gotoxy, wherex/y +* `` ? gfx_init/done, palette, putpixel, hline/vline/rect/fill_rect/line, text ? for both 320 and 640 modes (gfx_\*16 variants) +* `` ? full 14-function driver wrapper + mouse_cursor_t with bitmap support +* `` ? chdir / getcwd / mkdir / rmdir / ffirst / fnext / ffblk +* `` ? getdatetime / setdatetime + POSIX time / localtime / etc. +* `` ? raw ports, ESTEX/BIOS function numbers, env API +* `` ? exit / \_exit / atexit +* `` ? mem\_alloc\_pages / mem\_free\_block / bank\_read / bank\_write +* `` ? Solid-C compatibility layer (aliases + BOOL/WORD/uint types) + +## Toolchain commands + +```sh +make all # build mkexe + lib + every example +make floppy # repack mame/v306/IMG/mc.img with all .exe files +make check # 17 mkexe unit-tests +make clean # remove all build artefacts +make sdcc # one-time: fetch SDCC 4.5 binary +``` + +### sprinter-cc options + +``` +sprinter-cc -o foo.exe foo.c [more.c ...] [options] + + --memory MODE tiny | small | big | huge | manual (default: tiny) + --memory-manual SPEC explicit placement (CODE=W1|W2,DATA=W1|W2|SAME,BANKED=W1|W3) + --stack-size N bytes reserved for the stack (default ~1278) + --crt0=TYPE default | minimal | banked | small + --bank N=FILE.c compile FILE.c into bank N (repeatable, max 15) + --debug enable runtime diagnostics (defines DEBUG_RT) + -I PATH extra include path + -L 0xADDR / -E / -S override load / entry / stack addresses + -Wl FLAG pass FLAG to sdldz80 + --mkexe FLAG pass FLAG to mkexe (e.g. --mkexe -p --mkexe 0 for bank padding) + -v verbose +``` + +## Status + +What works in v1.0: +* Compile / link / pack to SprintEXE ? verified on all 27 examples +* Four memory modes (tiny / small / big / huge) +* Graphics (both modes) with accelerator +* Mouse (text + graphics cursor) +* File I/O, directories, environment, time +* All headers listed above + +Deferred to v2.0 (see `docs/TODO.md`): +* **Turbo-C-style BGI graphics API** ? `initgraph` / `setcolor` / `circle` / + `getimage` / `putimage` / etc. on top of our `gfx_*` primitives +* Remaining Solid-C compatibility gaps (Phase 2/3) ? see `docs/solid_c_compatibility.md` +* Manual memory mode +* Rewrite FILE\* stream API (current implementation is very primitive and doesn't use buffers) + +Deferred to v3.0: +* **IM2 interrupt handlers** ? research complete (`docs/im2_isr_design.md`), + implementation scheduled for v3 +* **Audio API** (AY-3-8910 + COVOX) ? requires IM2 +* **ISA-8 slot drivers** ? requires IM2 (???) + +## Documentation + +* `docs/TODO.md` ? roadmap and open work items +* `docs/solid_c_compatibility.md` ? gap analysis vs Solid-C 2004 +* `docs/im2_isr_design.md` ? interrupt handler design (v2) +* `docs/converted/` ? source documentation (ESTEX, BIOS, architecture) + converted to plain text for `grep` +* `docs/reference/`, `docs/samples/`, `docs/memory management/` ? original + Russian docs and code samples from Peters Plus + +## Repository layout + +``` +bin/sprinter-cc one-line compiler driver (bash) +toolchain/mkexe/ host-side tool: .ihx -> .exe SprintEXE +toolchain/check_banks.py post-link bank size enforcer +runtime/ crt0 variants (default, minimal, small, banked) + bank trampolines, heap, heap_top +libc/include/ headers +libc/io|stdio|mem|gfx/ C and asm sources for libsprinter.lib +lib/ Makefile that archives libsprinter.lib via sdar +examples/ 27 example programs +mame/v306/ MAME binary + Sprinter ROM/HDD images + floppy script +third_party/sdcc/ vendored SDCC 4.5 (fetched via `make sdcc`) +third_party/solid-c/ reference: original Sprinter native C (for compat target) +docs/ documentation +``` + +## License + +This repository contains: +* Original code in `bin/`, `toolchain/`, `runtime/`, `libc/`, `lib/`, `examples/` ? + MIT-licensed. +* `third_party/sdcc/` ? SDCC 4.5 under GPLv2 with linking exception + (see `third_party/sdcc/COPYING.txt`) +* `third_party/solid-c/` ? original Sprinter Solid C, used only as a reference + +## Credits + +* **Sprinter / Peters Plus** ? , ਩ ਭ and the original team +* **SDCC** ? for the underlying Z80 compiler +* **MAME** ? for the Sprinter Sp2000 emulation + +--- + +For questions / patches: see CONTRIBUTING.md (TBD) or open an issue. + +--- + +# TODO / Roadmap + + 浪 뢠 ਮ.  ॠ ணࠬ ? ਮ ᬥ. + +## ⠯ 5 ? malloc / free + banking-aware page allocator ? + +- [x] SDCC's `malloc`/`free` + `runtime/heap.s` ( library heap.rel, 14000- heap 2) +- [x] `libc/mem/mem_alloc.c` ? page allocator: `mem_alloc_pages`/`mem_free_block`/`mem_get_page`/`mem_info` १ ESTEX `$3C/$3D/$3E` + BIOS `$C4` +- [x] `libc/mem/bank_io.c` ? HOME-१ `bank_read`/`bank_write`/`bank_load_byte`/`bank_store_byte` ᢮ W3 +- [x] `examples/malloc_test/` ? ஢ઠ SDCC's malloc (~210 64- allocations १ heap) +- [x] `examples/mem_test/` ? ஢ઠ page allocator: 3 ࠭, ࠧ १ bank_write, 䨪 १ bank_read + +## ⠯ 6 ? argv parsing + sprinter-cc wrapper ? + +- [x] crt0 ESTEX command-line IX-prefix (inline asm `runtime/crt0.s`) +- [x] Strip leading CP/M-style space (DSS quirk) +- [x] । `argc`/`argv` main() १ HL/DE (SDCC __sdcccall(1) ABI) +- [x] argv[0] = basename .EXE १ ESTEX APPINFO ($47 subfn 2) +- [x] `runtime/crt0_minimal.s` ? opt-out 祭 쪨 ணࠬ +- [x] `runtime/crt0_banked.s` ? ⥯ ⮦ argv (parse_argv + get_progname ᪮஢ crt0.s; 㤥 factored argv.s libsprinter.lib) +- [x] Bash-⪠ `bin/sprinter-cc`: `sprinter-cc -o foo.exe foo.c` ப +- [x] প 権: `--memory`, `--memory-manual`, `--stack-size`, `--crt0=`, `--bank N=FILE.c`, `--debug`, `-I`, `-L`/`-E`/`-S`, `-Wl`, `--mkexe` + +## ⠯ 8 ? 䨪 (320?256?256 + 640?256?16 + accel + bitmap font) ? + +- [x] **8a** Graphics core: `gfx_init`/`gfx_done`/`gfx_clear`/`gfx_putpixel`/`gfx_pal_load`/`gfx_pal_set` (libc/gfx/gfx_core.c). १ BIOS PIC_SET_PAL ($A4). Verified 320?256?256. +- [x] **8b** /אַ㣮쭨/fill १ accelerator (libc/gfx/gfx_lines.c): `gfx_hline`/`gfx_vline` १ accel Fill (LD C,C / LD E,E + SMC block-size), `gfx_rect`/`gfx_fill_rect` heuristic 롮஬ ਥ樨 (h/v bursts count), `gfx_line` Bresenham . `gfx_clear` ⮦ ९ᠭ column-major accel (~4? ॥). +- [x] **8c** 640?256?16 mode (libc/gfx/gfx_16.c): `gfx_*16` API, HIGH nibble = LEFT pixel (㬥 misleading), per-row RMW vline ( = 2 ਧ⠫ ᥫ). +- [x] **8d** Bitmap font + gfx_text (libc/gfx/gfx_text.c): १ BIOS WIN_GET_ZG ($B8), interleaved layout `font[row*256+char]`, `gfx_text`/`gfx_putchar` 320 mode, `gfx_text16`/`gfx_putchar16` 640 mode pair-table lookup. + +. memory/sprinter_graphics.md, sprinter_accelerator.md, sprinter_graphics_16.md, sprinter_font_format.md. + + ( ): +- [ ] -quad 640: per-cell (mode 0x82 ࠧ蠥 1 4 per 16?8 cell) ? १ אַ area-ᠭ ࠭ 0x0300..0x039F + +## Auto-banking (. `memory/banking_roadmap.md` ⠫) + +Phase 1 ? file-level bin-packing ? ॠ뢠 ஥ ~30 KB . + +- [ ] `toolchain/auto_bank.py`: + - ࠧ `.rel`-䠩 ( .map ᫥ dry-run link') + - First-fit-decreasing bin-packing + - `#pragma codeseg BANKn` manual override + - ५뢠 묨 `-Wl-b_BANKn=...` ࠬࠬ + - ⠥ । + +Phase 2-5: incremental rebalance, declarative `banks.toml`, function-level, call-graph-aware. 쪮 ᫨/ . + +## Bank-local static data (mutable data ⮬ ) ? ? + +- [x] ਬ `examples/bank_local_data/` ? 㭪 BANK1 ᢮ writable BSS array + const table + malloc- +- [x] `mkexe -p 0` 㫥 padding (BSS-storage 㧪) +- [x] ᪨ 楯: `--codeseg BANK1 --constseg BANK1 --dataseg BANK1` bank1.c + `-Wl-b_BANK1=0x1C000` . **`--dataseg BANK1` ** ? ࠭ ⭮ - trampoline bug ᪨஢ १. +- [x] ** 䨪 trampoline'a runtime/bank.s** ? `pop af; out (n), a` ਫ A ? banked-㭪樨 騥 uint8_t 頫 . `pop bc; out (c), b` ࠭ A. +- [x] **malloc banked-㭪樨 ࠡ⠥ ஧筮** ? heap W2 (HOME), W2 ᢠ trampoline', pointer  ⥪. . memory/bank_local_data_pattern.md. +- [x] 㬥 memory: `memory/bank_local_data_pattern.md` ( 楯 + malloc + nuances), `memory/sdcc_banking.md` (trampoline fix) +- [ ] 樮쭮 ? `check_banks.py` ⮡ 뢠 ࠧ size = code + const + bss per bank (cosmetic) + +祬: 㫥 訬 private state (level loader, audio engine, scene data). W2 heap , ⨪ . + +## ᪠ solid-c (⨢ Sprinter C ? `third_party/solid-c/`) + +᫥ solid-c'᪮ libc (. `memory/solid_c_findings.md`)  ⮢ ᫥ 㭪権. ਮ **᮪** : + +### High-priority gaps ( ஢, 짠) +- [x] **`errno` + `strerror`/`perror`** ? ⠡窠 32 訡 (libc/io/errno.c) +- [x] **७ `open()`** O_CREAT/O_TRUNC/O_APPEND/O_EXCL state machine +- [x] **`atexit`** ? 8-callback LIFO + `exit()` + `_exit()` (libc/io/atexit.c) +- [x] **`setjmp`/`longjmp`** ? 6- jmp_buf={sp,ix,pc} (libc/io/setjmp.c) +- [x] **`sleep(seconds)`** ? 50Hz halt-loop (libc/io/sleep.c) +- [x] **ESTEX ENV API** ($46, getenv/putenv) ? libc/io/env.c. 竨 doc-bug: ॠ쭮 A=0 NOT FOUND + +### Medium-priority (㦭 shell-like ⨫) +- [ ] **Mouse driver** ? `rst $30h`, 17 㭪権. **砫 ࠡ⠥ MAME**. +- [x] **`ffirst`/`fnext` + ffblk_t struct** directory listing ? ॠ, demo: ls.exe +- [x] **`getdatetime`/`setdatetime`** १ ESTEX $21/$22 ? libc/io/time.c, demo: time_dir_test +- [x] **`chdir`/`getcwd`/`mkdir`/`rmdir`** ? wrappers ESTEX $1B-$1E ? libc/io/fsdir.c +- [x] **conio: `kbhit`/`getch`/`getche`/`cputs`/`clrscr`/`gotoxy`** ? ॠ +- [x] **conio extras**: `wherex`/`wherey` ($53), `wrchar`/`rdchar` ($58/$57), `textmode_get/set` ($50/$51), `clrscr_attr` ($56) + COLOR macros + +### Low-priority ? ? FILE* stack + +- [x] ** unbuffered FILE\*** ? `libc/stdio/file.c` + `libc/include/stdio.h`. fopen/fclose/fputs/fgets/fread/fwrite/fseek/ftell/rewind/feof/ferror/clearerr/fflush + stdin/stdout/stderr pseudo-streams. . `memory/file_star_design.md` `examples/filetest`. +- [ ] fprintf / fscanf ? 㦭 printf-१-callback machinery. 짮⥫ `sprintf(buf, ...) + fputs(buf, fp)`. +- [ ] 樮 buffered mode (setvbuf, line/block buffering) ? ᫨ - . + +### POSIX time API ? ? +- [x] `libc/io/posix_time.c` ? time/localtime/gmtime/mktime/asctime/ctime getdatetime. SDCC's time.rel ( override _RtcRead). . `examples/ptime`. + +### sys/stat ? ? +- [x] `libc/io/stat.c` ? POSIX stat/fstat. ਤ open+fstat 䠩, ffirst+iter ( "."/".."). . `examples/stattest` `memory/estex_ffirst_dotdot.md`. + +### assert ? ? (ᯮ㥬 SDCC's __assert १ fallback include path) + +## libc/stdlib ? ? 㦭 (. memory/sdcc_stdlib_works.md) + +஢७ १ `examples/stdlib_test/`: SDCC z80.lib ᮤন ࠡ騥 ॠ樨: +- `atoi/atol/atof, strtol/strtoul, rand/srand, qsort/bsearch, abs/labs, div/ldiv` +- `` (memchr/cmp/set/cpy, strcat/cmp/cpy/len/chr/spn/etc.) +- `` (toupper/tolower) +- `` (sinf/cosf/sqrtf/etc.) + + ⮬᪨ ﭥ z80.lib 㦭. ** ९뢠**. + + Sprinter-specific 易⥫ 㫨 : atexit, env, errno, setjmp, putchar/puts/getchar, conio, fsdir, time, mouse, open/read/lseek/close. + +## Build-system: libsprinter.lib + sprinter-cc ? ? + +- [x] `lib/Makefile` ? ᮡࠥ libc/*.c `.rel`, 娢 १ sdar `lib/sprinter.lib` +- [x] 砥 runtime/bank.s runtime/heap.s (auto-pulled __banked/malloc) +- [x] `bin/sprinter-cc` ? bash-wrapper: `sprinter-cc -o foo.exe foo.c` ப +- [x] প 権 `--crt0=default|minimal|banked`, `--bank N=FILE.c`, `-I`, `-L`/`-E`/`-S`, `-Wl`, `--mkexe` +- [x] `examples/hello_sccc/` ? : `hello.c` ᮡࠥ shell-맮, ࠧ ᮢ Makefile (925 ) +- [x] Split `putchar.c` ? `putchar.c` + `puts.c` per-function granularity (puts override SDCC's z80.lib version) +- [x] `make all` (ᨬ `lib` । `examples`) + + 襭 (樮쭮): +- [ ] ஢ ⠫ examples sprinter-cc Makefile (ᬥ⨪) +- [ ] 쭥 libc/*.c per-function ( ⥪ granularity 㦥 㦭 ࠧ ? .rel 楫, 設⢠ 䠩 㭪) + +## ⠯ 9 ? memory modes sprinter-cc + +DSS 뤥 ࠭ ࠧ ਫ: < 16 KB ? ࠭, ⠫ 砥 ?࠭ #FF? (read=0xFF, write ). - ⮣ CODE--W1 + DATA--W2 쪮 ணࠬ . . [memory/sprinter_memory_modes.md](../../.claude/projects/-Volumes-SAM8-Projects-DIY-Z80-Sprinter-C-Compiler/memory/sprinter_memory_modes.md). + +- [x] **`tiny`**: (CODE+DATA+⥪) W2. Default. Verified hello/argv/conio/malloc/file/etc. +- [x] **`--memory MODE` 䫠 sprinter-cc**: parser + per-mode 䮫 CODE_LOC/DATA_LOC, override १  `--code-loc`/`--data-loc`. tiny ࠡ⠥; small/big/huge warning' (runtime ⮢). 2026-05-30. +- [x] **`--memory-manual SPEC`**: `CODE=W1|W2,DATA=W1|W2|SAME,BANKED=W1|W3`. 2026-05-30. +- [x] **`small` runtime**: `runtime/crt0_small.s` ᯮ ESTEX `$3D GETMEM` + `$3A SETWIN2` ⮡ 뤥 W2-࠭ gsinit. **** BIOS `$C4` ? ⥪ ⮬ ⠯ W1 (boot_stack HOME), BIOS ॡ ⥪ W2. ᫥ SP ४砥 0xBFFE, ⠭ flow. 2026-05-30, verified hello.exe. +- [x] **`small` auto-detect >16 KB ணࠬ**: `crt0_small.s` ⠥ `0xC2` (⥪ ࠭ W2 ? `0xA2`! W1). ᫨ 0xFF ? 뤥 page; DSS 㦥 ᤥ (ணࠬ ᠬ 뫥 W2). crt0 뢠 0..30 KB. mkexe ⠪ ࠧ蠥 HOME span W1+W2 (0x4000..0xBFFF). Verified hello: small (5 KB 䠩, SETWIN2 path) + 32 KB 䠩 (auto-skip). 2026-05-30. +- [x] **`big` runtime** (tiny + banked code W1): ࠬਧ `crt0_banked.s` + `bank.s` १ `.ifdef BANK_W1` ? 㣮 banking port (0xA2 vs 0xE2), 㣮 load-addr (0x4000 vs 0xC000). sprinter-cc prepend' `BANK_W1 = 1` `--memory big`, । `mkexe -B 0x4000`. ਬ `examples/banked_big/`. 2026-05-30. +- [x] **`huge` runtime** (small + banked code W3): merge W2-detect `crt0_small.s` `crt0_banked.s`. 騩 ਬ `examples/banked/` ⥯ ᯮ MEMORY=huge. 2026-05-30. +- [x] **`--debug` 䫠**: prepend `DEBUG_RT = 1` crt0 + `-DDEBUG_RT` sdcc. 뢠 symbol `_w2_self_allocated` (uint8_t) ? runtime diagnostic ஢ W2. 2026-05-30. + +### -襭 libc crt0 + +** `sprinter.lib`** ࠡ⠥ memory mode ? `.rel`-童 relocatable, SDLD dead-code elimination per-member ( 䨪  `gfx_core.rel` ..). Verified hello vs malloc_test १ map-䠩. + +**`gfx.lib` ⤥쭮 ? 㦥**: dead-code elimination 㦥 ࠡ⠥. + +**`libc_banked` (libc bank HOME)** ? ⮬, HOME (16 KB) user- + libc `huge` mode. १ `--codeseg BANK0` 樨 libc; trade-off: trampoline ~30 横 libc-맮. ਣ: ॠ쭠 ணࠬ HOME budget. + +**HW-ᨬ 㫨 ? `sprinter_home.lib` ⤥쭮.** libc 䨧᪨ W3, ⮬ W3: +- `gfx_*` ? `0xC000+` ᫥ swap W3 video page +- `bank_io` (mem_alloc_pages/bank_read/bank_write) ? swap' W3 १ `OUT (0xE2)` +- 騥 ISR ? 뢠 ਩ W3 㣮 + + huge mode 㫨 HOME (W1). 㤥 `libc_banked`, **६** 뤥塞 `sprinter_home.lib` (HOME-only) `sprinter.lib` (bankable). 쭠 奬: +``` +sprinter_home.lib HOME-only: gfx, bank_io, ISR shims +sprinter.lib bankable: printf, malloc, string, conio, stdio, env, ... +sprinter_banked.lib sprinter.lib --codeseg BANK0 ( huge) +``` +ਣ: ॠ `--memory huge` runtime. + +**crt0 ? mode:** +- `crt0.s` ? ⥪騩, **tiny/big**: SP=0xBFFE, argv (W2- 㦥 뤥 DSS). +- `crt0_minimal.s` ? ⥪騩, tiny argv. +- `crt0_small.s` ? **, step 3**: **small/huge**, W2 १ `mem_alloc_pages` gsinit, `0xA2`, ⮬ ⠭ flow. +- `crt0_banked.s` ? ⥪騩, **big**: trampoline-⠡ W3 , CODE W2. +- `crt0_banked_small.s` ? ****: huge = small (W2-alloc) + banked (W3 trampolines). + +sprinter-cc ࠥ crt0 `--memory` mode (ᥩ `--crt0=` override). +- [x] **ࠨ ࠧ ⥪**: 䫠 `sprinter-cc --stack-size BYTES`. Wrapper `heap_top.s` `___sdcc_heap_end = stack_top + 1 - stack_size`, ⤥ .rel per-program. Default ?1278 (heap_top=0xBB00) `runtime/heap_top.s`. 2026-05-30. + +䥩: `sprinter-cc --memory [tiny|small|big|huge|manual] [--memory-manual SPEC] [--stack-size N] foo.c`. `--memory-manual` ⮫쪮 `--memory manual`. + +## Known issues / quirks + +- **ESTEX $46 ENV API**: ? ࠡ⠥. - `DiskSyscalls.txt v1.6` 訡筮 뢠 return-status ? A=0 NOT FOUND, FOUND. 䨪஢ `memory/sprinter_platform.md`. + +## V2 (᫥ ५ v1) + +### Turbo-C-style graphics API (BGI-like) ? **MUST v2** + + `gfx_*` API ஢ **Turbo-C ``** (BGI) MS-DOS. +ணࠬ ਢ訥 Turbo-C ७ ᪨ 1--1. + +** ** ( ᭮ Borland BGI): + +Setup/teardown: +- `initgraph()` / `closegraph()` ? ᥩ `gfx_init`/`gfx_done`, alias +- `getmaxx()` / `getmaxy()` ? GFX_WIDTH-1 / GFX_HEIGHT-1 +- `cleardevice()` ? alias to gfx_clear +- `getgraphmode()` / `setgraphmode()` ? get_videomode/set_videomode + +Color/palette: +- `setcolor(c)`, `getcolor()` ? current draw color +- `setbkcolor(c)`, `getbkcolor()` ? background color +- `setpalette(idx, c)` ? entry +- `getpalette(&info)` ? read all palette + +Primitives ( 㦥 ? BGI- aliases): +- `putpixel(x, y, c)` ? gfx_putpixel +- `getpixel(x, y)` ? 㦭 ॠ (RMW ⭮ ? IN) +- `moveto(x, y)`, `lineto(x, y)`, `linerel(dx, dy)` ? current point + line drawing +- `line(x1, y1, x2, y2)` ? gfx_line +- `rectangle(x1, y1, x2, y2)` ? gfx_rect ( 㣮 API: x1,y1,x2,y2 vs x,y,w,h!) +- `bar(x1, y1, x2, y2)` ? gfx_fill_rect +- `bar3d(x1, y1, x2, y2, depth, topflag)` ? : rect + 3d edges +- `circle(x, y, r)`, `arc(...)`, `ellipse(...)`, `pieslice(...)` ? primitives +- `fillpoly()`, `drawpoly()` ? +- `floodfill(x, y, border_color)` ? + +Text on graphics screen: +- `outtext(s)` / `outtextxy(x, y, s)` ? gfx_text (alias) +- `settextstyle(font, dir, size)` ? multiple bitmap fonts +- `gettextsettings(&info)` +- `textwidth(s)` / `textheight(s)` ? measure + +Image manipulation: +- `imagesize(x1, y1, x2, y2)` ? bytes needed for getimage +- `getimage(x1, y1, x2, y2, buf)` ? save rect to buffer +- `putimage(x, y, buf, op)` ? paste back with COPY_PUT/XOR_PUT/AND_PUT/OR_PUT/NOT_PUT + +Clipping/viewport: +- `setviewport(x1, y1, x2, y2, clip)` ? drawing clip rect +- `getviewsettings(&info)` +- `clearviewport()` +- `setactivepage(p)` / `setvisualpage(p)` ? ਧ (Sprinter 2 screen) + +Line style: +- `setlinestyle(style, pattern, thickness)` ? SOLID_LINE / DOTTED_LINE / etc. +- `getlinesettings(&info)` + +**Acceptance:** ७ ⨯筮 Turbo-C BGI ணࠬ (饩 ᯮ짮 +moveto/lineto/circle/bar/setcolor) ࠡ ⢥ ࠢ. + +**Notes:** +- BGI fonts (TRIPLEX/SANS_SERIF/GOTHIC) ? BIOS font, ⠫ 㦭 + ( bitmap data lib) +- imagesize/getimage/putimage ? ᠬ ॡ game/animation +- Active/visual page ( ਧ) ? Sprinter ন 2 graphics pages, + 㦥 API switching + +. ⠪ `examples/` Turbo C 2.x BGIDEMO reference 㦭. + +### IM2 Interrupt Handlers ? **MUST v2** + +User- ISR १ Z80 IM 2 mode. 㦭 : +- Timer ticks (50 Hz frame counter, ) +- Music playback (AY, COVOX) +- Real-time games (input + game logic + render interrupt-driven) +- Async keyboard / mouse handling + +**Status:** v2. research + design `docs/im2_isr_design.md`. + +**襭 ⥪:** ॠ ⤥ memory mode `--memory im2` +( ⮣ ⮡ 騥 crt0). Detail' design-doc. + +** research'** ( ⥪ `docs/im2_isr_design.md`): +- Vector 0xFF ? frame + keyboard + CBL. Disambiguation ⠬ 0x19 / 0xFE +- Mouse hardware-IRQ 室 ( ⥪饩 ) +- Vector table / ISR / stack W2 (0x8000..0xBFFF) +- DSS ᢮ IM 2 handler ? 㦭 chain' ( / SYSTIME ) + +### 稥 㯭 㭪 v2 + +- [ ] **FILE API rewrite ? buffered streams** ? ⥪ ॠ + `libc/stdio/file.c` provisional unbuffered shim ( fputc/fgetc + = read/write syscall). 㦭 業 buffered ᥬ⨪ + Solid-C: + + ```c + typedef struct { + uint flags; // +0..1 file status flags + int level; // +2..3 empty/fill level of buffer + char *curp; // +4..5 current active pointer + int fd; // +6..7 underlying low-level fd + char *buffer; // +8..9 data transfer buffer + char hold; // +10 ungetc byte if no buffer + short token; // +11..12 reserved + char dummy; // +13 reserved + } FILE; + ``` + + stdin/stdout/stderr ? fd-થ `0 / -1 / -2`. ⥫ + stdout/stderr ࠭ ७: ESTEX OPEN positive + small fd (1, 2, ?) 筮 䠩 ? ᫨ stdout=1, ॠ + fd=1 ⠫ 䨪஬. fd=0 stdin ᭮ + (ESTEX 0 頥). fd । syscall' ? + ᯥਧ 䫠 `_F_CONIN/_F_CONOUT`. + + ਭ-⮪ (stdaux/stdprn) ॠ㥬 ? Sprinter ਭ୮ + API . + + ୠ⨢ ? ॠ third_party/solid-c (sources + `SRC/CLIB/`); ⠬ ⮢ buffered FILE + fopen/fread/fwrite/ + fseek/setvbuf .. ஢ 訬 open/read/write/lseek. + + rewrite deferred issues stdio-review: + - `fwrite` short-write ⠢ `_F_ERROR` + - `fgets(buf, 1, fp)` ? ⠭ "empty string", 㫨 NULL + - `mode_to_flags` ? break-out '+' (cosmetic) + +- [ ] **Audio API** ? AY-3-8910 + COVOX १ 뢠 (ॡ IM2) +- [ ] **ISA-8 slot support** ? ZX-Bus (sound, network, etc.) ? ॡ IM2 + ⥭ port + +## 稥 (v1 backlog, 騥) + +- [x] **#9: text I/O split (Turbo-C style)** ? stdio (puts/printf/putchar) ⥯ fast no-attr १ PCHARS/PUTCHAR. conio (cputs/cprintf/putch) ਬ attr १ textcolor/textbackground/textattr. KEEP_EXIST_ATTR ? conio fallback fast path. Verified hello.exe. . `memory/text_output_api_split.md`. 2026-05-31. +- [x] **Mouse API ** (१ driver, RST 30h) ? 14 㭪権 (init/show/hide/refresh/read/goto/bounds/text_cursor/load_cursor/get_cursor/get/set_sensitivity/video_mode_changed). . `memory/mouse_api.md`. Verified MAME 2026-05-31. Sensitivity = divider ( = ॥). +- [ ] Interrupt handlers ? IM 2 vector table HOME user ISR' +- [ ] প `restore SP on EXIT` ( z88dk +pps) ? ஢ 㦭 +- [ ] CI: ⮬᪨ ᪠ MAME `-aviwrite` screenshot-ࠢ, ⮡ ਬ஢ 室 祫 + +## ⮬ + +- প `` ( SDCC stdlib ? 㦭 ஢ crt0 ᮢ⨬) +- `` १ ESTEX SYSTIME (`$21`) CMOS BIOS-㭪樨 +- ZX Spectrum-ᮢ⨬ ० ⤥ target ( ஢ ᯥ㬮᪨ ணࠬ) +- প ZX-Bus (sound, network, etc.) ? 㦭 ࠩ +- Profile-guided optimization tools (hot/cold detection) 㯭 ணࠬ + +## Linker duplicate-symbol warnings (, 䨫஢) + + ᮧ⥫쭮 overrides' SDCC z80.lib 㭪樨 ᮡ⢥ ᨥ `sprinter.lib`, `sdldz80` `?ASlink-Warning-Definition of public symbol '...' found more than once`. ࢮ । (), ⮬ ४⭮ ? warning ⮫쪮 noise. + +騥 overrides: +- `_puts` ? १ PCHARS+\r\n vs SDCC posix puts +- `___sdcc_heap` ? heap W2 vs SDCC's ⠭ +- `_asctime`, `_localtime` ( 㣨 time) ? `posix_time.c` १ ESTEX SYSTIME vs SDCC's `time.rel` `_RtcRead` + +**饥 襭:** `bin/sprinter-cc` 䨫஢뢠 warning- (warning + 2 follow-up `Library:` ப) 뢮 `sdcc`. १ `-v` (verbose) 뢠. १ awk-pipe. + +** 襭:** +- ३ explicit `--nostdlib` + 筮 ᯨ᮪ 㦭 㫥 z80.lib (string, math, stdlib override') ? warning', ᪨஢ +- : २ `_puts` ? `_puts_sprinter` + alias १ linker flag ( 㢥७ SDCC ন) +- : ⠢ ᥩ (ࠡ祥 benign) ? ਮ + +## TODO: ஢ ॠ쭮 + +- [ ] **Port_Y banking trick** (`docs/part2/SprinterGraphics programming.txt`): + ⢥ত ᫥ `OUT (0x89), Y` 0xC000+0x400*N W3 + ப Y..Y+15 ( ணࠬ஢ ? 16 ப). + Empirical 2026-06-01 MAME 0.283 trick ** ࠡ⠥** ? ᥫ + ᠬ 0xC000+row_width 室 . ᪨ + `docs/samples/plasma2.asm` ⮦ ᯮ banking, ⠭ + Port_Y per row. + : + 1. ॠ쭮 Sprinter + 2. dual-write (`_gfx_putpixel_raw` + ன write `0xD000+x`) + 3. ᫨ ? MAME, issue + ९ + 4. ᫨ ⮦ ? 㬥 , 㤠 㯮 + ⠢ ⥪ ॠ (Port_Y per pixel) + 5. ᫨ banking ࠡ⠥ ? ஢ Port_Y + `_gfx_putpixel_raw` (sentinel out-of-range, . memory/gfx_port_y_banking.md) + + 易 먣 Bresenham (60-pixel ) ? 8? + OUT (0x89) 権, `gfx_fill_rect 320x256` ? 16? . + release v1. + +## GFX: ७ `docs/part2/accelerator_doc.txt` + +᫥ ⥭ ⠫쭮 accelerator doc  ࠢ. + ᯮ ⮫쪮 ਧ⠫/⨪ Fill mode. + +### Quick wins ⥪ primitives + +- [ ] ** SMC `LD A, (var)` block-size**. 㬥  + ࠧ蠥 `LD A, (HL)`, `LD A, (BC)`, `LD A, (DE)` ( `LD A, r`). + 㡥 SMC complexity `gfx_lines.c:hfill_chunk/vfill_chunk` + `gfx_16.c:g16_hfill_chunk`. 饭 ⮫쪮 register-to-register. +- [ ] **஢ block-size**. 㬥 뢠 accel + block size bursts (. `Horizontal_Line_Fill`: ⠭ + size + `LD B,B` ⪫祭, ⮬ Fill mode ᯮ + ࠭ size). `gfx_fill_rect` 100 묨 + ப ? ⠭ size 1 ࠧ, 100. + +### Bank-prefix modes (port 0xE2 bits) + +㬥 뢠 ਠ ࠭ ⠭⭮ 0x50: + +| Bank byte | Effect | +|---|---| +| 0x50 | Normal write ? shadow + | +| 0x54 | "no copy in main shadow RAM" | +| 0x58 | **"FF is transparent"** ? 0xFF write ⠢ background | +| 0x5C | both | + +Bank 0x58 祬 mouse cursor 0xFF-஧筮. + **sprite-blending १ accel block copy**: + +- [ ] **`gfx_set_bank_transparent(on)`** 䫠 `gfx_set_bank` + 롮 0x50/0x58 ᮢ sprite' +- [ ] ᯮ짮 `gfx_blit()` ⮡ 䠪 + transparent sprites १ accel- + +### Block copy mode (sprite blit') + +`LD L,L` (horizontal) `LD A,A` (vertical) ? ० ஢ १ +256- accel memory. blit'. + +- [ ] **`gfx_blit(src_data, x, y, w, h)`** ? ஢ sprite' + (ந ࠧ, १ accel) +- [ ] **`gfx_blit_transparent(src, x, y, w, h)`** ? ᯮ짮 bank 0x58 + +. `Draw_Restangle_Data` accelerator_doc.txt ७. + +### AND / OR / XOR operations १ accel + +㬥 뢠 accel ন ᪨ 樨 +. ਬ: +- XOR ? (뤥 selection UI) +- OR / AND ? masking, alpha-style blending +- . ਬ accelerator_doc.txt: "256 bytes block coding via XOR" + +- [ ] **`gfx_xor_rect`** / **`gfx_or_rect`** / **`gfx_and_rect`** ? + ਬ⨢ ᪨ 権 אַ㣮쭨 +- [ ] **`gfx_invert_rect(x, y, w, h)`** ? alias xor 0xFF + +### Bitmap fonts ࠧ ࠧ஢ + + `gfx_text` / `gfx_putchar` प ࠡ 8?8 ⮬ +(BIOS WIN_GET_ZG 頥 256?8 ). UI / 쭨 +㦭: +- [ ] **`gfx_set_font_size(w, h)`** ? ४ ਭ/ glyph' +- [ ] **`gfx_set_font_data(ptr, w, h, advance)`** ? 㪠⥫ + 짮⥫᪨ + ࠧ +- [ ] প **proportional** (advance != w) ⮢ ? + array advance[256] ਭ glyph' +- [ ] **Big-font ०**: 8?16, 16?16, 16?8 ( 쭨) +- [ ] ⤥ API `gfx_text_ex(x, y, str, font_id)` + font_id 롨ࠥ 㦥 ⮢ +- [ ] **Anti-alias 2-bit ** ( 䮭 / ࠭ / 2- alpha?) + ? far future, smooth UI + +## ⠯ ⨬権 ( ᥩ) + +- **`gfx_line` १ accel ** ? Bresenham |dy| << |dx| ( ) 뤠 runs Y ( X): ᥫ, ᥫ, ᥫ, 蠣 Y, ᥫ, ᥫ... ⠪ run ? ⮢ 㬥 `gfx_hline` ( `vline`). + ᫥: runs 㭪 ; run length, ஬ 룮 accel hline 祬 N?putpixel (overhead accel ~20?s, putpixel ~5?s ? accel 룮 run ? 4-5 px); (dx ? dy) ⠢ Bresenham, ? run-length-based fill. + `gfx_line` orthogonal cases 㦥 १ accel ? ⨬஢ ⮫쪮 . + +- **`gfx_fill_rect` W3-swap ** ? ᥩ ७ `gfx_hline`/`gfx_vline` ᢮ DI/save-W3/restore-W3/EI. ᤥ internal `_fill_rect_inner` ন W3 DI 横; ~20?s ? ⢮ ப/⮫殢 . ਬ ᥬ ਬ⨢. +# MDView ? ᬮ騪 Markdown Sprinter + +**MDView** ? ணࠬ ᬮ 㬥⮢ ଠ *Markdown* +Sprinter ( Z80). 㬥 ࠭ ⤥쭮 W3 +᭮ RAM ணࠬ. + +## + +- 㬥 **128 ** (8 ࠭ EMM 16 ) +- **16 384** ࠭ ப +- ⮬᪨ ७ ᫮ ਭ ࠭ (80 ⮫殢) +- ਧ⠫ ᤢ ப ப ( , ⠡) +- -: 䠩, ப, 業 ப⪨ +- ப ﭨ ६ 㧪 樨 +- প ?? ᪫ ப + +## + +``` +mdview [_䠩.md] +``` + +᫨ 䠩 , 㦠 `README.MD`. + +## ࠢ + +``` + ⢨ + +Up Down ப⪠ ப / +PgUp PgDn ப⪠ ࠭ (30 ப) +Home 砫 㬥 +End 㬥 +Left Right ਧ⠫ ᤢ (⮫쪮 nowrap-ப) +F1 ࠢ +F8 ஢: CP866 ? CP1251 ? KOI8-R ? UTF-8 ? ... +F10 / Esc 室 ணࠬ +``` + +஢ । ⮬᪨ ⨨ (BOM + ⨪ + 4 ); `F8` ४砥 , ᫨ ⥪ 訡. +8- ஢ (CP866/CP1251/KOI8-R) ४ (६ +ᮢ). ன / (ਬ UTF-8) ந ? +ࢮ ४祭 (⪠ 㧠 ᯨ஬), . + +## ⠪ Markdown + +### + +ন ஢ H1?H4. ஢ H5 H6 ⮡ࠦ H4. + + # ࢮ ஢ + ## ண ஢ + ### 쥣 ஢ + #### ⮣ ஢ + +### ⮢ ଠ஢ + +** ⥪** 뤥 묨 񧤮窠: `**⥪**` + +*ᨢ* 뤥 묨 񧤮窠 `*⥪*` ન `_⥪_` + +`஥ ` 砥 묨 窠 + +~~ભ ⥪~~ ? ⨫: `~~⥪~~` + +### 㬥஢ ᯨ᮪ + +થ `-`, `*` `+`: + +- 㭪 ᯨ᪠ +- ன 㭪 ᯨ᪠ +- ⨩ 㭪 筮 ⥪⮬, 室 + 㤥 ७ ᫥ ப ࠭ 㯠 + +### 㬥஢ ᯨ᮪ + +1. +2. ன +3. ⨩ + +### + +> 稭 ᨬ `>`. ᪮쪮 ᫥⥫ +> ப ᪫ ⮬᪨ +> ७ᮬ ᫮. + +### (verbatim) + + 砥 ன 窨. +⥪ ⮡ࠦ ? ? ࠧ Markdown: + +``` +#include +#include + +int main(void) { + puts("Hello, Sprinter!"); + return 0; +} +``` + +### ਧ⠫쭠 + + ᨬ `---`, `***` `___` ⤥쭮 ப: + +--- + +## 孨᪨ ࠪ⨪ + +- **ଠ:** Sprinter, Z80 @ 21 +- **஢:** CP866 / CP1251 / KOI8-R / UTF-8 (⮮।, `F8`) +- **ᨬ ࠧ 䠩:** 128 +- **ᨬ쭮 ᫮ ப :** 16 384 +- ** :** small + - ணࠬ, c⥪, , ? a W1-W2 (32 , 0x4000?0xBFFF). + - 䠩 ? ࠭ EMM, ⮡ࠦ W3 (0xC000?0xFFFF) + +## TODO + +1. **祭 ࠧ 㬥⮢.** 128 : 筮 + ࠧ ࠡ 訬 - ࠭ , ஢ + ࠡ 8- ࠭栬 16. + +: ଠ஢ ⠡ ࠬ; প ஢ +CP866 / CP1251 / KOI8-R / UTF-8 ⮮। ४祭 `F8` +(ன ந , ࢮ ४祭). + +4. **᪮७ ७ਭ.** ப ࠭. ⨬ 横 뢮 + ᨬ १ BIOS WRCHAR ( 뢮, DMA). + +--- + +*MDView v0.2 (c) 2026 ஢ ..* + + +--- + +# Sprinter C Compiler ? v1.0 + +C toolchain for **Sprinter** ? the Z80-based home computer by Peters Plus, running +ESTEX DSS. Host: macOS / Linux. Target: `.EXE` files in SprintEXE format. + +Built on top of **SDCC 4.5** (vendored in `third_party/sdcc/`). This repository adds +everything Sprinter-specific: crt0, linker integration, libc wrappers over ESTEX, +banked-call trampolines, graphics & accelerator API, mouse driver wrappers, and the +`mkexe` utility for producing SprintEXE images. + +## What you get + +* **`bin/sprinter-cc`** ? one-line driver: `sprinter-cc -o foo.exe foo.c` +* **Memory modes**: `tiny`, `small`, `big`, `huge`, `manual` ? see below. +* **stdio + conio**: printf, puts, putchar, getchar, fopen/fread/..., cprintf, cputs, putch, textcolor/textbackground/textattr, gotoxy, kbhit/getch. +* **Graphics**: 320?256?256 and 640?256?16 modes, accelerator-backed primitives (hline / vline / rect / fill_rect / line via Bresenham, plus clear), bitmap-font text in both modes via BIOS character generator. +* **File I/O**: POSIX (`open`/`read`/`write`/`close`/`lseek`/`unlink`/`creat`), FILE\* streams (`fopen`/`fgets`/`fwrite`/...), directory listing (`ffirst`/`fnext`), `chdir`/`getcwd`/`mkdir`/`rmdir`, `stat`/`fstat`. +* **Memory**: 32 KB heap (W2-resident), banking-aware page allocator (`mem_alloc_pages`/`bank_read`/`bank_write`), explicit memory modes for sub-16 KB programs. +* **Mouse**: full Sprinter driver wrapper (14 functions including custom cursor bitmaps). +* **Environment**: `getenv`/`putenv`/`sysenv` over ESTEX `$46`. +* **Time**: `getdatetime`/`setdatetime` + POSIX `time`/`localtime`/`mktime`/`asctime`/`ctime`. +* **Misc**: `errno`/`strerror`/`perror`, `atexit`, `setjmp`/`longjmp`, `sleep`, full argv parsing in crt0. + +## Quick start + +```sh +git clone sprinter-c +cd sprinter-c +make sdcc # one-time: fetch SDCC 4.5 binary (~25 MB) +make all # build mkexe + libsprinter.lib + 27 examples +make floppy # pack everything into mame/v306/IMG/mc.img +cd mame/v306 && ./run_mame.sh # boot Sprinter in MAME +``` + +Compile a single program: + +```sh +cat > hello.c < +int main(void) { puts("Hello, Sprinter!"); return 0; } +EOF + +bin/sprinter-cc -o hello.exe hello.c +``` + +That's it ? `hello.exe` is now a valid SprintEXE you can `RUN HELLO` from the ESTEX shell. + +## Memory modes + +Sprinter's address space is four 16 KB windows (W0 / W1 / W2 / W3). DSS allocates +pages by program size ? small programs get only one page. Pick a memory mode based +on what your program needs: + +| Mode | Code lives in | Banking | Use when | Note | +|---|---|---|---|---| +| `tiny` (default) | W2 (0x8100+) | no | code+data < 14 KB | | +| `small` | W1-W2 (0x4100+) | no | code+data < 30 KB | | +| `big` | W2 + W1 banking | yes (W1) | tiny + extra code modules | | +| `huge` | W1-W2 + W3 banking | yes (W3) | small + extra code modules | | +| `manual` | user-specified | optional | special layouts | Not implemented | + +```sh +sprinter-cc --memory small -o big.exe bigprog.c +sprinter-cc --memory huge -o app.exe main.c --bank 1=engine.c --bank 2=ai.c +``` + +Banked functions are declared with `__banked`: + +```c +void engine_tick(int dt) __banked; // lives in BANK1, automatically swapped +``` + +## Examples (27 total) + +| Example | What it demonstrates | +|---|---| +| `hello` | Hello world with stdio + conio Turbo-C-style colors | +| `argv` | argv parsing in crt0 | +| `cat` | File I/O ? read & print TEST.TXT | +| `seek` | 32-bit lseek over a 100 KB file | +| `ls` | Directory listing via ffirst/fnext | +| `filetest` | FILE\* streams (fopen/fread/...) | +| `stattest` | `stat`/`fstat` on files and directories | +| `errno` | errno / strerror / perror | +| `mem_test` | Page allocator + bank\_read/bank\_write | +| `malloc` | Heap stress test (200+ allocations) | +| `banked` | Banked code in W3 (huge mode) | +| `bankedbg` | Banked code in W1 (big mode) | +| `banklocl` | Bank-local static data and BSS | +| `mouse` | Mouse driver in text mode | +| `gfx_mous` | Mouse with custom bitmap cursor in graphics mode | +| `gfx_demo` | 320?256?256 lines / rects / accelerator | +| `gfx_d16` | 640?256?16 same primitives | +| `gfx_text` | Bitmap-font text on graphics screen | +| `timedir` | Date/time + directory listing | +| `ptime` | POSIX time API | +| `openenv` | open() flags + environment vars | +| `conio` | conio API smoke test | +| `attrprob` | Probe Sprinter text attribute byte layout | +| `strtest` | string.h test (from SDCC's z80.lib) | +| `stdlib` | stdlib.h test (qsort / rand / strtol / etc.) | +| `assrtest` | assert() | +| `rt_test` | Runtime helpers (sleep, setjmp, atexit) | + +## Headers + +Standard: +* `` ? puts / printf / FILE\* + Sprinter-specific dec/hex helpers +* `` ? atoi / atof / malloc / qsort / ... (from SDCC z80.lib) +* `` / `` / `` ? from SDCC z80.lib +* `` ? read / write / close / lseek / unlink +* `` ? open / creat + O\_RDONLY / O\_CREAT / ... +* `` ? errno + error names + strerror +* `` ? stat / fstat +* `` / `` ? from SDCC + +Sprinter-specific: +* `` ? putch / cputs / cprintf, textcolor / textbackground / textattr, kbhit / getch, clrscr, gotoxy, wherex/y +* `` ? gfx_init/done, palette, putpixel, hline/vline/rect/fill_rect/line, text ? for both 320 and 640 modes (gfx_\*16 variants) +* `` ? full 14-function driver wrapper + mouse_cursor_t with bitmap support +* `` ? chdir / getcwd / mkdir / rmdir / ffirst / fnext / ffblk +* `` ? getdatetime / setdatetime + POSIX time / localtime / etc. +* `` ? raw ports, ESTEX/BIOS function numbers, env API +* `` ? exit / \_exit / atexit +* `` ? mem\_alloc\_pages / mem\_free\_block / bank\_read / bank\_write +* `` ? Solid-C compatibility layer (aliases + BOOL/WORD/uint types) + +## Toolchain commands + +```sh +make all # build mkexe + lib + every example +make floppy # repack mame/v306/IMG/mc.img with all .exe files +make check # 17 mkexe unit-tests +make clean # remove all build artefacts +make sdcc # one-time: fetch SDCC 4.5 binary +``` + +### sprinter-cc options + +``` +sprinter-cc -o foo.exe foo.c [more.c ...] [options] + + --memory MODE tiny | small | big | huge | manual (default: tiny) + --memory-manual SPEC explicit placement (CODE=W1|W2,DATA=W1|W2|SAME,BANKED=W1|W3) + --stack-size N bytes reserved for the stack (default ~1278) + --crt0=TYPE default | minimal | banked | small + --bank N=FILE.c compile FILE.c into bank N (repeatable, max 15) + --debug enable runtime diagnostics (defines DEBUG_RT) + -I PATH extra include path + -L 0xADDR / -E / -S override load / entry / stack addresses + -Wl FLAG pass FLAG to sdldz80 + --mkexe FLAG pass FLAG to mkexe (e.g. --mkexe -p --mkexe 0 for bank padding) + -v verbose +``` + +## Status + +What works in v1.0: +* Compile / link / pack to SprintEXE ? verified on all 27 examples +* Four memory modes (tiny / small / big / huge) +* Graphics (both modes) with accelerator +* Mouse (text + graphics cursor) +* File I/O, directories, environment, time +* All headers listed above + +Deferred to v2.0 (see `docs/TODO.md`): +* **Turbo-C-style BGI graphics API** ? `initgraph` / `setcolor` / `circle` / + `getimage` / `putimage` / etc. on top of our `gfx_*` primitives +* Remaining Solid-C compatibility gaps (Phase 2/3) ? see `docs/solid_c_compatibility.md` +* Manual memory mode +* Rewrite FILE\* stream API (current implementation is very primitive and doesn't use buffers) + +Deferred to v3.0: +* **IM2 interrupt handlers** ? research complete (`docs/im2_isr_design.md`), + implementation scheduled for v3 +* **Audio API** (AY-3-8910 + COVOX) ? requires IM2 +* **ISA-8 slot drivers** ? requires IM2 (???) + +## Documentation + +* `docs/TODO.md` ? roadmap and open work items +* `docs/solid_c_compatibility.md` ? gap analysis vs Solid-C 2004 +* `docs/im2_isr_design.md` ? interrupt handler design (v2) +* `docs/converted/` ? source documentation (ESTEX, BIOS, architecture) + converted to plain text for `grep` +* `docs/reference/`, `docs/samples/`, `docs/memory management/` ? original + Russian docs and code samples from Peters Plus + +## Repository layout + +``` +bin/sprinter-cc one-line compiler driver (bash) +toolchain/mkexe/ host-side tool: .ihx -> .exe SprintEXE +toolchain/check_banks.py post-link bank size enforcer +runtime/ crt0 variants (default, minimal, small, banked) + bank trampolines, heap, heap_top +libc/include/ headers +libc/io|stdio|mem|gfx/ C and asm sources for libsprinter.lib +lib/ Makefile that archives libsprinter.lib via sdar +examples/ 27 example programs +mame/v306/ MAME binary + Sprinter ROM/HDD images + floppy script +third_party/sdcc/ vendored SDCC 4.5 (fetched via `make sdcc`) +third_party/solid-c/ reference: original Sprinter native C (for compat target) +docs/ documentation +``` + +## License + +This repository contains: +* Original code in `bin/`, `toolchain/`, `runtime/`, `libc/`, `lib/`, `examples/` ? + MIT-licensed. +* `third_party/sdcc/` ? SDCC 4.5 under GPLv2 with linking exception + (see `third_party/sdcc/COPYING.txt`) +* `third_party/solid-c/` ? original Sprinter Solid C, used only as a reference + +## Credits + +* **Sprinter / Peters Plus** ? , ਩ ਭ and the original team +* **SDCC** ? for the underlying Z80 compiler +* **MAME** ? for the Sprinter Sp2000 emulation + +--- + +For questions / patches: see CONTRIBUTING.md (TBD) or open an issue. + +--- + +# TODO / Roadmap + + 浪 뢠 ਮ.  ॠ ணࠬ ? ਮ ᬥ. + +## ⠯ 5 ? malloc / free + banking-aware page allocator ? + +- [x] SDCC's `malloc`/`free` + `runtime/heap.s` ( library heap.rel, 14000- heap 2) +- [x] `libc/mem/mem_alloc.c` ? page allocator: `mem_alloc_pages`/`mem_free_block`/`mem_get_page`/`mem_info` १ ESTEX `$3C/$3D/$3E` + BIOS `$C4` +- [x] `libc/mem/bank_io.c` ? HOME-१ `bank_read`/`bank_write`/`bank_load_byte`/`bank_store_byte` ᢮ W3 +- [x] `examples/malloc_test/` ? ஢ઠ SDCC's malloc (~210 64- allocations १ heap) +- [x] `examples/mem_test/` ? ஢ઠ page allocator: 3 ࠭, ࠧ १ bank_write, 䨪 १ bank_read + +## ⠯ 6 ? argv parsing + sprinter-cc wrapper ? + +- [x] crt0 ESTEX command-line IX-prefix (inline asm `runtime/crt0.s`) +- [x] Strip leading CP/M-style space (DSS quirk) +- [x] । `argc`/`argv` main() १ HL/DE (SDCC __sdcccall(1) ABI) +- [x] argv[0] = basename .EXE १ ESTEX APPINFO ($47 subfn 2) +- [x] `runtime/crt0_minimal.s` ? opt-out 祭 쪨 ணࠬ +- [x] `runtime/crt0_banked.s` ? ⥯ ⮦ argv (parse_argv + get_progname ᪮஢ crt0.s; 㤥 factored argv.s libsprinter.lib) +- [x] Bash-⪠ `bin/sprinter-cc`: `sprinter-cc -o foo.exe foo.c` ப +- [x] প 権: `--memory`, `--memory-manual`, `--stack-size`, `--crt0=`, `--bank N=FILE.c`, `--debug`, `-I`, `-L`/`-E`/`-S`, `-Wl`, `--mkexe` + +## ⠯ 8 ? 䨪 (320?256?256 + 640?256?16 + accel + bitmap font) ? + +- [x] **8a** Graphics core: `gfx_init`/`gfx_done`/`gfx_clear`/`gfx_putpixel`/`gfx_pal_load`/`gfx_pal_set` (libc/gfx/gfx_core.c). १ BIOS PIC_SET_PAL ($A4). Verified 320?256?256. +- [x] **8b** /אַ㣮쭨/fill १ accelerator (libc/gfx/gfx_lines.c): `gfx_hline`/`gfx_vline` १ accel Fill (LD C,C / LD E,E + SMC block-size), `gfx_rect`/`gfx_fill_rect` heuristic 롮஬ ਥ樨 (h/v bursts count), `gfx_line` Bresenham . `gfx_clear` ⮦ ९ᠭ column-major accel (~4? ॥). +- [x] **8c** 640?256?16 mode (libc/gfx/gfx_16.c): `gfx_*16` API, HIGH nibble = LEFT pixel (㬥 misleading), per-row RMW vline ( = 2 ਧ⠫ ᥫ). +- [x] **8d** Bitmap font + gfx_text (libc/gfx/gfx_text.c): १ BIOS WIN_GET_ZG ($B8), interleaved layout `font[row*256+char]`, `gfx_text`/`gfx_putchar` 320 mode, `gfx_text16`/`gfx_putchar16` 640 mode pair-table lookup. + +. memory/sprinter_graphics.md, sprinter_accelerator.md, sprinter_graphics_16.md, sprinter_font_format.md. + + ( ): +- [ ] -quad 640: per-cell (mode 0x82 ࠧ蠥 1 4 per 16?8 cell) ? १ אַ area-ᠭ ࠭ 0x0300..0x039F + +## Auto-banking (. `memory/banking_roadmap.md` ⠫) + +Phase 1 ? file-level bin-packing ? ॠ뢠 ஥ ~30 KB . + +- [ ] `toolchain/auto_bank.py`: + - ࠧ `.rel`-䠩 ( .map ᫥ dry-run link') + - First-fit-decreasing bin-packing + - `#pragma codeseg BANKn` manual override + - ५뢠 묨 `-Wl-b_BANKn=...` ࠬࠬ + - ⠥ । + +Phase 2-5: incremental rebalance, declarative `banks.toml`, function-level, call-graph-aware. 쪮 ᫨/ . + +## Bank-local static data (mutable data ⮬ ) ? ? + +- [x] ਬ `examples/bank_local_data/` ? 㭪 BANK1 ᢮ writable BSS array + const table + malloc- +- [x] `mkexe -p 0` 㫥 padding (BSS-storage 㧪) +- [x] ᪨ 楯: `--codeseg BANK1 --constseg BANK1 --dataseg BANK1` bank1.c + `-Wl-b_BANK1=0x1C000` . **`--dataseg BANK1` ** ? ࠭ ⭮ - trampoline bug ᪨஢ १. +- [x] ** 䨪 trampoline'a runtime/bank.s** ? `pop af; out (n), a` ਫ A ? banked-㭪樨 騥 uint8_t 頫 . `pop bc; out (c), b` ࠭ A. +- [x] **malloc banked-㭪樨 ࠡ⠥ ஧筮** ? heap W2 (HOME), W2 ᢠ trampoline', pointer  ⥪. . memory/bank_local_data_pattern.md. +- [x] 㬥 memory: `memory/bank_local_data_pattern.md` ( 楯 + malloc + nuances), `memory/sdcc_banking.md` (trampoline fix) +- [ ] 樮쭮 ? `check_banks.py` ⮡ 뢠 ࠧ size = code + const + bss per bank (cosmetic) + +祬: 㫥 訬 private state (level loader, audio engine, scene data). W2 heap , ⨪ . + +## ᪠ solid-c (⨢ Sprinter C ? `third_party/solid-c/`) + +᫥ solid-c'᪮ libc (. `memory/solid_c_findings.md`)  ⮢ ᫥ 㭪権. ਮ **᮪** : + +### High-priority gaps ( ஢, 짠) +- [x] **`errno` + `strerror`/`perror`** ? ⠡窠 32 訡 (libc/io/errno.c) +- [x] **७ `open()`** O_CREAT/O_TRUNC/O_APPEND/O_EXCL state machine +- [x] **`atexit`** ? 8-callback LIFO + `exit()` + `_exit()` (libc/io/atexit.c) +- [x] **`setjmp`/`longjmp`** ? 6- jmp_buf={sp,ix,pc} (libc/io/setjmp.c) +- [x] **`sleep(seconds)`** ? 50Hz halt-loop (libc/io/sleep.c) +- [x] **ESTEX ENV API** ($46, getenv/putenv) ? libc/io/env.c. 竨 doc-bug: ॠ쭮 A=0 NOT FOUND + +### Medium-priority (㦭 shell-like ⨫) +- [ ] **Mouse driver** ? `rst $30h`, 17 㭪権. **砫 ࠡ⠥ MAME**. +- [x] **`ffirst`/`fnext` + ffblk_t struct** directory listing ? ॠ, demo: ls.exe +- [x] **`getdatetime`/`setdatetime`** १ ESTEX $21/$22 ? libc/io/time.c, demo: time_dir_test +- [x] **`chdir`/`getcwd`/`mkdir`/`rmdir`** ? wrappers ESTEX $1B-$1E ? libc/io/fsdir.c +- [x] **conio: `kbhit`/`getch`/`getche`/`cputs`/`clrscr`/`gotoxy`** ? ॠ +- [x] **conio extras**: `wherex`/`wherey` ($53), `wrchar`/`rdchar` ($58/$57), `textmode_get/set` ($50/$51), `clrscr_attr` ($56) + COLOR macros + +### Low-priority ? ? FILE* stack + +- [x] ** unbuffered FILE\*** ? `libc/stdio/file.c` + `libc/include/stdio.h`. fopen/fclose/fputs/fgets/fread/fwrite/fseek/ftell/rewind/feof/ferror/clearerr/fflush + stdin/stdout/stderr pseudo-streams. . `memory/file_star_design.md` `examples/filetest`. +- [ ] fprintf / fscanf ? 㦭 printf-१-callback machinery. 짮⥫ `sprintf(buf, ...) + fputs(buf, fp)`. +- [ ] 樮 buffered mode (setvbuf, line/block buffering) ? ᫨ - . + +### POSIX time API ? ? +- [x] `libc/io/posix_time.c` ? time/localtime/gmtime/mktime/asctime/ctime getdatetime. SDCC's time.rel ( override _RtcRead). . `examples/ptime`. + +### sys/stat ? ? +- [x] `libc/io/stat.c` ? POSIX stat/fstat. ਤ open+fstat 䠩, ffirst+iter ( "."/".."). . `examples/stattest` `memory/estex_ffirst_dotdot.md`. + +### assert ? ? (ᯮ㥬 SDCC's __assert १ fallback include path) + +## libc/stdlib ? ? 㦭 (. memory/sdcc_stdlib_works.md) + +஢७ १ `examples/stdlib_test/`: SDCC z80.lib ᮤন ࠡ騥 ॠ樨: +- `atoi/atol/atof, strtol/strtoul, rand/srand, qsort/bsearch, abs/labs, div/ldiv` +- `` (memchr/cmp/set/cpy, strcat/cmp/cpy/len/chr/spn/etc.) +- `` (toupper/tolower) +- `` (sinf/cosf/sqrtf/etc.) + + ⮬᪨ ﭥ z80.lib 㦭. ** ९뢠**. + + Sprinter-specific 易⥫ 㫨 : atexit, env, errno, setjmp, putchar/puts/getchar, conio, fsdir, time, mouse, open/read/lseek/close. + +## Build-system: libsprinter.lib + sprinter-cc ? ? + +- [x] `lib/Makefile` ? ᮡࠥ libc/*.c `.rel`, 娢 १ sdar `lib/sprinter.lib` +- [x] 砥 runtime/bank.s runtime/heap.s (auto-pulled __banked/malloc) +- [x] `bin/sprinter-cc` ? bash-wrapper: `sprinter-cc -o foo.exe foo.c` ப +- [x] প 権 `--crt0=default|minimal|banked`, `--bank N=FILE.c`, `-I`, `-L`/`-E`/`-S`, `-Wl`, `--mkexe` +- [x] `examples/hello_sccc/` ? : `hello.c` ᮡࠥ shell-맮, ࠧ ᮢ Makefile (925 ) +- [x] Split `putchar.c` ? `putchar.c` + `puts.c` per-function granularity (puts override SDCC's z80.lib version) +- [x] `make all` (ᨬ `lib` । `examples`) + + 襭 (樮쭮): +- [ ] ஢ ⠫ examples sprinter-cc Makefile (ᬥ⨪) +- [ ] 쭥 libc/*.c per-function ( ⥪ granularity 㦥 㦭 ࠧ ? .rel 楫, 設⢠ 䠩 㭪) + +## ⠯ 9 ? memory modes sprinter-cc + +DSS 뤥 ࠭ ࠧ ਫ: < 16 KB ? ࠭, ⠫ 砥 ?࠭ #FF? (read=0xFF, write ). - ⮣ CODE--W1 + DATA--W2 쪮 ணࠬ . . [memory/sprinter_memory_modes.md](../../.claude/projects/-Volumes-SAM8-Projects-DIY-Z80-Sprinter-C-Compiler/memory/sprinter_memory_modes.md). + +- [x] **`tiny`**: (CODE+DATA+⥪) W2. Default. Verified hello/argv/conio/malloc/file/etc. +- [x] **`--memory MODE` 䫠 sprinter-cc**: parser + per-mode 䮫 CODE_LOC/DATA_LOC, override १  `--code-loc`/`--data-loc`. tiny ࠡ⠥; small/big/huge warning' (runtime ⮢). 2026-05-30. +- [x] **`--memory-manual SPEC`**: `CODE=W1|W2,DATA=W1|W2|SAME,BANKED=W1|W3`. 2026-05-30. +- [x] **`small` runtime**: `runtime/crt0_small.s` ᯮ ESTEX `$3D GETMEM` + `$3A SETWIN2` ⮡ 뤥 W2-࠭ gsinit. **** BIOS `$C4` ? ⥪ ⮬ ⠯ W1 (boot_stack HOME), BIOS ॡ ⥪ W2. ᫥ SP ४砥 0xBFFE, ⠭ flow. 2026-05-30, verified hello.exe. +- [x] **`small` auto-detect >16 KB ணࠬ**: `crt0_small.s` ⠥ `0xC2` (⥪ ࠭ W2 ? `0xA2`! W1). ᫨ 0xFF ? 뤥 page; DSS 㦥 ᤥ (ணࠬ ᠬ 뫥 W2). crt0 뢠 0..30 KB. mkexe ⠪ ࠧ蠥 HOME span W1+W2 (0x4000..0xBFFF). Verified hello: small (5 KB 䠩, SETWIN2 path) + 32 KB 䠩 (auto-skip). 2026-05-30. +- [x] **`big` runtime** (tiny + banked code W1): ࠬਧ `crt0_banked.s` + `bank.s` १ `.ifdef BANK_W1` ? 㣮 banking port (0xA2 vs 0xE2), 㣮 load-addr (0x4000 vs 0xC000). sprinter-cc prepend' `BANK_W1 = 1` `--memory big`, । `mkexe -B 0x4000`. ਬ `examples/banked_big/`. 2026-05-30. +- [x] **`huge` runtime** (small + banked code W3): merge W2-detect `crt0_small.s` `crt0_banked.s`. 騩 ਬ `examples/banked/` ⥯ ᯮ MEMORY=huge. 2026-05-30. +- [x] **`--debug` 䫠**: prepend `DEBUG_RT = 1` crt0 + `-DDEBUG_RT` sdcc. 뢠 symbol `_w2_self_allocated` (uint8_t) ? runtime diagnostic ஢ W2. 2026-05-30. + +### -襭 libc crt0 + +** `sprinter.lib`** ࠡ⠥ memory mode ? `.rel`-童 relocatable, SDLD dead-code elimination per-member ( 䨪  `gfx_core.rel` ..). Verified hello vs malloc_test १ map-䠩. + +**`gfx.lib` ⤥쭮 ? 㦥**: dead-code elimination 㦥 ࠡ⠥. + +**`libc_banked` (libc bank HOME)** ? ⮬, HOME (16 KB) user- + libc `huge` mode. १ `--codeseg BANK0` 樨 libc; trade-off: trampoline ~30 横 libc-맮. ਣ: ॠ쭠 ணࠬ HOME budget. + +**HW-ᨬ 㫨 ? `sprinter_home.lib` ⤥쭮.** libc 䨧᪨ W3, ⮬ W3: +- `gfx_*` ? `0xC000+` ᫥ swap W3 video page +- `bank_io` (mem_alloc_pages/bank_read/bank_write) ? swap' W3 १ `OUT (0xE2)` +- 騥 ISR ? 뢠 ਩ W3 㣮 + + huge mode 㫨 HOME (W1). 㤥 `libc_banked`, **६** 뤥塞 `sprinter_home.lib` (HOME-only) `sprinter.lib` (bankable). 쭠 奬: +``` +sprinter_home.lib HOME-only: gfx, bank_io, ISR shims +sprinter.lib bankable: printf, malloc, string, conio, stdio, env, ... +sprinter_banked.lib sprinter.lib --codeseg BANK0 ( huge) +``` +ਣ: ॠ `--memory huge` runtime. + +**crt0 ? mode:** +- `crt0.s` ? ⥪騩, **tiny/big**: SP=0xBFFE, argv (W2- 㦥 뤥 DSS). +- `crt0_minimal.s` ? ⥪騩, tiny argv. +- `crt0_small.s` ? **, step 3**: **small/huge**, W2 १ `mem_alloc_pages` gsinit, `0xA2`, ⮬ ⠭ flow. +- `crt0_banked.s` ? ⥪騩, **big**: trampoline-⠡ W3 , CODE W2. +- `crt0_banked_small.s` ? ****: huge = small (W2-alloc) + banked (W3 trampolines). + +sprinter-cc ࠥ crt0 `--memory` mode (ᥩ `--crt0=` override). +- [x] **ࠨ ࠧ ⥪**: 䫠 `sprinter-cc --stack-size BYTES`. Wrapper `heap_top.s` `___sdcc_heap_end = stack_top + 1 - stack_size`, ⤥ .rel per-program. Default ?1278 (heap_top=0xBB00) `runtime/heap_top.s`. 2026-05-30. + +䥩: `sprinter-cc --memory [tiny|small|big|huge|manual] [--memory-manual SPEC] [--stack-size N] foo.c`. `--memory-manual` ⮫쪮 `--memory manual`. + +## Known issues / quirks + +- **ESTEX $46 ENV API**: ? ࠡ⠥. - `DiskSyscalls.txt v1.6` 訡筮 뢠 return-status ? A=0 NOT FOUND, FOUND. 䨪஢ `memory/sprinter_platform.md`. + +## V2 (᫥ ५ v1) + +### Turbo-C-style graphics API (BGI-like) ? **MUST v2** + + `gfx_*` API ஢ **Turbo-C ``** (BGI) MS-DOS. +ணࠬ ਢ訥 Turbo-C ७ ᪨ 1--1. + +** ** ( ᭮ Borland BGI): + +Setup/teardown: +- `initgraph()` / `closegraph()` ? ᥩ `gfx_init`/`gfx_done`, alias +- `getmaxx()` / `getmaxy()` ? GFX_WIDTH-1 / GFX_HEIGHT-1 +- `cleardevice()` ? alias to gfx_clear +- `getgraphmode()` / `setgraphmode()` ? get_videomode/set_videomode + +Color/palette: +- `setcolor(c)`, `getcolor()` ? current draw color +- `setbkcolor(c)`, `getbkcolor()` ? background color +- `setpalette(idx, c)` ? entry +- `getpalette(&info)` ? read all palette + +Primitives ( 㦥 ? BGI- aliases): +- `putpixel(x, y, c)` ? gfx_putpixel +- `getpixel(x, y)` ? 㦭 ॠ (RMW ⭮ ? IN) +- `moveto(x, y)`, `lineto(x, y)`, `linerel(dx, dy)` ? current point + line drawing +- `line(x1, y1, x2, y2)` ? gfx_line +- `rectangle(x1, y1, x2, y2)` ? gfx_rect ( 㣮 API: x1,y1,x2,y2 vs x,y,w,h!) +- `bar(x1, y1, x2, y2)` ? gfx_fill_rect +- `bar3d(x1, y1, x2, y2, depth, topflag)` ? : rect + 3d edges +- `circle(x, y, r)`, `arc(...)`, `ellipse(...)`, `pieslice(...)` ? primitives +- `fillpoly()`, `drawpoly()` ? +- `floodfill(x, y, border_color)` ? + +Text on graphics screen: +- `outtext(s)` / `outtextxy(x, y, s)` ? gfx_text (alias) +- `settextstyle(font, dir, size)` ? multiple bitmap fonts +- `gettextsettings(&info)` +- `textwidth(s)` / `textheight(s)` ? measure + +Image manipulation: +- `imagesize(x1, y1, x2, y2)` ? bytes needed for getimage +- `getimage(x1, y1, x2, y2, buf)` ? save rect to buffer +- `putimage(x, y, buf, op)` ? paste back with COPY_PUT/XOR_PUT/AND_PUT/OR_PUT/NOT_PUT + +Clipping/viewport: +- `setviewport(x1, y1, x2, y2, clip)` ? drawing clip rect +- `getviewsettings(&info)` +- `clearviewport()` +- `setactivepage(p)` / `setvisualpage(p)` ? ਧ (Sprinter 2 screen) + +Line style: +- `setlinestyle(style, pattern, thickness)` ? SOLID_LINE / DOTTED_LINE / etc. +- `getlinesettings(&info)` + +**Acceptance:** ७ ⨯筮 Turbo-C BGI ணࠬ (饩 ᯮ짮 +moveto/lineto/circle/bar/setcolor) ࠡ ⢥ ࠢ. + +**Notes:** +- BGI fonts (TRIPLEX/SANS_SERIF/GOTHIC) ? BIOS font, ⠫ 㦭 + ( bitmap data lib) +- imagesize/getimage/putimage ? ᠬ ॡ game/animation +- Active/visual page ( ਧ) ? Sprinter ন 2 graphics pages, + 㦥 API switching + +. ⠪ `examples/` Turbo C 2.x BGIDEMO reference 㦭. + +### IM2 Interrupt Handlers ? **MUST v2** + +User- ISR १ Z80 IM 2 mode. 㦭 : +- Timer ticks (50 Hz frame counter, ) +- Music playback (AY, COVOX) +- Real-time games (input + game logic + render interrupt-driven) +- Async keyboard / mouse handling + +**Status:** v2. research + design `docs/im2_isr_design.md`. + +**襭 ⥪:** ॠ ⤥ memory mode `--memory im2` +( ⮣ ⮡ 騥 crt0). Detail' design-doc. + +** research'** ( ⥪ `docs/im2_isr_design.md`): +- Vector 0xFF ? frame + keyboard + CBL. Disambiguation ⠬ 0x19 / 0xFE +- Mouse hardware-IRQ 室 ( ⥪饩 ) +- Vector table / ISR / stack W2 (0x8000..0xBFFF) +- DSS ᢮ IM 2 handler ? 㦭 chain' ( / SYSTIME ) + +### 稥 㯭 㭪 v2 + +- [ ] **FILE API rewrite ? buffered streams** ? ⥪ ॠ + `libc/stdio/file.c` provisional unbuffered shim ( fputc/fgetc + = read/write syscall). 㦭 業 buffered ᥬ⨪ + Solid-C: + + ```c + typedef struct { + uint flags; // +0..1 file status flags + int level; // +2..3 empty/fill level of buffer + char *curp; // +4..5 current active pointer + int fd; // +6..7 underlying low-level fd + char *buffer; // +8..9 data transfer buffer + char hold; // +10 ungetc byte if no buffer + short token; // +11..12 reserved + char dummy; // +13 reserved + } FILE; + ``` + + stdin/stdout/stderr ? fd-થ `0 / -1 / -2`. ⥫ + stdout/stderr ࠭ ७: ESTEX OPEN positive + small fd (1, 2, ?) 筮 䠩 ? ᫨ stdout=1, ॠ + fd=1 ⠫ 䨪஬. fd=0 stdin ᭮ + (ESTEX 0 頥). fd । syscall' ? + ᯥਧ 䫠 `_F_CONIN/_F_CONOUT`. + + ਭ-⮪ (stdaux/stdprn) ॠ㥬 ? Sprinter ਭ୮ + API . + + ୠ⨢ ? ॠ third_party/solid-c (sources + `SRC/CLIB/`); ⠬ ⮢ buffered FILE + fopen/fread/fwrite/ + fseek/setvbuf .. ஢ 訬 open/read/write/lseek. + + rewrite deferred issues stdio-review: + - `fwrite` short-write ⠢ `_F_ERROR` + - `fgets(buf, 1, fp)` ? ⠭ "empty string", 㫨 NULL + - `mode_to_flags` ? break-out '+' (cosmetic) + +- [ ] **Audio API** ? AY-3-8910 + COVOX १ 뢠 (ॡ IM2) +- [ ] **ISA-8 slot support** ? ZX-Bus (sound, network, etc.) ? ॡ IM2 + ⥭ port + +## 稥 (v1 backlog, 騥) + +- [x] **#9: text I/O split (Turbo-C style)** ? stdio (puts/printf/putchar) ⥯ fast no-attr १ PCHARS/PUTCHAR. conio (cputs/cprintf/putch) ਬ attr १ textcolor/textbackground/textattr. KEEP_EXIST_ATTR ? conio fallback fast path. Verified hello.exe. . `memory/text_output_api_split.md`. 2026-05-31. +- [x] **Mouse API ** (१ driver, RST 30h) ? 14 㭪権 (init/show/hide/refresh/read/goto/bounds/text_cursor/load_cursor/get_cursor/get/set_sensitivity/video_mode_changed). . `memory/mouse_api.md`. Verified MAME 2026-05-31. Sensitivity = divider ( = ॥). +- [ ] Interrupt handlers ? IM 2 vector table HOME user ISR' +- [ ] প `restore SP on EXIT` ( z88dk +pps) ? ஢ 㦭 +- [ ] CI: ⮬᪨ ᪠ MAME `-aviwrite` screenshot-ࠢ, ⮡ ਬ஢ 室 祫 + +## ⮬ + +- প `` ( SDCC stdlib ? 㦭 ஢ crt0 ᮢ⨬) +- `` १ ESTEX SYSTIME (`$21`) CMOS BIOS-㭪樨 +- ZX Spectrum-ᮢ⨬ ० ⤥ target ( ஢ ᯥ㬮᪨ ணࠬ) +- প ZX-Bus (sound, network, etc.) ? 㦭 ࠩ +- Profile-guided optimization tools (hot/cold detection) 㯭 ணࠬ + +## Linker duplicate-symbol warnings (, 䨫஢) + + ᮧ⥫쭮 overrides' SDCC z80.lib 㭪樨 ᮡ⢥ ᨥ `sprinter.lib`, `sdldz80` `?ASlink-Warning-Definition of public symbol '...' found more than once`. ࢮ । (), ⮬ ४⭮ ? warning ⮫쪮 noise. + +騥 overrides: +- `_puts` ? १ PCHARS+\r\n vs SDCC posix puts +- `___sdcc_heap` ? heap W2 vs SDCC's ⠭ +- `_asctime`, `_localtime` ( 㣨 time) ? `posix_time.c` १ ESTEX SYSTIME vs SDCC's `time.rel` `_RtcRead` + +**饥 襭:** `bin/sprinter-cc` 䨫஢뢠 warning- (warning + 2 follow-up `Library:` ப) 뢮 `sdcc`. १ `-v` (verbose) 뢠. १ awk-pipe. + +** 襭:** +- ३ explicit `--nostdlib` + 筮 ᯨ᮪ 㦭 㫥 z80.lib (string, math, stdlib override') ? warning', ᪨஢ +- : २ `_puts` ? `_puts_sprinter` + alias १ linker flag ( 㢥७ SDCC ন) +- : ⠢ ᥩ (ࠡ祥 benign) ? ਮ + +## TODO: ஢ ॠ쭮 + +- [ ] **Port_Y banking trick** (`docs/part2/SprinterGraphics programming.txt`): + ⢥ত ᫥ `OUT (0x89), Y` 0xC000+0x400*N W3 + ப Y..Y+15 ( ணࠬ஢ ? 16 ப). + Empirical 2026-06-01 MAME 0.283 trick ** ࠡ⠥** ? ᥫ + ᠬ 0xC000+row_width 室 . ᪨ + `docs/samples/plasma2.asm` ⮦ ᯮ banking, ⠭ + Port_Y per row. + : + 1. ॠ쭮 Sprinter + 2. dual-write (`_gfx_putpixel_raw` + ன write `0xD000+x`) + 3. ᫨ ? MAME, issue + ९ + 4. ᫨ ⮦ ? 㬥 , 㤠 㯮 + ⠢ ⥪ ॠ (Port_Y per pixel) + 5. ᫨ banking ࠡ⠥ ? ஢ Port_Y + `_gfx_putpixel_raw` (sentinel out-of-range, . memory/gfx_port_y_banking.md) + + 易 먣 Bresenham (60-pixel ) ? 8? + OUT (0x89) 権, `gfx_fill_rect 320x256` ? 16? . + release v1. + +## GFX: ७ `docs/part2/accelerator_doc.txt` + +᫥ ⥭ ⠫쭮 accelerator doc  ࠢ. + ᯮ ⮫쪮 ਧ⠫/⨪ Fill mode. + +### Quick wins ⥪ primitives + +- [ ] ** SMC `LD A, (var)` block-size**. 㬥  + ࠧ蠥 `LD A, (HL)`, `LD A, (BC)`, `LD A, (DE)` ( `LD A, r`). + 㡥 SMC complexity `gfx_lines.c:hfill_chunk/vfill_chunk` + `gfx_16.c:g16_hfill_chunk`. 饭 ⮫쪮 register-to-register. +- [ ] **஢ block-size**. 㬥 뢠 accel + block size bursts (. `Horizontal_Line_Fill`: ⠭ + size + `LD B,B` ⪫祭, ⮬ Fill mode ᯮ + ࠭ size). `gfx_fill_rect` 100 묨 + ப ? ⠭ size 1 ࠧ, 100. + +### Bank-prefix modes (port 0xE2 bits) + +㬥 뢠 ਠ ࠭ ⠭⭮ 0x50: + +| Bank byte | Effect | +|---|---| +| 0x50 | Normal write ? shadow + | +| 0x54 | "no copy in main shadow RAM" | +| 0x58 | **"FF is transparent"** ? 0xFF write ⠢ background | +| 0x5C | both | + +Bank 0x58 祬 mouse cursor 0xFF-஧筮. + **sprite-blending १ accel block copy**: + +- [ ] **`gfx_set_bank_transparent(on)`** 䫠 `gfx_set_bank` + 롮 0x50/0x58 ᮢ sprite' +- [ ] ᯮ짮 `gfx_blit()` ⮡ 䠪 + transparent sprites १ accel- + +### Block copy mode (sprite blit') + +`LD L,L` (horizontal) `LD A,A` (vertical) ? ० ஢ १ +256- accel memory. blit'. + +- [ ] **`gfx_blit(src_data, x, y, w, h)`** ? ஢ sprite' + (ந ࠧ, १ accel) +- [ ] **`gfx_blit_transparent(src, x, y, w, h)`** ? ᯮ짮 bank 0x58 + +. `Draw_Restangle_Data` accelerator_doc.txt ७. + +### AND / OR / XOR operations १ accel + +㬥 뢠 accel ন ᪨ 樨 +. ਬ: +- XOR ? (뤥 selection UI) +- OR / AND ? masking, alpha-style blending +- . ਬ accelerator_doc.txt: "256 bytes block coding via XOR" + +- [ ] **`gfx_xor_rect`** / **`gfx_or_rect`** / **`gfx_and_rect`** ? + ਬ⨢ ᪨ 権 אַ㣮쭨 +- [ ] **`gfx_invert_rect(x, y, w, h)`** ? alias xor 0xFF + +### Bitmap fonts ࠧ ࠧ஢ + + `gfx_text` / `gfx_putchar` प ࠡ 8?8 ⮬ +(BIOS WIN_GET_ZG 頥 256?8 ). UI / 쭨 +㦭: +- [ ] **`gfx_set_font_size(w, h)`** ? ४ ਭ/ glyph' +- [ ] **`gfx_set_font_data(ptr, w, h, advance)`** ? 㪠⥫ + 짮⥫᪨ + ࠧ +- [ ] প **proportional** (advance != w) ⮢ ? + array advance[256] ਭ glyph' +- [ ] **Big-font ०**: 8?16, 16?16, 16?8 ( 쭨) +- [ ] ⤥ API `gfx_text_ex(x, y, str, font_id)` + font_id 롨ࠥ 㦥 ⮢ +- [ ] **Anti-alias 2-bit ** ( 䮭 / ࠭ / 2- alpha?) + ? far future, smooth UI + +## ⠯ ⨬権 ( ᥩ) + +- **`gfx_line` १ accel ** ? Bresenham |dy| << |dx| ( ) 뤠 runs Y ( X): ᥫ, ᥫ, ᥫ, 蠣 Y, ᥫ, ᥫ... ⠪ run ? ⮢ 㬥 `gfx_hline` ( `vline`). + ᫥: runs 㭪 ; run length, ஬ 룮 accel hline 祬 N?putpixel (overhead accel ~20?s, putpixel ~5?s ? accel 룮 run ? 4-5 px); (dx ? dy) ⠢ Bresenham, ? run-length-based fill. + `gfx_line` orthogonal cases 㦥 १ accel ? ⨬஢ ⮫쪮 . + +- **`gfx_fill_rect` W3-swap ** ? ᥩ ७ `gfx_hline`/`gfx_vline` ᢮ DI/save-W3/restore-W3/EI. ᤥ internal `_fill_rect_inner` ন W3 DI 横; ~20?s ? ⢮ ப/⮫殢 . ਬ ᥬ ਬ⨢. +# MDView ? ᬮ騪 Markdown Sprinter + +**MDView** ? ணࠬ ᬮ 㬥⮢ ଠ *Markdown* +Sprinter ( Z80). 㬥 ࠭ ⤥쭮 W3 +᭮ RAM ணࠬ. + +## + +- 㬥 **128 ** (8 ࠭ EMM 16 ) +- **16 384** ࠭ ப +- ⮬᪨ ७ ᫮ ਭ ࠭ (80 ⮫殢) +- ਧ⠫ ᤢ ப ப ( , ⠡) +- -: 䠩, ப, 業 ப⪨ +- ப ﭨ ६ 㧪 樨 +- প ?? ᪫ ப + +## + +``` +mdview [_䠩.md] +``` + +᫨ 䠩 , 㦠 `README.MD`. + +## ࠢ + +``` + ⢨ + +Up Down ப⪠ ப / +PgUp PgDn ப⪠ ࠭ (30 ப) +Home 砫 㬥 +End 㬥 +Left Right ਧ⠫ ᤢ (⮫쪮 nowrap-ப) +F1 ࠢ +F8 ஢: CP866 ? CP1251 ? KOI8-R ? UTF-8 ? ... +F10 / Esc 室 ணࠬ +``` + +஢ । ⮬᪨ ⨨ (BOM + ⨪ + 4 ); `F8` ४砥 , ᫨ ⥪ 訡. +8- ஢ (CP866/CP1251/KOI8-R) ४ (६ +ᮢ). ன / (ਬ UTF-8) ந ? +ࢮ ४祭 (⪠ 㧠 ᯨ஬), . + +## ⠪ Markdown + +### + +ন ஢ H1?H4. ஢ H5 H6 ⮡ࠦ H4. + + # ࢮ ஢ + ## ண ஢ + ### 쥣 ஢ + #### ⮣ ஢ + +### ⮢ ଠ஢ + +** ⥪** 뤥 묨 񧤮窠: `**⥪**` + +*ᨢ* 뤥 묨 񧤮窠 `*⥪*` ન `_⥪_` + +`஥ ` 砥 묨 窠 + +~~ભ ⥪~~ ? ⨫: `~~⥪~~` + +### 㬥஢ ᯨ᮪ + +થ `-`, `*` `+`: + +- 㭪 ᯨ᪠ +- ன 㭪 ᯨ᪠ +- ⨩ 㭪 筮 ⥪⮬, 室 + 㤥 ७ ᫥ ப ࠭ 㯠 + +### 㬥஢ ᯨ᮪ + +1. +2. ன +3. ⨩ + +### + +> 稭 ᨬ `>`. ᪮쪮 ᫥⥫ +> ப ᪫ ⮬᪨ +> ७ᮬ ᫮. + +### (verbatim) + + 砥 ன 窨. +⥪ ⮡ࠦ ? ? ࠧ Markdown: + +``` +#include +#include + +int main(void) { + puts("Hello, Sprinter!"); + return 0; +} +``` + +### ਧ⠫쭠 + + ᨬ `---`, `***` `___` ⤥쭮 ப: + +--- + +## 孨᪨ ࠪ⨪ + +- **ଠ:** Sprinter, Z80 @ 21 +- **஢:** CP866 / CP1251 / KOI8-R / UTF-8 (⮮।, `F8`) +- **ᨬ ࠧ 䠩:** 128 +- **ᨬ쭮 ᫮ ப :** 16 384 +- **ᨬ쭠 ப ७-:** 255 祥 (. ࠭祭 ) +- ** :** small + - ணࠬ, c⥪, , ? a W1-W2 (32 , 0x4000?0xBFFF). + - 䠩 ? ࠭ EMM, ⮡ࠦ W3 (0xC000?0xFFFF) + +## ࠭祭 + +### ப MD-० ? 255 祥 + +- ࠭ ப ** 255 (ᨬ, ਡ)** +? ⠭ `MAX_CACHE_LINE_LEN`. ⨯: `g_ncells` +`cache_rec_t.len` ? `uint8_t`. ᠥ ப, ⭥ ᥣ +**ਧ⠫쭮 ஫㥬** ப ( ப ⠡, 䫠 +`IF_HSCROLL`), MD-० ࠢ. + +** ந室 ப:** 樨 `gc_put()` +뢠 祩 ᫥ 255- (`if (g_ncells < MAX_CACHE_LINE_LEN)`). + ⮫쪮 255 祥, ⮪ **** ? +஫ ** થ १** 255- 樨 (થ `>` 砥 +? । ?). ९ ? `gc_put` ஢ ࠭. + +: ?255 祥? ? **७७ ਭ**, 室. + ࠧ稢 ஡ ( `TAB_STOP`), 祩 ⠡ +஡ ਭ + ࠬ `` ? ⮬ ⨣ ࠭, 祬 +255 ?? ᨬ. + +> **RAW-० (`F2`) ⮣ ** ? אַ 䠩 +> ⮢, ப 楫 (१ wrap `F3` ਧ. ஫). + +** ** (業, ॠ) ? `uint16_t`: +- `cache_rec_t.len` `uint8_t?uint16_t` ? **஢ 8 ** + (len ꥤ pad-), `idx<<3` . ᯫ⭮. +- `g_ncells` / `g_ncells_at_space` ? `uint16_t` ? 業 **/᪮**: + 16-⭠ 䬥⨪ Z80 祬 `gc_put` (맮 祩) + scan-横. ਥ: **+0.2?0.4 ** + 樨. +- `g_cells[MAX_CACHE_LINE_LEN*2]` near-RAM (W2) ? 業 + ****: `2 ? ` . 510 ; 512 ? +0.5 , 1024 ? +1.5 . + EMM- ⥭ (1 ) ப ﭥ ? 㧪 near. +- `viewport_x` ( `docset_t`) + ⮫ `max_vx` (ᥩ 248) ? `uint16_t`, + ࠭ >255 , ஫ . `widths[]`/`ccx` ⠡/. + + ஬ ? 512?1023: 墠 ᥬ ⨭/⠡栬, + 業 ~+0.3 +0.5?1.5 near-RAM. ** 㬥 `uint16_t`** ? + ⠢ થ १ 255- 樨, ⮡ 뫠 . + +## TODO + +1. **祭 ࠧ 㬥⮢.** 128 : 筮 + ࠧ ࠡ 訬 - ࠭ , ஢ + ࠡ 8- ࠭栬 16. + +: ଠ஢ ⠡ ࠬ; প ஢ +CP866 / CP1251 / KOI8-R / UTF-8 ⮮। ४祭 `F8` +(ன ந , ࢮ ४祭). + +4. **᪮७ ७ਭ.** ப ࠭. ⨬ 横 뢮 + ᨬ १ BIOS WRCHAR ( 뢮, DMA). + +--- + +*MDView v0.2 (c) 2026 ஢ ..* + + +--- + +# Sprinter C Compiler ? v1.0 + +C toolchain for **Sprinter** ? the Z80-based home computer by Peters Plus, running +ESTEX DSS. Host: macOS / Linux. Target: `.EXE` files in SprintEXE format. + +Built on top of **SDCC 4.5** (vendored in `third_party/sdcc/`). This repository adds +everything Sprinter-specific: crt0, linker integration, libc wrappers over ESTEX, +banked-call trampolines, graphics & accelerator API, mouse driver wrappers, and the +`mkexe` utility for producing SprintEXE images. + +## What you get + +* **`bin/sprinter-cc`** ? one-line driver: `sprinter-cc -o foo.exe foo.c` +* **Memory modes**: `tiny`, `small`, `big`, `huge`, `manual` ? see below. +* **stdio + conio**: printf, puts, putchar, getchar, fopen/fread/..., cprintf, cputs, putch, textcolor/textbackground/textattr, gotoxy, kbhit/getch. +* **Graphics**: 320?256?256 and 640?256?16 modes, accelerator-backed primitives (hline / vline / rect / fill_rect / line via Bresenham, plus clear), bitmap-font text in both modes via BIOS character generator. +* **File I/O**: POSIX (`open`/`read`/`write`/`close`/`lseek`/`unlink`/`creat`), FILE\* streams (`fopen`/`fgets`/`fwrite`/...), directory listing (`ffirst`/`fnext`), `chdir`/`getcwd`/`mkdir`/`rmdir`, `stat`/`fstat`. +* **Memory**: 32 KB heap (W2-resident), banking-aware page allocator (`mem_alloc_pages`/`bank_read`/`bank_write`), explicit memory modes for sub-16 KB programs. +* **Mouse**: full Sprinter driver wrapper (14 functions including custom cursor bitmaps). +* **Environment**: `getenv`/`putenv`/`sysenv` over ESTEX `$46`. +* **Time**: `getdatetime`/`setdatetime` + POSIX `time`/`localtime`/`mktime`/`asctime`/`ctime`. +* **Misc**: `errno`/`strerror`/`perror`, `atexit`, `setjmp`/`longjmp`, `sleep`, full argv parsing in crt0. + +## Quick start + +```sh +git clone sprinter-c +cd sprinter-c +make sdcc # one-time: fetch SDCC 4.5 binary (~25 MB) +make all # build mkexe + libsprinter.lib + 27 examples +make floppy # pack everything into mame/v306/IMG/mc.img +cd mame/v306 && ./run_mame.sh # boot Sprinter in MAME +``` + +Compile a single program: + +```sh +cat > hello.c < +int main(void) { puts("Hello, Sprinter!"); return 0; } +EOF + +bin/sprinter-cc -o hello.exe hello.c +``` + +That's it ? `hello.exe` is now a valid SprintEXE you can `RUN HELLO` from the ESTEX shell. + +## Memory modes + +Sprinter's address space is four 16 KB windows (W0 / W1 / W2 / W3). DSS allocates +pages by program size ? small programs get only one page. Pick a memory mode based +on what your program needs: + +| Mode | Code lives in | Banking | Use when | Note | +|---|---|---|---|---| +| `tiny` (default) | W2 (0x8100+) | no | code+data < 14 KB | | +| `small` | W1-W2 (0x4100+) | no | code+data < 30 KB | | +| `big` | W2 + W1 banking | yes (W1) | tiny + extra code modules | | +| `huge` | W1-W2 + W3 banking | yes (W3) | small + extra code modules | | +| `manual` | user-specified | optional | special layouts | Not implemented | + +```sh +sprinter-cc --memory small -o big.exe bigprog.c +sprinter-cc --memory huge -o app.exe main.c --bank 1=engine.c --bank 2=ai.c +``` + +Banked functions are declared with `__banked`: + +```c +void engine_tick(int dt) __banked; // lives in BANK1, automatically swapped +``` + +## Examples (27 total) + +| Example | What it demonstrates | +|---|---| +| `hello` | Hello world with stdio + conio Turbo-C-style colors | +| `argv` | argv parsing in crt0 | +| `cat` | File I/O ? read & print TEST.TXT | +| `seek` | 32-bit lseek over a 100 KB file | +| `ls` | Directory listing via ffirst/fnext | +| `filetest` | FILE\* streams (fopen/fread/...) | +| `stattest` | `stat`/`fstat` on files and directories | +| `errno` | errno / strerror / perror | +| `mem_test` | Page allocator + bank\_read/bank\_write | +| `malloc` | Heap stress test (200+ allocations) | +| `banked` | Banked code in W3 (huge mode) | +| `bankedbg` | Banked code in W1 (big mode) | +| `banklocl` | Bank-local static data and BSS | +| `mouse` | Mouse driver in text mode | +| `gfx_mous` | Mouse with custom bitmap cursor in graphics mode | +| `gfx_demo` | 320?256?256 lines / rects / accelerator | +| `gfx_d16` | 640?256?16 same primitives | +| `gfx_text` | Bitmap-font text on graphics screen | +| `timedir` | Date/time + directory listing | +| `ptime` | POSIX time API | +| `openenv` | open() flags + environment vars | +| `conio` | conio API smoke test | +| `attrprob` | Probe Sprinter text attribute byte layout | +| `strtest` | string.h test (from SDCC's z80.lib) | +| `stdlib` | stdlib.h test (qsort / rand / strtol / etc.) | +| `assrtest` | assert() | +| `rt_test` | Runtime helpers (sleep, setjmp, atexit) | + +## Headers + +Standard: +* `` ? puts / printf / FILE\* + Sprinter-specific dec/hex helpers +* `` ? atoi / atof / malloc / qsort / ... (from SDCC z80.lib) +* `` / `` / `` ? from SDCC z80.lib +* `` ? read / write / close / lseek / unlink +* `` ? open / creat + O\_RDONLY / O\_CREAT / ... +* `` ? errno + error names + strerror +* `` ? stat / fstat +* `` / `` ? from SDCC + +Sprinter-specific: +* `` ? putch / cputs / cprintf, textcolor / textbackground / textattr, kbhit / getch, clrscr, gotoxy, wherex/y +* `` ? gfx_init/done, palette, putpixel, hline/vline/rect/fill_rect/line, text ? for both 320 and 640 modes (gfx_\*16 variants) +* `` ? full 14-function driver wrapper + mouse_cursor_t with bitmap support +* `` ? chdir / getcwd / mkdir / rmdir / ffirst / fnext / ffblk +* `` ? getdatetime / setdatetime + POSIX time / localtime / etc. +* `` ? raw ports, ESTEX/BIOS function numbers, env API +* `` ? exit / \_exit / atexit +* `` ? mem\_alloc\_pages / mem\_free\_block / bank\_read / bank\_write +* `` ? Solid-C compatibility layer (aliases + BOOL/WORD/uint types) + +## Toolchain commands + +```sh +make all # build mkexe + lib + every example +make floppy # repack mame/v306/IMG/mc.img with all .exe files +make check # 17 mkexe unit-tests +make clean # remove all build artefacts +make sdcc # one-time: fetch SDCC 4.5 binary +``` + +### sprinter-cc options + +``` +sprinter-cc -o foo.exe foo.c [more.c ...] [options] + + --memory MODE tiny | small | big | huge | manual (default: tiny) + --memory-manual SPEC explicit placement (CODE=W1|W2,DATA=W1|W2|SAME,BANKED=W1|W3) + --stack-size N bytes reserved for the stack (default ~1278) + --crt0=TYPE default | minimal | banked | small + --bank N=FILE.c compile FILE.c into bank N (repeatable, max 15) + --debug enable runtime diagnostics (defines DEBUG_RT) + -I PATH extra include path + -L 0xADDR / -E / -S override load / entry / stack addresses + -Wl FLAG pass FLAG to sdldz80 + --mkexe FLAG pass FLAG to mkexe (e.g. --mkexe -p --mkexe 0 for bank padding) + -v verbose +``` + +## Status + +What works in v1.0: +* Compile / link / pack to SprintEXE ? verified on all 27 examples +* Four memory modes (tiny / small / big / huge) +* Graphics (both modes) with accelerator +* Mouse (text + graphics cursor) +* File I/O, directories, environment, time +* All headers listed above + +Deferred to v2.0 (see `docs/TODO.md`): +* **Turbo-C-style BGI graphics API** ? `initgraph` / `setcolor` / `circle` / + `getimage` / `putimage` / etc. on top of our `gfx_*` primitives +* Remaining Solid-C compatibility gaps (Phase 2/3) ? see `docs/solid_c_compatibility.md` +* Manual memory mode +* Rewrite FILE\* stream API (current implementation is very primitive and doesn't use buffers) + +Deferred to v3.0: +* **IM2 interrupt handlers** ? research complete (`docs/im2_isr_design.md`), + implementation scheduled for v3 +* **Audio API** (AY-3-8910 + COVOX) ? requires IM2 +* **ISA-8 slot drivers** ? requires IM2 (???) + +## Documentation + +* `docs/TODO.md` ? roadmap and open work items +* `docs/solid_c_compatibility.md` ? gap analysis vs Solid-C 2004 +* `docs/im2_isr_design.md` ? interrupt handler design (v2) +* `docs/converted/` ? source documentation (ESTEX, BIOS, architecture) + converted to plain text for `grep` +* `docs/reference/`, `docs/samples/`, `docs/memory management/` ? original + Russian docs and code samples from Peters Plus + +## Repository layout + +``` +bin/sprinter-cc one-line compiler driver (bash) +toolchain/mkexe/ host-side tool: .ihx -> .exe SprintEXE +toolchain/check_banks.py post-link bank size enforcer +runtime/ crt0 variants (default, minimal, small, banked) + bank trampolines, heap, heap_top +libc/include/ headers +libc/io|stdio|mem|gfx/ C and asm sources for libsprinter.lib +lib/ Makefile that archives libsprinter.lib via sdar +examples/ 27 example programs +mame/v306/ MAME binary + Sprinter ROM/HDD images + floppy script +third_party/sdcc/ vendored SDCC 4.5 (fetched via `make sdcc`) +third_party/solid-c/ reference: original Sprinter native C (for compat target) +docs/ documentation +``` + +## License + +This repository contains: +* Original code in `bin/`, `toolchain/`, `runtime/`, `libc/`, `lib/`, `examples/` ? + MIT-licensed. +* `third_party/sdcc/` ? SDCC 4.5 under GPLv2 with linking exception + (see `third_party/sdcc/COPYING.txt`) +* `third_party/solid-c/` ? original Sprinter Solid C, used only as a reference + +## Credits + +* **Sprinter / Peters Plus** ? , ਩ ਭ and the original team +* **SDCC** ? for the underlying Z80 compiler +* **MAME** ? for the Sprinter Sp2000 emulation + +--- + +For questions / patches: see CONTRIBUTING.md (TBD) or open an issue. + +--- + +# TODO / Roadmap + + 浪 뢠 ਮ.  ॠ ணࠬ ? ਮ ᬥ. + +## ⠯ 5 ? malloc / free + banking-aware page allocator ? + +- [x] SDCC's `malloc`/`free` + `runtime/heap.s` ( library heap.rel, 14000- heap 2) +- [x] `libc/mem/mem_alloc.c` ? page allocator: `mem_alloc_pages`/`mem_free_block`/`mem_get_page`/`mem_info` १ ESTEX `$3C/$3D/$3E` + BIOS `$C4` +- [x] `libc/mem/bank_io.c` ? HOME-१ `bank_read`/`bank_write`/`bank_load_byte`/`bank_store_byte` ᢮ W3 +- [x] `examples/malloc_test/` ? ஢ઠ SDCC's malloc (~210 64- allocations १ heap) +- [x] `examples/mem_test/` ? ஢ઠ page allocator: 3 ࠭, ࠧ १ bank_write, 䨪 १ bank_read + +## ⠯ 6 ? argv parsing + sprinter-cc wrapper ? + +- [x] crt0 ESTEX command-line IX-prefix (inline asm `runtime/crt0.s`) +- [x] Strip leading CP/M-style space (DSS quirk) +- [x] । `argc`/`argv` main() १ HL/DE (SDCC __sdcccall(1) ABI) +- [x] argv[0] = basename .EXE १ ESTEX APPINFO ($47 subfn 2) +- [x] `runtime/crt0_minimal.s` ? opt-out 祭 쪨 ணࠬ +- [x] `runtime/crt0_banked.s` ? ⥯ ⮦ argv (parse_argv + get_progname ᪮஢ crt0.s; 㤥 factored argv.s libsprinter.lib) +- [x] Bash-⪠ `bin/sprinter-cc`: `sprinter-cc -o foo.exe foo.c` ப +- [x] প 権: `--memory`, `--memory-manual`, `--stack-size`, `--crt0=`, `--bank N=FILE.c`, `--debug`, `-I`, `-L`/`-E`/`-S`, `-Wl`, `--mkexe` + +## ⠯ 8 ? 䨪 (320?256?256 + 640?256?16 + accel + bitmap font) ? + +- [x] **8a** Graphics core: `gfx_init`/`gfx_done`/`gfx_clear`/`gfx_putpixel`/`gfx_pal_load`/`gfx_pal_set` (libc/gfx/gfx_core.c). १ BIOS PIC_SET_PAL ($A4). Verified 320?256?256. +- [x] **8b** /אַ㣮쭨/fill १ accelerator (libc/gfx/gfx_lines.c): `gfx_hline`/`gfx_vline` १ accel Fill (LD C,C / LD E,E + SMC block-size), `gfx_rect`/`gfx_fill_rect` heuristic 롮஬ ਥ樨 (h/v bursts count), `gfx_line` Bresenham . `gfx_clear` ⮦ ९ᠭ column-major accel (~4? ॥). +- [x] **8c** 640?256?16 mode (libc/gfx/gfx_16.c): `gfx_*16` API, HIGH nibble = LEFT pixel (㬥 misleading), per-row RMW vline ( = 2 ਧ⠫ ᥫ). +- [x] **8d** Bitmap font + gfx_text (libc/gfx/gfx_text.c): १ BIOS WIN_GET_ZG ($B8), interleaved layout `font[row*256+char]`, `gfx_text`/`gfx_putchar` 320 mode, `gfx_text16`/`gfx_putchar16` 640 mode pair-table lookup. + +. memory/sprinter_graphics.md, sprinter_accelerator.md, sprinter_graphics_16.md, sprinter_font_format.md. + + ( ): +- [ ] -quad 640: per-cell (mode 0x82 ࠧ蠥 1 4 per 16?8 cell) ? १ אַ area-ᠭ ࠭ 0x0300..0x039F + +## Auto-banking (. `memory/banking_roadmap.md` ⠫) + +Phase 1 ? file-level bin-packing ? ॠ뢠 ஥ ~30 KB . + +- [ ] `toolchain/auto_bank.py`: + - ࠧ `.rel`-䠩 ( .map ᫥ dry-run link') + - First-fit-decreasing bin-packing + - `#pragma codeseg BANKn` manual override + - ५뢠 묨 `-Wl-b_BANKn=...` ࠬࠬ + - ⠥ । + +Phase 2-5: incremental rebalance, declarative `banks.toml`, function-level, call-graph-aware. 쪮 ᫨/ . + +## Bank-local static data (mutable data ⮬ ) ? ? + +- [x] ਬ `examples/bank_local_data/` ? 㭪 BANK1 ᢮ writable BSS array + const table + malloc- +- [x] `mkexe -p 0` 㫥 padding (BSS-storage 㧪) +- [x] ᪨ 楯: `--codeseg BANK1 --constseg BANK1 --dataseg BANK1` bank1.c + `-Wl-b_BANK1=0x1C000` . **`--dataseg BANK1` ** ? ࠭ ⭮ - trampoline bug ᪨஢ १. +- [x] ** 䨪 trampoline'a runtime/bank.s** ? `pop af; out (n), a` ਫ A ? banked-㭪樨 騥 uint8_t 頫 . `pop bc; out (c), b` ࠭ A. +- [x] **malloc banked-㭪樨 ࠡ⠥ ஧筮** ? heap W2 (HOME), W2 ᢠ trampoline', pointer  ⥪. . memory/bank_local_data_pattern.md. +- [x] 㬥 memory: `memory/bank_local_data_pattern.md` ( 楯 + malloc + nuances), `memory/sdcc_banking.md` (trampoline fix) +- [ ] 樮쭮 ? `check_banks.py` ⮡ 뢠 ࠧ size = code + const + bss per bank (cosmetic) + +祬: 㫥 訬 private state (level loader, audio engine, scene data). W2 heap , ⨪ . + +## ᪠ solid-c (⨢ Sprinter C ? `third_party/solid-c/`) + +᫥ solid-c'᪮ libc (. `memory/solid_c_findings.md`)  ⮢ ᫥ 㭪権. ਮ **᮪** : + +### High-priority gaps ( ஢, 짠) +- [x] **`errno` + `strerror`/`perror`** ? ⠡窠 32 訡 (libc/io/errno.c) +- [x] **७ `open()`** O_CREAT/O_TRUNC/O_APPEND/O_EXCL state machine +- [x] **`atexit`** ? 8-callback LIFO + `exit()` + `_exit()` (libc/io/atexit.c) +- [x] **`setjmp`/`longjmp`** ? 6- jmp_buf={sp,ix,pc} (libc/io/setjmp.c) +- [x] **`sleep(seconds)`** ? 50Hz halt-loop (libc/io/sleep.c) +- [x] **ESTEX ENV API** ($46, getenv/putenv) ? libc/io/env.c. 竨 doc-bug: ॠ쭮 A=0 NOT FOUND + +### Medium-priority (㦭 shell-like ⨫) +- [ ] **Mouse driver** ? `rst $30h`, 17 㭪権. **砫 ࠡ⠥ MAME**. +- [x] **`ffirst`/`fnext` + ffblk_t struct** directory listing ? ॠ, demo: ls.exe +- [x] **`getdatetime`/`setdatetime`** १ ESTEX $21/$22 ? libc/io/time.c, demo: time_dir_test +- [x] **`chdir`/`getcwd`/`mkdir`/`rmdir`** ? wrappers ESTEX $1B-$1E ? libc/io/fsdir.c +- [x] **conio: `kbhit`/`getch`/`getche`/`cputs`/`clrscr`/`gotoxy`** ? ॠ +- [x] **conio extras**: `wherex`/`wherey` ($53), `wrchar`/`rdchar` ($58/$57), `textmode_get/set` ($50/$51), `clrscr_attr` ($56) + COLOR macros + +### Low-priority ? ? FILE* stack + +- [x] ** unbuffered FILE\*** ? `libc/stdio/file.c` + `libc/include/stdio.h`. fopen/fclose/fputs/fgets/fread/fwrite/fseek/ftell/rewind/feof/ferror/clearerr/fflush + stdin/stdout/stderr pseudo-streams. . `memory/file_star_design.md` `examples/filetest`. +- [ ] fprintf / fscanf ? 㦭 printf-१-callback machinery. 짮⥫ `sprintf(buf, ...) + fputs(buf, fp)`. +- [ ] 樮 buffered mode (setvbuf, line/block buffering) ? ᫨ - . + +### POSIX time API ? ? +- [x] `libc/io/posix_time.c` ? time/localtime/gmtime/mktime/asctime/ctime getdatetime. SDCC's time.rel ( override _RtcRead). . `examples/ptime`. + +### sys/stat ? ? +- [x] `libc/io/stat.c` ? POSIX stat/fstat. ਤ open+fstat 䠩, ffirst+iter ( "."/".."). . `examples/stattest` `memory/estex_ffirst_dotdot.md`. + +### assert ? ? (ᯮ㥬 SDCC's __assert १ fallback include path) + +## libc/stdlib ? ? 㦭 (. memory/sdcc_stdlib_works.md) + +஢७ १ `examples/stdlib_test/`: SDCC z80.lib ᮤন ࠡ騥 ॠ樨: +- `atoi/atol/atof, strtol/strtoul, rand/srand, qsort/bsearch, abs/labs, div/ldiv` +- `` (memchr/cmp/set/cpy, strcat/cmp/cpy/len/chr/spn/etc.) +- `` (toupper/tolower) +- `` (sinf/cosf/sqrtf/etc.) + + ⮬᪨ ﭥ z80.lib 㦭. ** ९뢠**. + + Sprinter-specific 易⥫ 㫨 : atexit, env, errno, setjmp, putchar/puts/getchar, conio, fsdir, time, mouse, open/read/lseek/close. + +## Build-system: libsprinter.lib + sprinter-cc ? ? + +- [x] `lib/Makefile` ? ᮡࠥ libc/*.c `.rel`, 娢 १ sdar `lib/sprinter.lib` +- [x] 砥 runtime/bank.s runtime/heap.s (auto-pulled __banked/malloc) +- [x] `bin/sprinter-cc` ? bash-wrapper: `sprinter-cc -o foo.exe foo.c` ப +- [x] প 権 `--crt0=default|minimal|banked`, `--bank N=FILE.c`, `-I`, `-L`/`-E`/`-S`, `-Wl`, `--mkexe` +- [x] `examples/hello_sccc/` ? : `hello.c` ᮡࠥ shell-맮, ࠧ ᮢ Makefile (925 ) +- [x] Split `putchar.c` ? `putchar.c` + `puts.c` per-function granularity (puts override SDCC's z80.lib version) +- [x] `make all` (ᨬ `lib` । `examples`) + + 襭 (樮쭮): +- [ ] ஢ ⠫ examples sprinter-cc Makefile (ᬥ⨪) +- [ ] 쭥 libc/*.c per-function ( ⥪ granularity 㦥 㦭 ࠧ ? .rel 楫, 設⢠ 䠩 㭪) + +## ⠯ 9 ? memory modes sprinter-cc + +DSS 뤥 ࠭ ࠧ ਫ: < 16 KB ? ࠭, ⠫ 砥 ?࠭ #FF? (read=0xFF, write ). - ⮣ CODE--W1 + DATA--W2 쪮 ணࠬ . . [memory/sprinter_memory_modes.md](../../.claude/projects/-Volumes-SAM8-Projects-DIY-Z80-Sprinter-C-Compiler/memory/sprinter_memory_modes.md). + +- [x] **`tiny`**: (CODE+DATA+⥪) W2. Default. Verified hello/argv/conio/malloc/file/etc. +- [x] **`--memory MODE` 䫠 sprinter-cc**: parser + per-mode 䮫 CODE_LOC/DATA_LOC, override १  `--code-loc`/`--data-loc`. tiny ࠡ⠥; small/big/huge warning' (runtime ⮢). 2026-05-30. +- [x] **`--memory-manual SPEC`**: `CODE=W1|W2,DATA=W1|W2|SAME,BANKED=W1|W3`. 2026-05-30. +- [x] **`small` runtime**: `runtime/crt0_small.s` ᯮ ESTEX `$3D GETMEM` + `$3A SETWIN2` ⮡ 뤥 W2-࠭ gsinit. **** BIOS `$C4` ? ⥪ ⮬ ⠯ W1 (boot_stack HOME), BIOS ॡ ⥪ W2. ᫥ SP ४砥 0xBFFE, ⠭ flow. 2026-05-30, verified hello.exe. +- [x] **`small` auto-detect >16 KB ணࠬ**: `crt0_small.s` ⠥ `0xC2` (⥪ ࠭ W2 ? `0xA2`! W1). ᫨ 0xFF ? 뤥 page; DSS 㦥 ᤥ (ணࠬ ᠬ 뫥 W2). crt0 뢠 0..30 KB. mkexe ⠪ ࠧ蠥 HOME span W1+W2 (0x4000..0xBFFF). Verified hello: small (5 KB 䠩, SETWIN2 path) + 32 KB 䠩 (auto-skip). 2026-05-30. +- [x] **`big` runtime** (tiny + banked code W1): ࠬਧ `crt0_banked.s` + `bank.s` १ `.ifdef BANK_W1` ? 㣮 banking port (0xA2 vs 0xE2), 㣮 load-addr (0x4000 vs 0xC000). sprinter-cc prepend' `BANK_W1 = 1` `--memory big`, । `mkexe -B 0x4000`. ਬ `examples/banked_big/`. 2026-05-30. +- [x] **`huge` runtime** (small + banked code W3): merge W2-detect `crt0_small.s` `crt0_banked.s`. 騩 ਬ `examples/banked/` ⥯ ᯮ MEMORY=huge. 2026-05-30. +- [x] **`--debug` 䫠**: prepend `DEBUG_RT = 1` crt0 + `-DDEBUG_RT` sdcc. 뢠 symbol `_w2_self_allocated` (uint8_t) ? runtime diagnostic ஢ W2. 2026-05-30. + +### -襭 libc crt0 + +** `sprinter.lib`** ࠡ⠥ memory mode ? `.rel`-童 relocatable, SDLD dead-code elimination per-member ( 䨪  `gfx_core.rel` ..). Verified hello vs malloc_test १ map-䠩. + +**`gfx.lib` ⤥쭮 ? 㦥**: dead-code elimination 㦥 ࠡ⠥. + +**`libc_banked` (libc bank HOME)** ? ⮬, HOME (16 KB) user- + libc `huge` mode. १ `--codeseg BANK0` 樨 libc; trade-off: trampoline ~30 横 libc-맮. ਣ: ॠ쭠 ணࠬ HOME budget. + +**HW-ᨬ 㫨 ? `sprinter_home.lib` ⤥쭮.** libc 䨧᪨ W3, ⮬ W3: +- `gfx_*` ? `0xC000+` ᫥ swap W3 video page +- `bank_io` (mem_alloc_pages/bank_read/bank_write) ? swap' W3 १ `OUT (0xE2)` +- 騥 ISR ? 뢠 ਩ W3 㣮 + + huge mode 㫨 HOME (W1). 㤥 `libc_banked`, **६** 뤥塞 `sprinter_home.lib` (HOME-only) `sprinter.lib` (bankable). 쭠 奬: +``` +sprinter_home.lib HOME-only: gfx, bank_io, ISR shims +sprinter.lib bankable: printf, malloc, string, conio, stdio, env, ... +sprinter_banked.lib sprinter.lib --codeseg BANK0 ( huge) +``` +ਣ: ॠ `--memory huge` runtime. + +**crt0 ? mode:** +- `crt0.s` ? ⥪騩, **tiny/big**: SP=0xBFFE, argv (W2- 㦥 뤥 DSS). +- `crt0_minimal.s` ? ⥪騩, tiny argv. +- `crt0_small.s` ? **, step 3**: **small/huge**, W2 १ `mem_alloc_pages` gsinit, `0xA2`, ⮬ ⠭ flow. +- `crt0_banked.s` ? ⥪騩, **big**: trampoline-⠡ W3 , CODE W2. +- `crt0_banked_small.s` ? ****: huge = small (W2-alloc) + banked (W3 trampolines). + +sprinter-cc ࠥ crt0 `--memory` mode (ᥩ `--crt0=` override). +- [x] **ࠨ ࠧ ⥪**: 䫠 `sprinter-cc --stack-size BYTES`. Wrapper `heap_top.s` `___sdcc_heap_end = stack_top + 1 - stack_size`, ⤥ .rel per-program. Default ?1278 (heap_top=0xBB00) `runtime/heap_top.s`. 2026-05-30. + +䥩: `sprinter-cc --memory [tiny|small|big|huge|manual] [--memory-manual SPEC] [--stack-size N] foo.c`. `--memory-manual` ⮫쪮 `--memory manual`. + +## Known issues / quirks + +- **ESTEX $46 ENV API**: ? ࠡ⠥. - `DiskSyscalls.txt v1.6` 訡筮 뢠 return-status ? A=0 NOT FOUND, FOUND. 䨪஢ `memory/sprinter_platform.md`. + +## V2 (᫥ ५ v1) + +### Turbo-C-style graphics API (BGI-like) ? **MUST v2** + + `gfx_*` API ஢ **Turbo-C ``** (BGI) MS-DOS. +ணࠬ ਢ訥 Turbo-C ७ ᪨ 1--1. + +** ** ( ᭮ Borland BGI): + +Setup/teardown: +- `initgraph()` / `closegraph()` ? ᥩ `gfx_init`/`gfx_done`, alias +- `getmaxx()` / `getmaxy()` ? GFX_WIDTH-1 / GFX_HEIGHT-1 +- `cleardevice()` ? alias to gfx_clear +- `getgraphmode()` / `setgraphmode()` ? get_videomode/set_videomode + +Color/palette: +- `setcolor(c)`, `getcolor()` ? current draw color +- `setbkcolor(c)`, `getbkcolor()` ? background color +- `setpalette(idx, c)` ? entry +- `getpalette(&info)` ? read all palette + +Primitives ( 㦥 ? BGI- aliases): +- `putpixel(x, y, c)` ? gfx_putpixel +- `getpixel(x, y)` ? 㦭 ॠ (RMW ⭮ ? IN) +- `moveto(x, y)`, `lineto(x, y)`, `linerel(dx, dy)` ? current point + line drawing +- `line(x1, y1, x2, y2)` ? gfx_line +- `rectangle(x1, y1, x2, y2)` ? gfx_rect ( 㣮 API: x1,y1,x2,y2 vs x,y,w,h!) +- `bar(x1, y1, x2, y2)` ? gfx_fill_rect +- `bar3d(x1, y1, x2, y2, depth, topflag)` ? : rect + 3d edges +- `circle(x, y, r)`, `arc(...)`, `ellipse(...)`, `pieslice(...)` ? primitives +- `fillpoly()`, `drawpoly()` ? +- `floodfill(x, y, border_color)` ? + +Text on graphics screen: +- `outtext(s)` / `outtextxy(x, y, s)` ? gfx_text (alias) +- `settextstyle(font, dir, size)` ? multiple bitmap fonts +- `gettextsettings(&info)` +- `textwidth(s)` / `textheight(s)` ? measure + +Image manipulation: +- `imagesize(x1, y1, x2, y2)` ? bytes needed for getimage +- `getimage(x1, y1, x2, y2, buf)` ? save rect to buffer +- `putimage(x, y, buf, op)` ? paste back with COPY_PUT/XOR_PUT/AND_PUT/OR_PUT/NOT_PUT + +Clipping/viewport: +- `setviewport(x1, y1, x2, y2, clip)` ? drawing clip rect +- `getviewsettings(&info)` +- `clearviewport()` +- `setactivepage(p)` / `setvisualpage(p)` ? ਧ (Sprinter 2 screen) + +Line style: +- `setlinestyle(style, pattern, thickness)` ? SOLID_LINE / DOTTED_LINE / etc. +- `getlinesettings(&info)` + +**Acceptance:** ७ ⨯筮 Turbo-C BGI ணࠬ (饩 ᯮ짮 +moveto/lineto/circle/bar/setcolor) ࠡ ⢥ ࠢ. + +**Notes:** +- BGI fonts (TRIPLEX/SANS_SERIF/GOTHIC) ? BIOS font, ⠫ 㦭 + ( bitmap data lib) +- imagesize/getimage/putimage ? ᠬ ॡ game/animation +- Active/visual page ( ਧ) ? Sprinter ন 2 graphics pages, + 㦥 API switching + +. ⠪ `examples/` Turbo C 2.x BGIDEMO reference 㦭. + +### IM2 Interrupt Handlers ? **MUST v2** + +User- ISR १ Z80 IM 2 mode. 㦭 : +- Timer ticks (50 Hz frame counter, ) +- Music playback (AY, COVOX) +- Real-time games (input + game logic + render interrupt-driven) +- Async keyboard / mouse handling + +**Status:** v2. research + design `docs/im2_isr_design.md`. + +**襭 ⥪:** ॠ ⤥ memory mode `--memory im2` +( ⮣ ⮡ 騥 crt0). Detail' design-doc. + +** research'** ( ⥪ `docs/im2_isr_design.md`): +- Vector 0xFF ? frame + keyboard + CBL. Disambiguation ⠬ 0x19 / 0xFE +- Mouse hardware-IRQ 室 ( ⥪饩 ) +- Vector table / ISR / stack W2 (0x8000..0xBFFF) +- DSS ᢮ IM 2 handler ? 㦭 chain' ( / SYSTIME ) + +### 稥 㯭 㭪 v2 + +- [ ] **FILE API rewrite ? buffered streams** ? ⥪ ॠ + `libc/stdio/file.c` provisional unbuffered shim ( fputc/fgetc + = read/write syscall). 㦭 業 buffered ᥬ⨪ + Solid-C: + + ```c + typedef struct { + uint flags; // +0..1 file status flags + int level; // +2..3 empty/fill level of buffer + char *curp; // +4..5 current active pointer + int fd; // +6..7 underlying low-level fd + char *buffer; // +8..9 data transfer buffer + char hold; // +10 ungetc byte if no buffer + short token; // +11..12 reserved + char dummy; // +13 reserved + } FILE; + ``` + + stdin/stdout/stderr ? fd-થ `0 / -1 / -2`. ⥫ + stdout/stderr ࠭ ७: ESTEX OPEN positive + small fd (1, 2, ?) 筮 䠩 ? ᫨ stdout=1, ॠ + fd=1 ⠫ 䨪஬. fd=0 stdin ᭮ + (ESTEX 0 頥). fd । syscall' ? + ᯥਧ 䫠 `_F_CONIN/_F_CONOUT`. + + ਭ-⮪ (stdaux/stdprn) ॠ㥬 ? Sprinter ਭ୮ + API . + + ୠ⨢ ? ॠ third_party/solid-c (sources + `SRC/CLIB/`); ⠬ ⮢ buffered FILE + fopen/fread/fwrite/ + fseek/setvbuf .. ஢ 訬 open/read/write/lseek. + + rewrite deferred issues stdio-review: + - `fwrite` short-write ⠢ `_F_ERROR` + - `fgets(buf, 1, fp)` ? ⠭ "empty string", 㫨 NULL + - `mode_to_flags` ? break-out '+' (cosmetic) + +- [ ] **Audio API** ? AY-3-8910 + COVOX १ 뢠 (ॡ IM2) +- [ ] **ISA-8 slot support** ? ZX-Bus (sound, network, etc.) ? ॡ IM2 + ⥭ port + +## 稥 (v1 backlog, 騥) + +- [x] **#9: text I/O split (Turbo-C style)** ? stdio (puts/printf/putchar) ⥯ fast no-attr १ PCHARS/PUTCHAR. conio (cputs/cprintf/putch) ਬ attr १ textcolor/textbackground/textattr. KEEP_EXIST_ATTR ? conio fallback fast path. Verified hello.exe. . `memory/text_output_api_split.md`. 2026-05-31. +- [x] **Mouse API ** (१ driver, RST 30h) ? 14 㭪権 (init/show/hide/refresh/read/goto/bounds/text_cursor/load_cursor/get_cursor/get/set_sensitivity/video_mode_changed). . `memory/mouse_api.md`. Verified MAME 2026-05-31. Sensitivity = divider ( = ॥). +- [ ] Interrupt handlers ? IM 2 vector table HOME user ISR' +- [ ] প `restore SP on EXIT` ( z88dk +pps) ? ஢ 㦭 +- [ ] CI: ⮬᪨ ᪠ MAME `-aviwrite` screenshot-ࠢ, ⮡ ਬ஢ 室 祫 + +## ⮬ + +- প `` ( SDCC stdlib ? 㦭 ஢ crt0 ᮢ⨬) +- `` १ ESTEX SYSTIME (`$21`) CMOS BIOS-㭪樨 +- ZX Spectrum-ᮢ⨬ ० ⤥ target ( ஢ ᯥ㬮᪨ ணࠬ) +- প ZX-Bus (sound, network, etc.) ? 㦭 ࠩ +- Profile-guided optimization tools (hot/cold detection) 㯭 ணࠬ + +## Linker duplicate-symbol warnings (, 䨫஢) + + ᮧ⥫쭮 overrides' SDCC z80.lib 㭪樨 ᮡ⢥ ᨥ `sprinter.lib`, `sdldz80` `?ASlink-Warning-Definition of public symbol '...' found more than once`. ࢮ । (), ⮬ ४⭮ ? warning ⮫쪮 noise. + +騥 overrides: +- `_puts` ? १ PCHARS+\r\n vs SDCC posix puts +- `___sdcc_heap` ? heap W2 vs SDCC's ⠭ +- `_asctime`, `_localtime` ( 㣨 time) ? `posix_time.c` १ ESTEX SYSTIME vs SDCC's `time.rel` `_RtcRead` + +**饥 襭:** `bin/sprinter-cc` 䨫஢뢠 warning- (warning + 2 follow-up `Library:` ப) 뢮 `sdcc`. १ `-v` (verbose) 뢠. १ awk-pipe. + +** 襭:** +- ३ explicit `--nostdlib` + 筮 ᯨ᮪ 㦭 㫥 z80.lib (string, math, stdlib override') ? warning', ᪨஢ +- : २ `_puts` ? `_puts_sprinter` + alias १ linker flag ( 㢥७ SDCC ন) +- : ⠢ ᥩ (ࠡ祥 benign) ? ਮ + +## TODO: ஢ ॠ쭮 + +- [ ] **Port_Y banking trick** (`docs/part2/SprinterGraphics programming.txt`): + ⢥ত ᫥ `OUT (0x89), Y` 0xC000+0x400*N W3 + ப Y..Y+15 ( ணࠬ஢ ? 16 ப). + Empirical 2026-06-01 MAME 0.283 trick ** ࠡ⠥** ? ᥫ + ᠬ 0xC000+row_width 室 . ᪨ + `docs/samples/plasma2.asm` ⮦ ᯮ banking, ⠭ + Port_Y per row. + : + 1. ॠ쭮 Sprinter + 2. dual-write (`_gfx_putpixel_raw` + ன write `0xD000+x`) + 3. ᫨ ? MAME, issue + ९ + 4. ᫨ ⮦ ? 㬥 , 㤠 㯮 + ⠢ ⥪ ॠ (Port_Y per pixel) + 5. ᫨ banking ࠡ⠥ ? ஢ Port_Y + `_gfx_putpixel_raw` (sentinel out-of-range, . memory/gfx_port_y_banking.md) + + 易 먣 Bresenham (60-pixel ) ? 8? + OUT (0x89) 権, `gfx_fill_rect 320x256` ? 16? . + release v1. + +## GFX: ७ `docs/part2/accelerator_doc.txt` + +᫥ ⥭ ⠫쭮 accelerator doc  ࠢ. + ᯮ ⮫쪮 ਧ⠫/⨪ Fill mode. + +### Quick wins ⥪ primitives + +- [ ] ** SMC `LD A, (var)` block-size**. 㬥  + ࠧ蠥 `LD A, (HL)`, `LD A, (BC)`, `LD A, (DE)` ( `LD A, r`). + 㡥 SMC complexity `gfx_lines.c:hfill_chunk/vfill_chunk` + `gfx_16.c:g16_hfill_chunk`. 饭 ⮫쪮 register-to-register. +- [ ] **஢ block-size**. 㬥 뢠 accel + block size bursts (. `Horizontal_Line_Fill`: ⠭ + size + `LD B,B` ⪫祭, ⮬ Fill mode ᯮ + ࠭ size). `gfx_fill_rect` 100 묨 + ப ? ⠭ size 1 ࠧ, 100. + +### Bank-prefix modes (port 0xE2 bits) + +㬥 뢠 ਠ ࠭ ⠭⭮ 0x50: + +| Bank byte | Effect | +|---|---| +| 0x50 | Normal write ? shadow + | +| 0x54 | "no copy in main shadow RAM" | +| 0x58 | **"FF is transparent"** ? 0xFF write ⠢ background | +| 0x5C | both | + +Bank 0x58 祬 mouse cursor 0xFF-஧筮. + **sprite-blending १ accel block copy**: + +- [ ] **`gfx_set_bank_transparent(on)`** 䫠 `gfx_set_bank` + 롮 0x50/0x58 ᮢ sprite' +- [ ] ᯮ짮 `gfx_blit()` ⮡ 䠪 + transparent sprites १ accel- + +### Block copy mode (sprite blit') + +`LD L,L` (horizontal) `LD A,A` (vertical) ? ० ஢ १ +256- accel memory. blit'. + +- [ ] **`gfx_blit(src_data, x, y, w, h)`** ? ஢ sprite' + (ந ࠧ, १ accel) +- [ ] **`gfx_blit_transparent(src, x, y, w, h)`** ? ᯮ짮 bank 0x58 + +. `Draw_Restangle_Data` accelerator_doc.txt ७. + +### AND / OR / XOR operations १ accel + +㬥 뢠 accel ন ᪨ 樨 +. ਬ: +- XOR ? (뤥 selection UI) +- OR / AND ? masking, alpha-style blending +- . ਬ accelerator_doc.txt: "256 bytes block coding via XOR" + +- [ ] **`gfx_xor_rect`** / **`gfx_or_rect`** / **`gfx_and_rect`** ? + ਬ⨢ ᪨ 権 אַ㣮쭨 +- [ ] **`gfx_invert_rect(x, y, w, h)`** ? alias xor 0xFF + +### Bitmap fonts ࠧ ࠧ஢ + + `gfx_text` / `gfx_putchar` प ࠡ 8?8 ⮬ +(BIOS WIN_GET_ZG 頥 256?8 ). UI / 쭨 +㦭: +- [ ] **`gfx_set_font_size(w, h)`** ? ४ ਭ/ glyph' +- [ ] **`gfx_set_font_data(ptr, w, h, advance)`** ? 㪠⥫ + 짮⥫᪨ + ࠧ +- [ ] প **proportional** (advance != w) ⮢ ? + array advance[256] ਭ glyph' +- [ ] **Big-font ०**: 8?16, 16?16, 16?8 ( 쭨) +- [ ] ⤥ API `gfx_text_ex(x, y, str, font_id)` + font_id 롨ࠥ 㦥 ⮢ +- [ ] **Anti-alias 2-bit ** ( 䮭 / ࠭ / 2- alpha?) + ? far future, smooth UI + +## ⠯ ⨬権 ( ᥩ) + +- **`gfx_line` १ accel ** ? Bresenham |dy| << |dx| ( ) 뤠 runs Y ( X): ᥫ, ᥫ, ᥫ, 蠣 Y, ᥫ, ᥫ... ⠪ run ? ⮢ 㬥 `gfx_hline` ( `vline`). + ᫥: runs 㭪 ; run length, ஬ 룮 accel hline 祬 N?putpixel (overhead accel ~20?s, putpixel ~5?s ? accel 룮 run ? 4-5 px); (dx ? dy) ⠢ Bresenham, ? run-length-based fill. + `gfx_line` orthogonal cases 㦥 १ accel ? ⨬஢ ⮫쪮 . + +- **`gfx_fill_rect` W3-swap ** ? ᥩ ७ `gfx_hline`/`gfx_vline` ᢮ DI/save-W3/restore-W3/EI. ᤥ internal `_fill_rect_inner` ন W3 DI 横; ~20?s ? ⢮ ப/⮫殢 . ਬ ᥬ ਬ⨢. +# MDView ? ᬮ騪 Markdown Sprinter + +**MDView** ? ணࠬ ᬮ 㬥⮢ ଠ *Markdown* +Sprinter ( Z80). 㬥 ࠭ ⤥쭮 W3 +᭮ RAM ணࠬ. + +## + +- 㬥 **128 ** (8 ࠭ EMM 16 ) +- **16 384** ࠭ ப +- ⮬᪨ ७ ᫮ ਭ ࠭ (80 ⮫殢) +- ਧ⠫ ᤢ ப ப ( , ⠡) +- -: 䠩, ப, 業 ப⪨ +- ப ﭨ ६ 㧪 樨 +- প ?? ᪫ ப + +## + +``` +mdview [_䠩.md] +``` + +᫨ 䠩 , 㦠 `README.MD`. + +## ࠢ + +``` + ⢨ + +Up Down ப⪠ ப / +PgUp PgDn ப⪠ ࠭ (30 ப) +Home 砫 㬥 +End 㬥 +Left Right ਧ⠫ ᤢ (⮫쪮 nowrap-ப) +F1 ࠢ +F8 ஢: CP866 ? CP1251 ? KOI8-R ? UTF-8 ? ... +F10 / Esc 室 ணࠬ +``` + +஢ । ⮬᪨ ⨨ (BOM + ⨪ + 4 ); `F8` ४砥 , ᫨ ⥪ 訡. +8- ஢ (CP866/CP1251/KOI8-R) ४ (६ +ᮢ). ன / (ਬ UTF-8) ந ? +ࢮ ४祭 (⪠ 㧠 ᯨ஬), . + +## ⠪ Markdown + +### + +ন ஢ H1?H4. ஢ H5 H6 ⮡ࠦ H4. + + # ࢮ ஢ + ## ண ஢ + ### 쥣 ஢ + #### ⮣ ஢ + +### ⮢ ଠ஢ + +** ⥪** 뤥 묨 񧤮窠: `**⥪**` + +*ᨢ* 뤥 묨 񧤮窠 `*⥪*` ન `_⥪_` + +`஥ ` 砥 묨 窠 + +~~ભ ⥪~~ ? ⨫: `~~⥪~~` + +### 㬥஢ ᯨ᮪ + +થ `-`, `*` `+`: + +- 㭪 ᯨ᪠ +- ன 㭪 ᯨ᪠ +- ⨩ 㭪 筮 ⥪⮬, 室 + 㤥 ७ ᫥ ப ࠭ 㯠 + +### 㬥஢ ᯨ᮪ + +1. +2. ன +3. ⨩ + +### + +> 稭 ᨬ `>`. ᪮쪮 ᫥⥫ +> ப ᪫ ⮬᪨ +> ७ᮬ ᫮. + +### (verbatim) + + 砥 ன 窨. +⥪ ⮡ࠦ ? ? ࠧ Markdown: + +``` +#include +#include + +int main(void) { + puts("Hello, Sprinter!"); + return 0; +} +``` + +### ਧ⠫쭠 + + ᨬ `---`, `***` `___` ⤥쭮 ப: + +--- + +## 孨᪨ ࠪ⨪ + +- **ଠ:** Sprinter, Z80 @ 21 +- **஢:** CP866 / CP1251 / KOI8-R / UTF-8 (⮮।, `F8`) +- **ᨬ ࠧ 䠩:** 128 +- **ᨬ쭮 ᫮ ப :** 16 384 +- ** :** small + - ணࠬ, c⥪, , ? a W1-W2 (32 , 0x4000?0xBFFF). + - 䠩 ? ࠭ EMM, ⮡ࠦ W3 (0xC000?0xFFFF) + +## TODO + +1. **祭 ࠧ 㬥⮢.** 128 : 筮 + ࠧ ࠡ 訬 - ࠭ , ஢ + ࠡ 8- ࠭栬 16. + +: ଠ஢ ⠡ ࠬ; প ஢ +CP866 / CP1251 / KOI8-R / UTF-8 ⮮। ४祭 `F8` +(ன ந , ࢮ ४祭). + +4. **᪮७ ७ਭ.** ப ࠭. ⨬ 横 뢮 + ᨬ १ BIOS WRCHAR ( 뢮, DMA). + +--- + +*MDView v0.2 (c) 2026 ஢ ..* + + +--- + +# Sprinter C Compiler ? v1.0 + +C toolchain for **Sprinter** ? the Z80-based home computer by Peters Plus, running +ESTEX DSS. Host: macOS / Linux. Target: `.EXE` files in SprintEXE format. + +Built on top of **SDCC 4.5** (vendored in `third_party/sdcc/`). This repository adds +everything Sprinter-specific: crt0, linker integration, libc wrappers over ESTEX, +banked-call trampolines, graphics & accelerator API, mouse driver wrappers, and the +`mkexe` utility for producing SprintEXE images. + +## What you get + +* **`bin/sprinter-cc`** ? one-line driver: `sprinter-cc -o foo.exe foo.c` +* **Memory modes**: `tiny`, `small`, `big`, `huge`, `manual` ? see below. +* **stdio + conio**: printf, puts, putchar, getchar, fopen/fread/..., cprintf, cputs, putch, textcolor/textbackground/textattr, gotoxy, kbhit/getch. +* **Graphics**: 320?256?256 and 640?256?16 modes, accelerator-backed primitives (hline / vline / rect / fill_rect / line via Bresenham, plus clear), bitmap-font text in both modes via BIOS character generator. +* **File I/O**: POSIX (`open`/`read`/`write`/`close`/`lseek`/`unlink`/`creat`), FILE\* streams (`fopen`/`fgets`/`fwrite`/...), directory listing (`ffirst`/`fnext`), `chdir`/`getcwd`/`mkdir`/`rmdir`, `stat`/`fstat`. +* **Memory**: 32 KB heap (W2-resident), banking-aware page allocator (`mem_alloc_pages`/`bank_read`/`bank_write`), explicit memory modes for sub-16 KB programs. +* **Mouse**: full Sprinter driver wrapper (14 functions including custom cursor bitmaps). +* **Environment**: `getenv`/`putenv`/`sysenv` over ESTEX `$46`. +* **Time**: `getdatetime`/`setdatetime` + POSIX `time`/`localtime`/`mktime`/`asctime`/`ctime`. +* **Misc**: `errno`/`strerror`/`perror`, `atexit`, `setjmp`/`longjmp`, `sleep`, full argv parsing in crt0. + +## Quick start + +```sh +git clone sprinter-c +cd sprinter-c +make sdcc # one-time: fetch SDCC 4.5 binary (~25 MB) +make all # build mkexe + libsprinter.lib + 27 examples +make floppy # pack everything into mame/v306/IMG/mc.img +cd mame/v306 && ./run_mame.sh # boot Sprinter in MAME +``` + +Compile a single program: + +```sh +cat > hello.c < +int main(void) { puts("Hello, Sprinter!"); return 0; } +EOF + +bin/sprinter-cc -o hello.exe hello.c +``` + +That's it ? `hello.exe` is now a valid SprintEXE you can `RUN HELLO` from the ESTEX shell. + +## Memory modes + +Sprinter's address space is four 16 KB windows (W0 / W1 / W2 / W3). DSS allocates +pages by program size ? small programs get only one page. Pick a memory mode based +on what your program needs: + +| Mode | Code lives in | Banking | Use when | Note | +|---|---|---|---|---| +| `tiny` (default) | W2 (0x8100+) | no | code+data < 14 KB | | +| `small` | W1-W2 (0x4100+) | no | code+data < 30 KB | | +| `big` | W2 + W1 banking | yes (W1) | tiny + extra code modules | | +| `huge` | W1-W2 + W3 banking | yes (W3) | small + extra code modules | | +| `manual` | user-specified | optional | special layouts | Not implemented | + +```sh +sprinter-cc --memory small -o big.exe bigprog.c +sprinter-cc --memory huge -o app.exe main.c --bank 1=engine.c --bank 2=ai.c +``` + +Banked functions are declared with `__banked`: + +```c +void engine_tick(int dt) __banked; // lives in BANK1, automatically swapped +``` + +## Examples (27 total) + +| Example | What it demonstrates | +|---|---| +| `hello` | Hello world with stdio + conio Turbo-C-style colors | +| `argv` | argv parsing in crt0 | +| `cat` | File I/O ? read & print TEST.TXT | +| `seek` | 32-bit lseek over a 100 KB file | +| `ls` | Directory listing via ffirst/fnext | +| `filetest` | FILE\* streams (fopen/fread/...) | +| `stattest` | `stat`/`fstat` on files and directories | +| `errno` | errno / strerror / perror | +| `mem_test` | Page allocator + bank\_read/bank\_write | +| `malloc` | Heap stress test (200+ allocations) | +| `banked` | Banked code in W3 (huge mode) | +| `bankedbg` | Banked code in W1 (big mode) | +| `banklocl` | Bank-local static data and BSS | +| `mouse` | Mouse driver in text mode | +| `gfx_mous` | Mouse with custom bitmap cursor in graphics mode | +| `gfx_demo` | 320?256?256 lines / rects / accelerator | +| `gfx_d16` | 640?256?16 same primitives | +| `gfx_text` | Bitmap-font text on graphics screen | +| `timedir` | Date/time + directory listing | +| `ptime` | POSIX time API | +| `openenv` | open() flags + environment vars | +| `conio` | conio API smoke test | +| `attrprob` | Probe Sprinter text attribute byte layout | +| `strtest` | string.h test (from SDCC's z80.lib) | +| `stdlib` | stdlib.h test (qsort / rand / strtol / etc.) | +| `assrtest` | assert() | +| `rt_test` | Runtime helpers (sleep, setjmp, atexit) | + +## Headers + +Standard: +* `` ? puts / printf / FILE\* + Sprinter-specific dec/hex helpers +* `` ? atoi / atof / malloc / qsort / ... (from SDCC z80.lib) +* `` / `` / `` ? from SDCC z80.lib +* `` ? read / write / close / lseek / unlink +* `` ? open / creat + O\_RDONLY / O\_CREAT / ... +* `` ? errno + error names + strerror +* `` ? stat / fstat +* `` / `` ? from SDCC + +Sprinter-specific: +* `` ? putch / cputs / cprintf, textcolor / textbackground / textattr, kbhit / getch, clrscr, gotoxy, wherex/y +* `` ? gfx_init/done, palette, putpixel, hline/vline/rect/fill_rect/line, text ? for both 320 and 640 modes (gfx_\*16 variants) +* `` ? full 14-function driver wrapper + mouse_cursor_t with bitmap support +* `` ? chdir / getcwd / mkdir / rmdir / ffirst / fnext / ffblk +* `` ? getdatetime / setdatetime + POSIX time / localtime / etc. +* `` ? raw ports, ESTEX/BIOS function numbers, env API +* `` ? exit / \_exit / atexit +* `` ? mem\_alloc\_pages / mem\_free\_block / bank\_read / bank\_write +* `` ? Solid-C compatibility layer (aliases + BOOL/WORD/uint types) + +## Toolchain commands + +```sh +make all # build mkexe + lib + every example +make floppy # repack mame/v306/IMG/mc.img with all .exe files +make check # 17 mkexe unit-tests +make clean # remove all build artefacts +make sdcc # one-time: fetch SDCC 4.5 binary +``` + +### sprinter-cc options + +``` +sprinter-cc -o foo.exe foo.c [more.c ...] [options] + + --memory MODE tiny | small | big | huge | manual (default: tiny) + --memory-manual SPEC explicit placement (CODE=W1|W2,DATA=W1|W2|SAME,BANKED=W1|W3) + --stack-size N bytes reserved for the stack (default ~1278) + --crt0=TYPE default | minimal | banked | small + --bank N=FILE.c compile FILE.c into bank N (repeatable, max 15) + --debug enable runtime diagnostics (defines DEBUG_RT) + -I PATH extra include path + -L 0xADDR / -E / -S override load / entry / stack addresses + -Wl FLAG pass FLAG to sdldz80 + --mkexe FLAG pass FLAG to mkexe (e.g. --mkexe -p --mkexe 0 for bank padding) + -v verbose +``` + +## Status + +What works in v1.0: +* Compile / link / pack to SprintEXE ? verified on all 27 examples +* Four memory modes (tiny / small / big / huge) +* Graphics (both modes) with accelerator +* Mouse (text + graphics cursor) +* File I/O, directories, environment, time +* All headers listed above + +Deferred to v2.0 (see `docs/TODO.md`): +* **Turbo-C-style BGI graphics API** ? `initgraph` / `setcolor` / `circle` / + `getimage` / `putimage` / etc. on top of our `gfx_*` primitives +* Remaining Solid-C compatibility gaps (Phase 2/3) ? see `docs/solid_c_compatibility.md` +* Manual memory mode +* Rewrite FILE\* stream API (current implementation is very primitive and doesn't use buffers) + +Deferred to v3.0: +* **IM2 interrupt handlers** ? research complete (`docs/im2_isr_design.md`), + implementation scheduled for v3 +* **Audio API** (AY-3-8910 + COVOX) ? requires IM2 +* **ISA-8 slot drivers** ? requires IM2 (???) + +## Documentation + +* `docs/TODO.md` ? roadmap and open work items +* `docs/solid_c_compatibility.md` ? gap analysis vs Solid-C 2004 +* `docs/im2_isr_design.md` ? interrupt handler design (v2) +* `docs/converted/` ? source documentation (ESTEX, BIOS, architecture) + converted to plain text for `grep` +* `docs/reference/`, `docs/samples/`, `docs/memory management/` ? original + Russian docs and code samples from Peters Plus + +## Repository layout + +``` +bin/sprinter-cc one-line compiler driver (bash) +toolchain/mkexe/ host-side tool: .ihx -> .exe SprintEXE +toolchain/check_banks.py post-link bank size enforcer +runtime/ crt0 variants (default, minimal, small, banked) + bank trampolines, heap, heap_top +libc/include/ headers +libc/io|stdio|mem|gfx/ C and asm sources for libsprinter.lib +lib/ Makefile that archives libsprinter.lib via sdar +examples/ 27 example programs +mame/v306/ MAME binary + Sprinter ROM/HDD images + floppy script +third_party/sdcc/ vendored SDCC 4.5 (fetched via `make sdcc`) +third_party/solid-c/ reference: original Sprinter native C (for compat target) +docs/ documentation +``` + +## License + +This repository contains: +* Original code in `bin/`, `toolchain/`, `runtime/`, `libc/`, `lib/`, `examples/` ? + MIT-licensed. +* `third_party/sdcc/` ? SDCC 4.5 under GPLv2 with linking exception + (see `third_party/sdcc/COPYING.txt`) +* `third_party/solid-c/` ? original Sprinter Solid C, used only as a reference + +## Credits + +* **Sprinter / Peters Plus** ? , ਩ ਭ and the original team +* **SDCC** ? for the underlying Z80 compiler +* **MAME** ? for the Sprinter Sp2000 emulation + +--- + +For questions / patches: see CONTRIBUTING.md (TBD) or open an issue. + +--- + +# TODO / Roadmap + + 浪 뢠 ਮ.  ॠ ணࠬ ? ਮ ᬥ. + +## ⠯ 5 ? malloc / free + banking-aware page allocator ? + +- [x] SDCC's `malloc`/`free` + `runtime/heap.s` ( library heap.rel, 14000- heap 2) +- [x] `libc/mem/mem_alloc.c` ? page allocator: `mem_alloc_pages`/`mem_free_block`/`mem_get_page`/`mem_info` १ ESTEX `$3C/$3D/$3E` + BIOS `$C4` +- [x] `libc/mem/bank_io.c` ? HOME-१ `bank_read`/`bank_write`/`bank_load_byte`/`bank_store_byte` ᢮ W3 +- [x] `examples/malloc_test/` ? ஢ઠ SDCC's malloc (~210 64- allocations १ heap) +- [x] `examples/mem_test/` ? ஢ઠ page allocator: 3 ࠭, ࠧ १ bank_write, 䨪 १ bank_read + +## ⠯ 6 ? argv parsing + sprinter-cc wrapper ? + +- [x] crt0 ESTEX command-line IX-prefix (inline asm `runtime/crt0.s`) +- [x] Strip leading CP/M-style space (DSS quirk) +- [x] । `argc`/`argv` main() १ HL/DE (SDCC __sdcccall(1) ABI) +- [x] argv[0] = basename .EXE १ ESTEX APPINFO ($47 subfn 2) +- [x] `runtime/crt0_minimal.s` ? opt-out 祭 쪨 ணࠬ +- [x] `runtime/crt0_banked.s` ? ⥯ ⮦ argv (parse_argv + get_progname ᪮஢ crt0.s; 㤥 factored argv.s libsprinter.lib) +- [x] Bash-⪠ `bin/sprinter-cc`: `sprinter-cc -o foo.exe foo.c` ப +- [x] প 権: `--memory`, `--memory-manual`, `--stack-size`, `--crt0=`, `--bank N=FILE.c`, `--debug`, `-I`, `-L`/`-E`/`-S`, `-Wl`, `--mkexe` + +## ⠯ 8 ? 䨪 (320?256?256 + 640?256?16 + accel + bitmap font) ? + +- [x] **8a** Graphics core: `gfx_init`/`gfx_done`/`gfx_clear`/`gfx_putpixel`/`gfx_pal_load`/`gfx_pal_set` (libc/gfx/gfx_core.c). १ BIOS PIC_SET_PAL ($A4). Verified 320?256?256. +- [x] **8b** /אַ㣮쭨/fill १ accelerator (libc/gfx/gfx_lines.c): `gfx_hline`/`gfx_vline` १ accel Fill (LD C,C / LD E,E + SMC block-size), `gfx_rect`/`gfx_fill_rect` heuristic 롮஬ ਥ樨 (h/v bursts count), `gfx_line` Bresenham . `gfx_clear` ⮦ ९ᠭ column-major accel (~4? ॥). +- [x] **8c** 640?256?16 mode (libc/gfx/gfx_16.c): `gfx_*16` API, HIGH nibble = LEFT pixel (㬥 misleading), per-row RMW vline ( = 2 ਧ⠫ ᥫ). +- [x] **8d** Bitmap font + gfx_text (libc/gfx/gfx_text.c): १ BIOS WIN_GET_ZG ($B8), interleaved layout `font[row*256+char]`, `gfx_text`/`gfx_putchar` 320 mode, `gfx_text16`/`gfx_putchar16` 640 mode pair-table lookup. + +. memory/sprinter_graphics.md, sprinter_accelerator.md, sprinter_graphics_16.md, sprinter_font_format.md. + + ( ): +- [ ] -quad 640: per-cell (mode 0x82 ࠧ蠥 1 4 per 16?8 cell) ? १ אַ area-ᠭ ࠭ 0x0300..0x039F + +## Auto-banking (. `memory/banking_roadmap.md` ⠫) + +Phase 1 ? file-level bin-packing ? ॠ뢠 ஥ ~30 KB . + +- [ ] `toolchain/auto_bank.py`: + - ࠧ `.rel`-䠩 ( .map ᫥ dry-run link') + - First-fit-decreasing bin-packing + - `#pragma codeseg BANKn` manual override + - ५뢠 묨 `-Wl-b_BANKn=...` ࠬࠬ + - ⠥ । + +Phase 2-5: incremental rebalance, declarative `banks.toml`, function-level, call-graph-aware. 쪮 ᫨/ . + +## Bank-local static data (mutable data ⮬ ) ? ? + +- [x] ਬ `examples/bank_local_data/` ? 㭪 BANK1 ᢮ writable BSS array + const table + malloc- +- [x] `mkexe -p 0` 㫥 padding (BSS-storage 㧪) +- [x] ᪨ 楯: `--codeseg BANK1 --constseg BANK1 --dataseg BANK1` bank1.c + `-Wl-b_BANK1=0x1C000` . **`--dataseg BANK1` ** ? ࠭ ⭮ - trampoline bug ᪨஢ १. +- [x] ** 䨪 trampoline'a runtime/bank.s** ? `pop af; out (n), a` ਫ A ? banked-㭪樨 騥 uint8_t 頫 . `pop bc; out (c), b` ࠭ A. +- [x] **malloc banked-㭪樨 ࠡ⠥ ஧筮** ? heap W2 (HOME), W2 ᢠ trampoline', pointer  ⥪. . memory/bank_local_data_pattern.md. +- [x] 㬥 memory: `memory/bank_local_data_pattern.md` ( 楯 + malloc + nuances), `memory/sdcc_banking.md` (trampoline fix) +- [ ] 樮쭮 ? `check_banks.py` ⮡ 뢠 ࠧ size = code + const + bss per bank (cosmetic) + +祬: 㫥 訬 private state (level loader, audio engine, scene data). W2 heap , ⨪ . + +## ᪠ solid-c (⨢ Sprinter C ? `third_party/solid-c/`) + +᫥ solid-c'᪮ libc (. `memory/solid_c_findings.md`)  ⮢ ᫥ 㭪権. ਮ **᮪** : + +### High-priority gaps ( ஢, 짠) +- [x] **`errno` + `strerror`/`perror`** ? ⠡窠 32 訡 (libc/io/errno.c) +- [x] **७ `open()`** O_CREAT/O_TRUNC/O_APPEND/O_EXCL state machine +- [x] **`atexit`** ? 8-callback LIFO + `exit()` + `_exit()` (libc/io/atexit.c) +- [x] **`setjmp`/`longjmp`** ? 6- jmp_buf={sp,ix,pc} (libc/io/setjmp.c) +- [x] **`sleep(seconds)`** ? 50Hz halt-loop (libc/io/sleep.c) +- [x] **ESTEX ENV API** ($46, getenv/putenv) ? libc/io/env.c. 竨 doc-bug: ॠ쭮 A=0 NOT FOUND + +### Medium-priority (㦭 shell-like ⨫) +- [ ] **Mouse driver** ? `rst $30h`, 17 㭪権. **砫 ࠡ⠥ MAME**. +- [x] **`ffirst`/`fnext` + ffblk_t struct** directory listing ? ॠ, demo: ls.exe +- [x] **`getdatetime`/`setdatetime`** १ ESTEX $21/$22 ? libc/io/time.c, demo: time_dir_test +- [x] **`chdir`/`getcwd`/`mkdir`/`rmdir`** ? wrappers ESTEX $1B-$1E ? libc/io/fsdir.c +- [x] **conio: `kbhit`/`getch`/`getche`/`cputs`/`clrscr`/`gotoxy`** ? ॠ +- [x] **conio extras**: `wherex`/`wherey` ($53), `wrchar`/`rdchar` ($58/$57), `textmode_get/set` ($50/$51), `clrscr_attr` ($56) + COLOR macros + +### Low-priority ? ? FILE* stack + +- [x] ** unbuffered FILE\*** ? `libc/stdio/file.c` + `libc/include/stdio.h`. fopen/fclose/fputs/fgets/fread/fwrite/fseek/ftell/rewind/feof/ferror/clearerr/fflush + stdin/stdout/stderr pseudo-streams. . `memory/file_star_design.md` `examples/filetest`. +- [ ] fprintf / fscanf ? 㦭 printf-१-callback machinery. 짮⥫ `sprintf(buf, ...) + fputs(buf, fp)`. +- [ ] 樮 buffered mode (setvbuf, line/block buffering) ? ᫨ - . + +### POSIX time API ? ? +- [x] `libc/io/posix_time.c` ? time/localtime/gmtime/mktime/asctime/ctime getdatetime. SDCC's time.rel ( override _RtcRead). . `examples/ptime`. + +### sys/stat ? ? +- [x] `libc/io/stat.c` ? POSIX stat/fstat. ਤ open+fstat 䠩, ffirst+iter ( "."/".."). . `examples/stattest` `memory/estex_ffirst_dotdot.md`. + +### assert ? ? (ᯮ㥬 SDCC's __assert १ fallback include path) + +## libc/stdlib ? ? 㦭 (. memory/sdcc_stdlib_works.md) + +஢७ १ `examples/stdlib_test/`: SDCC z80.lib ᮤন ࠡ騥 ॠ樨: +- `atoi/atol/atof, strtol/strtoul, rand/srand, qsort/bsearch, abs/labs, div/ldiv` +- `` (memchr/cmp/set/cpy, strcat/cmp/cpy/len/chr/spn/etc.) +- `` (toupper/tolower) +- `` (sinf/cosf/sqrtf/etc.) + + ⮬᪨ ﭥ z80.lib 㦭. ** ९뢠**. + + Sprinter-specific 易⥫ 㫨 : atexit, env, errno, setjmp, putchar/puts/getchar, conio, fsdir, time, mouse, open/read/lseek/close. + +## Build-system: libsprinter.lib + sprinter-cc ? ? + +- [x] `lib/Makefile` ? ᮡࠥ libc/*.c `.rel`, 娢 १ sdar `lib/sprinter.lib` +- [x] 砥 runtime/bank.s runtime/heap.s (auto-pulled __banked/malloc) +- [x] `bin/sprinter-cc` ? bash-wrapper: `sprinter-cc -o foo.exe foo.c` ப +- [x] প 権 `--crt0=default|minimal|banked`, `--bank N=FILE.c`, `-I`, `-L`/`-E`/`-S`, `-Wl`, `--mkexe` +- [x] `examples/hello_sccc/` ? : `hello.c` ᮡࠥ shell-맮, ࠧ ᮢ Makefile (925 ) +- [x] Split `putchar.c` ? `putchar.c` + `puts.c` per-function granularity (puts override SDCC's z80.lib version) +- [x] `make all` (ᨬ `lib` । `examples`) + + 襭 (樮쭮): +- [ ] ஢ ⠫ examples sprinter-cc Makefile (ᬥ⨪) +- [ ] 쭥 libc/*.c per-function ( ⥪ granularity 㦥 㦭 ࠧ ? .rel 楫, 設⢠ 䠩 㭪) + +## ⠯ 9 ? memory modes sprinter-cc + +DSS 뤥 ࠭ ࠧ ਫ: < 16 KB ? ࠭, ⠫ 砥 ?࠭ #FF? (read=0xFF, write ). - ⮣ CODE--W1 + DATA--W2 쪮 ணࠬ . . [memory/sprinter_memory_modes.md](../../.claude/projects/-Volumes-SAM8-Projects-DIY-Z80-Sprinter-C-Compiler/memory/sprinter_memory_modes.md). + +- [x] **`tiny`**: (CODE+DATA+⥪) W2. Default. Verified hello/argv/conio/malloc/file/etc. +- [x] **`--memory MODE` 䫠 sprinter-cc**: parser + per-mode 䮫 CODE_LOC/DATA_LOC, override १  `--code-loc`/`--data-loc`. tiny ࠡ⠥; small/big/huge warning' (runtime ⮢). 2026-05-30. +- [x] **`--memory-manual SPEC`**: `CODE=W1|W2,DATA=W1|W2|SAME,BANKED=W1|W3`. 2026-05-30. +- [x] **`small` runtime**: `runtime/crt0_small.s` ᯮ ESTEX `$3D GETMEM` + `$3A SETWIN2` ⮡ 뤥 W2-࠭ gsinit. **** BIOS `$C4` ? ⥪ ⮬ ⠯ W1 (boot_stack HOME), BIOS ॡ ⥪ W2. ᫥ SP ४砥 0xBFFE, ⠭ flow. 2026-05-30, verified hello.exe. +- [x] **`small` auto-detect >16 KB ணࠬ**: `crt0_small.s` ⠥ `0xC2` (⥪ ࠭ W2 ? `0xA2`! W1). ᫨ 0xFF ? 뤥 page; DSS 㦥 ᤥ (ணࠬ ᠬ 뫥 W2). crt0 뢠 0..30 KB. mkexe ⠪ ࠧ蠥 HOME span W1+W2 (0x4000..0xBFFF). Verified hello: small (5 KB 䠩, SETWIN2 path) + 32 KB 䠩 (auto-skip). 2026-05-30. +- [x] **`big` runtime** (tiny + banked code W1): ࠬਧ `crt0_banked.s` + `bank.s` १ `.ifdef BANK_W1` ? 㣮 banking port (0xA2 vs 0xE2), 㣮 load-addr (0x4000 vs 0xC000). sprinter-cc prepend' `BANK_W1 = 1` `--memory big`, । `mkexe -B 0x4000`. ਬ `examples/banked_big/`. 2026-05-30. +- [x] **`huge` runtime** (small + banked code W3): merge W2-detect `crt0_small.s` `crt0_banked.s`. 騩 ਬ `examples/banked/` ⥯ ᯮ MEMORY=huge. 2026-05-30. +- [x] **`--debug` 䫠**: prepend `DEBUG_RT = 1` crt0 + `-DDEBUG_RT` sdcc. 뢠 symbol `_w2_self_allocated` (uint8_t) ? runtime diagnostic ஢ W2. 2026-05-30. + +### -襭 libc crt0 + +** `sprinter.lib`** ࠡ⠥ memory mode ? `.rel`-童 relocatable, SDLD dead-code elimination per-member ( 䨪  `gfx_core.rel` ..). Verified hello vs malloc_test १ map-䠩. + +**`gfx.lib` ⤥쭮 ? 㦥**: dead-code elimination 㦥 ࠡ⠥. + +**`libc_banked` (libc bank HOME)** ? ⮬, HOME (16 KB) user- + libc `huge` mode. १ `--codeseg BANK0` 樨 libc; trade-off: trampoline ~30 横 libc-맮. ਣ: ॠ쭠 ணࠬ HOME budget. + +**HW-ᨬ 㫨 ? `sprinter_home.lib` ⤥쭮.** libc 䨧᪨ W3, ⮬ W3: +- `gfx_*` ? `0xC000+` ᫥ swap W3 video page +- `bank_io` (mem_alloc_pages/bank_read/bank_write) ? swap' W3 १ `OUT (0xE2)` +- 騥 ISR ? 뢠 ਩ W3 㣮 + + huge mode 㫨 HOME (W1). 㤥 `libc_banked`, **६** 뤥塞 `sprinter_home.lib` (HOME-only) `sprinter.lib` (bankable). 쭠 奬: +``` +sprinter_home.lib HOME-only: gfx, bank_io, ISR shims +sprinter.lib bankable: printf, malloc, string, conio, stdio, env, ... +sprinter_banked.lib sprinter.lib --codeseg BANK0 ( huge) +``` +ਣ: ॠ `--memory huge` runtime. + +**crt0 ? mode:** +- `crt0.s` ? ⥪騩, **tiny/big**: SP=0xBFFE, argv (W2- 㦥 뤥 DSS). +- `crt0_minimal.s` ? ⥪騩, tiny argv. +- `crt0_small.s` ? **, step 3**: **small/huge**, W2 १ `mem_alloc_pages` gsinit, `0xA2`, ⮬ ⠭ flow. +- `crt0_banked.s` ? ⥪騩, **big**: trampoline-⠡ W3 , CODE W2. +- `crt0_banked_small.s` ? ****: huge = small (W2-alloc) + banked (W3 trampolines). + +sprinter-cc ࠥ crt0 `--memory` mode (ᥩ `--crt0=` override). +- [x] **ࠨ ࠧ ⥪**: 䫠 `sprinter-cc --stack-size BYTES`. Wrapper `heap_top.s` `___sdcc_heap_end = stack_top + 1 - stack_size`, ⤥ .rel per-program. Default ?1278 (heap_top=0xBB00) `runtime/heap_top.s`. 2026-05-30. + +䥩: `sprinter-cc --memory [tiny|small|big|huge|manual] [--memory-manual SPEC] [--stack-size N] foo.c`. `--memory-manual` ⮫쪮 `--memory manual`. + +## Known issues / quirks + +- **ESTEX $46 ENV API**: ? ࠡ⠥. - `DiskSyscalls.txt v1.6` 訡筮 뢠 return-status ? A=0 NOT FOUND, FOUND. 䨪஢ `memory/sprinter_platform.md`. + +## V2 (᫥ ५ v1) + +### Turbo-C-style graphics API (BGI-like) ? **MUST v2** + + `gfx_*` API ஢ **Turbo-C ``** (BGI) MS-DOS. +ணࠬ ਢ訥 Turbo-C ७ ᪨ 1--1. + +** ** ( ᭮ Borland BGI): + +Setup/teardown: +- `initgraph()` / `closegraph()` ? ᥩ `gfx_init`/`gfx_done`, alias +- `getmaxx()` / `getmaxy()` ? GFX_WIDTH-1 / GFX_HEIGHT-1 +- `cleardevice()` ? alias to gfx_clear +- `getgraphmode()` / `setgraphmode()` ? get_videomode/set_videomode + +Color/palette: +- `setcolor(c)`, `getcolor()` ? current draw color +- `setbkcolor(c)`, `getbkcolor()` ? background color +- `setpalette(idx, c)` ? entry +- `getpalette(&info)` ? read all palette + +Primitives ( 㦥 ? BGI- aliases): +- `putpixel(x, y, c)` ? gfx_putpixel +- `getpixel(x, y)` ? 㦭 ॠ (RMW ⭮ ? IN) +- `moveto(x, y)`, `lineto(x, y)`, `linerel(dx, dy)` ? current point + line drawing +- `line(x1, y1, x2, y2)` ? gfx_line +- `rectangle(x1, y1, x2, y2)` ? gfx_rect ( 㣮 API: x1,y1,x2,y2 vs x,y,w,h!) +- `bar(x1, y1, x2, y2)` ? gfx_fill_rect +- `bar3d(x1, y1, x2, y2, depth, topflag)` ? : rect + 3d edges +- `circle(x, y, r)`, `arc(...)`, `ellipse(...)`, `pieslice(...)` ? primitives +- `fillpoly()`, `drawpoly()` ? +- `floodfill(x, y, border_color)` ? + +Text on graphics screen: +- `outtext(s)` / `outtextxy(x, y, s)` ? gfx_text (alias) +- `settextstyle(font, dir, size)` ? multiple bitmap fonts +- `gettextsettings(&info)` +- `textwidth(s)` / `textheight(s)` ? measure + +Image manipulation: +- `imagesize(x1, y1, x2, y2)` ? bytes needed for getimage +- `getimage(x1, y1, x2, y2, buf)` ? save rect to buffer +- `putimage(x, y, buf, op)` ? paste back with COPY_PUT/XOR_PUT/AND_PUT/OR_PUT/NOT_PUT + +Clipping/viewport: +- `setviewport(x1, y1, x2, y2, clip)` ? drawing clip rect +- `getviewsettings(&info)` +- `clearviewport()` +- `setactivepage(p)` / `setvisualpage(p)` ? ਧ (Sprinter 2 screen) + +Line style: +- `setlinestyle(style, pattern, thickness)` ? SOLID_LINE / DOTTED_LINE / etc. +- `getlinesettings(&info)` + +**Acceptance:** ७ ⨯筮 Turbo-C BGI ணࠬ (饩 ᯮ짮 +moveto/lineto/circle/bar/setcolor) ࠡ ⢥ ࠢ. + +**Notes:** +- BGI fonts (TRIPLEX/SANS_SERIF/GOTHIC) ? BIOS font, ⠫ 㦭 + ( bitmap data lib) +- imagesize/getimage/putimage ? ᠬ ॡ game/animation +- Active/visual page ( ਧ) ? Sprinter ন 2 graphics pages, + 㦥 API switching + +. ⠪ `examples/` Turbo C 2.x BGIDEMO reference 㦭. + +### IM2 Interrupt Handlers ? **MUST v2** + +User- ISR १ Z80 IM 2 mode. 㦭 : +- Timer ticks (50 Hz frame counter, ) +- Music playback (AY, COVOX) +- Real-time games (input + game logic + render interrupt-driven) +- Async keyboard / mouse handling + +**Status:** v2. research + design `docs/im2_isr_design.md`. + +**襭 ⥪:** ॠ ⤥ memory mode `--memory im2` +( ⮣ ⮡ 騥 crt0). Detail' design-doc. + +** research'** ( ⥪ `docs/im2_isr_design.md`): +- Vector 0xFF ? frame + keyboard + CBL. Disambiguation ⠬ 0x19 / 0xFE +- Mouse hardware-IRQ 室 ( ⥪饩 ) +- Vector table / ISR / stack W2 (0x8000..0xBFFF) +- DSS ᢮ IM 2 handler ? 㦭 chain' ( / SYSTIME ) + +### 稥 㯭 㭪 v2 + +- [ ] **FILE API rewrite ? buffered streams** ? ⥪ ॠ + `libc/stdio/file.c` provisional unbuffered shim ( fputc/fgetc + = read/write syscall). 㦭 業 buffered ᥬ⨪ + Solid-C: + + ```c + typedef struct { + uint flags; // +0..1 file status flags + int level; // +2..3 empty/fill level of buffer + char *curp; // +4..5 current active pointer + int fd; // +6..7 underlying low-level fd + char *buffer; // +8..9 data transfer buffer + char hold; // +10 ungetc byte if no buffer + short token; // +11..12 reserved + char dummy; // +13 reserved + } FILE; + ``` + + stdin/stdout/stderr ? fd-થ `0 / -1 / -2`. ⥫ + stdout/stderr ࠭ ७: ESTEX OPEN positive + small fd (1, 2, ?) 筮 䠩 ? ᫨ stdout=1, ॠ + fd=1 ⠫ 䨪஬. fd=0 stdin ᭮ + (ESTEX 0 頥). fd । syscall' ? + ᯥਧ 䫠 `_F_CONIN/_F_CONOUT`. + + ਭ-⮪ (stdaux/stdprn) ॠ㥬 ? Sprinter ਭ୮ + API . + + ୠ⨢ ? ॠ third_party/solid-c (sources + `SRC/CLIB/`); ⠬ ⮢ buffered FILE + fopen/fread/fwrite/ + fseek/setvbuf .. ஢ 訬 open/read/write/lseek. + + rewrite deferred issues stdio-review: + - `fwrite` short-write ⠢ `_F_ERROR` + - `fgets(buf, 1, fp)` ? ⠭ "empty string", 㫨 NULL + - `mode_to_flags` ? break-out '+' (cosmetic) + +- [ ] **Audio API** ? AY-3-8910 + COVOX १ 뢠 (ॡ IM2) +- [ ] **ISA-8 slot support** ? ZX-Bus (sound, network, etc.) ? ॡ IM2 + ⥭ port + +## 稥 (v1 backlog, 騥) + +- [x] **#9: text I/O split (Turbo-C style)** ? stdio (puts/printf/putchar) ⥯ fast no-attr १ PCHARS/PUTCHAR. conio (cputs/cprintf/putch) ਬ attr १ textcolor/textbackground/textattr. KEEP_EXIST_ATTR ? conio fallback fast path. Verified hello.exe. . `memory/text_output_api_split.md`. 2026-05-31. +- [x] **Mouse API ** (१ driver, RST 30h) ? 14 㭪権 (init/show/hide/refresh/read/goto/bounds/text_cursor/load_cursor/get_cursor/get/set_sensitivity/video_mode_changed). . `memory/mouse_api.md`. Verified MAME 2026-05-31. Sensitivity = divider ( = ॥). +- [ ] Interrupt handlers ? IM 2 vector table HOME user ISR' +- [ ] প `restore SP on EXIT` ( z88dk +pps) ? ஢ 㦭 +- [ ] CI: ⮬᪨ ᪠ MAME `-aviwrite` screenshot-ࠢ, ⮡ ਬ஢ 室 祫 + +## ⮬ + +- প `` ( SDCC stdlib ? 㦭 ஢ crt0 ᮢ⨬) +- `` १ ESTEX SYSTIME (`$21`) CMOS BIOS-㭪樨 +- ZX Spectrum-ᮢ⨬ ० ⤥ target ( ஢ ᯥ㬮᪨ ணࠬ) +- প ZX-Bus (sound, network, etc.) ? 㦭 ࠩ +- Profile-guided optimization tools (hot/cold detection) 㯭 ணࠬ + +## Linker duplicate-symbol warnings (, 䨫஢) + + ᮧ⥫쭮 overrides' SDCC z80.lib 㭪樨 ᮡ⢥ ᨥ `sprinter.lib`, `sdldz80` `?ASlink-Warning-Definition of public symbol '...' found more than once`. ࢮ । (), ⮬ ४⭮ ? warning ⮫쪮 noise. + +騥 overrides: +- `_puts` ? १ PCHARS+\r\n vs SDCC posix puts +- `___sdcc_heap` ? heap W2 vs SDCC's ⠭ +- `_asctime`, `_localtime` ( 㣨 time) ? `posix_time.c` १ ESTEX SYSTIME vs SDCC's `time.rel` `_RtcRead` + +**饥 襭:** `bin/sprinter-cc` 䨫஢뢠 warning- (warning + 2 follow-up `Library:` ப) 뢮 `sdcc`. १ `-v` (verbose) 뢠. १ awk-pipe. + +** 襭:** +- ३ explicit `--nostdlib` + 筮 ᯨ᮪ 㦭 㫥 z80.lib (string, math, stdlib override') ? warning', ᪨஢ +- : २ `_puts` ? `_puts_sprinter` + alias १ linker flag ( 㢥७ SDCC ন) +- : ⠢ ᥩ (ࠡ祥 benign) ? ਮ + +## TODO: ஢ ॠ쭮 + +- [ ] **Port_Y banking trick** (`docs/part2/SprinterGraphics programming.txt`): + ⢥ত ᫥ `OUT (0x89), Y` 0xC000+0x400*N W3 + ப Y..Y+15 ( ணࠬ஢ ? 16 ப). + Empirical 2026-06-01 MAME 0.283 trick ** ࠡ⠥** ? ᥫ + ᠬ 0xC000+row_width 室 . ᪨ + `docs/samples/plasma2.asm` ⮦ ᯮ banking, ⠭ + Port_Y per row. + : + 1. ॠ쭮 Sprinter + 2. dual-write (`_gfx_putpixel_raw` + ன write `0xD000+x`) + 3. ᫨ ? MAME, issue + ९ + 4. ᫨ ⮦ ? 㬥 , 㤠 㯮 + ⠢ ⥪ ॠ (Port_Y per pixel) + 5. ᫨ banking ࠡ⠥ ? ஢ Port_Y + `_gfx_putpixel_raw` (sentinel out-of-range, . memory/gfx_port_y_banking.md) + + 易 먣 Bresenham (60-pixel ) ? 8? + OUT (0x89) 権, `gfx_fill_rect 320x256` ? 16? . + release v1. + +## GFX: ७ `docs/part2/accelerator_doc.txt` + +᫥ ⥭ ⠫쭮 accelerator doc  ࠢ. + ᯮ ⮫쪮 ਧ⠫/⨪ Fill mode. + +### Quick wins ⥪ primitives + +- [ ] ** SMC `LD A, (var)` block-size**. 㬥  + ࠧ蠥 `LD A, (HL)`, `LD A, (BC)`, `LD A, (DE)` ( `LD A, r`). + 㡥 SMC complexity `gfx_lines.c:hfill_chunk/vfill_chunk` + `gfx_16.c:g16_hfill_chunk`. 饭 ⮫쪮 register-to-register. +- [ ] **஢ block-size**. 㬥 뢠 accel + block size bursts (. `Horizontal_Line_Fill`: ⠭ + size + `LD B,B` ⪫祭, ⮬ Fill mode ᯮ + ࠭ size). `gfx_fill_rect` 100 묨 + ப ? ⠭ size 1 ࠧ, 100. + +### Bank-prefix modes (port 0xE2 bits) + +㬥 뢠 ਠ ࠭ ⠭⭮ 0x50: + +| Bank byte | Effect | +|---|---| +| 0x50 | Normal write ? shadow + | +| 0x54 | "no copy in main shadow RAM" | +| 0x58 | **"FF is transparent"** ? 0xFF write ⠢ background | +| 0x5C | both | + +Bank 0x58 祬 mouse cursor 0xFF-஧筮. + **sprite-blending १ accel block copy**: + +- [ ] **`gfx_set_bank_transparent(on)`** 䫠 `gfx_set_bank` + 롮 0x50/0x58 ᮢ sprite' +- [ ] ᯮ짮 `gfx_blit()` ⮡ 䠪 + transparent sprites १ accel- + +### Block copy mode (sprite blit') + +`LD L,L` (horizontal) `LD A,A` (vertical) ? ० ஢ १ +256- accel memory. blit'. + +- [ ] **`gfx_blit(src_data, x, y, w, h)`** ? ஢ sprite' + (ந ࠧ, १ accel) +- [ ] **`gfx_blit_transparent(src, x, y, w, h)`** ? ᯮ짮 bank 0x58 + +. `Draw_Restangle_Data` accelerator_doc.txt ७. + +### AND / OR / XOR operations १ accel + +㬥 뢠 accel ন ᪨ 樨 +. ਬ: +- XOR ? (뤥 selection UI) +- OR / AND ? masking, alpha-style blending +- . ਬ accelerator_doc.txt: "256 bytes block coding via XOR" + +- [ ] **`gfx_xor_rect`** / **`gfx_or_rect`** / **`gfx_and_rect`** ? + ਬ⨢ ᪨ 権 אַ㣮쭨 +- [ ] **`gfx_invert_rect(x, y, w, h)`** ? alias xor 0xFF + +### Bitmap fonts ࠧ ࠧ஢ + + `gfx_text` / `gfx_putchar` प ࠡ 8?8 ⮬ +(BIOS WIN_GET_ZG 頥 256?8 ). UI / 쭨 +㦭: +- [ ] **`gfx_set_font_size(w, h)`** ? ४ ਭ/ glyph' +- [ ] **`gfx_set_font_data(ptr, w, h, advance)`** ? 㪠⥫ + 짮⥫᪨ + ࠧ +- [ ] প **proportional** (advance != w) ⮢ ? + array advance[256] ਭ glyph' +- [ ] **Big-font ०**: 8?16, 16?16, 16?8 ( 쭨) +- [ ] ⤥ API `gfx_text_ex(x, y, str, font_id)` + font_id 롨ࠥ 㦥 ⮢ +- [ ] **Anti-alias 2-bit ** ( 䮭 / ࠭ / 2- alpha?) + ? far future, smooth UI + +## ⠯ ⨬権 ( ᥩ) + +- **`gfx_line` १ accel ** ? Bresenham |dy| << |dx| ( ) 뤠 runs Y ( X): ᥫ, ᥫ, ᥫ, 蠣 Y, ᥫ, ᥫ... ⠪ run ? ⮢ 㬥 `gfx_hline` ( `vline`). + ᫥: runs 㭪 ; run length, ஬ 룮 accel hline 祬 N?putpixel (overhead accel ~20?s, putpixel ~5?s ? accel 룮 run ? 4-5 px); (dx ? dy) ⠢ Bresenham, ? run-length-based fill. + `gfx_line` orthogonal cases 㦥 १ accel ? ⨬஢ ⮫쪮 . + +- **`gfx_fill_rect` W3-swap ** ? ᥩ ७ `gfx_hline`/`gfx_vline` ᢮ DI/save-W3/restore-W3/EI. ᤥ internal `_fill_rect_inner` ন W3 DI 横; ~20?s ? ⢮ ப/⮫殢 . ਬ ᥬ ਬ⨢. diff --git a/examples/mdview2/testfiles/LINES.MD b/examples/mdview2/testfiles/LINES.MD index 35c9e63..80273ed 100644 --- a/examples/mdview2/testfiles/LINES.MD +++ b/examples/mdview2/testfiles/LINES.MD @@ -22001,4 +22001,3004 @@ row 21997 row 21998 row 21999 row 22000 +row 22001 +row 22002 +row 22003 +row 22004 +row 22005 +row 22006 +row 22007 +row 22008 +row 22009 +row 22010 +row 22011 +row 22012 +row 22013 +row 22014 +row 22015 +row 22016 +row 22017 +row 22018 +row 22019 +row 22020 +row 22021 +row 22022 +row 22023 +row 22024 +row 22025 +row 22026 +row 22027 +row 22028 +row 22029 +row 22030 +row 22031 +row 22032 +row 22033 +row 22034 +row 22035 +row 22036 +row 22037 +row 22038 +row 22039 +row 22040 +row 22041 +row 22042 +row 22043 +row 22044 +row 22045 +row 22046 +row 22047 +row 22048 +row 22049 +row 22050 +row 22051 +row 22052 +row 22053 +row 22054 +row 22055 +row 22056 +row 22057 +row 22058 +row 22059 +row 22060 +row 22061 +row 22062 +row 22063 +row 22064 +row 22065 +row 22066 +row 22067 +row 22068 +row 22069 +row 22070 +row 22071 +row 22072 +row 22073 +row 22074 +row 22075 +row 22076 +row 22077 +row 22078 +row 22079 +row 22080 +row 22081 +row 22082 +row 22083 +row 22084 +row 22085 +row 22086 +row 22087 +row 22088 +row 22089 +row 22090 +row 22091 +row 22092 +row 22093 +row 22094 +row 22095 +row 22096 +row 22097 +row 22098 +row 22099 +row 22100 +row 22101 +row 22102 +row 22103 +row 22104 +row 22105 +row 22106 +row 22107 +row 22108 +row 22109 +row 22110 +row 22111 +row 22112 +row 22113 +row 22114 +row 22115 +row 22116 +row 22117 +row 22118 +row 22119 +row 22120 +row 22121 +row 22122 +row 22123 +row 22124 +row 22125 +row 22126 +row 22127 +row 22128 +row 22129 +row 22130 +row 22131 +row 22132 +row 22133 +row 22134 +row 22135 +row 22136 +row 22137 +row 22138 +row 22139 +row 22140 +row 22141 +row 22142 +row 22143 +row 22144 +row 22145 +row 22146 +row 22147 +row 22148 +row 22149 +row 22150 +row 22151 +row 22152 +row 22153 +row 22154 +row 22155 +row 22156 +row 22157 +row 22158 +row 22159 +row 22160 +row 22161 +row 22162 +row 22163 +row 22164 +row 22165 +row 22166 +row 22167 +row 22168 +row 22169 +row 22170 +row 22171 +row 22172 +row 22173 +row 22174 +row 22175 +row 22176 +row 22177 +row 22178 +row 22179 +row 22180 +row 22181 +row 22182 +row 22183 +row 22184 +row 22185 +row 22186 +row 22187 +row 22188 +row 22189 +row 22190 +row 22191 +row 22192 +row 22193 +row 22194 +row 22195 +row 22196 +row 22197 +row 22198 +row 22199 +row 22200 +row 22201 +row 22202 +row 22203 +row 22204 +row 22205 +row 22206 +row 22207 +row 22208 +row 22209 +row 22210 +row 22211 +row 22212 +row 22213 +row 22214 +row 22215 +row 22216 +row 22217 +row 22218 +row 22219 +row 22220 +row 22221 +row 22222 +row 22223 +row 22224 +row 22225 +row 22226 +row 22227 +row 22228 +row 22229 +row 22230 +row 22231 +row 22232 +row 22233 +row 22234 +row 22235 +row 22236 +row 22237 +row 22238 +row 22239 +row 22240 +row 22241 +row 22242 +row 22243 +row 22244 +row 22245 +row 22246 +row 22247 +row 22248 +row 22249 +row 22250 +row 22251 +row 22252 +row 22253 +row 22254 +row 22255 +row 22256 +row 22257 +row 22258 +row 22259 +row 22260 +row 22261 +row 22262 +row 22263 +row 22264 +row 22265 +row 22266 +row 22267 +row 22268 +row 22269 +row 22270 +row 22271 +row 22272 +row 22273 +row 22274 +row 22275 +row 22276 +row 22277 +row 22278 +row 22279 +row 22280 +row 22281 +row 22282 +row 22283 +row 22284 +row 22285 +row 22286 +row 22287 +row 22288 +row 22289 +row 22290 +row 22291 +row 22292 +row 22293 +row 22294 +row 22295 +row 22296 +row 22297 +row 22298 +row 22299 +row 22300 +row 22301 +row 22302 +row 22303 +row 22304 +row 22305 +row 22306 +row 22307 +row 22308 +row 22309 +row 22310 +row 22311 +row 22312 +row 22313 +row 22314 +row 22315 +row 22316 +row 22317 +row 22318 +row 22319 +row 22320 +row 22321 +row 22322 +row 22323 +row 22324 +row 22325 +row 22326 +row 22327 +row 22328 +row 22329 +row 22330 +row 22331 +row 22332 +row 22333 +row 22334 +row 22335 +row 22336 +row 22337 +row 22338 +row 22339 +row 22340 +row 22341 +row 22342 +row 22343 +row 22344 +row 22345 +row 22346 +row 22347 +row 22348 +row 22349 +row 22350 +row 22351 +row 22352 +row 22353 +row 22354 +row 22355 +row 22356 +row 22357 +row 22358 +row 22359 +row 22360 +row 22361 +row 22362 +row 22363 +row 22364 +row 22365 +row 22366 +row 22367 +row 22368 +row 22369 +row 22370 +row 22371 +row 22372 +row 22373 +row 22374 +row 22375 +row 22376 +row 22377 +row 22378 +row 22379 +row 22380 +row 22381 +row 22382 +row 22383 +row 22384 +row 22385 +row 22386 +row 22387 +row 22388 +row 22389 +row 22390 +row 22391 +row 22392 +row 22393 +row 22394 +row 22395 +row 22396 +row 22397 +row 22398 +row 22399 +row 22400 +row 22401 +row 22402 +row 22403 +row 22404 +row 22405 +row 22406 +row 22407 +row 22408 +row 22409 +row 22410 +row 22411 +row 22412 +row 22413 +row 22414 +row 22415 +row 22416 +row 22417 +row 22418 +row 22419 +row 22420 +row 22421 +row 22422 +row 22423 +row 22424 +row 22425 +row 22426 +row 22427 +row 22428 +row 22429 +row 22430 +row 22431 +row 22432 +row 22433 +row 22434 +row 22435 +row 22436 +row 22437 +row 22438 +row 22439 +row 22440 +row 22441 +row 22442 +row 22443 +row 22444 +row 22445 +row 22446 +row 22447 +row 22448 +row 22449 +row 22450 +row 22451 +row 22452 +row 22453 +row 22454 +row 22455 +row 22456 +row 22457 +row 22458 +row 22459 +row 22460 +row 22461 +row 22462 +row 22463 +row 22464 +row 22465 +row 22466 +row 22467 +row 22468 +row 22469 +row 22470 +row 22471 +row 22472 +row 22473 +row 22474 +row 22475 +row 22476 +row 22477 +row 22478 +row 22479 +row 22480 +row 22481 +row 22482 +row 22483 +row 22484 +row 22485 +row 22486 +row 22487 +row 22488 +row 22489 +row 22490 +row 22491 +row 22492 +row 22493 +row 22494 +row 22495 +row 22496 +row 22497 +row 22498 +row 22499 +row 22500 +row 22501 +row 22502 +row 22503 +row 22504 +row 22505 +row 22506 +row 22507 +row 22508 +row 22509 +row 22510 +row 22511 +row 22512 +row 22513 +row 22514 +row 22515 +row 22516 +row 22517 +row 22518 +row 22519 +row 22520 +row 22521 +row 22522 +row 22523 +row 22524 +row 22525 +row 22526 +row 22527 +row 22528 +row 22529 +row 22530 +row 22531 +row 22532 +row 22533 +row 22534 +row 22535 +row 22536 +row 22537 +row 22538 +row 22539 +row 22540 +row 22541 +row 22542 +row 22543 +row 22544 +row 22545 +row 22546 +row 22547 +row 22548 +row 22549 +row 22550 +row 22551 +row 22552 +row 22553 +row 22554 +row 22555 +row 22556 +row 22557 +row 22558 +row 22559 +row 22560 +row 22561 +row 22562 +row 22563 +row 22564 +row 22565 +row 22566 +row 22567 +row 22568 +row 22569 +row 22570 +row 22571 +row 22572 +row 22573 +row 22574 +row 22575 +row 22576 +row 22577 +row 22578 +row 22579 +row 22580 +row 22581 +row 22582 +row 22583 +row 22584 +row 22585 +row 22586 +row 22587 +row 22588 +row 22589 +row 22590 +row 22591 +row 22592 +row 22593 +row 22594 +row 22595 +row 22596 +row 22597 +row 22598 +row 22599 +row 22600 +row 22601 +row 22602 +row 22603 +row 22604 +row 22605 +row 22606 +row 22607 +row 22608 +row 22609 +row 22610 +row 22611 +row 22612 +row 22613 +row 22614 +row 22615 +row 22616 +row 22617 +row 22618 +row 22619 +row 22620 +row 22621 +row 22622 +row 22623 +row 22624 +row 22625 +row 22626 +row 22627 +row 22628 +row 22629 +row 22630 +row 22631 +row 22632 +row 22633 +row 22634 +row 22635 +row 22636 +row 22637 +row 22638 +row 22639 +row 22640 +row 22641 +row 22642 +row 22643 +row 22644 +row 22645 +row 22646 +row 22647 +row 22648 +row 22649 +row 22650 +row 22651 +row 22652 +row 22653 +row 22654 +row 22655 +row 22656 +row 22657 +row 22658 +row 22659 +row 22660 +row 22661 +row 22662 +row 22663 +row 22664 +row 22665 +row 22666 +row 22667 +row 22668 +row 22669 +row 22670 +row 22671 +row 22672 +row 22673 +row 22674 +row 22675 +row 22676 +row 22677 +row 22678 +row 22679 +row 22680 +row 22681 +row 22682 +row 22683 +row 22684 +row 22685 +row 22686 +row 22687 +row 22688 +row 22689 +row 22690 +row 22691 +row 22692 +row 22693 +row 22694 +row 22695 +row 22696 +row 22697 +row 22698 +row 22699 +row 22700 +row 22701 +row 22702 +row 22703 +row 22704 +row 22705 +row 22706 +row 22707 +row 22708 +row 22709 +row 22710 +row 22711 +row 22712 +row 22713 +row 22714 +row 22715 +row 22716 +row 22717 +row 22718 +row 22719 +row 22720 +row 22721 +row 22722 +row 22723 +row 22724 +row 22725 +row 22726 +row 22727 +row 22728 +row 22729 +row 22730 +row 22731 +row 22732 +row 22733 +row 22734 +row 22735 +row 22736 +row 22737 +row 22738 +row 22739 +row 22740 +row 22741 +row 22742 +row 22743 +row 22744 +row 22745 +row 22746 +row 22747 +row 22748 +row 22749 +row 22750 +row 22751 +row 22752 +row 22753 +row 22754 +row 22755 +row 22756 +row 22757 +row 22758 +row 22759 +row 22760 +row 22761 +row 22762 +row 22763 +row 22764 +row 22765 +row 22766 +row 22767 +row 22768 +row 22769 +row 22770 +row 22771 +row 22772 +row 22773 +row 22774 +row 22775 +row 22776 +row 22777 +row 22778 +row 22779 +row 22780 +row 22781 +row 22782 +row 22783 +row 22784 +row 22785 +row 22786 +row 22787 +row 22788 +row 22789 +row 22790 +row 22791 +row 22792 +row 22793 +row 22794 +row 22795 +row 22796 +row 22797 +row 22798 +row 22799 +row 22800 +row 22801 +row 22802 +row 22803 +row 22804 +row 22805 +row 22806 +row 22807 +row 22808 +row 22809 +row 22810 +row 22811 +row 22812 +row 22813 +row 22814 +row 22815 +row 22816 +row 22817 +row 22818 +row 22819 +row 22820 +row 22821 +row 22822 +row 22823 +row 22824 +row 22825 +row 22826 +row 22827 +row 22828 +row 22829 +row 22830 +row 22831 +row 22832 +row 22833 +row 22834 +row 22835 +row 22836 +row 22837 +row 22838 +row 22839 +row 22840 +row 22841 +row 22842 +row 22843 +row 22844 +row 22845 +row 22846 +row 22847 +row 22848 +row 22849 +row 22850 +row 22851 +row 22852 +row 22853 +row 22854 +row 22855 +row 22856 +row 22857 +row 22858 +row 22859 +row 22860 +row 22861 +row 22862 +row 22863 +row 22864 +row 22865 +row 22866 +row 22867 +row 22868 +row 22869 +row 22870 +row 22871 +row 22872 +row 22873 +row 22874 +row 22875 +row 22876 +row 22877 +row 22878 +row 22879 +row 22880 +row 22881 +row 22882 +row 22883 +row 22884 +row 22885 +row 22886 +row 22887 +row 22888 +row 22889 +row 22890 +row 22891 +row 22892 +row 22893 +row 22894 +row 22895 +row 22896 +row 22897 +row 22898 +row 22899 +row 22900 +row 22901 +row 22902 +row 22903 +row 22904 +row 22905 +row 22906 +row 22907 +row 22908 +row 22909 +row 22910 +row 22911 +row 22912 +row 22913 +row 22914 +row 22915 +row 22916 +row 22917 +row 22918 +row 22919 +row 22920 +row 22921 +row 22922 +row 22923 +row 22924 +row 22925 +row 22926 +row 22927 +row 22928 +row 22929 +row 22930 +row 22931 +row 22932 +row 22933 +row 22934 +row 22935 +row 22936 +row 22937 +row 22938 +row 22939 +row 22940 +row 22941 +row 22942 +row 22943 +row 22944 +row 22945 +row 22946 +row 22947 +row 22948 +row 22949 +row 22950 +row 22951 +row 22952 +row 22953 +row 22954 +row 22955 +row 22956 +row 22957 +row 22958 +row 22959 +row 22960 +row 22961 +row 22962 +row 22963 +row 22964 +row 22965 +row 22966 +row 22967 +row 22968 +row 22969 +row 22970 +row 22971 +row 22972 +row 22973 +row 22974 +row 22975 +row 22976 +row 22977 +row 22978 +row 22979 +row 22980 +row 22981 +row 22982 +row 22983 +row 22984 +row 22985 +row 22986 +row 22987 +row 22988 +row 22989 +row 22990 +row 22991 +row 22992 +row 22993 +row 22994 +row 22995 +row 22996 +row 22997 +row 22998 +row 22999 +row 23000 +row 23001 +row 23002 +row 23003 +row 23004 +row 23005 +row 23006 +row 23007 +row 23008 +row 23009 +row 23010 +row 23011 +row 23012 +row 23013 +row 23014 +row 23015 +row 23016 +row 23017 +row 23018 +row 23019 +row 23020 +row 23021 +row 23022 +row 23023 +row 23024 +row 23025 +row 23026 +row 23027 +row 23028 +row 23029 +row 23030 +row 23031 +row 23032 +row 23033 +row 23034 +row 23035 +row 23036 +row 23037 +row 23038 +row 23039 +row 23040 +row 23041 +row 23042 +row 23043 +row 23044 +row 23045 +row 23046 +row 23047 +row 23048 +row 23049 +row 23050 +row 23051 +row 23052 +row 23053 +row 23054 +row 23055 +row 23056 +row 23057 +row 23058 +row 23059 +row 23060 +row 23061 +row 23062 +row 23063 +row 23064 +row 23065 +row 23066 +row 23067 +row 23068 +row 23069 +row 23070 +row 23071 +row 23072 +row 23073 +row 23074 +row 23075 +row 23076 +row 23077 +row 23078 +row 23079 +row 23080 +row 23081 +row 23082 +row 23083 +row 23084 +row 23085 +row 23086 +row 23087 +row 23088 +row 23089 +row 23090 +row 23091 +row 23092 +row 23093 +row 23094 +row 23095 +row 23096 +row 23097 +row 23098 +row 23099 +row 23100 +row 23101 +row 23102 +row 23103 +row 23104 +row 23105 +row 23106 +row 23107 +row 23108 +row 23109 +row 23110 +row 23111 +row 23112 +row 23113 +row 23114 +row 23115 +row 23116 +row 23117 +row 23118 +row 23119 +row 23120 +row 23121 +row 23122 +row 23123 +row 23124 +row 23125 +row 23126 +row 23127 +row 23128 +row 23129 +row 23130 +row 23131 +row 23132 +row 23133 +row 23134 +row 23135 +row 23136 +row 23137 +row 23138 +row 23139 +row 23140 +row 23141 +row 23142 +row 23143 +row 23144 +row 23145 +row 23146 +row 23147 +row 23148 +row 23149 +row 23150 +row 23151 +row 23152 +row 23153 +row 23154 +row 23155 +row 23156 +row 23157 +row 23158 +row 23159 +row 23160 +row 23161 +row 23162 +row 23163 +row 23164 +row 23165 +row 23166 +row 23167 +row 23168 +row 23169 +row 23170 +row 23171 +row 23172 +row 23173 +row 23174 +row 23175 +row 23176 +row 23177 +row 23178 +row 23179 +row 23180 +row 23181 +row 23182 +row 23183 +row 23184 +row 23185 +row 23186 +row 23187 +row 23188 +row 23189 +row 23190 +row 23191 +row 23192 +row 23193 +row 23194 +row 23195 +row 23196 +row 23197 +row 23198 +row 23199 +row 23200 +row 23201 +row 23202 +row 23203 +row 23204 +row 23205 +row 23206 +row 23207 +row 23208 +row 23209 +row 23210 +row 23211 +row 23212 +row 23213 +row 23214 +row 23215 +row 23216 +row 23217 +row 23218 +row 23219 +row 23220 +row 23221 +row 23222 +row 23223 +row 23224 +row 23225 +row 23226 +row 23227 +row 23228 +row 23229 +row 23230 +row 23231 +row 23232 +row 23233 +row 23234 +row 23235 +row 23236 +row 23237 +row 23238 +row 23239 +row 23240 +row 23241 +row 23242 +row 23243 +row 23244 +row 23245 +row 23246 +row 23247 +row 23248 +row 23249 +row 23250 +row 23251 +row 23252 +row 23253 +row 23254 +row 23255 +row 23256 +row 23257 +row 23258 +row 23259 +row 23260 +row 23261 +row 23262 +row 23263 +row 23264 +row 23265 +row 23266 +row 23267 +row 23268 +row 23269 +row 23270 +row 23271 +row 23272 +row 23273 +row 23274 +row 23275 +row 23276 +row 23277 +row 23278 +row 23279 +row 23280 +row 23281 +row 23282 +row 23283 +row 23284 +row 23285 +row 23286 +row 23287 +row 23288 +row 23289 +row 23290 +row 23291 +row 23292 +row 23293 +row 23294 +row 23295 +row 23296 +row 23297 +row 23298 +row 23299 +row 23300 +row 23301 +row 23302 +row 23303 +row 23304 +row 23305 +row 23306 +row 23307 +row 23308 +row 23309 +row 23310 +row 23311 +row 23312 +row 23313 +row 23314 +row 23315 +row 23316 +row 23317 +row 23318 +row 23319 +row 23320 +row 23321 +row 23322 +row 23323 +row 23324 +row 23325 +row 23326 +row 23327 +row 23328 +row 23329 +row 23330 +row 23331 +row 23332 +row 23333 +row 23334 +row 23335 +row 23336 +row 23337 +row 23338 +row 23339 +row 23340 +row 23341 +row 23342 +row 23343 +row 23344 +row 23345 +row 23346 +row 23347 +row 23348 +row 23349 +row 23350 +row 23351 +row 23352 +row 23353 +row 23354 +row 23355 +row 23356 +row 23357 +row 23358 +row 23359 +row 23360 +row 23361 +row 23362 +row 23363 +row 23364 +row 23365 +row 23366 +row 23367 +row 23368 +row 23369 +row 23370 +row 23371 +row 23372 +row 23373 +row 23374 +row 23375 +row 23376 +row 23377 +row 23378 +row 23379 +row 23380 +row 23381 +row 23382 +row 23383 +row 23384 +row 23385 +row 23386 +row 23387 +row 23388 +row 23389 +row 23390 +row 23391 +row 23392 +row 23393 +row 23394 +row 23395 +row 23396 +row 23397 +row 23398 +row 23399 +row 23400 +row 23401 +row 23402 +row 23403 +row 23404 +row 23405 +row 23406 +row 23407 +row 23408 +row 23409 +row 23410 +row 23411 +row 23412 +row 23413 +row 23414 +row 23415 +row 23416 +row 23417 +row 23418 +row 23419 +row 23420 +row 23421 +row 23422 +row 23423 +row 23424 +row 23425 +row 23426 +row 23427 +row 23428 +row 23429 +row 23430 +row 23431 +row 23432 +row 23433 +row 23434 +row 23435 +row 23436 +row 23437 +row 23438 +row 23439 +row 23440 +row 23441 +row 23442 +row 23443 +row 23444 +row 23445 +row 23446 +row 23447 +row 23448 +row 23449 +row 23450 +row 23451 +row 23452 +row 23453 +row 23454 +row 23455 +row 23456 +row 23457 +row 23458 +row 23459 +row 23460 +row 23461 +row 23462 +row 23463 +row 23464 +row 23465 +row 23466 +row 23467 +row 23468 +row 23469 +row 23470 +row 23471 +row 23472 +row 23473 +row 23474 +row 23475 +row 23476 +row 23477 +row 23478 +row 23479 +row 23480 +row 23481 +row 23482 +row 23483 +row 23484 +row 23485 +row 23486 +row 23487 +row 23488 +row 23489 +row 23490 +row 23491 +row 23492 +row 23493 +row 23494 +row 23495 +row 23496 +row 23497 +row 23498 +row 23499 +row 23500 +row 23501 +row 23502 +row 23503 +row 23504 +row 23505 +row 23506 +row 23507 +row 23508 +row 23509 +row 23510 +row 23511 +row 23512 +row 23513 +row 23514 +row 23515 +row 23516 +row 23517 +row 23518 +row 23519 +row 23520 +row 23521 +row 23522 +row 23523 +row 23524 +row 23525 +row 23526 +row 23527 +row 23528 +row 23529 +row 23530 +row 23531 +row 23532 +row 23533 +row 23534 +row 23535 +row 23536 +row 23537 +row 23538 +row 23539 +row 23540 +row 23541 +row 23542 +row 23543 +row 23544 +row 23545 +row 23546 +row 23547 +row 23548 +row 23549 +row 23550 +row 23551 +row 23552 +row 23553 +row 23554 +row 23555 +row 23556 +row 23557 +row 23558 +row 23559 +row 23560 +row 23561 +row 23562 +row 23563 +row 23564 +row 23565 +row 23566 +row 23567 +row 23568 +row 23569 +row 23570 +row 23571 +row 23572 +row 23573 +row 23574 +row 23575 +row 23576 +row 23577 +row 23578 +row 23579 +row 23580 +row 23581 +row 23582 +row 23583 +row 23584 +row 23585 +row 23586 +row 23587 +row 23588 +row 23589 +row 23590 +row 23591 +row 23592 +row 23593 +row 23594 +row 23595 +row 23596 +row 23597 +row 23598 +row 23599 +row 23600 +row 23601 +row 23602 +row 23603 +row 23604 +row 23605 +row 23606 +row 23607 +row 23608 +row 23609 +row 23610 +row 23611 +row 23612 +row 23613 +row 23614 +row 23615 +row 23616 +row 23617 +row 23618 +row 23619 +row 23620 +row 23621 +row 23622 +row 23623 +row 23624 +row 23625 +row 23626 +row 23627 +row 23628 +row 23629 +row 23630 +row 23631 +row 23632 +row 23633 +row 23634 +row 23635 +row 23636 +row 23637 +row 23638 +row 23639 +row 23640 +row 23641 +row 23642 +row 23643 +row 23644 +row 23645 +row 23646 +row 23647 +row 23648 +row 23649 +row 23650 +row 23651 +row 23652 +row 23653 +row 23654 +row 23655 +row 23656 +row 23657 +row 23658 +row 23659 +row 23660 +row 23661 +row 23662 +row 23663 +row 23664 +row 23665 +row 23666 +row 23667 +row 23668 +row 23669 +row 23670 +row 23671 +row 23672 +row 23673 +row 23674 +row 23675 +row 23676 +row 23677 +row 23678 +row 23679 +row 23680 +row 23681 +row 23682 +row 23683 +row 23684 +row 23685 +row 23686 +row 23687 +row 23688 +row 23689 +row 23690 +row 23691 +row 23692 +row 23693 +row 23694 +row 23695 +row 23696 +row 23697 +row 23698 +row 23699 +row 23700 +row 23701 +row 23702 +row 23703 +row 23704 +row 23705 +row 23706 +row 23707 +row 23708 +row 23709 +row 23710 +row 23711 +row 23712 +row 23713 +row 23714 +row 23715 +row 23716 +row 23717 +row 23718 +row 23719 +row 23720 +row 23721 +row 23722 +row 23723 +row 23724 +row 23725 +row 23726 +row 23727 +row 23728 +row 23729 +row 23730 +row 23731 +row 23732 +row 23733 +row 23734 +row 23735 +row 23736 +row 23737 +row 23738 +row 23739 +row 23740 +row 23741 +row 23742 +row 23743 +row 23744 +row 23745 +row 23746 +row 23747 +row 23748 +row 23749 +row 23750 +row 23751 +row 23752 +row 23753 +row 23754 +row 23755 +row 23756 +row 23757 +row 23758 +row 23759 +row 23760 +row 23761 +row 23762 +row 23763 +row 23764 +row 23765 +row 23766 +row 23767 +row 23768 +row 23769 +row 23770 +row 23771 +row 23772 +row 23773 +row 23774 +row 23775 +row 23776 +row 23777 +row 23778 +row 23779 +row 23780 +row 23781 +row 23782 +row 23783 +row 23784 +row 23785 +row 23786 +row 23787 +row 23788 +row 23789 +row 23790 +row 23791 +row 23792 +row 23793 +row 23794 +row 23795 +row 23796 +row 23797 +row 23798 +row 23799 +row 23800 +row 23801 +row 23802 +row 23803 +row 23804 +row 23805 +row 23806 +row 23807 +row 23808 +row 23809 +row 23810 +row 23811 +row 23812 +row 23813 +row 23814 +row 23815 +row 23816 +row 23817 +row 23818 +row 23819 +row 23820 +row 23821 +row 23822 +row 23823 +row 23824 +row 23825 +row 23826 +row 23827 +row 23828 +row 23829 +row 23830 +row 23831 +row 23832 +row 23833 +row 23834 +row 23835 +row 23836 +row 23837 +row 23838 +row 23839 +row 23840 +row 23841 +row 23842 +row 23843 +row 23844 +row 23845 +row 23846 +row 23847 +row 23848 +row 23849 +row 23850 +row 23851 +row 23852 +row 23853 +row 23854 +row 23855 +row 23856 +row 23857 +row 23858 +row 23859 +row 23860 +row 23861 +row 23862 +row 23863 +row 23864 +row 23865 +row 23866 +row 23867 +row 23868 +row 23869 +row 23870 +row 23871 +row 23872 +row 23873 +row 23874 +row 23875 +row 23876 +row 23877 +row 23878 +row 23879 +row 23880 +row 23881 +row 23882 +row 23883 +row 23884 +row 23885 +row 23886 +row 23887 +row 23888 +row 23889 +row 23890 +row 23891 +row 23892 +row 23893 +row 23894 +row 23895 +row 23896 +row 23897 +row 23898 +row 23899 +row 23900 +row 23901 +row 23902 +row 23903 +row 23904 +row 23905 +row 23906 +row 23907 +row 23908 +row 23909 +row 23910 +row 23911 +row 23912 +row 23913 +row 23914 +row 23915 +row 23916 +row 23917 +row 23918 +row 23919 +row 23920 +row 23921 +row 23922 +row 23923 +row 23924 +row 23925 +row 23926 +row 23927 +row 23928 +row 23929 +row 23930 +row 23931 +row 23932 +row 23933 +row 23934 +row 23935 +row 23936 +row 23937 +row 23938 +row 23939 +row 23940 +row 23941 +row 23942 +row 23943 +row 23944 +row 23945 +row 23946 +row 23947 +row 23948 +row 23949 +row 23950 +row 23951 +row 23952 +row 23953 +row 23954 +row 23955 +row 23956 +row 23957 +row 23958 +row 23959 +row 23960 +row 23961 +row 23962 +row 23963 +row 23964 +row 23965 +row 23966 +row 23967 +row 23968 +row 23969 +row 23970 +row 23971 +row 23972 +row 23973 +row 23974 +row 23975 +row 23976 +row 23977 +row 23978 +row 23979 +row 23980 +row 23981 +row 23982 +row 23983 +row 23984 +row 23985 +row 23986 +row 23987 +row 23988 +row 23989 +row 23990 +row 23991 +row 23992 +row 23993 +row 23994 +row 23995 +row 23996 +row 23997 +row 23998 +row 23999 +row 24000 +row 24001 +row 24002 +row 24003 +row 24004 +row 24005 +row 24006 +row 24007 +row 24008 +row 24009 +row 24010 +row 24011 +row 24012 +row 24013 +row 24014 +row 24015 +row 24016 +row 24017 +row 24018 +row 24019 +row 24020 +row 24021 +row 24022 +row 24023 +row 24024 +row 24025 +row 24026 +row 24027 +row 24028 +row 24029 +row 24030 +row 24031 +row 24032 +row 24033 +row 24034 +row 24035 +row 24036 +row 24037 +row 24038 +row 24039 +row 24040 +row 24041 +row 24042 +row 24043 +row 24044 +row 24045 +row 24046 +row 24047 +row 24048 +row 24049 +row 24050 +row 24051 +row 24052 +row 24053 +row 24054 +row 24055 +row 24056 +row 24057 +row 24058 +row 24059 +row 24060 +row 24061 +row 24062 +row 24063 +row 24064 +row 24065 +row 24066 +row 24067 +row 24068 +row 24069 +row 24070 +row 24071 +row 24072 +row 24073 +row 24074 +row 24075 +row 24076 +row 24077 +row 24078 +row 24079 +row 24080 +row 24081 +row 24082 +row 24083 +row 24084 +row 24085 +row 24086 +row 24087 +row 24088 +row 24089 +row 24090 +row 24091 +row 24092 +row 24093 +row 24094 +row 24095 +row 24096 +row 24097 +row 24098 +row 24099 +row 24100 +row 24101 +row 24102 +row 24103 +row 24104 +row 24105 +row 24106 +row 24107 +row 24108 +row 24109 +row 24110 +row 24111 +row 24112 +row 24113 +row 24114 +row 24115 +row 24116 +row 24117 +row 24118 +row 24119 +row 24120 +row 24121 +row 24122 +row 24123 +row 24124 +row 24125 +row 24126 +row 24127 +row 24128 +row 24129 +row 24130 +row 24131 +row 24132 +row 24133 +row 24134 +row 24135 +row 24136 +row 24137 +row 24138 +row 24139 +row 24140 +row 24141 +row 24142 +row 24143 +row 24144 +row 24145 +row 24146 +row 24147 +row 24148 +row 24149 +row 24150 +row 24151 +row 24152 +row 24153 +row 24154 +row 24155 +row 24156 +row 24157 +row 24158 +row 24159 +row 24160 +row 24161 +row 24162 +row 24163 +row 24164 +row 24165 +row 24166 +row 24167 +row 24168 +row 24169 +row 24170 +row 24171 +row 24172 +row 24173 +row 24174 +row 24175 +row 24176 +row 24177 +row 24178 +row 24179 +row 24180 +row 24181 +row 24182 +row 24183 +row 24184 +row 24185 +row 24186 +row 24187 +row 24188 +row 24189 +row 24190 +row 24191 +row 24192 +row 24193 +row 24194 +row 24195 +row 24196 +row 24197 +row 24198 +row 24199 +row 24200 +row 24201 +row 24202 +row 24203 +row 24204 +row 24205 +row 24206 +row 24207 +row 24208 +row 24209 +row 24210 +row 24211 +row 24212 +row 24213 +row 24214 +row 24215 +row 24216 +row 24217 +row 24218 +row 24219 +row 24220 +row 24221 +row 24222 +row 24223 +row 24224 +row 24225 +row 24226 +row 24227 +row 24228 +row 24229 +row 24230 +row 24231 +row 24232 +row 24233 +row 24234 +row 24235 +row 24236 +row 24237 +row 24238 +row 24239 +row 24240 +row 24241 +row 24242 +row 24243 +row 24244 +row 24245 +row 24246 +row 24247 +row 24248 +row 24249 +row 24250 +row 24251 +row 24252 +row 24253 +row 24254 +row 24255 +row 24256 +row 24257 +row 24258 +row 24259 +row 24260 +row 24261 +row 24262 +row 24263 +row 24264 +row 24265 +row 24266 +row 24267 +row 24268 +row 24269 +row 24270 +row 24271 +row 24272 +row 24273 +row 24274 +row 24275 +row 24276 +row 24277 +row 24278 +row 24279 +row 24280 +row 24281 +row 24282 +row 24283 +row 24284 +row 24285 +row 24286 +row 24287 +row 24288 +row 24289 +row 24290 +row 24291 +row 24292 +row 24293 +row 24294 +row 24295 +row 24296 +row 24297 +row 24298 +row 24299 +row 24300 +row 24301 +row 24302 +row 24303 +row 24304 +row 24305 +row 24306 +row 24307 +row 24308 +row 24309 +row 24310 +row 24311 +row 24312 +row 24313 +row 24314 +row 24315 +row 24316 +row 24317 +row 24318 +row 24319 +row 24320 +row 24321 +row 24322 +row 24323 +row 24324 +row 24325 +row 24326 +row 24327 +row 24328 +row 24329 +row 24330 +row 24331 +row 24332 +row 24333 +row 24334 +row 24335 +row 24336 +row 24337 +row 24338 +row 24339 +row 24340 +row 24341 +row 24342 +row 24343 +row 24344 +row 24345 +row 24346 +row 24347 +row 24348 +row 24349 +row 24350 +row 24351 +row 24352 +row 24353 +row 24354 +row 24355 +row 24356 +row 24357 +row 24358 +row 24359 +row 24360 +row 24361 +row 24362 +row 24363 +row 24364 +row 24365 +row 24366 +row 24367 +row 24368 +row 24369 +row 24370 +row 24371 +row 24372 +row 24373 +row 24374 +row 24375 +row 24376 +row 24377 +row 24378 +row 24379 +row 24380 +row 24381 +row 24382 +row 24383 +row 24384 +row 24385 +row 24386 +row 24387 +row 24388 +row 24389 +row 24390 +row 24391 +row 24392 +row 24393 +row 24394 +row 24395 +row 24396 +row 24397 +row 24398 +row 24399 +row 24400 +row 24401 +row 24402 +row 24403 +row 24404 +row 24405 +row 24406 +row 24407 +row 24408 +row 24409 +row 24410 +row 24411 +row 24412 +row 24413 +row 24414 +row 24415 +row 24416 +row 24417 +row 24418 +row 24419 +row 24420 +row 24421 +row 24422 +row 24423 +row 24424 +row 24425 +row 24426 +row 24427 +row 24428 +row 24429 +row 24430 +row 24431 +row 24432 +row 24433 +row 24434 +row 24435 +row 24436 +row 24437 +row 24438 +row 24439 +row 24440 +row 24441 +row 24442 +row 24443 +row 24444 +row 24445 +row 24446 +row 24447 +row 24448 +row 24449 +row 24450 +row 24451 +row 24452 +row 24453 +row 24454 +row 24455 +row 24456 +row 24457 +row 24458 +row 24459 +row 24460 +row 24461 +row 24462 +row 24463 +row 24464 +row 24465 +row 24466 +row 24467 +row 24468 +row 24469 +row 24470 +row 24471 +row 24472 +row 24473 +row 24474 +row 24475 +row 24476 +row 24477 +row 24478 +row 24479 +row 24480 +row 24481 +row 24482 +row 24483 +row 24484 +row 24485 +row 24486 +row 24487 +row 24488 +row 24489 +row 24490 +row 24491 +row 24492 +row 24493 +row 24494 +row 24495 +row 24496 +row 24497 +row 24498 +row 24499 +row 24500 +row 24501 +row 24502 +row 24503 +row 24504 +row 24505 +row 24506 +row 24507 +row 24508 +row 24509 +row 24510 +row 24511 +row 24512 +row 24513 +row 24514 +row 24515 +row 24516 +row 24517 +row 24518 +row 24519 +row 24520 +row 24521 +row 24522 +row 24523 +row 24524 +row 24525 +row 24526 +row 24527 +row 24528 +row 24529 +row 24530 +row 24531 +row 24532 +row 24533 +row 24534 +row 24535 +row 24536 +row 24537 +row 24538 +row 24539 +row 24540 +row 24541 +row 24542 +row 24543 +row 24544 +row 24545 +row 24546 +row 24547 +row 24548 +row 24549 +row 24550 +row 24551 +row 24552 +row 24553 +row 24554 +row 24555 +row 24556 +row 24557 +row 24558 +row 24559 +row 24560 +row 24561 +row 24562 +row 24563 +row 24564 +row 24565 +row 24566 +row 24567 +row 24568 +row 24569 +row 24570 +row 24571 +row 24572 +row 24573 +row 24574 +row 24575 +row 24576 +row 24577 +row 24578 +row 24579 +row 24580 +row 24581 +row 24582 +row 24583 +row 24584 +row 24585 +row 24586 +row 24587 +row 24588 +row 24589 +row 24590 +row 24591 +row 24592 +row 24593 +row 24594 +row 24595 +row 24596 +row 24597 +row 24598 +row 24599 +row 24600 +row 24601 +row 24602 +row 24603 +row 24604 +row 24605 +row 24606 +row 24607 +row 24608 +row 24609 +row 24610 +row 24611 +row 24612 +row 24613 +row 24614 +row 24615 +row 24616 +row 24617 +row 24618 +row 24619 +row 24620 +row 24621 +row 24622 +row 24623 +row 24624 +row 24625 +row 24626 +row 24627 +row 24628 +row 24629 +row 24630 +row 24631 +row 24632 +row 24633 +row 24634 +row 24635 +row 24636 +row 24637 +row 24638 +row 24639 +row 24640 +row 24641 +row 24642 +row 24643 +row 24644 +row 24645 +row 24646 +row 24647 +row 24648 +row 24649 +row 24650 +row 24651 +row 24652 +row 24653 +row 24654 +row 24655 +row 24656 +row 24657 +row 24658 +row 24659 +row 24660 +row 24661 +row 24662 +row 24663 +row 24664 +row 24665 +row 24666 +row 24667 +row 24668 +row 24669 +row 24670 +row 24671 +row 24672 +row 24673 +row 24674 +row 24675 +row 24676 +row 24677 +row 24678 +row 24679 +row 24680 +row 24681 +row 24682 +row 24683 +row 24684 +row 24685 +row 24686 +row 24687 +row 24688 +row 24689 +row 24690 +row 24691 +row 24692 +row 24693 +row 24694 +row 24695 +row 24696 +row 24697 +row 24698 +row 24699 +row 24700 +row 24701 +row 24702 +row 24703 +row 24704 +row 24705 +row 24706 +row 24707 +row 24708 +row 24709 +row 24710 +row 24711 +row 24712 +row 24713 +row 24714 +row 24715 +row 24716 +row 24717 +row 24718 +row 24719 +row 24720 +row 24721 +row 24722 +row 24723 +row 24724 +row 24725 +row 24726 +row 24727 +row 24728 +row 24729 +row 24730 +row 24731 +row 24732 +row 24733 +row 24734 +row 24735 +row 24736 +row 24737 +row 24738 +row 24739 +row 24740 +row 24741 +row 24742 +row 24743 +row 24744 +row 24745 +row 24746 +row 24747 +row 24748 +row 24749 +row 24750 +row 24751 +row 24752 +row 24753 +row 24754 +row 24755 +row 24756 +row 24757 +row 24758 +row 24759 +row 24760 +row 24761 +row 24762 +row 24763 +row 24764 +row 24765 +row 24766 +row 24767 +row 24768 +row 24769 +row 24770 +row 24771 +row 24772 +row 24773 +row 24774 +row 24775 +row 24776 +row 24777 +row 24778 +row 24779 +row 24780 +row 24781 +row 24782 +row 24783 +row 24784 +row 24785 +row 24786 +row 24787 +row 24788 +row 24789 +row 24790 +row 24791 +row 24792 +row 24793 +row 24794 +row 24795 +row 24796 +row 24797 +row 24798 +row 24799 +row 24800 +row 24801 +row 24802 +row 24803 +row 24804 +row 24805 +row 24806 +row 24807 +row 24808 +row 24809 +row 24810 +row 24811 +row 24812 +row 24813 +row 24814 +row 24815 +row 24816 +row 24817 +row 24818 +row 24819 +row 24820 +row 24821 +row 24822 +row 24823 +row 24824 +row 24825 +row 24826 +row 24827 +row 24828 +row 24829 +row 24830 +row 24831 +row 24832 +row 24833 +row 24834 +row 24835 +row 24836 +row 24837 +row 24838 +row 24839 +row 24840 +row 24841 +row 24842 +row 24843 +row 24844 +row 24845 +row 24846 +row 24847 +row 24848 +row 24849 +row 24850 +row 24851 +row 24852 +row 24853 +row 24854 +row 24855 +row 24856 +row 24857 +row 24858 +row 24859 +row 24860 +row 24861 +row 24862 +row 24863 +row 24864 +row 24865 +row 24866 +row 24867 +row 24868 +row 24869 +row 24870 +row 24871 +row 24872 +row 24873 +row 24874 +row 24875 +row 24876 +row 24877 +row 24878 +row 24879 +row 24880 +row 24881 +row 24882 +row 24883 +row 24884 +row 24885 +row 24886 +row 24887 +row 24888 +row 24889 +row 24890 +row 24891 +row 24892 +row 24893 +row 24894 +row 24895 +row 24896 +row 24897 +row 24898 +row 24899 +row 24900 +row 24901 +row 24902 +row 24903 +row 24904 +row 24905 +row 24906 +row 24907 +row 24908 +row 24909 +row 24910 +row 24911 +row 24912 +row 24913 +row 24914 +row 24915 +row 24916 +row 24917 +row 24918 +row 24919 +row 24920 +row 24921 +row 24922 +row 24923 +row 24924 +row 24925 +row 24926 +row 24927 +row 24928 +row 24929 +row 24930 +row 24931 +row 24932 +row 24933 +row 24934 +row 24935 +row 24936 +row 24937 +row 24938 +row 24939 +row 24940 +row 24941 +row 24942 +row 24943 +row 24944 +row 24945 +row 24946 +row 24947 +row 24948 +row 24949 +row 24950 +row 24951 +row 24952 +row 24953 +row 24954 +row 24955 +row 24956 +row 24957 +row 24958 +row 24959 +row 24960 +row 24961 +row 24962 +row 24963 +row 24964 +row 24965 +row 24966 +row 24967 +row 24968 +row 24969 +row 24970 +row 24971 +row 24972 +row 24973 +row 24974 +row 24975 +row 24976 +row 24977 +row 24978 +row 24979 +row 24980 +row 24981 +row 24982 +row 24983 +row 24984 +row 24985 +row 24986 +row 24987 +row 24988 +row 24989 +row 24990 +row 24991 +row 24992 +row 24993 +row 24994 +row 24995 +row 24996 +row 24997 +row 24998 +row 24999 +row 25000 ``` diff --git a/examples/mdview2/testfiles/gen_testfiles.py b/examples/mdview2/testfiles/gen_testfiles.py index 44fbe11..47fe694 100644 --- a/examples/mdview2/testfiles/gen_testfiles.py +++ b/examples/mdview2/testfiles/gen_testfiles.py @@ -24,13 +24,16 @@ def write(name, data): print(f"{name}: {os.path.getsize(path)} bytes") -# --- BIG.MD: склейка README + READMEBG ×2, перекодировано в CP866 ----------- -big = bytearray() -for _ in range(2): - for fn in ('README.MD', 'READMEBG.MD'): - with open(os.path.join(ROOT, fn), encoding='utf-8') as f: - big += f.read().encode('cp866', errors='replace') -write('BIG.MD', bytes(big)) +# --- BIG.MD / HUGE.MD: склейка README + READMEBG, перекодировано в CP866 ----- +# BIG (×2 ≈170 КБ) — успешный рендер большого файла (<256 КБ). +# HUGE (×4 ≈340 КБ) — БОЛЬШЕ 256 КБ: проверка клампа (читаются первые 256 КБ + +# строка-предупреждение TRUNC_FILE). +prose = bytearray() +for fn in ('README.MD', 'READMEBG.MD'): + with open(os.path.join(ROOT, fn), encoding='utf-8') as f: + prose += f.read().encode('cp866', errors='replace') +write('BIG.MD', bytes(prose * 2)) +write('HUGE.MD', bytes(prose * 4)) # --- TABLES.MD: неровные таблицы -> исчерпание контент-кэша ------------------ # Один широкий столбец (72 симв.) на таблицу задаёт ширину; остальные ячейки @@ -57,7 +60,7 @@ write('TABLES.MD', '\n'.join(out) + '\n') # контент БЕЗ склейки -> кладём всё в fenced code block (verbatim, 1:1 # строка-источник = экранная строка). 22000 строк > 18432 -> TRUNC_LINES; # контент мал (~9 ячеек/строка), кап контента не задевается. -N = 22000 +N = 25000 # ~250 КБ -> 16 страниц -> max_lines = 18432; строк больше -> обрыв на 18432 out = ['# Short lines test - line limit trigger', '', '```'] out += [f'row {i:05d}' for i in range(1, N + 1)] out.append('```')