From 07f1a649c5419c35cc37ec1850306441af824455 Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Sun, 21 Apr 2019 21:49:43 +0930 Subject: [PATCH] implement colour codes and updating colour RAM --- c64/kernal/blink_cursor.s | 13 ++++++++++--- c64/kernal/chrout.s | 20 +++++++++++++++++++- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/c64/kernal/blink_cursor.s b/c64/kernal/blink_cursor.s index 4dd8e55c..fbb0e531 100644 --- a/c64/kernal/blink_cursor.s +++ b/c64/kernal/blink_cursor.s @@ -27,17 +27,21 @@ blink_cursor: 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 + sta cursor_saved_character eor #$80 sta (current_screen_line_ptr),y + ;; Also set cursor colour + lda (current_screen_line_colour_ptr),y + sta colour_under_cursor + lda text_colour + sta (current_screen_line_colour_ptr),y + lda #1 sta cursor_is_visible jmp reset_blink_timer @@ -46,6 +50,9 @@ undraw_cursor: lda cursor_saved_character ldy current_screen_x sta (current_screen_line_ptr),y + lda colour_under_cursor + sta (current_screen_line_colour_ptr),y + lda #0 sta cursor_is_visible ;; Fall through diff --git a/c64/kernal/chrout.s b/c64/kernal/chrout.s index c517cc7d..2e1855c8 100644 --- a/c64/kernal/chrout.s +++ b/c64/kernal/chrout.s @@ -37,6 +37,18 @@ not_0a: jmp screen_advance_to_next_line not_0d: + ;; Check for quote mode + + ;; Check for colours + ldx #$f +colour_check_loop: + cmp colour_codes,x + bne + + stx text_colour + jmp chrout_done + * dex + bpl colour_check_loop + ;; Check for cursor movement keys cmp #$11 bne not_11 @@ -121,7 +133,9 @@ chrout_l1: ldy current_screen_x sta (current_screen_line_ptr),y - ;; XXX - Update colour RAM also + ;; Set colour + lda text_colour + sta (current_screen_line_colour_ptr),y ;; Advance the column, and scroll screen down if we need ;; to insert a 2nd line in this logical line. @@ -333,3 +347,7 @@ advance_screen_pointer_40_bytes: jmp update_colour_line_pointer +colour_codes: + ;; CHR$ codes for the 16 colours + .byte 144,5,28,159,156,30,31,158 + .byte 129,149,150,151,152,153,154,155