From 61c9595901b86ca60eaeb9a65db6a7ddb1309976 Mon Sep 17 00:00:00 2001 From: user Date: Thu, 16 Jul 2026 15:35:07 +0200 Subject: term: cursor + O(1) line scrolling Rework the terminal from a static one-tile-per-screen-position model to LINE-BOUND tiles with an assign[] indirection, so scrolling is cheap: - Each line-slot L owns the 20 VRAM tiles at positions [L*20..L*20+19]. - assign[screen_row] -> line-slot; the tilemap points each screen row at its slot's tiles. - Scroll = rotate assign[], blank+rebuild only the new bottom line (20 tiles), and rewrite the tilemap. O(1 line) instead of rebuilding all 360 tiles. - term_putc: printable + \n \r \b, line wrap at col 40, cursor advance with scroll-on-overflow. - Cursor: an underline OR'd into the current cell's tile via wCurMask (no sprites/OAM); moving it just re-renders the old and new tiles. - term_demo drives 24 lines through term_putc to exercise scroll+cursor. Also fixes a vicious bug this shook out: build_tile advanced its 16-bit glyph pointers with `ld hl, wGlyphL+1 / inc [hl]`, which CLOBBERS HL -- and HL is the live VRAM destination pointer. Whenever a glyph's 8 bytes straddled a page boundary (common with long/varied lines) the next tile bytes were written into WRAM at $D580+, corrupting wGlyphL/wVram/wCurRow/ wCurCol and freezing the display. Now the pointers are bumped via A so HL is preserved. (Note: the emulator build had also been silently failing on an unrelated debug edit, masking this for a while.) Verified by screenshot: 24 lines scroll to show the last 18 + a visible cursor at the "ready$" prompt; serial shell and filesystem still work. --- src/boot.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/boot.asm') diff --git a/src/boot.asm b/src/boot.asm index 0a5f2e3..ea52858 100644 --- a/src/boot.asm +++ b/src/boot.asm @@ -57,7 +57,7 @@ KernelInit: ld [wCurProc+1], a call fs_init ; mount the disk (format on first boot; persists) call term_init ; set up the LCD text terminal - call term_test ; render a test pattern + call term_demo ; cursor + scroll demo ; --- spawn the init task (pid 1); it fork()s the rest --- ld hl, TaskInit -- cgit v1.3.1-sl0p