From 7527c7a2204857bbc7c57743930a484908bb630c Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 23 Aug 2020 22:44:22 +0200 Subject: [PATCH] fix for possible cursor-related scren corruption --- src/kernal/screen/cursor.s | 18 +++++++++---- src/kernal/screen/cursor_show.s | 2 ++ src/kernal/screen_m65/mega65_cursor.s | 38 +++++++++++++++++++++++---- 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/src/kernal/screen/cursor.s b/src/kernal/screen/cursor.s index 999c40d4..f01eccf6 100644 --- a/src/kernal/screen/cursor.s +++ b/src/kernal/screen/cursor.s @@ -50,6 +50,9 @@ cursor_draw: bne cursor_blink_timer_reset // branches always + +// XXX code below is probably not 100% safe + cursor_disable: lda #$80 @@ -59,23 +62,27 @@ cursor_disable: cursor_hide_if_visible: + // Set countdown to high value, to prevent IRQ interference + lda #$FF + sta BLNCT + + // If cursor is not visible, nothing to do lda BLNON - beq cursor_blink_end + beq cursor_blink_timer_reset // FALLTROUGH cursor_undraw: - // Prevent interrupts from updating cursor - lda #0 - sta BLNON - jsr screen_get_clipped_PNTR lda GDBLN sta (PNT),y lda GDCOL sta (USER),y + lda #0 + sta BLNON + // FALLTROUGH cursor_blink_timer_reset: @@ -87,4 +94,5 @@ cursor_blink_timer_reset: // FALLTROUGH cursor_blink_end: + rts diff --git a/src/kernal/screen/cursor_show.s b/src/kernal/screen/cursor_show.s index d700679f..5a9ad31e 100644 --- a/src/kernal/screen/cursor_show.s +++ b/src/kernal/screen/cursor_show.s @@ -12,6 +12,7 @@ cursor_show_if_enabled: + lda BLNSW bne cursor_show_end lda BLNON @@ -36,4 +37,5 @@ cursor_show: // FALLTROUGH cursor_show_end: + rts diff --git a/src/kernal/screen_m65/mega65_cursor.s b/src/kernal/screen_m65/mega65_cursor.s index 7c89e4ea..b30eae5c 100644 --- a/src/kernal/screen_m65/mega65_cursor.s +++ b/src/kernal/screen_m65/mega65_cursor.s @@ -10,10 +10,28 @@ // - GDCOL (colour under cursor) // + +m65_cursor_disable: // XXX utilize this! + + // Make sure IRQ won't interfere by increasing the counter XXX reuse in legacy mode + lda #$FF + sta BLNCT + + // Disable cursor blinking + lda #$80 + sta BLNSW + + // FALLTHROUGH + m65_cursor_hide_if_visible: + // Set countdown to high value, to prevent IRQ interference + lda #$FF + sta BLNCT + + // If cursor is not visible, nothing to do lda BLNON - beq m65_cursor_end + beq m65_cursor_blink_timer_reset // FALLTROUGH @@ -21,8 +39,10 @@ m65_cursor_undraw: // XXX provide implementation - lda #$80 - sta BLNSW + + // Mark cursor as not drawn + lda #0 + sta BLNON rts @@ -35,6 +55,14 @@ m65_cursor_show_if_enabled: // FALLTROUGH -m65_cursor_end: +m65_cursor_blink_timer_reset: // XXX reuse code from main KERNAL - rts + // Rest blink counter (Mapping the 64, p39-40) + lda #20 + sta BLNCT + + // FALLTROUGH + +m65_cursor_blink_end: + + rts \ No newline at end of file