Завершить разделение SDK и внешних проектов

This commit is contained in:
Александр Петров
2026-09-16 10:01:43 +03:00
parent 0e74aaa7ee
commit 2e7ffd64a4
1965 changed files with 373 additions and 201393 deletions
+19 -65
View File
@@ -1,76 +1,30 @@
# Examples tour
# Programs and examples
The release ships with 27 example programs in `examples/`. Every one of them
is a self-contained demo with comments — they were used as regression tests
during development.
The SDK release includes its regression programs in `tests/`: `hello`,
`cat`, `gfx_demo`, `bgitest` and others. They exercise compiler, libc,
graphics and Sprinter runtime behavior. Build them with `make`; `make floppy`
packs them into a local `build/media/toolkit-tests.img`.
## Build any example
Larger demonstrations (`balls`, `mdview`, `mdview2`, `rpgwalk`, `scroll`,
`space`) are published in the separate Examples project. Clone it separately
and point it at this installed SDK:
```sh
cd examples/hello
export SPRINTER_ROOT=/path/to/sprinter-c
cd /path/to/Examples
pyenv exec python -m pip install -r requirements.txt
make
```
That produces `hello.exe` next to `hello.c` using `examples/example.mk`.
## Categories
### Hello world / basics
* **`hello`** — stdio + conio Turbo-C-style colours
* **`argv`** — argv parsing in crt0
* **`conio`** — conio API smoke test
* **`attrprob`** — probe Sprinter text-attribute byte layout
### File I/O
* **`cat`** — read & print TEST.TXT
* **`seek`** — 32-bit lseek over a 100 KB file
* **`ls`** — directory listing via ffirst/fnext
* **`filetest`** — FILE* streams (`fopen`/`fread`/`fwrite`/`fclose`)
* **`stattest`** — `stat`/`fstat` on files and directories
* **`openenv`** — open() flags + environment variables
### Memory & banking
* **`malloc`** — heap stress test (200+ allocations)
* **`mem_test`** — page allocator + `bank_read`/`bank_write`
* **`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
### Graphics
* **`gfx_demo`** — 320×256×256: lines, rectangles, fill via accelerator
* **`gfx_d16`** — 640×256×16: same primitives in 16-color mode
* **`gfx_text`** — bitmap-font text on graphics screen
### Misc
* **`errno`** — errno / strerror / perror
* **`timedir`** — date/time + directory listing
* **`ptime`** — POSIX time API (time / localtime / mktime)
* **`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)
## Example.mk
Every example uses `examples/example.mk`. A minimal Makefile looks like:
For your own program, use the SDK's `app.mk`:
```makefile
PROJ_ROOT := $(abspath $(CURDIR)/../..)
EXAMPLE := my_app
include $(PROJ_ROOT)/examples/example.mk
SPRINTER_ROOT ?= /path/to/sprinter-c
EXAMPLE := my_app
include $(SPRINTER_ROOT)/app.mk
```
Optional knobs (set before `include`):
```makefile
MEMORY := huge # default tiny
STACK_SIZE := 4096 # default ~1278
EXTRA_SRCS := helper.c util.c # extra .c files in same dir
EXTRA_FLAGS := --bank 1=engine.c --debug # pass-through to sprinter-cc
```
Use this template for your own programs.
`make floppy` creates an image under the application's `build/media/`.
For an emulator launch, set `MAME_HOME` to a prepared MAME runtime with
`mame.arm`, `roms/` and `IMG/`; `MAME_BIN`, `MAME_ROMPATH`, `MAME_DSS_IMAGE`,
`MAME_SYSTEM_HDD_IMAGE` and `MAME_BIOS` can override each part.