From da2fa7ac906ff20cf94a4c7a63b8bfeb8468e449 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 3 Jan 2020 20:48:38 +0100 Subject: [PATCH] size-optimized screen clearing --- c64/kernal/screen/clear_screen_real.s | 58 +---------------------- c64/kernal/screen/e544.clear_screen.jmp.s | 11 ----- c64/kernal/screen/e544.clear_screen.s | 30 ++++++++++++ 3 files changed, 31 insertions(+), 68 deletions(-) delete mode 100644 c64/kernal/screen/e544.clear_screen.jmp.s create mode 100644 c64/kernal/screen/e544.clear_screen.s diff --git a/c64/kernal/screen/clear_screen_real.s b/c64/kernal/screen/clear_screen_real.s index 2094cb9a..eaad8592 100644 --- a/c64/kernal/screen/clear_screen_real.s +++ b/c64/kernal/screen/clear_screen_real.s @@ -7,60 +7,4 @@ clear_screen_real: - - // Clear the line link table - cheecked on original ROMs, - // the highest bit set means that the line is NOT a logical - // continuation of the previous one - - lda #$80 - ldy #24 -!: - sta LDTBL,y - dey - bpl !- - - // YYY flow can probably be size-optimized by calling screen_clear_line in a loop - - // Clear screen character RAM. Unfortunately, the HIBASE value is not on the zero page, - // we will reuse PNT (it will be overridden in a moment nevertheless) as the pointer - - iny // sets .Y to 0 - sty PNT+0 - lda HIBASE - sta PNT+1 - - ldx #$03 // countdown for pages to update - -clear_screen_loop: - - ldy #$00 - lda #$20 // space character screen code -!: - sta (PNT),y - iny - cpy #250 // clear 250 bytes only, do not cross 1000 bytes barrier - bne !- - - lda PNT+0 - clc - adc #250 - sta PNT+0 - bcc !+ - inc PNT+1 -!: - dex - bpl clear_screen_loop - - // Now clear the colour RAM - .Y is now 250, make use of this fact - - lda COLOR -!: - sta $D800 - 1 + 250 * 0, y - sta $D800 - 1 + 250 * 1, y - sta $D800 - 1 + 250 * 2, y - sta $D800 - 1 + 250 * 3, y - dey - bne !- - - // Fall to cursor home routine - jmp cursor_home + rts \ No newline at end of file diff --git a/c64/kernal/screen/e544.clear_screen.jmp.s b/c64/kernal/screen/e544.clear_screen.jmp.s deleted file mode 100644 index 1e9b4a2e..00000000 --- a/c64/kernal/screen/e544.clear_screen.jmp.s +++ /dev/null @@ -1,11 +0,0 @@ - -// -// Clear screen and initialise line link table, described in: -// -// - [CM64] Computes Mapping the Commodore 64 - pages 215-216 -// - - -clear_screen: - - jmp clear_screen_real diff --git a/c64/kernal/screen/e544.clear_screen.s b/c64/kernal/screen/e544.clear_screen.s new file mode 100644 index 00000000..1ee9bec9 --- /dev/null +++ b/c64/kernal/screen/e544.clear_screen.s @@ -0,0 +1,30 @@ + +// +// Clear screen and initialise line link table, described in: +// +// - [CM64] Computes Mapping the Commodore 64 - pages 215-216 +// + + +clear_screen: + + // Clear the line link table - cheecked on original ROMs, + // the highest bit set means that the line is NOT a logical + // continuation of the previous one + + lda #$80 + ldy #24 +!: + sta LDTBL,y + dey + bpl !- + + // Clear all the rows + ldx #24 +!: + jsr screen_clear_line + dex + bpl !- + + // Fall to cursor home routine + jmp cursor_home