Commit Graph

56 Commits

Author SHA1 Message Date
snark13 4a081501d8 libc: сплит «1 функция = 1 модуль» — вся библиотека, wildcard-сборка
- bios/conio/env/errno/gfx/io/mem/mouse/stdio/stdlib/string/sys/time/
  video разложены по модулям: общие статики и helpers — в internal
  _-модулях (_conio.h/_mouse.h/_gfx.h/_palette.h/_atexit.h/_time.h)
- lib/Makefile: LIBC_C = wildcard libc/*/*.c — гранулярность файлов
  = гранулярность DCE линкера
- эффект _CODE: gfx_text 6986→2568 Б, gfx_mous −1745, gfx_demo/d16
  −542; ранее timedir −3270, ls −3098, stattest −2995
- комментарии оставшихся модулей переведены на русский; puts: убран
  мёртвый pchars; videomode_raw разложен на get/set
- docs/libc-split-asm-cases.md — правила asm-связок между модулями;
  docs/libc-roadmap.md — план этапа
- восстановлен examples/mdview/SAMPLE.MD (нужен make floppy)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 16:08:58 +03:00
snark13 1b78dda125 mdview2: статус-бар в отдельный модуль, упростить alloc_set_storage
- mdview2_status.c: вынести статус-бар/меню/спиннер из ядра
- mdview2.c: убрать retry-цикл в alloc_set_storage (fail-fast вместо
  ложной устойчивости — при нехватке EMM под индекс контент тоже не влезет)
- mdview2.h: дополнить экспортами статус-модуля
- mdview2_md.c / mdview2_raw.c: зачистка после расщепления
- mdview/mdview.c: переименовать scroll_* → md_scroll_* (симметрия)
- docs/fast_ram.md, docs/turboc.txt: добавить справочные доки
- examples/mdview2/README.MD, READMEBG.MD: обновить описание

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-26 23:19:00 +03:00
snark13 138e783e72 mdview2: горизонтальный скролл по типу блока + фиксы fence/HR/SDCC
Горизонтальный скролл (Фаза 5, финал):
- Скроллим по ТИПУ, а не по длине: новый флаг IF_HSCROLL ставится только
  на код и таблицы; HR и границы fence (IF_NOWRAP без IF_HSCROLL) не
  двигаются. Блок едет целиком, включая строки короче 80.
- Обход бага кодогенерации SDCC z80: `if (n!=g) g=n;` пишет (n-g) вместо n
  (SUB сравнения затирает A, store переиспользует испорченный A). Лечится
  записью viewport_x ДО сравнения. Минимальный репродьюсер и оба описания
  для трекера — в docs/bugs/sdcc-z80-cmp-store-a/ (воспроизводится на чистом
  sdcc 4.5, в т.ч. с --no-peep → это кодогенератор, не peephole).

Рендеринг:
- Отступленный fence (```c внутри списка) теперь распознаётся: is_fence_raw
  пропускает ведущие пробелы/табы; то же в рендере прячет строку-границу.
- Строки-разделители (HR, ровно 80) больше не участвуют в скролле.

Чистка: удалён мёртвый код (is_fence_delim, get_init_style[_raw], is_cont,
seg_flags). Makefile (mdview/mdview2): iconv UTF-8→CP866 завершается ненулевым
кодом при отбрасывании символов — игнорируем (|| true).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 10:11:27 +03:00
snark13 6992c1436e docs(mdview): добавить описание работы и тестовые паттерны
Co-Authored-By: Oz <oz-agent@warp.dev>
2026-06-07 22:39:14 +03:00
snark13 527d4a6a18 libc review: mem/, stdio/, fixes in sprinter-cc and FILE shim
libc/mem/:
  • Split bank_io.c into bank_io_w3.c (existing W3 helpers, base 0xC000,
    port 0xE2) and bank_io_w1.c (new mirror through W1, base 0x4000,
    port 0xA2).  Two .rel files so DCE picks only the needed group:
    a W3-only user pulls ~70 bytes instead of all 134.  W1 variants are
    `--memory tiny`-only (any other mode runs code from W1 or uses W1
    for the banked-code segment, swapping it crashes).
  • mem_alloc.c: add CF=err checks for mem_free_block and mem_get_page
    (were silently ignored), per-function docstrings on alloc/free/
    get_page/info, drop the confused "wait wrong order" comment in
    mem_info.  Header sprinter_mem.h gets matching per-function doc.

libc/stdio/:
  • Add hex_print.c (hex8/hex16/hex32, ~26 bytes) and dec_print.c
    (dec8/dec16/dec32, ~170 bytes) ported from solid-c STDLIB.ASM.
    Replaces the printf("%u"/"%X") wrappers in solid_helpers.c that
    dragged in the 3-5 KB printf machinery.
    - hex* use the classic cp 10 / sbc 0x69 / daa nibble→ASCII trick;
      hex8 self-calls for the high nibble, hex16/hex32 tail-call hex8.
    - dec32 is the master routine; dec8/dec16 jump into shared entry
      points (__dec_entry3 / __dec_entry5).  32-bit subtract-power-of-10
      keeps the high 16 bits in HL alt (shadow set).
    - DISCOVERY: ESTEX PUTCHAR ($5B) on our Sprinter build preserves
      the main register set + IX but CLOBBERS the shadow set
      (BC'/DE'/HL').  solid-c's original code assumed otherwise and
      garbled output for values ≥ 6 digits.  Fix: save/restore HL alt
      around the RST 10 in _dec_emit_or_skip.  Documented in
      memory/estex_putchar_abi.md.
  • file.c: drop stdaux/stdprn (no Sprinter printer API), change
    stdin/stdout/stderr fd markers to 0/-1/-2 (positive fds clash with
    ESTEX OPEN return values), add TODO header pointing at v2 buffered
    FILE rewrite (see docs/TODO.md for the Solid-C reference struct).

bin/sprinter-cc:
  • --memory big and --memory huge now always use crt0_banked.s (was:
    only with --bank flags), matching docs/memory_modes_implemented.md.
    When the user has no --bank flags, generate a tiny stub with
    `const uint8_t n_banks = 0;` and assemble bank.s for _bank_pages.
    Without this fix, openenv with --memory big could not see the
    estex_file_handle symbol exported by crt0_banked.

examples/openenv:
  • Add usage of estex_file_handle to confirm the crt0_banked startup-
    info is reachable.  Local extern decl — keeps the symbol out of
    sprinter.h since it only exists in big/huge builds.

examples/dec_test:
  • New regression test covering hex8/16/32 and dec8/16/32 across the
    interesting boundary values.

.gitignore: add .kilo/ (editor session cache).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-04 09:26:10 +03:00
snark13 c71e249a4e Add full compiler toolchain, libc, examples and reference docs
First substantive commit: the entire Sprinter C compiler tree on top of
the bare README+gitignore initial commit.

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

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

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