From c84091291ae1f9eabbe6c1887e0f5473ddc58dbb Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 5 Jan 2020 18:06:25 +0100 Subject: [PATCH] screen scroll rework finished --- c64/kernal/screen/screen_scroll_up.s | 200 ++++++++++----------------- 1 file changed, 71 insertions(+), 129 deletions(-) diff --git a/c64/kernal/screen/screen_scroll_up.s b/c64/kernal/screen/screen_scroll_up.s index d50f2304..74cfdf82 100644 --- a/c64/kernal/screen/screen_scroll_up.s +++ b/c64/kernal/screen/screen_scroll_up.s @@ -6,18 +6,6 @@ screen_scroll_up: - // Preserve SAL and EAL - - lda SAL+0 - pha - lda SAL+1 - pha - lda EAL+0 - pha - lda EAL+1 - pha - -screen_scroll_up_next: #if CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65 @@ -62,14 +50,76 @@ screen_scroll_up_delay_done: lda #$80 sta LDTBL+24 - // Now, we need to scroll both screen memory and color memory + // Preserve SAL and EAL + lda SAL+0 + pha + lda SAL+1 + pha + lda EAL+0 + pha + lda EAL+1 + pha + // Now, we need to scroll both screen memory and color memory; first create start/end pointers - // YYY implement + lda HIBASE + sta SAL+1 + sta EAL+1 + lda #>$D800 + sta PNT+1 + sta USER+1 + lda #$00 + sta EAL+0 + sta USER+0 + lda #40 + sta SAL+0 + sta PNT+0 + // Now copy, SAL->EAL, PNT->USER, in a loop + + ldy #$00 + +screen_scroll_up_loop: + + lda (SAL), y + sta (EAL), y + lda (PNT), y + sta (USER), y + + // Check if this was the last byte (last destination byte for color copy is #DBBF) + + cpy #$BF + bne !+ // definitely not the last byte + lda USER+1 + cmp #$DB + beq screen_scroll_up_loop_done +!: + // Increment .Y, possibly advance pointers + + iny + bne screen_scroll_up_loop + + inc SAL+1 + inc EAL+1 + inc USER+1 + inc PNT+1 + bne screen_scroll_up_loop // branch alwayys + +screen_scroll_up_loop_done: + + // Restore SAL and EAL + + pla + sta EAL+1 + pla + sta EAL+0 + pla + sta SAL+1 + pla + sta SAL+0 // Clear the newly introduced line @@ -83,22 +133,15 @@ screen_scroll_up_delay_done: // If the first line is linked, scroll once more bit LDTBL+0 - bpl screen_scroll_up_next +#if CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65 + bpl_far screen_scroll_up +#else + bpl screen_scroll_up +#endif - // Restore SAL and EAL - - pla - sta EAL+1 - pla - sta EAL+0 - pla - sta SAL+1 - pla - sta SAL+0 + // Recalculate PNT and USER - // Return - - rts + jmp screen_calculate_PNT_USER @@ -135,105 +178,4 @@ is_last_line: // FALLTHROUGH to screen_scroll_up - - -scroll_screen_up: - - // Preserve EAL - lda EAL+0 - pha - lda EAL+1 - pha - - // Now scroll the whole screen up either one or two lines - // based on whether the first screen line is linked or not. - - // Get pointers to start of screen + colour RAM - lda HIBASE - sta PNT+1 - sta SAL+1 - lda #>$D800 - sta USER+1 - sta EAL+1 - lda #$00 - sta PNT+0 - sta USER+0 - - // Get pointers to screen/colour RAM source - lda LDTBL+0 - bmi !+ - lda #40 - .byte $2C // BIT $nnnn to skip next instruction -!: - lda #80 - sta SAL+0 - sta EAL+0 - - // Copy first three pages - ldy #$00 - ldx #3 -scroll_copy_loop: - lda (EAL),y - sta (USER),y - lda (SAL),y - sta (PNT),y - - iny - bne scroll_copy_loop - - inc SAL+1 - inc PNT+1 - inc EAL+1 - inc USER+1 - dex - bne scroll_copy_loop - - // Copy last partial page - // We need to copy 1000-(3*256)-line length - // = 232 - line length - lda SAL+0 - lda #232 - sec - sbc SAL+0 - tax -scroll_copy_loop2: - lda (EAL),y - sta (USER),y - lda (SAL),y - sta (PNT),y - iny - dex - bne scroll_copy_loop2 - - // Restore EAL - pla - sta EAL+1 - pla - sta EAL+0 - - // Fill in scrolled up area - ldx SAL+0 -scroll_copy_loop3: - lda COLOR - sta (USER),y - lda #$20 - sta (PNT),y - iny - dex - bne scroll_copy_loop3 - - // Shift line linkage list - ldy #0 - ldx #24 -link_copy: - lda LDTBL+1,y - sta LDTBL+0,y - iny - dex - bne link_copy - // Clear line link flag of last line - stx LDTBL+24 - - // Restore correct line pointers - jmp screen_calculate_line_pointer */ \ No newline at end of file