From ca0d316948ef0cce3b03cc2230a118a4b21e07a4 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 5 Jan 2020 21:59:17 +0100 Subject: [PATCH] provided screen scroll up unofficial routine --- STATUS.md | 4 +- c64/kernal/,stubs/e8ea.scroll_line.s | 4 - c64/kernal/{,stubs => screen}/e8ea.interop | 0 ...en_scroll_up.s => e8ea.screen_scroll_up.s} | 78 ++----------------- c64/kernal/screen/screen_grow_logical_line.s | 51 ++++++------ c64/kernal/screen/screen_scroll_delay.s | 40 ++++++++++ 6 files changed, 76 insertions(+), 101 deletions(-) delete mode 100644 c64/kernal/,stubs/e8ea.scroll_line.s rename c64/kernal/{,stubs => screen}/e8ea.interop (100%) rename c64/kernal/screen/{screen_scroll_up.s => e8ea.screen_scroll_up.s} (53%) create mode 100644 c64/kernal/screen/screen_scroll_delay.s diff --git a/STATUS.md b/STATUS.md index 0768d8bb..f3574c3c 100644 --- a/STATUS.md +++ b/STATUS.md @@ -235,7 +235,7 @@ Not all of them - only these we want to have implemented. | `$E518` | legacy part of CINT | DONE | | | `$E51B` | init screen keyboard, no VIC | DONE | | | `$E544` | clear screen | DONE | | -| `$E50C` | set cursor position | PARTIAL | | +| `$E50C` | set cursor position | DONE | | | `$E566` | home cursor | DONE | | | `$E56C` | set PNT and USER values | DONE | | | `$E5A0` | setup VIC II & I/O | DONE | | @@ -243,7 +243,7 @@ Not all of them - only these we want to have implemented. | `$E701` | previous line | NOT DONE | | | `$E716` | screen CHROUT | NOT DONE | | | `$E8DA` | color code table | DONE | | -| `$E8EA` | scroll line | NOT DONE | | +| `$E8EA` | scroll logical line up | DONE | | | `$E96C` | insert line on top | NOT DONE | | | `$E9FF` | clear line | DONE | | | `$EA31` | default IRQ | PARTIAL | | diff --git a/c64/kernal/,stubs/e8ea.scroll_line.s b/c64/kernal/,stubs/e8ea.scroll_line.s deleted file mode 100644 index 4e5b7d5f..00000000 --- a/c64/kernal/,stubs/e8ea.scroll_line.s +++ /dev/null @@ -1,4 +0,0 @@ - -// XXX provide documentation and implementation - - STUB_IMPLEMENTATION() diff --git a/c64/kernal/,stubs/e8ea.interop b/c64/kernal/screen/e8ea.interop similarity index 100% rename from c64/kernal/,stubs/e8ea.interop rename to c64/kernal/screen/e8ea.interop diff --git a/c64/kernal/screen/screen_scroll_up.s b/c64/kernal/screen/e8ea.screen_scroll_up.s similarity index 53% rename from c64/kernal/screen/screen_scroll_up.s rename to c64/kernal/screen/e8ea.screen_scroll_up.s index 2314dd2a..eb9186fe 100644 --- a/c64/kernal/screen/screen_scroll_up.s +++ b/c64/kernal/screen/e8ea.screen_scroll_up.s @@ -1,43 +1,18 @@ // -// Scroll the whole screen up by 1 logical line +// Scroll the whole screen up by 1 logical line, described in: +// +// - [CM64] Computes Mapping the Commodore 64 - page 218 // screen_scroll_up: + // First handle CTRL and NO_SCRL keys -#if CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65 + jsr screen_scroll_delay - // 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 #$09 -!: - ldx #$FF - jsr wait_x_bars - dey - bne !- - -screen_scroll_up_delay_done: - - // First scroll the LDTBL (line link table) + // Scroll the LDTBL (line link table) ldy #$00 !: @@ -133,49 +108,8 @@ screen_scroll_up_loop_done: // If the first line is linked, scroll once more bit LDTBL+0 -#if CONFIG_KEYBOARD_C128 || CONFIG_KEYBOARD_C65 - bpl_far screen_scroll_up -#else bpl screen_scroll_up -#endif // Recalculate PNT and USER jmp screen_calculate_PNT_USER - - - - - - -/* YYY disabled for rework, add CTRL and NO_SCROLL support - -not_last_line: - rts - -screen_scroll_up_if_on_last_line: - - // Colour RAM is always in fixed place, so is easiest - // to use to check if we are on the last line. - // The last line is at $D800 + 24*40 = $DBC0 - lda USER+1 - cmp #>$DBC0 - bne not_last_line - - lda USER+0 - cmp #<$DBC0 - beq is_last_line - - jsr screen_get_current_line_logical_length - clc - adc USER+0 - cmp #<$DBE7-1 - bcc not_last_line - -is_last_line: - - dec TBLX - - // FALLTHROUGH to screen_scroll_up - -*/ \ No newline at end of file diff --git a/c64/kernal/screen/screen_grow_logical_line.s b/c64/kernal/screen/screen_grow_logical_line.s index 9a1caa8b..98f20304 100644 --- a/c64/kernal/screen/screen_grow_logical_line.s +++ b/c64/kernal/screen/screen_grow_logical_line.s @@ -7,33 +7,38 @@ screen_grow_logical_line_done: screen_grow_logical_line: - jmp screen_grow_logical_line // YYY + // Do not grow line if previus one is grown + + ldy TBLX + lda LDTBL,y + bpl screen_grow_logical_line_done + + // If last line, scroll the screen up + cpy #24 + bne !+ + jsr screen_scroll_up + ldy TBLX +!: + // Do not grow line if already grown + iny + lda LDTBL,y + bpl screen_grow_logical_line_done + + // Mark current line as grown + lda #$00 + sta LDTBL,y + + // Now we have to scroll lines downwards to make space + + + + .break + rts + /* YYY disabled for rework - // Do not grow line if it is already grown - ldy TBLX - lda LDTBL,y - bmi screen_grow_logical_line_done - - // Do not grow line if previous grown - dey - bmi !+ - lda LDTBL,y - bmi screen_grow_logical_line_done -!: - iny - - // Mark current line as grown - lda #$80 - sta LDTBL,y - - // Now make space for the extra line added. - // If we are on the last physical line of the screen, - // Then we need to scroll the screen up - jsr screen_scroll_up_if_on_last_line - // Count the number of physical lines to scroll down ldx #$01 ldy TBLX diff --git a/c64/kernal/screen/screen_scroll_delay.s b/c64/kernal/screen/screen_scroll_delay.s new file mode 100644 index 00000000..557b931e --- /dev/null +++ b/c64/kernal/screen/screen_scroll_delay.s @@ -0,0 +1,40 @@ + +// +// Handles CTRL and NO_SCRL during screen scroll +// + + +screen_scroll_delay: + +#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_delay_done + + ldy #$09 +!: + ldx #$FF + jsr wait_x_bars + dey + bne !- + +screen_scroll_delay_done: + + rts