Files
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

213 lines
7.3 KiB
NASM

device ZXSPECTRUM128
;---------------------------------------------------------------------------------
PAGE0 equ #82
PAGE1 equ #A2
PAGE2 equ #C2
PAGE3 equ #E2
RGMOD equ #C9
RGADR equ #89
PORT_Y equ #89
ORG 8100h-512
code_start
;--------EXE-file header:---------------------------------------------------------
dw 5845h ; EXE Signature
db 45h ; Reserved (EXE type)
db 00h ; Version of EXE file
dw 0200h ; Code offset
dw 0000h
dw 0000h ; Primary loader size or 0 (no primary loader)
dw 0000h ; Reserved
dw 0000h ; Reserved
dw 0000h ; Reserved
dw START ; Loading address
dw START ; Starting address (register PC)
dw 0C000h ; Stack address (register SP)
ds 490 ; Reserved
;-------------------------------------------------------------------------------
START ld a,0x81
ld bc,0x0050
rst 0x10
jp c,VMError
LD A,0x50
OUT (PAGE3),A
;-------- Draw plasma ----------------------------------------------------------
ld bc,0 ;y
loop_y push bc
ld de,320 ;x
ld a,c
out (PORT_Y),a
loop_x ld hl,plasm_tab
add hl,de
ld a,(hl)
ld hl,plasm_tab
add hl,bc
add a,(hl) ;color
ld hl,#c000-1
add hl,de
ld (hl),a ;draw
dec de
ld a,d
or e
jr nz,loop_x
pop bc
inc c
jr nz,loop_y
;-------- Palette cycling------------------------------------------------------
main_loop halt
ld b,0
ld c,0
ld de,pal_R_tab
ld ix,pal_G_tab
ld iy,pal_B_tab
loop_color ld a,c
out (PORT_Y),a
ld hl,#c000+992
ld a,(de)
ld (hl),a
inc hl
ld a,(ix+0)
ld (hl),a
inc hl
ld a,(iy+0)
ld (hl),a
inc de,ix,iy
inc c
djnz loop_color
;
ld a,(pal_R_tab)
ld hl,pal_R_tab+1
ld de,pal_R_tab
ld bc,255
ldir
ld (pal_R_tab+255),a
;
ld a,(pal_B_tab)
ld hl,pal_B_tab+1
ld de,pal_B_tab
ld bc,255
ldir
ld (pal_B_tab+255),a
;
ld a,(pal_G_tab)
ld hl,pal_G_tab+1
ld de,pal_G_tab
ld bc,255
ldir
ld (pal_G_tab+255),a
;---------------------------------------------------------------------------------
ld c,33h ; check keypress
rst 10h
or a
jr z,main_loop
;---------------------------------------------------------------------------------
Exit ld bc,0x0041
rst 0x10
VMError ld hl,ErrorMessage
ld bc,0x005c
rst 0x10
jr Exit
ErrorMessage db "videomode error",0x0d,0x0a,0x00
;------ precalculated data -------------------------------------------------------
plasm_tab db 31,30,30,29,29,28,27,27,26,26,26,25,25,25,25,25
db 25,25,25,25,25,25,25,25,25,26,26,26,27,27,28,28
db 29,29,30,30,31,32,32,33,34,34,35,36,37,38,38,39
db 40,41,42,43,44,44,45,46,47,48,49,50,50,51,52,53
db 54,55,55,56,57,58,58,59,60,61,61,62,62,63,64,64
db 65,65,66,66,67,67,67,68,68,68,68,69,69,69,69,69
db 69,70,70,70,70,70,70,69,69,69,69,69,69,68,68,68
db 68,67,67,67,67,66,66,66,65,65,64,64,64,63,63,62
db 62,62,61,61,60,60,60,59,59,59,58,58,58,57,57,57
db 57,56,56,56,56,56,55,55,55,55,55,55,55,55,55,55
db 55,56,56,56,56,56,57,57,57,58,58,58,59,59,60,60
db 61,61,62,63,63,64,65,65,66,67,68,68,69,70,71,72
db 73,73,74,75,76,77,78,79,80,81,82,82,83,84,85,86
db 87,88,89,90,90,91,92,93,94,94,95,96,96,97,98,98
db 99,99,100,100,101,101,102,102,102,102,103,103,103,103,103,103
db 103,103,103,103,102,102,102,101,101,100,100,99,99,98,98,97
db 96,95,94,93,92,92,90,89,88,87,86,85,84,82,81,80
db 78,77,75,74,72,71,69,68,66,65,63,61,60,58,56,55
db 53,51,50,48,46,45,43,42,40,38,37,35,33,32,30,29
db 27,26,25,23,22,20,19,18,17,15,14,13,12,11,10,9
db 8,8,7,6,5,5,4,4,3,3,3,2,2,2,2,2
db 2,2,2,2,3,3,3,4,4,5,5,6,7,8,8,9
db 10,11,12,14,15,16,17,19,20,21,23,24,26,27,29,31
db 32,34,36,37,39,41,43,45,47,48,50,52,54,56,58,60
db 62,64,66,68,70,72,74,75,77,79,81,83,85,86,88,90
db 92,93,95,97,98,100,101,103,104,105,107,108,109,110,112,113
db 114,115,116,116,117,118,119,119,120,120,121,121,122,122,122,122
db 122,122,122,122,122,122,122,122,121,121,120,120,119,119,118,117
db 116,116,115,114,113,112,111,110,109,107,106,105,104,102,101,100
db 98,97,95,94,93,91,90,88,86,85,83,82,80,79,77,75
db 74,72,71,69,68,66,65,63,62,60,59,57,56,54,53,52
db 50,49,48,47,45,44,43,42,41,40,39,38,37,36,35,35
;
pal_R_tab db 0,0,0,1,2,3,5,7,9,12,14,17,21,24,28,32
db 36,41,46,50,55,61,66,72,77,83,89,95,101,107,113,119
db 125,131,138,144,150,156,162,167,173,179,184,190,195,200,205,209
db 214,218,222,226,229,232,235,238,240,243,245,246,247,248,249,249
db 249,249,249,248,247,245,244,242,239,237,234,231,227,224,220,216
db 212,207,202,197,192,187,182,176,170,165,159,153,147,141,134,128
db 122,116,110,104,98,92,86,80,74,69,63,58,53,48,43,39
db 34,30,26,22,19,16,13,10,8,6,4,3,1,0,0,0
db 0,0,0,1,3,4,6,8,10,13,16,19,22,26,30,34
db 39,43,48,53,58,63,69,74,80,86,92,98,104,110,116,122
db 128,134,141,147,153,159,165,170,176,182,187,192,197,202,207,212
db 216,220,224,227,231,234,237,239,242,244,245,247,248,249,249,249
db 249,249,248,247,246,245,243,240,238,235,232,229,226,222,218,214
db 209,205,200,195,190,184,179,173,167,162,156,150,144,138,131,125
db 119,113,107,101,95,89,83,77,72,66,61,55,50,46,41,36
db 32,28,24,21,17,14,12,9,7,5,3,2,1,0,0,0
;
pal_G_tab db 125,118,112,106,100,94,88,82,76,71,65,60,55,50,45,40
db 36,32,28,24,20,17,14,11,9,7,5,3,2,1,0,0
db 0,0,0,1,2,3,5,7,9,12,15,18,21,25,29,33
db 37,41,46,51,56,61,67,72,78,84,90,96,102,108,114,120
db 126,132,138,144,150,156,162,168,174,180,185,190,195,200,205,210
db 214,218,222,226,230,233,236,238,241,243,245,246,248,248,249,249
db 249,249,249,248,247,245,243,241,239,236,234,230,227,223,219,215
db 211,206,202,197,192,186,181,175,170,164,158,152,146,140,134,128
db 121,115,109,103,97,91,85,79,74,68,63,57,52,47,43,38
db 34,30,26,22,19,15,13,10,8,6,4,2,1,0,0,0
db 0,0,1,1,3,4,6,8,11,13,16,19,23,27,31,35
db 39,44,49,54,59,64,69,75,81,87,93,99,105,111,117,123
db 129,135,141,147,153,159,165,171,177,182,188,193,198,203,208,212
db 216,220,224,228,231,234,237,240,242,244,246,247,248,249,249,249
db 249,249,248,247,246,244,242,240,238,235,232,229,225,221,217,213
db 209,204,199,194,189,184,178,173,167,161,155,149,143,137,131,125
;
pal_B_tab db 0,0,1,3,5,8,12,16,21,27,33,39,46,54,62,70
db 79,88,97,106,115,125,134,143,153,162,171,180,188,196,204,211
db 218,224,230,235,240,244,248,250,252,254,254,254,254,252,250,248
db 244,240,235,230,224,218,211,204,196,188,180,171,162,153,143,134
db 125,115,106,97,88,79,70,62,54,46,39,33,27,21,16,12
db 8,5,3,1,0,0,0,1,3,5,8,12,16,21,27,33
db 39,46,54,62,70,79,88,97,106,115,125,134,143,153,162,171
db 180,188,196,204,211,218,224,230,235,240,244,248,250,252,254,254
db 254,254,252,250,248,244,240,235,230,224,218,211,204,196,188,180
db 171,162,153,143,134,125,115,106,97,88,79,70,62,54,46,39
db 33,27,21,16,12,8,5,3,1,0,0,0,1,3,5,8
db 12,16,21,27,33,39,46,54,62,70,79,88,97,106,115,125
db 134,143,153,162,171,180,188,196,204,211,218,224,230,235,240,244
db 248,250,252,254,254,254,254,252,250,248,244,240,235,230,224,218
db 211,204,196,188,180,171,162,153,143,134,125,115,106,97,88,79
db 70,62,54,46,39,33,27,21,16,12,8,5,3,1,0,0
;-------------------------------------------------------------------------------------------------
code_end nop
SAVEBIN "plasma2.exe", code_start, code_end - code_start