From b565577fd371ea0a8d6255e61017e0e4f8f5b9e1 Mon Sep 17 00:00:00 2001 From: user Date: Thu, 16 Jul 2026 16:11:06 +0200 Subject: osk: wrap the cursor around all four edges Left at column 0 wraps to the last column (and vice-versa); up at the top row wraps to the bottom (and vice-versa). Makes reaching far keys quicker - e.g. the Enter/space area is one UP away from the top row. --- src/osk.asm | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/osk.asm b/src/osk.asm index b8ee611..490a402 100644 --- a/src/osk.asm +++ b/src/osk.asm @@ -246,38 +246,46 @@ osk_toggle:: ld [rLCDC], a ret -; movement (with clamping); each moves the highlight +; movement with wrap-around; each moves the highlight osk_up: + call osk_unhighlight ld a, [wOskRow] or a - ret z - call osk_unhighlight - ld hl, wOskRow - dec [hl] + jr nz, .d + ld a, OSK_ROWS ; 0 -> ROWS, so dec wraps to ROWS-1 +.d + dec a + ld [wOskRow], a jr osk_highlight osk_down: - ld a, [wOskRow] - cp OSK_ROWS-1 - ret z call osk_unhighlight - ld hl, wOskRow - inc [hl] + ld a, [wOskRow] + inc a + cp OSK_ROWS + jr c, .s + xor a ; past bottom -> wrap to 0 +.s + ld [wOskRow], a jr osk_highlight osk_left: + call osk_unhighlight ld a, [wOskCol] or a - ret z - call osk_unhighlight - ld hl, wOskCol - dec [hl] + jr nz, .d + ld a, OSK_COLS +.d + dec a + ld [wOskCol], a jr osk_highlight osk_right: - ld a, [wOskCol] - cp OSK_COLS-1 - ret z call osk_unhighlight - ld hl, wOskCol - inc [hl] + ld a, [wOskCol] + inc a + cp OSK_COLS + jr c, .s + xor a +.s + ld [wOskCol], a jr osk_highlight ; -> A = type value of the selected key -- cgit v1.3.1-sl0p