From b5452c5df57d8187e26f74b340ae1d630e37167a Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 16 Dec 2020 20:08:37 +0100 Subject: [PATCH] started work on escape sequences, some cleanup --- src/aliases/,aliases_ram_lowmem_m65.s | 15 +-- src/kernal/screen_m65/mega65_chrout_screen.s | 5 + .../screen_m65/mega65_chrout_screen_control.s | 6 -- .../mega65_chrout_screen_control_2.s | 10 +- .../screen_m65/mega65_chrout_screen_escmode.s | 100 ++++++++++++++++++ .../screen_m65/mega65_screen_tables_misc.s | 49 +++++++++ src/mon_m65/bsmon.s | 12 +-- src/zvm_m65/,aliases_zvm.s | 22 ++-- 8 files changed, 193 insertions(+), 26 deletions(-) create mode 100644 src/kernal/screen_m65/mega65_chrout_screen_escmode.s diff --git a/src/aliases/,aliases_ram_lowmem_m65.s b/src/aliases/,aliases_ram_lowmem_m65.s index b4b050ee..9ddab1e5 100644 --- a/src/aliases/,aliases_ram_lowmem_m65.s +++ b/src/aliases/,aliases_ram_lowmem_m65.s @@ -64,13 +64,14 @@ !addr M65_TXTWIN_Y1 = $591 ; text window - bottom-right Y coordinate + 1 !addr M65_TXTROW_OFF = $592 ; $592-$593 offset to the current text row from the viewport start !addr M65_SCRCOLMAX = $594 ; maximum allowed column - !addr M65_KB_BUCKY = $595 ; result of bucky keys scan - !addr M65_KB_COLSCAN = $596 ; $596-$59E results of keyboard scan, columns 0-8 - !addr M65_JOYCRSR = $59F ; joystick to be used for cursor movement - !addr M65_KB_PRESSED = $560 ; $560-$562 keys pressed, used during scanning keyboard - !addr M65_KB_PRESSED_OLD = $563 ; $563-$565 keys pressed during previous scan - !addr M65_KB_PRESSED_NEW = $566 ; $566-$568 set of M65_KB_PRESSED minus M65_KB_PRESSED_OLD - ; $569-$5EB -- UNUSED -- + !addr M65_ESCMODE = $595 ; flag - if set, escape mode is in effect + !addr M65_KB_BUCKY = $596 ; result of bucky keys scan + !addr M65_KB_COLSCAN = $597 ; $597-$59F results of keyboard scan, columns 0-8 + !addr M65_KB_PRESSED = $5A0 ; $5A0-$5A2 keys pressed, used during scanning keyboard + !addr M65_KB_PRESSED_OLD = $5A3 ; $5A3-$5A5 keys pressed during previous scan + !addr M65_KB_PRESSED_NEW = $5A6 ; $5A6-$5A8 set of M65_KB_PRESSED minus M65_KB_PRESSED_OLD + !addr M65_JOYCRSR = $5A9 ; joystick to be used for cursor movement + ; $5AA-$5EB -- UNUSED -- !addr M65_DMAGIC_LIST = $5F1 ; $5EF-$5FF reserved for DMAgic list, 15 bytes (modulo bytes are not needed) !addr M65_RS232_INBUF = $600 ; $600-$6FF -- reserved for RS-232 input buffer -- !addr M65_RS232_OUTBUF = $700 ; $700-$7FF -- reserved for RS-232 output buffer -- diff --git a/src/kernal/screen_m65/mega65_chrout_screen.s b/src/kernal/screen_m65/mega65_chrout_screen.s index 933062f8..805aeb92 100644 --- a/src/kernal/screen_m65/mega65_chrout_screen.s +++ b/src/kernal/screen_m65/mega65_chrout_screen.s @@ -15,6 +15,11 @@ m65_chrout_screen: lda SCHAR tax + ; Check for escape mode + + bit M65_ESCMODE + +bmi m65_chrout_screen_escmode + ; All the PETSCII control codes are within $0x, $1x, $8x, $9x, remaining ; ones are always printable characters; separate away control codes diff --git a/src/kernal/screen_m65/mega65_chrout_screen_control.s b/src/kernal/screen_m65/mega65_chrout_screen_control.s index 6d7d844c..07b9d196 100644 --- a/src/kernal/screen_m65/mega65_chrout_screen_control.s +++ b/src/kernal/screen_m65/mega65_chrout_screen_control.s @@ -89,12 +89,6 @@ m65_chrout_screen_FLASHING_OFF: +nop m65_chrout_screen_TAB_SET_CLR: +nop -m65_chrout_screen_ESC: - +nop m65_chrout_screen_BELL: jmp m65_chrout_screen_done - -; XXX: implement the following functionalities according to MEGA65 book: -; CTRL +T +Z +E +Q +G +J +U +W +B +N +M +] +I +X +K +L +[ -; ESC +@ +A +B +C +D +E +F +G +H +I +J +K +L +M +N +O +P +Q +S +T +U +V +W +X +Y +Z +1..8 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 d935efab..b3895d31 100644 --- a/src/kernal/screen_m65/mega65_chrout_screen_control_2.s +++ b/src/kernal/screen_m65/mega65_chrout_screen_control_2.s @@ -2,6 +2,15 @@ ;; #LAYOUT# * * #IGNORE +; Escape mode support + +m65_chrout_screen_ESC: + + lda #$FF + sta M65_ESCMODE + bra m65_chrout_screen_ctrl2_end + + ; 'REVERSE' mode support m65_chrout_screen_RVS_ON: @@ -14,7 +23,6 @@ m65_chrout_screen_RVS_ON: m65_chrout_screen_RVS_OFF: lda #$00 - sta RVS ; FALLTROUGH diff --git a/src/kernal/screen_m65/mega65_chrout_screen_escmode.s b/src/kernal/screen_m65/mega65_chrout_screen_escmode.s new file mode 100644 index 00000000..bedbcc91 --- /dev/null +++ b/src/kernal/screen_m65/mega65_chrout_screen_escmode.s @@ -0,0 +1,100 @@ +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE + + +m65_chrout_screen_escmode: + + ; Regardless if the escape sequence is supported, or not - cancel escape mode + + lda #$00 + sta M65_ESCMODE + + ; XXX + +m65_chrout_screen_escmode_end: + + jmp m65_chrout_screen_done + + +; XXX: implement screen routines below: + +m65_chrout_esc_0: + +nop +m65_chrout_esc_1: + +nop +m65_chrout_esc_2: + +nop +m65_chrout_esc_3: + +nop +m65_chrout_esc_4: + +nop +m65_chrout_esc_5: + +nop +m65_chrout_esc_6: + +nop +m65_chrout_esc_7: + +nop +m65_chrout_esc_8: + +nop +m65_chrout_esc_9: + +nop +m65_chrout_esc_AT: + +nop +m65_chrout_esc_A: + +nop +m65_chrout_esc_B: + +nop +m65_chrout_esc_C: + +nop +m65_chrout_esc_D: + +nop +m65_chrout_esc_E: + +nop +m65_chrout_esc_F: + +nop +m65_chrout_esc_G: + +nop +m65_chrout_esc_H: + +nop +m65_chrout_esc_I: + +nop +m65_chrout_esc_J: + +nop +m65_chrout_esc_K: + +nop +m65_chrout_esc_L: + +nop +m65_chrout_esc_M: + +nop +m65_chrout_esc_N: + +nop +m65_chrout_esc_O: + +nop +m65_chrout_esc_P: + +nop +m65_chrout_esc_Q: + +nop +m65_chrout_esc_R: + +nop +m65_chrout_esc_S: + +nop +m65_chrout_esc_T: + +nop +m65_chrout_esc_U: + +nop +m65_chrout_esc_V: + +nop +m65_chrout_esc_W: + +nop +m65_chrout_esc_X: + +nop +m65_chrout_esc_Y: + +nop +m65_chrout_esc_Z: + +nop +m65_chrout_esc_LBR: + +nop +m65_chrout_esc_RBR: + +nop + + jmp m65_chrout_screen_done diff --git a/src/kernal/screen_m65/mega65_screen_tables_misc.s b/src/kernal/screen_m65/mega65_screen_tables_misc.s index 7982c519..98f7de36 100644 --- a/src/kernal/screen_m65/mega65_screen_tables_misc.s +++ b/src/kernal/screen_m65/mega65_screen_tables_misc.s @@ -110,3 +110,52 @@ m65_chrout_screen_jumptable: !word m65_chrout_screen_DEL !word m65_chrout_screen_RETURN !word m65_chrout_screen_RETURN + +m65_chrout_screen_jumptable_escape: + + !word m65_chrout_esc_0 + !word m65_chrout_esc_1 + !word m65_chrout_esc_2 + !word m65_chrout_esc_3 + !word m65_chrout_esc_4 + !word m65_chrout_esc_5 + !word m65_chrout_esc_6 + !word m65_chrout_esc_7 + !word m65_chrout_esc_8 + !word m65_chrout_esc_9 + !word m65_chrout_screen_done ; ':' + !word m65_chrout_screen_done ; ';' + !word m65_chrout_screen_done ; '<' + !word m65_chrout_screen_done ; '=' + !word m65_chrout_screen_done ; '>' + !word m65_chrout_screen_done ; '?' + !word m65_chrout_esc_AT + !word m65_chrout_esc_A + !word m65_chrout_esc_B + !word m65_chrout_esc_C + !word m65_chrout_esc_D + !word m65_chrout_esc_E + !word m65_chrout_esc_F + !word m65_chrout_esc_G + !word m65_chrout_esc_H + !word m65_chrout_esc_I + !word m65_chrout_esc_J + !word m65_chrout_esc_K + !word m65_chrout_esc_L + !word m65_chrout_esc_M + !word m65_chrout_esc_N + !word m65_chrout_esc_O + !word m65_chrout_esc_P + !word m65_chrout_esc_Q + !word m65_chrout_esc_R + !word m65_chrout_esc_S + !word m65_chrout_esc_T + !word m65_chrout_esc_U + !word m65_chrout_esc_V + !word m65_chrout_esc_W + !word m65_chrout_esc_X + !word m65_chrout_esc_Y + !word m65_chrout_esc_Z + !word m65_chrout_esc_LBR + !word m65_chrout_screen_done ; pound symbol + !word m65_chrout_esc_RBR diff --git a/src/mon_m65/bsmon.s b/src/mon_m65/bsmon.s index 755c3ada..3f4d3e9c 100644 --- a/src/mon_m65/bsmon.s +++ b/src/mon_m65/bsmon.s @@ -219,8 +219,8 @@ Mon_Error ; put a question mark at the end of the text JSR PRIMM - !pet KEY_ESC, "o",KEY_CRSR_RIGHT,'?',0 - LDX #$f8 ; reset stack pointer + !pet KEY_ESC, 'o', KEY_CRSR_RIGHT, '?', 0 + LDX #$f8 ; reset stack pointer XXX probably would be better to restore original TXS BRA Main @@ -574,7 +574,7 @@ Mon_Set_Memory @next BCC @loop @exit JSR PRIMM - !pet KEY_ESC, "o" + !pet KEY_ESC, 'o' !pet $91,$00 JSR Dump_Row JMP Main @@ -1250,7 +1250,7 @@ Mon_Assemble STA [Long_PC],Z @print JSR PRIMM - !pet 13,$91,"a ", KEY_ESC, "q",0 + !pet 13,$91,"a ", KEY_ESC, 'q', 0 JSR Print_Code INC Op_Size LDA Op_Size @@ -1892,7 +1892,7 @@ CR_Erase ; ****** JSR PRIMM - !pet KEY_RETURN, KEY_ESC, "q",0 + !pet KEY_RETURN, KEY_ESC, 'q', 0 RTS ; ******* @@ -2766,7 +2766,7 @@ BP_ZERO !pet "b-p 9 0",0 ; set buffer pointer to 0 Reg_Text ; ****** JSR PRIMM - !pet KEY_RETURN, " pc sr ac xr yr zr bp sp nvebdizc", KEY_RETURN, "; ",0 + !pet KEY_RETURN, " pc sr ac xr yr zr bp sp nvebdizc", KEY_RETURN, "; ", KEY_ESC, 'q', 0 RTS ; ****** diff --git a/src/zvm_m65/,aliases_zvm.s b/src/zvm_m65/,aliases_zvm.s index 05442f7e..7af12809 100644 --- a/src/zvm_m65/,aliases_zvm.s +++ b/src/zvm_m65/,aliases_zvm.s @@ -10,12 +10,12 @@ !addr REG_A_SH = $0A ; shadow registers !addr REG_F_SH = $0B -!addr REG_B_SH = $0C -!addr REG_C_SH = $0D -!addr REG_D_SH = $0E -!addr REG_E_SH = $0F -!addr REG_H_SH = $10 -!addr REG_L_SH = $11 +!addr REG_C_SH = $0C +!addr REG_B_SH = $0D +!addr REG_E_SH = $0E +!addr REG_D_SH = $0F +!addr REG_L_SH = $10 +!addr REG_H_SH = $11 !addr REG_IX = $12 ; 16-bit index register !addr REG_IY = $14 ; 16-bit index register @@ -38,3 +38,13 @@ !addr VEC_store_via_IY_d = $72 !addr VEC_fetch_via_nn = $74 !addr VEC_store_via_nn = $76 + +; Masks for Z80 flag (F) register + +!set Z80FLG_S = %10000000 ; sign +!set Z80FLG_Z = %01000000 ; zero +!set Z80FLG_H = %00010000 ; half carry +!set Z80FLG_P = %00000100 ; parity +!set Z80FLG_O = %00000100 ; overflow +!set Z80FLG_A = %00000010 ; add/subtract +!set Z80FLG_C = %00000001 ; carry