From 9ef81db3d4e99ebf08d0b6bc07b00c9693b64024 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 1 Jan 2020 20:20:49 +0100 Subject: [PATCH] screen clearing fixes --- c64/kernal/screen/clear_screen_real.s | 101 +++++++++++++------------- c64/kernal/screen/cursor_home.s | 26 +++++++ 2 files changed, 76 insertions(+), 51 deletions(-) diff --git a/c64/kernal/screen/clear_screen_real.s b/c64/kernal/screen/clear_screen_real.s index 83126486..6654f922 100644 --- a/c64/kernal/screen/clear_screen_real.s +++ b/c64/kernal/screen/clear_screen_real.s @@ -1,70 +1,69 @@ -// Clear screen and initialise line link table -// (Compute's Mapping the 64 p215-216) + +// +// Clear screen and initialise line link table, described in: +// +// - [CM64] Computes Mapping the Commodore 64 - pages 215-216 +// clear_screen_real: - rts -/* YYY disabled for rework + // First disable the cursor + jsr cursor_disable -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 - // XXX it is probably a good idea to hide cursor first - - // Clear line link table - // (Compute's Mapping the 64 p215) - - lda #$00 - ldy #24 -clearscreen_l1: + lda #$80 + ldy #24 +!: sta LDTBL,y dey - bpl clearscreen_l1 + bpl !- - // Y now = #$FF + // YYY flow can probably be size-optimized, by clearing a single row each time (we will need such a subroutine) - // 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 PNT - // as it is the first appropriate place for it found when - // searching through the ZP allocations listed in - // Compute's Mapping the 64 - sta PNT+0 + // 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 - iny // Y now = #$00 - lda #$20 // space character -clearscreen_l2: + sta PNT+1 + + ldx #$03 // countdown for pages to update + +clear_screen_loop: + + ldy #$00 + lda #$01 // space character screen code +!: sta (PNT),y iny - bne clearscreen_l2 - // To draw only 1000 bytes, add 250 to address each time - lda PNT + cpy #250 // clear 250 bytes only, do not cross 1000 bytes barrier + bne !- + + lda PNT+0 clc - adc #<250 - sta PNT - lda PNT+1 - adc #>250 - sta PNT+1 - lda #$20 // get space character again + adc #250 + sta PNT+0 + bcc !+ + inc PNT+1 +!: dex - bpl clearscreen_l2 + bpl clear_screen_loop + + // Now clear the colour RAM - .Y is now 250, make use of this fact - // Clear colour RAM - // (Compute's Mapping the 64 p216) lda COLOR -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 +!: + 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 !- - // (Compute's Mapping the 64 p216) + // Fall to cursor home routine jmp cursor_home - -*/ diff --git a/c64/kernal/screen/cursor_home.s b/c64/kernal/screen/cursor_home.s index bd9461e4..c73d1237 100644 --- a/c64/kernal/screen/cursor_home.s +++ b/c64/kernal/screen/cursor_home.s @@ -3,6 +3,32 @@ // Home the cursor (Compute's Mapping the 64 p216) // +// Variables: (http://sta.c64.org/cbm64mem.html) +// - $C7 - RVS - reverse mode switch +// - $C8 - INDX - length of line minus 1 during screen input. Values: $27, 39; $4F, 79. +// - $C9 - LXSP+0 - cursor row during screen input. Values: $00-$18, 0-24. +// - $CA - LXSP+1 - cursor column during screen input. Values: $00-$27, 0-39. +// - $CC - BLNSW - cursor visibility switch. Values: $01-$FF: Cursor is off. +// - $CD - BLNCT - delay counter for changing cursor phase. Values: +// - $CE - GDBLN - screen code of character under cursor +// - $CF - BLNON - cursor phase switch +// - $D0 - CRSW - end of line switch during screen input +// - $D1-$D2 - PNT - pointer to current line in screen memory. +// - $D3 - PNTR - current cursor column. Values: $00-$27, 0-39. +// - $D4 - QTSW - quotation mode switch +// - $D5 - LNMX - length of current screen line minus 1. Values: $27, 39; $4F, 79. +// - $D6 - TBLX - current cursor row. Values: $00-$18, 0-24. +// - $D8 - INSRT - number of insertions +// - $D9-$F1 - LDTBL - link table +// - $F2 - temporary value for screen scroll +// - $F3-$F4 - USER - pointer to current line in Color RAM. +// - $02A5 - TLNIDX - number of line currently being scrolled during scrolling the screen + + +cursor_home: + jmp cursor_home + + /* YYY disabled for rework cursor_home: