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>
This commit is contained in:
2026-06-03 16:13:21 +03:00
parent f542608b3f
commit c71e249a4e
404 changed files with 75155 additions and 58 deletions
+87
View File
@@ -0,0 +1,87 @@
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <sprinter.h>
#include <sprinter_mem.h>
/*
* Exercises the ESTEX EMM page allocator + bank_read/bank_write helpers.
*
* Plan:
* 1. Show free-page count via mem_info.
* 2. Allocate 3 pages → block id.
* 3. For each page in the block, write a recognizable pattern via
* bank_write, then read it back via bank_read into a near buffer.
* 4. Cross-check the readback to prove pages are independent.
* 5. Free the block, show the free-page count again.
*/
static void show_mem(const char *label)
{
uint16_t total, free_pages;
mem_info(&total, &free_pages);
printf(" %s total=%u free=%u (each page = 16 KB)\n",
label, total, free_pages);
}
int main(void)
{
puts("Sprinter page allocator demo");
puts("");
show_mem("before:");
uint8_t blk = mem_alloc_pages(3);
if (blk == 0) {
puts(" mem_alloc_pages(3) failed");
(void)getchar();
return 1;
}
printf(" allocated block id = %u (3 pages)\n", blk);
show_mem("after alloc:");
/* Show the physical page numbers we got. */
for (uint8_t i = 0; i < 3; i++) {
uint8_t phys = mem_get_page(blk, i);
printf(" page %u of block = phys 0x%02X\n", i, phys);
}
/* Write a 32-byte pattern at offset 0 of each page; pattern depends
* on page index so we can distinguish them. */
char buf[33];
for (uint8_t i = 0; i < 3; i++) {
uint8_t phys = mem_get_page(blk, i);
for (int j = 0; j < 32; j++) {
buf[j] = 'A' + (char)i; /* page 0 -> 'A', page 1 -> 'B', page 2 -> 'C' */
}
buf[32] = 0;
bank_write(phys, 0, buf, 32);
printf(" wrote 32 x '%c' to page %u (phys 0x%02X)\n",
'A' + i, i, phys);
}
/* Read back and verify each page has its own pattern. */
puts("");
puts("readback:");
for (uint8_t i = 0; i < 3; i++) {
uint8_t phys = mem_get_page(blk, i);
memset(buf, 0, sizeof(buf));
bank_read(phys, 0, buf, 32);
buf[32] = 0;
printf(" page %u (phys 0x%02X) first 32 bytes: \"%s\"\n",
i, phys, buf);
}
/* Single-byte API spot check. */
bank_store_byte(mem_get_page(blk, 1), 100, 0x42);
uint8_t got = bank_load_byte(mem_get_page(blk, 1), 100);
printf("\n store/load single byte at page1[100]: 0x%02X (expect 0x42)\n", got);
mem_free_block(blk);
show_mem("after free:");
puts("");
puts("Press any key to exit.");
(void)getchar();
return 0;
}