From 9a154b371014e56d0d3528223f47980aaccba965 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 23 Aug 2020 12:17:32 +0200 Subject: [PATCH] more control codes for MEGA65 screen editor --- src/aliases/,aliases_ram_lowmem_m65.s | 4 +- src/basic/basic_commands/cmd_go_goto_run.s | 14 +-- src/basic/board_m65/mega65_imports.s | 1 + src/basic/init/initmsg_real.s | 4 +- src/kernal/screen/chrout_screen_rvs.s | 6 +- src/kernal/screen_m65/mega65_chrout_screen.s | 13 +++ .../screen_m65/mega65_chrout_screen_control.s | 89 ++++++++++++++++--- 7 files changed, 108 insertions(+), 23 deletions(-) diff --git a/src/aliases/,aliases_ram_lowmem_m65.s b/src/aliases/,aliases_ram_lowmem_m65.s index 47e77a3a..1391e59d 100644 --- a/src/aliases/,aliases_ram_lowmem_m65.s +++ b/src/aliases/,aliases_ram_lowmem_m65.s @@ -24,8 +24,8 @@ // Page 0 - other reused values // - .label M65__TXTROW = PNTR // screen row - .label M65__TXTCOL = TBLX // screen column + .label M65__TXTROW = TBLX // screen row + .label M65__TXTCOL = PNTR // screen column // // Pages 4-7 - reused screen memory diff --git a/src/basic/basic_commands/cmd_go_goto_run.s b/src/basic/basic_commands/cmd_go_goto_run.s index 848a1c30..cb1395d4 100644 --- a/src/basic/basic_commands/cmd_go_goto_run.s +++ b/src/basic/basic_commands/cmd_go_goto_run.s @@ -37,10 +37,10 @@ cmd_go_syntax_error: jsr helper_ask_if_sure bcs cmd_go_rts jsr M65_MODE64 - jmp do_clr + jmp_8 cmd_go_switchmode_clr_banner !: cmp #65 - bne !+ + bne_16 do_ILLEGAL_QUANTITY_error // If in C64 compatibility mode - switch to native mode @@ -50,9 +50,13 @@ cmd_go_syntax_error: jsr helper_ask_if_sure bcs cmd_go_rts jsr M65_MODE65 - jmp do_clr -!: - jmp do_ILLEGAL_QUANTITY_error + + // FALLTROUGH + +cmd_go_switchmode_clr_banner: + + jsr do_clr + jmp INITMSG cmd_go_rts: diff --git a/src/basic/board_m65/mega65_imports.s b/src/basic/board_m65/mega65_imports.s index 9461ee1b..53209d8d 100644 --- a/src/basic/board_m65/mega65_imports.s +++ b/src/basic/board_m65/mega65_imports.s @@ -24,6 +24,7 @@ .label JCHRIN = KERNAL_0.JCHRIN .label JREADST = KERNAL_0.JREADST .label SELDEV = KERNAL_0.SELDEV +.label M65_ISMODE65 = KERNAL_0.M65_ISMODE65 .label plot_set = KERNAL_0.plot_set .label init_oldtxt = BASIC_0.init_oldtxt .label tmpstr_free_all_reset = BASIC_0.tmpstr_free_all_reset diff --git a/src/basic/init/initmsg_real.s b/src/basic/init/initmsg_real.s index 98df977a..c7779163 100644 --- a/src/basic/init/initmsg_real.s +++ b/src/basic/init/initmsg_real.s @@ -123,7 +123,8 @@ initmsg_real: #if ROM_LAYOUT_M65 - // XXX make it different for future Mega65 native mode + jsr M65_ISMODE65 + bcc !+ // XXX for MEGA65 native mode, display something else instead ldx #$02 ldy #$21 @@ -132,6 +133,7 @@ initmsg_real: lda #text_mode_64 jsr STROUT +!: #endif diff --git a/src/kernal/screen/chrout_screen_rvs.s b/src/kernal/screen/chrout_screen_rvs.s index 47dce95f..5703cacc 100644 --- a/src/kernal/screen/chrout_screen_rvs.s +++ b/src/kernal/screen/chrout_screen_rvs.s @@ -11,11 +11,13 @@ chrout_screen_RVS_ON: lda #$80 - bne !+ // branch always + skip_2_bytes_trash_nvz + + // FALLTROUGH chrout_screen_RVS_OFF: lda #$00 -!: + sta RVS jmp chrout_screen_done diff --git a/src/kernal/screen_m65/mega65_chrout_screen.s b/src/kernal/screen_m65/mega65_chrout_screen.s index 4e9abced..486661e2 100644 --- a/src/kernal/screen_m65/mega65_chrout_screen.s +++ b/src/kernal/screen_m65/mega65_chrout_screen.s @@ -84,6 +84,11 @@ m65_chrout_screen_literal: // entry point for m65_chrout_screen_quote // Store the new character in screen memory, restore .Z txa + + bit RVS + bpl !+ + ora #$80 // reverse the character XXX consider doing this within chrout_to_screen_code +!: sta_lp (M65_LPNT_SCR),z plz @@ -91,8 +96,16 @@ m65_chrout_screen_literal: // entry point for m65_chrout_screen_quote inc M65__TXTCOL + // FALLTROUGH + +m65_chrout_fix_column_row: + // XXX continue the implementation - fix the cursor position + nop + + // FALLTROUGH + m65_chrout_screen_done: // XXX reenable cursor diff --git a/src/kernal/screen_m65/mega65_chrout_screen_control.s b/src/kernal/screen_m65/mega65_chrout_screen_control.s index 76fb00c8..867fa58c 100644 --- a/src/kernal/screen_m65/mega65_chrout_screen_control.s +++ b/src/kernal/screen_m65/mega65_chrout_screen_control.s @@ -73,6 +73,81 @@ m65_chrout_try_color_loop: + +// XXX: consider moving to separate files + +m65_chrout_screen_RETURN: + + // RETURN clears quote and insert modes, it also clears reverse flag + + lda #$00 + sta QTSW + sta INSRT + sta RVS + + // XXX should we clear special colour attributes too? + + // Move cursor to the beginning of the next line + + sta M65__TXTCOL + inc M65__TXTROW + + // Correct the column/row values + + jmp m65_chrout_fix_column_row + + + + +m65_chrout_screen_RVS_ON: + + lda #$80 + skip_2_bytes_trash_nvz + + // FALLTROUGH + +m65_chrout_screen_RVS_OFF: + + lda #$00 + + sta RVS + jmp m65_chrout_screen_done + + + +m65_chrout_screen_CRSR_RIGHT: + + inc M65__TXTCOL + skip_2_bytes_trash_nvz + + // FALLTROUGH + +m65_chrout_screen_CRSR_LEFT: + + dec M65__TXTCOL + skip_2_bytes_trash_nvz + + // FALLTROUGH + +m65_chrout_screen_CRSR_DOWN: + + inc M65__TXTROW + skip_2_bytes_trash_nvz + + // FALLTROUGH + +m65_chrout_screen_CRSR_UP: + + dec M65__TXTROW + + // Correct the column/row values + + jmp m65_chrout_fix_column_row + + + + + // XXX: implement screen routines below: m65_chrout_screen_quote: @@ -89,18 +164,6 @@ m65_chrout_screen_TXT: nop m65_chrout_screen_GFX: nop -m65_chrout_screen_RVS_OFF: - nop -m65_chrout_screen_RVS_ON: - nop -m65_chrout_screen_CRSR_RIGHT: - nop -m65_chrout_screen_CRSR_LEFT: - nop -m65_chrout_screen_CRSR_DOWN: - nop -m65_chrout_screen_CRSR_UP: - nop m65_chrout_screen_INS: nop m65_chrout_screen_TAB: @@ -125,5 +188,5 @@ m65_chrout_screen_STOP: nop m65_chrout_screen_DEL: nop -m65_chrout_screen_RETURN: + jmp m65_chrout_screen_done