From 2c5e181457d6baeaeadb206576df302543f3aa96 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 29 Aug 2020 21:08:34 +0200 Subject: [PATCH] work on INS support for MEGA65 mode --- src/kernal/screen/chrout_screen.s | 20 ++--- .../screen/chrout_screen_jumptable_codes.s | 2 +- src/kernal/screen_m65/mega65_chrout_screen.s | 13 ++- .../screen_m65/mega65_chrout_screen_control.s | 8 +- .../mega65_chrout_screen_control_2.s | 87 ++++++++++++++++--- .../screen_m65/mega65_chrout_screen_quote.s | 22 +++++ src/kernal/screen_m65/mega65_cursor.s | 1 + .../mega65_screen_helpers_scrlpnt.s | 4 - .../screen_m65/mega65_screen_tables_misc.s | 2 +- 9 files changed, 126 insertions(+), 33 deletions(-) create mode 100644 src/kernal/screen_m65/mega65_chrout_screen_quote.s diff --git a/src/kernal/screen/chrout_screen.s b/src/kernal/screen/chrout_screen.s index 596a3ce9..e306fdcb 100644 --- a/src/kernal/screen/chrout_screen.s +++ b/src/kernal/screen/chrout_screen.s @@ -41,16 +41,6 @@ chrout_screen_literal: // entry point for chrout_screen_quote tax // store screen code, we need .A for calculations - // First we need offset from PNT in .Y, we can take it from PNTR - - jsr screen_get_clipped_PNTR - - // Put the character on the screen - - txa - ora RVS // Computes Mapping the 64, page 38 - sta (PNT),y - // Decrement number of chars waiting to be inserted lda INSRT @@ -62,6 +52,16 @@ chrout_screen_literal: // entry point for chrout_screen_quote txa jsr screen_check_toggle_quote + // First we need offset from PNT in .Y, we can take it from PNTR + + jsr screen_get_clipped_PNTR + + // Put the character on the screen + + txa + ora RVS // Computes Mapping the 64, page 38 + sta (PNT),y + // Set colour of the newly printed character lda COLOR diff --git a/src/kernal/screen/chrout_screen_jumptable_codes.s b/src/kernal/screen/chrout_screen_jumptable_codes.s index 4299d42a..000284bd 100644 --- a/src/kernal/screen/chrout_screen_jumptable_codes.s +++ b/src/kernal/screen/chrout_screen_jumptable_codes.s @@ -23,10 +23,10 @@ chrout_screen_jumptable_codes: .byte KEY_CRSR_LEFT .byte KEY_CRSR_DOWN .byte KEY_CRSR_UP - .byte KEY_INS __chrout_screen_jumptable_quote_guard: + .byte KEY_INS #if CONFIG_EDIT_STOPQUOTE .byte KEY_STOP #endif diff --git a/src/kernal/screen_m65/mega65_chrout_screen.s b/src/kernal/screen_m65/mega65_chrout_screen.s index 9251532d..9f444318 100644 --- a/src/kernal/screen_m65/mega65_chrout_screen.s +++ b/src/kernal/screen_m65/mega65_chrout_screen.s @@ -38,12 +38,13 @@ m65_chrout_screen_literal: // entry point for m65_chrout_screen_quote phz - // Prepare .Z and M65_LPNT_SCR for colour memory manipulation + // Prepare M65_LPNT_SCR for colour memory manipulation jsr m65_helper_scrlpnt_color // Store the new color in screen memory + ldz M65__TXTCOL lda COLOR sta_lp (M65_LPNT_SCR),z @@ -51,6 +52,16 @@ m65_chrout_screen_literal: // entry point for m65_chrout_screen_quote jsr m65_helper_scrlpnt_to_screen + // Decrement number of chars waiting to be inserted + + lda INSRT + beq !+ + dec INSRT +!: + // Toggle quote flag if required + txa + jsr screen_check_toggle_quote + // Store the new character in screen memory, restore .Z txa diff --git a/src/kernal/screen_m65/mega65_chrout_screen_control.s b/src/kernal/screen_m65/mega65_chrout_screen_control.s index 55cf1b07..1fef3924 100644 --- a/src/kernal/screen_m65/mega65_chrout_screen_control.s +++ b/src/kernal/screen_m65/mega65_chrout_screen_control.s @@ -75,14 +75,10 @@ m65_chrout_try_color_loop: // XXX: implement screen routines below: -m65_chrout_screen_quote: - nop m65_chrout_screen_CLR: nop m65_chrout_screen_HOME: nop -m65_chrout_screen_INS: - nop m65_chrout_screen_TAB: nop m65_chrout_screen_LINE_FEED: @@ -101,7 +97,9 @@ m65_chrout_screen_ESC: nop m65_chrout_screen_BELL: nop -m65_chrout_screen_STOP: +m65_chrout_screen_GFX: + nop +m65_chrout_screen_TXT: nop m65_chrout_screen_DEL: nop diff --git a/src/kernal/screen_m65/mega65_chrout_screen_control_2.s b/src/kernal/screen_m65/mega65_chrout_screen_control_2.s index 8ebfcfa2..d6bca52c 100644 --- a/src/kernal/screen_m65/mega65_chrout_screen_control_2.s +++ b/src/kernal/screen_m65/mega65_chrout_screen_control_2.s @@ -40,19 +40,84 @@ m65_chrout_screen_SHIFT_OFF: sta MODE jmp_8 m65_chrout_screen_ctrl2_end +// STOP key -// GFX/TXT switching support +m65_chrout_screen_STOP: -m65_chrout_screen_GFX: - - lda VIC_YMCSB - and #$02 // to upper case -!: - sta VIC_YMCSB + lda #$00 + sta QTSW + sta INSRT jmp_8 m65_chrout_screen_ctrl2_end -m65_chrout_screen_TXT: +// INS key - lda VIC_YMCSB - ora #$02 // to lower case - bne !- // branch always +m65_chrout_screen_INS: + + // First prepare the pointer to the current row + + jsr m65_helper_scrlpnt_color + jsr m65_helper_scrlpnt_to_screen + + // Check for windowed mode + + lda M65_SCRWINMODE + bmi_16 m65_chrout_screen_INS_winmode + + // Check if last character of the line is space + + ldy M65_SCRMODE + lda m65_scrtab_txtwidth,y + dec_a + taz + lda_lp (M65_LPNT_SCR), z + cmp #$20 + bne_16 m65_chrout_screen_ctrl2_end + phz + + // Last character is space - move the characters + + jsr m65_chrout_screen_INS_copy + + // Store space in the current character cell + + lda #$20 + sta_lp (M65_LPNT_SCR), z + + // Move the color memory + + jsr m65_helper_scrlpnt_color + plz + jsr m65_chrout_screen_INS_copy + + // Store current colour in the current character cell + + lda COLOR + and #$0F + sta_lp (M65_LPNT_SCR), z + + // Increase insert mode count (which causes quote-mode like behaviour) and quit + + inc INSRT + jmp_8 m65_chrout_screen_ctrl2_end + +m65_chrout_screen_INS_winmode: + + // Check if last character of the line within window is space + + // XXX provide implementation + + jmp_8 m65_chrout_screen_ctrl2_end + + + +m65_chrout_screen_INS_copy: + + dez + lda_lp (M65_LPNT_SCR), z + inz + sta_lp (M65_LPNT_SCR), z + dez + cpz M65__TXTCOL + bne m65_chrout_screen_INS_copy + + rts diff --git a/src/kernal/screen_m65/mega65_chrout_screen_quote.s b/src/kernal/screen_m65/mega65_chrout_screen_quote.s new file mode 100644 index 00000000..16f0668a --- /dev/null +++ b/src/kernal/screen_m65/mega65_chrout_screen_quote.s @@ -0,0 +1,22 @@ +// #LAYOUT# M65 KERNAL_1 #TAKE +// #LAYOUT# * * #IGNORE + +// +// CHROUT routine - screen support, control codes in quote mode, MEGA65 native mode version +// + + +m65_chrout_screen_quote: + + // Low control codes are just +$80 + clc + adc #$80 + + // If it overflowed, then it is a high control code, + // so we need to make it be $80 + $40 + char + // as we will have flipped back to just $00 + char, we should + // now add $c0 if C is set from overflow + bcc !+ + adc #$BF // C=1, so adding $BF + C = add $C0 +!: + jmp m65_chrout_screen_literal diff --git a/src/kernal/screen_m65/mega65_cursor.s b/src/kernal/screen_m65/mega65_cursor.s index 54d0ec36..3df29bf2 100644 --- a/src/kernal/screen_m65/mega65_cursor.s +++ b/src/kernal/screen_m65/mega65_cursor.s @@ -39,6 +39,7 @@ m65_cursor_undraw: // Cursor undraw - color jsr m65_helper_scrlpnt_color + ldz M65__TXTCOL lda GDCOL sta_lp (M65_LPNT_SCR),z diff --git a/src/kernal/screen_m65/mega65_screen_helpers_scrlpnt.s b/src/kernal/screen_m65/mega65_screen_helpers_scrlpnt.s index f9b91ccf..31630d11 100644 --- a/src/kernal/screen_m65/mega65_screen_helpers_scrlpnt.s +++ b/src/kernal/screen_m65/mega65_screen_helpers_scrlpnt.s @@ -4,10 +4,6 @@ m65_helper_scrlpnt_color: - // Set .Z to the current column - - ldz M65__TXTCOL // XXX probably not the best place for this - // Setting M65_LPNT_SCR to point to colour memory (starts from $FF80000) lda #$0F diff --git a/src/kernal/screen_m65/mega65_screen_tables_misc.s b/src/kernal/screen_m65/mega65_screen_tables_misc.s index 579d8b64..578f19c5 100644 --- a/src/kernal/screen_m65/mega65_screen_tables_misc.s +++ b/src/kernal/screen_m65/mega65_screen_tables_misc.s @@ -59,7 +59,6 @@ m65_chrout_screen_jumptable_codes: .byte KEY_CRSR_LEFT .byte KEY_CRSR_DOWN .byte KEY_CRSR_UP - .byte KEY_INS .byte KEY_TAB .byte KEY_LINE_FEED .byte KEY_UNDERLINE_ON @@ -72,6 +71,7 @@ m65_chrout_screen_jumptable_codes: __m65_chrout_screen_jumptable_quote_guard: + .byte KEY_INS .byte KEY_STOP .byte KEY_DEL .byte KEY_RETURN