From 44df124fc7b1d3186a1cef9a692400ca02b8c870 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 5 Jan 2020 17:27:37 +0100 Subject: [PATCH] started work on screen scroll --- c64/kernal/iec/iec_wait1ms.s | 6 +- .../screen/screen_advance_to_next_line.s | 3 +- ...p_if_on_last_line.s => screen_scroll_up.s} | 107 +++++++++++++++++- 3 files changed, 108 insertions(+), 8 deletions(-) rename c64/kernal/screen/{screen_scroll_up_if_on_last_line.s => screen_scroll_up.s} (59%) diff --git a/c64/kernal/iec/iec_wait1ms.s b/c64/kernal/iec/iec_wait1ms.s index 4e81fb14..4e05f18e 100644 --- a/c64/kernal/iec/iec_wait1ms.s +++ b/c64/kernal/iec/iec_wait1ms.s @@ -16,9 +16,8 @@ iec_wait1ms: ldx #18 // we probably won't start with the beginning of raster #endif // CONFIG_IEC -#if CONFIG_IEC || (!CONFIG_TAPE_NO_MOTOR_CONTROL && (CONFIG_TAPE_TURBO || CONFIG_TAPE_NORMAL)) -wait_x_bars: // additional entry point for tape support +wait_x_bars: // additional entry point for delayy in screen and tape support // has to preserve .Y and put .X to 0 lda VIC_RASTER @@ -32,6 +31,3 @@ wait_x_bars: // additional entry point for tape support iec_wait_rts: // dummy RTS, for very short waits rts - - -#endif diff --git a/c64/kernal/screen/screen_advance_to_next_line.s b/c64/kernal/screen/screen_advance_to_next_line.s index 0a8f2baa..15a56d60 100644 --- a/c64/kernal/screen/screen_advance_to_next_line.s +++ b/c64/kernal/screen/screen_advance_to_next_line.s @@ -4,12 +4,11 @@ screen_advance_to_next_line: // Check if we are at the bottom of the screen ldy TBLX - cpy #$24 + cpy #24 bne !+ // We need to scroll the screen up jsr screen_scroll_up - skip_2_bytes_trash_nvz !: inc TBLX diff --git a/c64/kernal/screen/screen_scroll_up_if_on_last_line.s b/c64/kernal/screen/screen_scroll_up.s similarity index 59% rename from c64/kernal/screen/screen_scroll_up_if_on_last_line.s rename to c64/kernal/screen/screen_scroll_up.s index 42888bca..d50f2304 100644 --- a/c64/kernal/screen/screen_scroll_up_if_on_last_line.s +++ b/c64/kernal/screen/screen_scroll_up.s @@ -1,7 +1,110 @@ +// +// Scroll the whole screen up by 1 logical line +// + + 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 + + // Do not scroll if NO_SCRL is pressed and interrupts are enabled +!: + php + pla + and #%00000010 + bne !+ // branch if IRQs disabled, we cannot detect NO_SCRL status + + lda SHFLAG + and #KEY_FLAG_NO_SCRL + bne !- +!: +#endif + + // Check if CTRL key pressed - if so, perform a delay + + lda SHFLAG + and #KEY_FLAG_CTRL + beq screen_scroll_up_delay_done + + ldy #$03 +!: + ldx #$FF + jsr wait_x_bars + dey + bne !- + +screen_scroll_up_delay_done: + + // First scroll the LDTBL (line link table) + + ldy #$00 +!: + lda LDTBL+1, y + sta LDTBL+0, y + iny + cpy #24 + bne !- + + lda #$80 + sta LDTBL+24 + + // Now, we need to scroll both screen memory and color memory + + + + // YYY implement + + + + + // Clear the newly introduced line + + ldx #24 + jsr screen_clear_line + + // Decrement the current physical line number + + dec TBLX + + // If the first line is linked, scroll once more + + bit LDTBL+0 + bpl screen_scroll_up_next + + // Restore SAL and EAL + + pla + sta EAL+1 + pla + sta EAL+0 + pla + sta SAL+1 + pla + sta SAL+0 + + // Return + rts + + + + + /* YYY disabled for rework, add CTRL and NO_SCROLL support not_last_line: @@ -30,7 +133,9 @@ is_last_line: dec TBLX - // FALLTHROUGH + // FALLTHROUGH to screen_scroll_up + + scroll_screen_up: