From 2f43a8851a89661b304edd9396677080dcb3e003 Mon Sep 17 00:00:00 2001 From: user Date: Thu, 16 Jul 2026 16:40:45 +0200 Subject: term/osk: view-offset scroll region (lossless backlog on OSK toggle) Replace the shrink-and-scroll region with a view offset. The terminal is always 18 logical rows; term_write_tilemap maps screen row -> logical row + wViewTop (rows the OSK covers clamp to the cursor line). Showing the OSK sets the offset to OSK_ROWS so the cursor line lands at row 14 (above the keyboard) and hiding it sets the offset back to 0 - now purely a remap, so nothing is scrolled off or destroyed. term_set_view replaces term_set_rows; term_scroll/cursor_down are back to plain 18-row scrolling. Result: full 18-row backlog when the OSK is hidden, a shifted 15-row window when shown, and toggling is lossless (verified: OSK-shown view == baseline rows 3..17, and toggle on+off == baseline exactly). --- src/osk.asm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/osk.asm') diff --git a/src/osk.asm b/src/osk.asm index a34a863..5e316e3 100644 --- a/src/osk.asm +++ b/src/osk.asm @@ -236,9 +236,9 @@ osk_toggle:: ld [wOskVisible], a or a jr z, .hide - ; show: shrink the terminal to the rows above the keyboard, then enable window - ld a, 18 - OSK_ROWS - call term_set_rows + ; show: shift the view up so the cursor line clears the keyboard + ld a, OSK_ROWS + call term_set_view ld a, [rLCDC] or %00100000 ld [rLCDC], a @@ -247,8 +247,8 @@ osk_toggle:: ld a, [rLCDC] and %11011111 ld [rLCDC], a - ld a, 18 ; restore full-height terminal - call term_set_rows + xor a ; view unshifted -> full 18-row backlog + call term_set_view ret ; movement with wrap-around; each moves the highlight -- cgit v1.3.1-sl0p