aboutsummaryrefslogtreecommitdiffstats
path: root/src/color.asm
diff options
context:
space:
mode:
authoruser <user@clank>2026-07-18 20:41:27 +0200
committeruser <user@clank>2026-07-18 20:41:27 +0200
commit9e7d5f6e5e01b7473b84bc3449d7f8e0f78e7045 (patch)
tree5dcde624f3b366cc9244e08b0d2ca4ab35b338e2 /src/color.asm
parentkernel: a real timer source (64 Hz tick IRQ) + uptime(1) (diff)
downloadgbos-9e7d5f6e5e01b7473b84bc3449d7f8e0f78e7045.tar.gz
gbos-9e7d5f6e5e01b7473b84bc3449d7f8e0f78e7045.tar.xz
gbos-9e7d5f6e5e01b7473b84bc3449d7f8e0f78e7045.zip
term: 7-color terminal (per-glyph fg+bg) + ANSI escapes; colorize irc
Fano-plane palette scheme: the 7 colors map onto 7 CGB BG palettes so any color pair shares one palette; a tile's palette is picked from the set of colors its two cells need (tables generated by tools/gencolor.py). Per cell a packed (bg<<4)|fg byte lives alongside the char shadow, and the glyph blitter steers glyph/empty pixels to each cell's fg/bg color slots via plane masks. An ANSI-ish CSI parser (ESC [ .. m) drives it; usr/ansi.c demos it and the irc client now renders hashed nick colors, status dimming and a channel-activity bar.
Diffstat (limited to '')
-rw-r--r--src/color.asm40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/color.asm b/src/color.asm
new file mode 100644
index 0000000..5c12569
--- /dev/null
+++ b/src/color.asm
@@ -0,0 +1,40 @@
+; auto-generated by tools/gencolor.py - Fano-plane color tables
+; (foreground + background). DO NOT EDIT.
+SECTION "color", ROM0
+
+; 8 CGB BG palettes, 4 colors each (c0=black). Loaded at BCPS $80.
+PalData::
+ db $00,$00,$FF,$7F,$1F,$00,$E0,$7F ; palette 0
+ db $FF,$7F,$00,$00,$00,$00,$00,$00 ; palette 1
+ db $00,$00,$1F,$00,$E0,$03,$FF,$03 ; palette 2
+ db $00,$00,$1F,$00,$00,$7C,$1F,$7C ; palette 3
+ db $00,$00,$E0,$03,$00,$7C,$E0,$7F ; palette 4
+ db $00,$00,$E0,$03,$1F,$7C,$FF,$7F ; palette 5
+ db $00,$00,$FF,$03,$00,$7C,$FF,$7F ; palette 6
+ db $00,$00,$FF,$03,$1F,$7C,$E0,$7F ; palette 7
+
+; BitTab[color] = bit for that color in the 'colors present' set (black=0)
+BitTab::
+ db $00,$01,$02,$04,$08,$10,$20,$40
+
+; BestPal[set] = palette (0..7) covering the most colors in a 7-bit set
+BestPal::
+ db $00,$00,$02,$02,$02,$02,$02,$02,$03,$03,$04,$02,$06,$02,$02,$02 ; 0..15
+ db $03,$03,$05,$02,$07,$02,$02,$02,$03,$03,$03,$03,$03,$03,$02,$02 ; 16..31
+ db $00,$00,$04,$00,$07,$00,$02,$02,$04,$00,$04,$04,$04,$00,$04,$02 ; 32..47
+ db $07,$00,$04,$00,$07,$07,$07,$02,$03,$03,$04,$03,$07,$03,$04,$02 ; 48..63
+ db $00,$00,$05,$00,$06,$00,$02,$02,$06,$00,$04,$00,$06,$06,$06,$02 ; 64..79
+ db $05,$00,$05,$05,$05,$00,$05,$02,$03,$03,$05,$03,$06,$03,$05,$02 ; 80..95
+ db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$04,$00,$06,$00,$04,$00 ; 96..111
+ db $00,$00,$05,$00,$07,$00,$05,$00,$00,$00,$04,$00,$06,$00,$04,$00 ; 112..127
+
+; SlotOf[palette*8 + color] = that color's slot/id (0..3) in the palette
+SlotOf::
+ db $00,$02,$01,$01,$01,$01,$03,$01 ; palette 0
+ db $00,$01,$01,$01,$01,$01,$01,$01 ; palette 1
+ db $00,$01,$02,$03,$01,$01,$01,$01 ; palette 2
+ db $00,$01,$01,$01,$02,$03,$01,$01 ; palette 3
+ db $00,$01,$01,$01,$02,$01,$03,$01 ; palette 4
+ db $00,$01,$01,$01,$01,$02,$01,$03 ; palette 5
+ db $00,$01,$01,$01,$02,$01,$01,$03 ; palette 6
+ db $00,$01,$01,$01,$01,$02,$03,$01 ; palette 7