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:
@@ -0,0 +1,76 @@
|
||||
# example.mk — shared Makefile fragment for simple Sprinter ESTEX examples.
|
||||
#
|
||||
# Usage in an example's Makefile:
|
||||
#
|
||||
# PROJ_ROOT := $(abspath $(CURDIR)/../..)
|
||||
# EXAMPLE := my_example # base name (matches my_example.c)
|
||||
#
|
||||
# # Optional overrides (any combination):
|
||||
# # MEMORY := small # tiny | small | big | huge | manual
|
||||
# # STACK_SIZE := 2048 # bytes reserved for the stack
|
||||
# # EXTRA_SRCS := helper.c util.c # additional .c files in this dir
|
||||
# # EXTRA_FLAGS := --crt0=minimal # passed through to sprinter-cc
|
||||
# # EXTRA_DATA := test.txt # extra files to add to `make floppy`
|
||||
#
|
||||
# include $(PROJ_ROOT)/examples/example.mk
|
||||
#
|
||||
# Pipeline (all driven by sprinter-cc):
|
||||
# crt0 + EXAMPLE.c + EXTRA_SRCS --sdcc--> .ihx
|
||||
# .ihx --mkexe--> EXAMPLE.exe
|
||||
# linking against lib/sprinter.lib for libc.
|
||||
#
|
||||
# Targets provided:
|
||||
# all build $(EXAMPLE).exe (default)
|
||||
# clean remove build artefacts
|
||||
# floppy build the example and pack it (alone, plus EXTRA_DATA) into
|
||||
# mame/v306/IMG/mc.img — useful for trying a single program
|
||||
# without rebuilding every example. Top-level `make floppy`
|
||||
# (in the repo root) still packs all examples.
|
||||
# run floppy + launch MAME
|
||||
|
||||
SPRINTER_CC := $(PROJ_ROOT)/bin/sprinter-cc
|
||||
MKEXE := $(PROJ_ROOT)/toolchain/mkexe/mkexe
|
||||
LIB := $(PROJ_ROOT)/lib/sprinter.lib
|
||||
|
||||
MAME_DIR := $(PROJ_ROOT)/mame/v306
|
||||
FLOPPY_IMG := $(MAME_DIR)/IMG/mc.img
|
||||
MAKE_DISK := $(MAME_DIR)/make_disk.py
|
||||
RUN_MAME := $(MAME_DIR)/run_mame.sh
|
||||
|
||||
# Optional knobs — see top of file.
|
||||
MEMORY ?= tiny
|
||||
SOURCES := $(EXAMPLE).c $(EXTRA_SRCS)
|
||||
|
||||
CC_FLAGS := --memory $(MEMORY)
|
||||
ifneq ($(STACK_SIZE),)
|
||||
CC_FLAGS += --stack-size $(STACK_SIZE)
|
||||
endif
|
||||
CC_FLAGS += $(EXTRA_FLAGS)
|
||||
|
||||
all: $(EXAMPLE).exe
|
||||
|
||||
$(EXAMPLE).exe: $(SOURCES) $(MKEXE) $(LIB)
|
||||
$(SPRINTER_CC) $(CC_FLAGS) -o $@ $(SOURCES)
|
||||
|
||||
$(MKEXE):
|
||||
$(MAKE) -C $(PROJ_ROOT)/toolchain/mkexe
|
||||
|
||||
$(LIB):
|
||||
$(MAKE) -C $(PROJ_ROOT)/lib
|
||||
|
||||
clean:
|
||||
rm -rf .sprinter-cc-* $(EXAMPLE).exe
|
||||
|
||||
# `make floppy` packs ONLY this example (+ optional EXTRA_DATA files) into
|
||||
# the MAME floppy image, replacing whatever was there. Handy for trying a
|
||||
# single program without rebuilding all 27 examples.
|
||||
floppy: $(EXAMPLE).exe
|
||||
python3 $(MAKE_DISK) $(FLOPPY_IMG) $(EXAMPLE).exe $(EXTRA_DATA)
|
||||
@echo
|
||||
@echo "Floppy ready: $(FLOPPY_IMG) (with $(EXAMPLE).exe$(if $(EXTRA_DATA), + $(EXTRA_DATA))) "
|
||||
@echo "Run: cd $(MAME_DIR) && ./run_mame.sh"
|
||||
|
||||
run: floppy
|
||||
cd $(MAME_DIR) && ./run_mame.sh
|
||||
|
||||
.PHONY: all clean floppy run
|
||||
Reference in New Issue
Block a user