From 554fd415d34235fda6c172fc09b19278764f00c3 Mon Sep 17 00:00:00 2001 From: user Date: Sat, 18 Jul 2026 21:42:27 +0200 Subject: term: 3 more renderer wins - 10.9x scroll, 2.7x putc vs pre-cache 1. color_setup memoization: a call with the same (colL,colR) pair as last time returns immediately (masks/attr still valid in WRAM). Runs of same-colored cells - i.e. almost all text - hit this. 2. build_tile blank fast path: two spaces = bg-only planes, 8 constant rows; term_scroll's cleared line and every blank region skip the glyph pipeline entirely. 3. build_tile two-phase rewrite: combine both glyphs into wRowBuf with pointers in registers (the old per-row 16-bit WRAM pointer walk was most of the blit), then compose planes unrolled with plane-0 masks in B/C. 4. term_write_tilemap attr pass: split each row at the pos-256 VRAM bank boundary into two tight cache->tilemap copy runs - no per-tile addressing or bank test. Measured (emulator cycle counter, ANSI test screen): term_scroll 857k -> 248k (attr cache) -> 78.5k T-cycles term_write_tilemap 723k -> 114k -> 45.4k term_putc 18.2k -> 6.7k A scroll is now ~1.1 frames of guest CPU (was 12); a full 40-char line prints in ~63ms of guest time (was ~173ms). --- include/gbos.inc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/gbos.inc b/include/gbos.inc index e63d53f..be6009f 100644 --- a/include/gbos.inc +++ b/include/gbos.inc @@ -39,6 +39,9 @@ DEF wCSset EQU $D5AD ; color_setup scratch: 7-bit set of colors present DEF wCSpb EQU $D5AE ; color_setup scratch: palette*8 (SlotOf base) DEF wCStmp0 EQU $D5AF ; color_setup scratch: assembled plane-0 mask DEF wCStmp1 EQU $D5B0 ; color_setup scratch: assembled plane-1 mask +DEF wCSPL EQU $D5B1 ; color_setup memo: last (colL,colR) pair - a call +DEF wCSPR EQU $D5B2 ; with the same pair returns early (masks valid) +DEF wRowBuf EQU $D5B3 ; build_tile: 8 combined glyph rows (L=hi/R=lo nibble) DEF OSK_DOCK EQU 3 ; on-screen keyboard height in rows (dock at the bottom) DEF rKEY1 EQU $FF4D ; CGB speed switch DEF rSB EQU $FF01 ; serial data -- cgit v1.3.1-sl0p