From 3ff241918984e48f6bd11a4df9df5fc77df57ada Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Fri, 19 Apr 2019 20:30:41 +0930 Subject: [PATCH] implement main screen clear routine --- c64/kernal/cint.s | 3 +- c64/kernal/clear_screen.s | 60 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 c64/kernal/clear_screen.s diff --git a/c64/kernal/cint.s b/c64/kernal/cint.s index 2968abc1..54bedc38 100644 --- a/c64/kernal/cint.s +++ b/c64/kernal/cint.s @@ -35,8 +35,7 @@ cint: sta key_buffer_size ;; Fallthrough/jump to screen clear routine (Compute's Mapping the 64 p215) - ;; jmp clear_screen - + jmp clear_screen rts diff --git a/c64/kernal/clear_screen.s b/c64/kernal/clear_screen.s new file mode 100644 index 00000000..95991cc2 --- /dev/null +++ b/c64/kernal/clear_screen.s @@ -0,0 +1,60 @@ + ;; Clear screen and initialise line link table + ;; (Compute's Mapping the 64 p215-216) + +clear_screen: + + ;; Clear line link table + ;; (Compute's Mapping the 64 p215) + + lda #$00 + ldy #24 +clearscreen_l1: + sta screen_line_link_table,y + dey + bpl clearscreen_l1 + + ;; Y now = #$FF + + + ;; Clear screen RAM. + ;; We should do this at HIBASE, which annoyingly + ;; is no ZP, so we need to make a vector + ;; (Compute's Mapping the 64 p216) + ;; Get pointer to the screen into current_screen_line_ptr + ;; as it is the first appropriate place for it found when + ;; searching through the ZP allocations listed in + ;; Compute's Mapping the 64 + sta current_screen_line_ptr+0 + lda hibase + sta current_screen_line_ptr+1 + ldx #$03 ; countdown for pages to update + iny ; Y now = #$00 + lda #$20 ; space character +clearscreen_l2: + sta (current_screen_line_ptr),y + iny + bne clearscreen_l2 + ;; To draw only 1000 bytes, add 250 to address each time + lda current_screen_line_ptr + clc + adc #<250 + sta current_screen_line_ptr + lda current_screen_line_ptr+1 + adc #>250 + sta current_screen_line_ptr+1 + lda #$20 ; get space character again + dex + bpl clearscreen_l2 + + ;; Clear colour RAM + ;; (Compute's Mapping the 64 p216) + lda text_colour +clearscreen_l3: + sta $d800,y + sta $d900,y + sta $da00,y + sta $db00-24,y ; so we only erase 1000 bytes + iny + bne clearscreen_l3 + + rts