From c5f195fcdc184b66dbb865d5cca00646537a5ecc Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 29 Aug 2020 21:40:53 +0200 Subject: [PATCH] work towards INS key support in MEGA65 mode --- .../screen_m65/mega65_chrout_screen_control.s | 2 - .../mega65_chrout_screen_control_2.s | 74 +++++++++++++++++++ 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/src/kernal/screen_m65/mega65_chrout_screen_control.s b/src/kernal/screen_m65/mega65_chrout_screen_control.s index 57719d76..7e2f0f0e 100644 --- a/src/kernal/screen_m65/mega65_chrout_screen_control.s +++ b/src/kernal/screen_m65/mega65_chrout_screen_control.s @@ -79,8 +79,6 @@ 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: 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 61f8e8c8..e674ee3c 100644 --- a/src/kernal/screen_m65/mega65_chrout_screen_control_2.s +++ b/src/kernal/screen_m65/mega65_chrout_screen_control_2.s @@ -49,3 +49,77 @@ m65_chrout_screen_STOP: sta QTSW sta INSRT jmp_8 m65_chrout_screen_ctrl2_end + + +// INS key + +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