From d3ef25c441c29353274cd66392052c39beb4c1d9 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 9 Oct 2019 22:10:13 +0200 Subject: [PATCH] further CHROUT fixes and optimizations --- c64/kernal/f1ca.chrout.s | 9 ++-- c64/kernal/screen/chrout_screen.s | 17 +++++-- ...s => chrout_screen_advance_to_next_line.s} | 7 ++- c64/kernal/screen/chrout_screen_control.s | 48 ++++++++----------- c64/kernal/screen/chrout_screen_del.s | 6 ++- c64/kernal/screen/chrout_screen_ins.s | 4 +- 6 files changed, 46 insertions(+), 45 deletions(-) rename c64/kernal/screen/{screen_advance_to_next_line.s => chrout_screen_advance_to_next_line.s} (89%) diff --git a/c64/kernal/f1ca.chrout.s b/c64/kernal/f1ca.chrout.s index 4e84808e..46e187b4 100644 --- a/c64/kernal/f1ca.chrout.s +++ b/c64/kernal/f1ca.chrout.s @@ -43,12 +43,11 @@ chrout_iec: lda SCHAR jsr JCIOUT - bcc chrout_done + bcc chrout_done_success // FALLTROUGH chrout_done_fail: - jsr cursor_show_if_enabled plp @@ -68,7 +67,6 @@ chrout_done_fail: rts chrout_done_unknown_device: - jsr cursor_show_if_enabled plp @@ -87,9 +85,8 @@ chrout_done_unknown_device: // End wioth error jmp lvs_device_not_found_error -chrout_done: - jsr cursor_show_if_enabled - +chrout_done_success: + plp // Restore X and Y diff --git a/c64/kernal/screen/chrout_screen.s b/c64/kernal/screen/chrout_screen.s index 9025040e..119c11d2 100644 --- a/c64/kernal/screen/chrout_screen.s +++ b/c64/kernal/screen/chrout_screen.s @@ -99,10 +99,19 @@ not_quote: ldy PNTR !: cpy #80 - bcc no_screen_advance_to_next_line + bcc chrout_screen_done lda #0 sta PNTR - jmp screen_advance_to_next_line + jmp chrout_screen_advance_to_next_line -no_screen_advance_to_next_line: - jmp chrout_done + +chrout_screen_calc_lptr_done: + + jsr screen_calculate_line_pointer + + // FALLTROUGH + +chrout_screen_done: + + jsr cursor_show_if_enabled + jmp chrout_done_success diff --git a/c64/kernal/screen/screen_advance_to_next_line.s b/c64/kernal/screen/chrout_screen_advance_to_next_line.s similarity index 89% rename from c64/kernal/screen/screen_advance_to_next_line.s rename to c64/kernal/screen/chrout_screen_advance_to_next_line.s index 7aff572d..e62f13e1 100644 --- a/c64/kernal/screen/screen_advance_to_next_line.s +++ b/c64/kernal/screen/chrout_screen_advance_to_next_line.s @@ -1,5 +1,5 @@ -screen_advance_to_next_line: +chrout_screen_advance_to_next_line: // jsr cursor_hide_if_visible @@ -42,6 +42,5 @@ screen_advance_to_next_line: // Off the bottom of the screen jsr scroll_screen_up !: - - jsr screen_calculate_line_pointer - jmp chrout_done + + jmp chrout_screen_calc_lptr_done diff --git a/c64/kernal/screen/chrout_screen_control.s b/c64/kernal/screen/chrout_screen_control.s index 6b300daa..d78829a2 100644 --- a/c64/kernal/screen/chrout_screen_control.s +++ b/c64/kernal/screen/chrout_screen_control.s @@ -23,7 +23,7 @@ chrout_try_RETURN: sta QTSW sta INSRT sta RVS - jmp screen_advance_to_next_line + jmp chrout_screen_advance_to_next_line !: chrout_try_DEL: @@ -49,8 +49,7 @@ chrout_try_CRSR_UP: sec sbc #40 sta PNTR - jsr screen_calculate_line_pointer - jmp chrout_done + jmp chrout_screen_calc_lptr_done !: chrout_try_CRSR_DOWN: @@ -66,8 +65,7 @@ chrout_try_CRSR_DOWN: // so that we can tell if we really are on the bottom phys // screen line or not jsr screen_scroll_up_if_on_last_line - jsr screen_calculate_line_pointer - jmp chrout_done + jmp chrout_screen_calc_lptr_done !: chrout_try_CRSR_LEFT: @@ -76,9 +74,11 @@ chrout_try_CRSR_LEFT: lda TBLX ora PNTR - beq chrout_screen_control_done // if top-left screen character + bne position_not_top_left + jmp chrout_screen_done +position_not_top_left: dec PNTR - jmp chrout_screen_control_calcptr_done + jmp chrout_screen_calc_lptr_done !: chrout_try_CRSR_RIGHT: @@ -86,17 +86,16 @@ chrout_try_CRSR_RIGHT: bne !+ inc PNTR - jsr screen_calculate_line_pointer - jmp chrout_done + jmp chrout_screen_calc_lptr_done !: -chrout_try_RVS_ON: +chrout_try_RVS_ON: // XXX deduplicate with RVS_OFF cmp #$12 bne !+ lda #$80 sta RVS - bne chrout_screen_control_done // branch always + jmp chrout_screen_done !: chrout_try_RVS_OFF: @@ -105,7 +104,7 @@ chrout_try_RVS_OFF: lda #$00 sta RVS - beq chrout_screen_control_done // branch always + jmp chrout_screen_done !: chrout_try_MODE_TXT: @@ -114,7 +113,7 @@ chrout_try_MODE_TXT: // XXX - jmp chrout_done + jmp chrout_screen_done !: chrout_try_MODE_GFX: @@ -123,7 +122,7 @@ chrout_try_MODE_GFX: // XXX - jmp chrout_done + jmp chrout_screen_done !: chrout_try_COLOR: @@ -132,7 +131,7 @@ colour_check_loop: cmp colour_codes,x bne !+ stx COLOR - jmp chrout_done + jmp chrout_screen_done !: dex bpl colour_check_loop @@ -144,7 +143,7 @@ chrout_try_SHIFT_ENABLE: // XXX - jmp chrout_done + jmp chrout_screen_done !: chrout_try_SHIFT_DISABLE: @@ -153,7 +152,7 @@ chrout_try_SHIFT_DISABLE: // XXX - jmp chrout_done + jmp chrout_screen_done !: chrout_try_HOME: @@ -164,7 +163,7 @@ chrout_try_HOME: lda #$00 sta PNTR sta TBLX - beq chrout_screen_control_calcptr_done // branch always + jmp chrout_screen_calc_lptr_done !: chrout_try_CLR: @@ -172,7 +171,7 @@ chrout_try_CLR: bne !+ jsr clear_screen - jmp chrout_done + jmp chrout_screen_done !: chrout_try_INS: @@ -188,7 +187,7 @@ chrout_try_RUN_STOP: // XXX - jmp chrout_done + jmp chrout_screen_done !: chrout_try_FKEY: @@ -196,11 +195,6 @@ chrout_try_FKEY: // FALLTROUGH -chrout_screen_control_done: // unknown, LF, or no more actions required // XXX to !csc_done +!: // unknown, LF, or no more actions required // XXX to !csc_done - jmp chrout_done - -chrout_screen_control_calcptr_done: // XXX to !csc_calcptr_done - - jsr screen_calculate_line_pointer - jmp chrout_done + jmp chrout_screen_done diff --git a/c64/kernal/screen/chrout_screen_del.s b/c64/kernal/screen/chrout_screen_del.s index e1362ea3..135f4777 100644 --- a/c64/kernal/screen/chrout_screen_del.s +++ b/c64/kernal/screen/chrout_screen_del.s @@ -28,7 +28,7 @@ chrout_screen_del_column_0: lda LNMX sta PNTR - jmp chrout_screen_control_calcptr_done + jmp chrout_screen_calc_lptr_done chrout_screen_del_column_non_0: @@ -59,5 +59,7 @@ chrout_screen_del_column_non_0: !: dec PNTR + // FALLTROUGH + chrout_screen_del_done: - jmp chrout_done + jmp chrout_screen_done diff --git a/c64/kernal/screen/chrout_screen_ins.s b/c64/kernal/screen/chrout_screen_ins.s index 04899d13..8e0e7f63 100644 --- a/c64/kernal/screen/chrout_screen_ins.s +++ b/c64/kernal/screen/chrout_screen_ins.s @@ -17,7 +17,7 @@ chrout_screen_ins: beq !+ // Line is too long to extend - jmp chrout_done + jmp chrout_screen_done !: // Work out if line needs to be expanded, and if so expand it @@ -61,4 +61,4 @@ chrout_screen_ins: lda #$20 sta (PNT),y - jmp chrout_done + jmp chrout_screen_done