From 9b813f2a0eb8626f84489de0f55dc6da2ed22420 Mon Sep 17 00:00:00 2001 From: user Date: Sat, 18 Jul 2026 21:50:22 +0200 Subject: term: SCY ring-scroll - scroll writes ONE map row; OSK toggle is 212 cycles The BG map's 32 rows become a ring: logical row L always lives at map row (wMapTop + L) & 31, and SCY = (wMapTop + wViewTop)*8 places the view. Scrolling bumps wMapTop, rebuilds the one new bottom line and writes its single map row (map_row_one); the other 17 rows move for free. The whole OSK view dance - shift the cursor above the keys, restore the backlog on hide - is now term_view_update: one SCY write, no map rewrite at all. OSK safety: the keyboard lives on the WINDOW layer, which SCY never moves. Stale ring rows can only appear under it: wViewTop = max(0, wCurRow-14) <= 3 is nonzero only while the OSK is visible, and the window covers exactly those bottom 3 rows (WX=7, WY=120). Verified: scroll + view shift + scroll-while-OSK-up + backlog restore all pixel-correct via VRAM screenshots; full README demo passes. term_scroll: 78.5k -> 35.6k T-cycles (857k pre-optimization: 24x). OSK toggle: 45k tilemap rewrite -> 212 cycles. Regenerated demo/gbos-demo.gif on the new renderer. --- src/osk.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/osk.asm') diff --git a/src/osk.asm b/src/osk.asm index d5edad7..0f188eb 100644 --- a/src/osk.asm +++ b/src/osk.asm @@ -247,12 +247,12 @@ osk_toggle:: ld a, [rLCDC] or %00100000 ld [rLCDC], a - jp term_write_tilemap + jp term_view_update ; SCY-only now: the map ring is untouched .hide ld a, [rLCDC] and %11011111 ld [rLCDC], a - jp term_write_tilemap ; offset recomputes to 0 -> full backlog + jp term_view_update ; offset recomputes to 0 -> full backlog ; movement with wrap-around; each moves the highlight osk_up: -- cgit v1.3.1-sl0p