From 415d5a94bb2018d251226a43f11d471a0eceb11b Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Fri, 19 Apr 2019 23:40:51 +0930 Subject: [PATCH] hide cursor when drawing, minor other fixes --- c64/kernal/blink_cursor.s | 51 +++++++++++++++++++++++++++++++++++++++ c64/kernal/chrout.s | 4 ++- c64/kernal/irq_handler.s | 6 +++-- 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 c64/kernal/blink_cursor.s diff --git a/c64/kernal/blink_cursor.s b/c64/kernal/blink_cursor.s new file mode 100644 index 00000000..c4d38752 --- /dev/null +++ b/c64/kernal/blink_cursor.s @@ -0,0 +1,51 @@ + ;; We have the following variables: + ;; cursor_blink_disable + ;; cursor_blink_countdown + ;; cursor_saved_character + ;; cursor_is_visible + ;; colour_under_cursor + +blink_cursor: + ;; Is the cursor enabled? + bit cursor_blink_disable + bne no_blink_cursor + + ;; Do we need to redraw things? + dec cursor_blink_countdown + bpl no_blink_cursor + + ;; XXX - Save character colour also! + + ;; Check if cursor was visible or not, and toggle + lda cursor_is_visible + bne undraw_cursor +draw_cursor: + ldy current_screen_x + lda (current_screen_line_ptr),y + sta cursor_saved_character + eor #$80 + sta (current_screen_line_ptr),y + lda #1 + sta cursor_is_visible + jmp reset_blink_timer + +undraw_cursor: + lda cursor_saved_character + ldy current_screen_x + sta (current_screen_line_ptr),y + lda #0 + sta cursor_is_visible + ;; Fall through +reset_blink_timer: + ;; Rest blink counter + ;; (Compute's Mapping the 64, p39-40) + lda #20 + sta cursor_blink_countdown +no_blink_cursor: + + rts + +hide_cursor_if_visible: + bit cursor_is_visible + bne undraw_cursor + rts diff --git a/c64/kernal/chrout.s b/c64/kernal/chrout.s index 06f75da6..ab3588b7 100644 --- a/c64/kernal/chrout.s +++ b/c64/kernal/chrout.s @@ -11,10 +11,12 @@ chrout: pha tya pha + + jsr hide_cursor_if_visible + lda last_printed_character_ascii tax - ;; Check for special characters ;; Linefeed (simply ignored) diff --git a/c64/kernal/irq_handler.s b/c64/kernal/irq_handler.s index 0a1349f1..dae57eb5 100644 --- a/c64/kernal/irq_handler.s +++ b/c64/kernal/irq_handler.s @@ -21,8 +21,10 @@ irq_handler: ;; (but only if initialised) lda $0314 ora $0315 - beq no_handler_installed + beq default_irq_handler jmp ($0314) -no_handler_installed: +default_irq_handler: + + jsr blink_cursor jmp return_from_interrupt