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:
Binary file not shown.
@@ -0,0 +1,194 @@
|
||||
;[]=======================================================================[]
|
||||
;
|
||||
; main.z80 -- stub file for TextOut procedures
|
||||
;
|
||||
; Created by Anton Enin 26-June-2002
|
||||
;
|
||||
; Last update 27-June-2002
|
||||
;
|
||||
; Copyright (C) 2002 R-lab
|
||||
;
|
||||
; This program should be compiled using z80asm
|
||||
; http://www.zxasm.narod.ru/
|
||||
;
|
||||
; z80asm.exe -f bin main.z80 -o a_print.exe
|
||||
;
|
||||
;[]=======================================================================[]
|
||||
; Sprinter constans -- see Sprinter docs
|
||||
|
||||
VPAGE equ 0x50 ; video memory page
|
||||
YPORT equ 0x89 ; y pos for write to the vram
|
||||
PAGE0 equ 0x82 ; memory page ports
|
||||
PAGE1 equ 0xA2 ;
|
||||
PAGE2 equ 0xC2 ;
|
||||
PAGE3 equ 0xE2 ;
|
||||
|
||||
struc HeaderStruct ; Estex Exe Header
|
||||
id: resb 3 ; exe file Id (must be 'EXE')
|
||||
version: resb 1 ; exe file version
|
||||
code_offeset: resd 1 ; offset to start code (header size)
|
||||
loader_size: resw 1 ; first loader size
|
||||
reserved1: resw 3 ; reserved
|
||||
start_address: resw 1 ; program org
|
||||
entry_point: resw 1 ; program entry point
|
||||
stack_point: resw 1 ; program stack point
|
||||
reserved2: resb 490 ; reserved
|
||||
endstruc
|
||||
|
||||
FONT_BASE equ 0x8000
|
||||
|
||||
;[]=======================================================================[]
|
||||
|
||||
section .text
|
||||
org 0x7E00
|
||||
|
||||
;[]=======================================================================[]
|
||||
; EXE header
|
||||
|
||||
ExeHeader: istruc HeaderStruct ; initialized structure
|
||||
at id, db 'EXE'
|
||||
at version, db 0
|
||||
at code_offeset, dd CodeStart - ExeHeader
|
||||
at loader_size, dw 0
|
||||
at start_address, dw 0x8000
|
||||
at entry_point, dw EntryPoint
|
||||
at stack_point, dw 0xBFFF
|
||||
iend
|
||||
CodeStart: ; start address is 0x8000
|
||||
;[]=======================================================================[]
|
||||
MyFont: ; characters images
|
||||
incbin "font.raw"
|
||||
|
||||
;[]=======================================================================[]
|
||||
; palette from Flex Navigator
|
||||
CustomPalette:
|
||||
db 0x00, 0x00, 0x00, 0x00 ; Black 00
|
||||
db 0x00, 0x00, 0xFF, 0x00 ; B.Red 01
|
||||
db 0x00, 0x80, 0x00, 0x00 ; Green 02
|
||||
db 0x00, 0xFF, 0xFF, 0x00 ; B.Yellow 03
|
||||
db 0x80, 0x00, 0x00, 0x00 ; Blue 04
|
||||
db 0xFF, 0xFF, 0x00, 0x00 ; Invert bg 05
|
||||
db 0x80, 0x00, 0x00, 0x00 ; Invert fg 06
|
||||
db 0x80, 0x80, 0x80, 0x00 ; BlackGray 07
|
||||
db 0xC0, 0xC0, 0xC0, 0x00 ; HighGray 08
|
||||
db 0x80, 0x00, 0x00, 0x00 ; Panel 09
|
||||
db 0xFF, 0xFF, 0x00, 0x00 ; Files 0A
|
||||
db 0x00, 0xFF, 0xFF, 0x00 ; Select Files 0B
|
||||
db 0x00, 0xFF, 0xFF, 0x00 ; InvSel Files 0C
|
||||
db 0xC0, 0xC0, 0xC0, 0x00 ; Reserved 0D
|
||||
db 0xFF, 0xFF, 0xFF, 0x00 ; White 0E
|
||||
db 0xFF, 0xFF, 0xFF, 0x00 ; White 0F
|
||||
|
||||
;[]=======================================================================[]
|
||||
; entry point
|
||||
align 16
|
||||
EntryPoint:
|
||||
call SetVideoMode ; set video mode
|
||||
|
||||
ld hl, TextStr1 ; text string
|
||||
ld de, 0x0020 ; x position
|
||||
ld bc, 0x0000 ; y position
|
||||
ld a, 0x02 ; background color = 0x00
|
||||
; foreground color = 0x02
|
||||
call TextOut
|
||||
|
||||
ld hl, TextStr2 ; text string
|
||||
ld de, 0x0020 ; x position
|
||||
ld bc, 0x0008 ; y position
|
||||
ld a, 0x1F ; background color = 0x01
|
||||
; foreground color = 0x0F
|
||||
call TextOut
|
||||
|
||||
ld c, 0x30 ; wait keypressed
|
||||
rst 0x10
|
||||
|
||||
call ResVideoMode ; restore video mode
|
||||
|
||||
ld bc, 0x0041
|
||||
rst 0x10 ; return to OS
|
||||
|
||||
;[]=======================================================================[]
|
||||
; set requist video mode 640x256x16
|
||||
SetVideoMode:
|
||||
ld c, 0x51 ; save previos vmode
|
||||
rst 0x10
|
||||
ld (vmode + 1), a
|
||||
ld a, b
|
||||
ld (vscrn + 1), a
|
||||
sub a
|
||||
call CrearVideoRam
|
||||
ld bc, 0x0050 ; set 640x256x16
|
||||
ld a, 0x82
|
||||
rst 0x10
|
||||
ld hl, CustomPalette
|
||||
ld de, 0x1000
|
||||
ld bc, 0xFFA4
|
||||
sub a
|
||||
rst 0x08 ; load palette
|
||||
ret
|
||||
|
||||
;[]=======================================================================[]
|
||||
; restore previos video mode
|
||||
ResVideoMode:
|
||||
sub a
|
||||
call CrearVideoRam
|
||||
vscrn: ld b, 0x00
|
||||
vmode: ld a, 0x00
|
||||
ld c, 0x50
|
||||
rst 0x10 ; set previos vmode
|
||||
ret
|
||||
|
||||
;[]=======================================================================[]
|
||||
; Clear video memory (first screen)
|
||||
; Input:
|
||||
; a - clear color (0-15)
|
||||
CrearVideoRam:
|
||||
and 0x0F
|
||||
ld e, a
|
||||
rlca
|
||||
rlca
|
||||
rlca
|
||||
rlca
|
||||
or e
|
||||
ld e, a
|
||||
in a, (YPORT) ; store modify ports
|
||||
ld c, a
|
||||
in a, (PAGE1)
|
||||
ld b, a
|
||||
push bc
|
||||
ld a, VPAGE
|
||||
out (PAGE1), a
|
||||
ld hl, 0x4000
|
||||
ld bc, 320 ; screen x size in bytes
|
||||
di
|
||||
ld d, d
|
||||
ld a, 0x00 ; set accel lenght to 256 bytes
|
||||
.loop: ld e, e ; fill vertical lines
|
||||
ld (hl), e
|
||||
ld b, b
|
||||
inc hl
|
||||
dec bc
|
||||
ld a, b
|
||||
or c
|
||||
jr nz, .loop
|
||||
ei
|
||||
pop bc
|
||||
ld a, b
|
||||
out (PAGE1), a
|
||||
ld a, c
|
||||
out (YPORT), a ; restore modify ports
|
||||
ret
|
||||
|
||||
;[]=======================================================================[]
|
||||
|
||||
%include "print.z80"
|
||||
|
||||
;[]=======================================================================[]
|
||||
; some text
|
||||
TextStr1: db 'Color print with acceleration.', 0
|
||||
TextStr2: db 'Written by Enin Anton. (c) Copyright 2002 R-lab', 0
|
||||
|
||||
;[]=======================================================================[]
|
||||
|
||||
CodeEnd:
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
z80asm.exe -f bin main.z80 -o a_print.exe
|
||||
@@ -0,0 +1,180 @@
|
||||
;[]=======================================================================[]
|
||||
;
|
||||
; Draw text string to the screen 640x256 in 16colors
|
||||
; Input:
|
||||
; hl - pointer to the C string (0 - end string)
|
||||
; de - x position
|
||||
; bc - y position
|
||||
; a - background and foreground color
|
||||
; d7 - d4 background color (0-15)
|
||||
; d3 - d0 foreground color (0-15)
|
||||
;
|
||||
; Output:
|
||||
; hl - pointer to the next byte behind string
|
||||
;
|
||||
; Destroy registers:
|
||||
; 'hl, 'de, 'bc
|
||||
|
||||
TextOut:
|
||||
push iy
|
||||
ld yl, c ; y position
|
||||
ld b, a ; store colors
|
||||
in a, (YPORT) ; store Y_PORT
|
||||
push af
|
||||
in a, (PAGE1)
|
||||
ld yh, a ; store PAGE1
|
||||
call PreparePrintColors
|
||||
push de ; x position
|
||||
exx
|
||||
pop bc
|
||||
srl b
|
||||
rr c ; start address for x position
|
||||
set 6, b ; print address start from 0x4000
|
||||
ld hl, BackgroundBuffer ; background buffer
|
||||
ld de, ForegroundBuffer ; foreground buffer
|
||||
exx
|
||||
ld c, l ; pointer to the string
|
||||
ld b, h
|
||||
; now:
|
||||
; bc - pointer to the C string
|
||||
; 'hl - pointer to the background buffer
|
||||
; 'de - pointer to the foreground buffer
|
||||
; 'bc - x position
|
||||
; yl - y position
|
||||
|
||||
di ; disable interrupts
|
||||
ld d, d ; set acceleration work lenght
|
||||
ld a, 0x08
|
||||
ld b, b
|
||||
ld a, (bc) ; test on null string
|
||||
inc bc
|
||||
or a
|
||||
jr z, .exit
|
||||
.loop1:
|
||||
ld l, a ; font is always aligned to 256 bytes
|
||||
ld h, FONT_BASE/256 ; pointer to the specialy font
|
||||
push bc
|
||||
ld b, (hl) ; character size x
|
||||
inc h
|
||||
ld e, (hl)
|
||||
inc h
|
||||
ld a, (hl) ; offset to character image
|
||||
add a, FONT_BASE/256
|
||||
ld d, a
|
||||
ld hl, 0x0008 ; line lenght in character image
|
||||
ex de, hl
|
||||
ld a, VPAGE
|
||||
out (PAGE1), a ; set video memory to 0x4000-0x8000
|
||||
.loop2:
|
||||
ld l, l ; linear load
|
||||
ld a, (hl) ; read 8 bytes to accel memory
|
||||
ld b, b
|
||||
exx
|
||||
ld a, yl
|
||||
out (YPORT), a ; set y position out
|
||||
ld l, l ; linear or
|
||||
or (hl) ; with BackgroundBuffer
|
||||
ld b, b
|
||||
ex de, hl
|
||||
ld l, l ; linear exclusive or
|
||||
xor (hl) ; with ForegroundBuffer
|
||||
ld a, a ; vertical write
|
||||
ld (bc), a ; write 8 bytes from accel memory to vram
|
||||
ld b, b
|
||||
ex de, hl
|
||||
inc bc ; next vertical line in video ram
|
||||
exx
|
||||
add hl, de ; next line in character image
|
||||
djnz .loop2
|
||||
pop bc
|
||||
ld a, yh
|
||||
out (PAGE1), a
|
||||
ld a, (bc)
|
||||
inc bc
|
||||
or a
|
||||
jr nz, .loop1 ; end string ?
|
||||
.exit:
|
||||
ei ; enable interrupts
|
||||
ld l, c ; return pointer to the end string
|
||||
ld h, b
|
||||
pop af
|
||||
out (YPORT), a ; restore YPORT
|
||||
pop iy
|
||||
ret
|
||||
|
||||
;[]=======================================================================[]
|
||||
;
|
||||
; Prepare text colors for accel text out
|
||||
; Input:
|
||||
; b - background and foreground color
|
||||
; d7 - d4 background color (0-15)
|
||||
; d3 - d0 foreground color (0-15)
|
||||
;
|
||||
; Destroy registers:
|
||||
; a, bc, 'hl
|
||||
|
||||
PreparePrintColors:
|
||||
ld a, b
|
||||
.prev_color: cp 0x00 ; color is prepared ?
|
||||
ret z
|
||||
ld (.prev_color + 1), a
|
||||
and 0x0F ; foreground color
|
||||
ld c, a
|
||||
rlca
|
||||
rlca
|
||||
rlca
|
||||
rlca
|
||||
or c
|
||||
exx
|
||||
cpl
|
||||
ld hl, ForegroundBuffer ; foreground buffer
|
||||
ld (hl), a
|
||||
inc hl
|
||||
ld (hl), a
|
||||
inc hl
|
||||
ld (hl), a
|
||||
inc hl
|
||||
ld (hl), a
|
||||
inc hl
|
||||
ld (hl), a
|
||||
inc hl
|
||||
ld (hl), a
|
||||
inc hl
|
||||
ld (hl), a
|
||||
inc hl
|
||||
ld (hl), a
|
||||
exx
|
||||
ld a, b
|
||||
and 0xF0 ; background color
|
||||
ld b, a
|
||||
rrca
|
||||
rrca
|
||||
rrca
|
||||
rrca
|
||||
or b
|
||||
exx
|
||||
xor (hl) ; exclusive or with foreground color
|
||||
ld hl, BackgroundBuffer ; background buffer
|
||||
ld (hl), a
|
||||
inc hl
|
||||
ld (hl), a
|
||||
inc hl
|
||||
ld (hl), a
|
||||
inc hl
|
||||
ld (hl), a
|
||||
inc hl
|
||||
ld (hl), a
|
||||
inc hl
|
||||
ld (hl), a
|
||||
inc hl
|
||||
ld (hl), a
|
||||
inc hl
|
||||
ld (hl), a
|
||||
exx
|
||||
ret
|
||||
|
||||
ForegroundBuffer:
|
||||
times 8 db 0
|
||||
BackgroundBuffer:
|
||||
times 8 db 0
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
The tutorial procedure for colour printing at the graphic screen 640x256x16.
|
||||
|
||||
This procedure was used in the Flex Navigator v1.xx.
|
||||
Written for Estex v1.xx or high.
|
||||
|
||||
Files description:
|
||||
main.z80 - initial(main) file
|
||||
print.z80 - printing procedure
|
||||
|
||||
Font format description:
|
||||
In the font used 256 symbols with height 8 points and various width.
|
||||
|
||||
+000 [256] - width of a symbol on X (for each symbol) (in bytes)
|
||||
+256 [256] - low byte of symbol image offset (for each symbol)
|
||||
+512 [256] - high byte of symbol image offset (for each symbol)
|
||||
+768 ... - images of symbols (from 0 to 255 symbol)
|
||||
images stored as vertical lines, 8 bytes per line, 4 bits per point.
|
||||
number of lines (in bytes) calculate from size of X
|
||||
background colour = 0x00
|
||||
foreground colour = 0x0F
|
||||
|
||||
for instance, image of "A" symbol:
|
||||
width of symbol on X = 4 (bytes)
|
||||
00 00 00 00
|
||||
00 FF FF 00
|
||||
0F 00 00 F0
|
||||
0F 00 00 F0
|
||||
0F FF FF F0
|
||||
0F 00 00 F0
|
||||
0F 00 00 F0
|
||||
00 00 00 00
|
||||
|
||||
In the image of symbol it will stored as:
|
||||
|
||||
00 00 0F 0F 0F 0F 0F 00 00 FF 00 00 FF 00 00 00 00 FF 00 00 FF 00 00 00 00 00 F0 F0 F0 F0 F0 00
|
||||
|
||||
Algorithm description:
|
||||
The main problem for the colour printing was fast transformation each point (background/foregraunf) to the necessary colour.
|
||||
Here, I will showed, how I could solve this a "hard" problem. ;) If somebody will think up faster variant, I will be glad to see it. :)
|
||||
|
||||
The printing on the screen realized by vertical lines with the help of accelerator at once till 8 bytes.
|
||||
We require 2 buffers, size in 8 bytes for the colors mixing (background and foreground). Because, to get mixed up we shall be at once till 1 vertical line. These buffers are initialized at each change of colour by function PreparePrintColors (It's made automatically and you don't need about it to care!).
|
||||
|
||||
Using print by function TextOut.
|
||||
|
||||
operation | - Logical Inclusive OR (in Z80 CPU instruction OR)
|
||||
operation ^ - Logical Exclusive OR (in Z80 CPU instruction XOR)
|
||||
|
||||
Function PreparePrintColors:
|
||||
|
||||
1. initialize ForegroundBuffer
|
||||
ForegroundBuffer = Foreground colour ^ 0xFF
|
||||
2. initialize BackgroundBuffer
|
||||
BackgroundBuffer = Background colour ^ ForegroundBuffer
|
||||
|
||||
Function TextOut (input parameters see in the source):
|
||||
actually, a image printing:
|
||||
Screen = (line_of_image | BackgroundBuffer) ^ ForegroundBuffer
|
||||
|
||||
Let's look at a point level:
|
||||
assume the colors for printing Background = 0, Foreground = 1
|
||||
|
||||
then ForegroundBuffer = 1 ^ 0xFF and result 0xFE
|
||||
also BackgroundBuffer = 0 ^ 0xFE and result 0xFE
|
||||
|
||||
for the background colour from a image (=0x00)
|
||||
Screen = (0x00 | 0xFE) ^ 0xFE result 0x00
|
||||
|
||||
for the foreground colour from a image (=0xFF)
|
||||
Screen = (0xFF | 0xFE) ^ 0xFE result 0x01
|
||||
|
||||
It's possible to do for any of colours...
|
||||
|
||||
This algorithm works slower when are printed of very small strings. It occurs because a lot of initialization are required. Also when made often change of colour (Though, I hadn't changing it in the Flex Navigator so often, only for necessary). ;)
|
||||
|
||||
27 june 2002
|
||||
Anton Enin (C) Copyright 2002 R-lab
|
||||
If you have the questions email me: r-lab@mail.ru or ask in the Sprinter's forum.
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
Пример процедур цветной печати на графический экран с разрешением 640x256x16 цветов.
|
||||
Такая процедура использовалась во Flex Navigator v1.xx.
|
||||
Написан под Estex v1.xx и выше.
|
||||
|
||||
Описание файлов:
|
||||
main.z80 - инициализирующий файл
|
||||
print.z80 - процедура печати
|
||||
|
||||
|
||||
Описание формата шрифта:
|
||||
в шрифте используется 256 символов, высотой 8 точек и различной длиной.
|
||||
|
||||
+000 [256] - длина символа по x (для каждого символа) (в байтах)
|
||||
+256 [256] - младший байт смешения на образ символа (для каждого символа)
|
||||
+512 [256] - старший байт смешения на образ символа (для каждого символа)
|
||||
+768 ... - образы символов (от 0 до 255 символа)
|
||||
образы храняться в виде вертикальных линий точек по 8 байт, по 4 бита на точку.
|
||||
кол-во линий (в байтах) определяется из размера по х
|
||||
цвет background = 0x00
|
||||
цвет foreground = 0x0F
|
||||
|
||||
например образ символа А:
|
||||
длина символа по x = 4 (байта)
|
||||
00 00 00 00
|
||||
00 FF FF 00
|
||||
0F 00 00 F0
|
||||
0F 00 00 F0
|
||||
0F FF FF F0
|
||||
0F 00 00 F0
|
||||
0F 00 00 F0
|
||||
00 00 00 00
|
||||
|
||||
в образе символа он будет лежать так:
|
||||
|
||||
00 00 0F 0F 0F 0F 0F 00 00 FF 00 00 FF 00 00 00 00 FF 00 00 FF 00 00 00 00 00 F0 F0 F0 F0 F0 00
|
||||
|
||||
|
||||
|
||||
Описание алгоритма:
|
||||
Самая главная проблема цветной печати это быстрое преоброзование точки фона/символа в нужный цвет.
|
||||
Здесь показано, как я вышел из этого "нелегкого" положения ;) Если кто-нибудь придумает более быстрый
|
||||
вариант, то я буду рад его увидеть :)
|
||||
|
||||
Печать на экран осуществляется вертикальными линиями с испольэованием акселератора сразу по 8 байт.
|
||||
Для замешивания цветов нам требуется 2 буфера (цвет background и foreground) размером в 8 байт, т.к.
|
||||
замешивать будем сразу по 1 вертикальной линии. Эти 2 буфера инициализируются заново при каждой смене
|
||||
цвета функцией PreparePrintColors (это делается автоматически, вам не нужно об этом заботиться!).
|
||||
Печатаем функцией TextOut.
|
||||
|
||||
операция | - поразрядное логическое ИЛИ (на Z80 CPU команда or)
|
||||
операция ^ - поразрядное исключение ИЛИ (на Z80 CPU команда xor)
|
||||
|
||||
Функция PreparePrintColors:
|
||||
1. инициализируем ForegroundBuffer
|
||||
ForegroundBuffer = цвет Foreground ^ 0xFF
|
||||
2. инициализируем BackgroundBuffer
|
||||
BackgroundBuffer = цвет Background ^ ForegroundBuffer
|
||||
|
||||
Функция TextOut (входные параметры см. в исходнике):
|
||||
непосредственно печать образа:
|
||||
Screen = (линия_образа | BackgroundBuffer) ^ ForegroundBuffer
|
||||
|
||||
Рассмотрим это на уровне точки:
|
||||
цвет печати допустим Background = 0, Foreground = 1
|
||||
|
||||
получаем ForegroundBuffer = 1 ^ 0xFF получаем 0xFE
|
||||
получаем BackgroundBuffer = 0 ^ 0xFE получаем 0xFE
|
||||
|
||||
для цвета background из образа (=0x00)
|
||||
Screen = (0x00 | 0xFE) ^ 0xFE получаем 0x00
|
||||
|
||||
для цвета foreground из образа (=0xFF)
|
||||
Screen = (0xFF | 0xFE) ^ 0xFE получаем 0x01
|
||||
|
||||
можно всё это проделать для любого из цветов...
|
||||
|
||||
Этот алгоритм работает медленнее при печати очень маленьких строк, из-за большой инициализации, а также из-за
|
||||
частой смены цвета (хотя я во Flex Navigato'e его часто не менял, только по надобности). ;)
|
||||
|
||||
27 june 2002
|
||||
Anton Enin (C) Copyright 2002 R-lab
|
||||
если есть вопросы e-mail: r-lab@mail.ru или на спринтер форуме.
|
||||
Reference in New Issue
Block a user