From 6bd5778db2380aabaea16e90c8faf08652e26b0d Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Fri, 19 Apr 2019 20:42:39 +0930 Subject: [PATCH] implement screen clear routines --- c64/kernal/,aliases.s | 4 +-- c64/kernal/clear_screen.s | 5 +-- c64/kernal/home_cursor.s | 10 ++++++ .../set_pointer_to_current_screen_line.s | 33 +++++++++++++++++++ 4 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 c64/kernal/home_cursor.s create mode 100644 c64/kernal/set_pointer_to_current_screen_line.s diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s index c0bd4ff0..091864e3 100644 --- a/c64/kernal/,aliases.s +++ b/c64/kernal/,aliases.s @@ -33,10 +33,10 @@ .alias cursor_is_visible $CF .alias input_source $D0 .alias current_screen_line_ptr $D1 - .alias current_screen_line_logical_column $D3 + .alias current_screen_x $D3 .alias quote_mode_flag $D4 .alias max_logical_line_length $D5 - .alias cursor_physical_screen_line $D6 + .alias current_screen_y $D6 .alias last_printed_character_ascii $D7 .alias insert_mode $D8 ; Bits 0 -3 = bits 8-11 of screen line address diff --git a/c64/kernal/clear_screen.s b/c64/kernal/clear_screen.s index 95991cc2..6b1d41fc 100644 --- a/c64/kernal/clear_screen.s +++ b/c64/kernal/clear_screen.s @@ -56,5 +56,6 @@ clearscreen_l3: sta $db00-24,y ; so we only erase 1000 bytes iny bne clearscreen_l3 - - rts + + ;; (Compute's Mapping the 64 p216) + jmp home_cursor diff --git a/c64/kernal/home_cursor.s b/c64/kernal/home_cursor.s new file mode 100644 index 00000000..eec755ee --- /dev/null +++ b/c64/kernal/home_cursor.s @@ -0,0 +1,10 @@ + ;; Home the cursor + ;; (Compute's Mapping the 64 p216) + +home_cursor: + + lda #$00 + sta current_screen_x + sta current_screen_y + + jmp set_pointer_to_current_screen_line diff --git a/c64/kernal/set_pointer_to_current_screen_line.s b/c64/kernal/set_pointer_to_current_screen_line.s new file mode 100644 index 00000000..37089d31 --- /dev/null +++ b/c64/kernal/set_pointer_to_current_screen_line.s @@ -0,0 +1,33 @@ + ;; Put the address of the screen current line + ;; into the pointer at $D1 (current_screen_line_ptr). + ;; It must take into account the screen line link table + ;; (Compute's Mapping the 64 p216) +set_pointer_to_current_screen_line: + ;; Get pointer to start of the screen + lda hibase + sta current_screen_line_ptr+1 + lda #$00 + sta current_screen_line_ptr+0 + + ;; Now advance for the number of lines + ldx current_screen_y + +sptcsl_l2: + ;; XXX - Should we read the columns per line from + ;; somewhere? + lda #<40 + ;; Double line length if line is linked + bit screen_line_link_table,x + bpl sptcsl_l1 + asl +sptcsl_l1: + clc + adc current_screen_line_ptr+0 + lda current_screen_line_ptr+1 + adc #>40 + sta current_screen_line_ptr+1 + + dex + bpl sptcsl_l2 + + rts