From 01c8e7399cc940d2d5d0540593e16724948bd6e3 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sat, 8 May 2021 14:58:44 -0400 Subject: Replace get_ctrlidx with get_index in print_char. This helps reduce code duplication, and makes it easier to both read, and add new handlers. --- programs/sub-suite/declare.s | 5 ++++- programs/sub-suite/subeditor.s | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/programs/sub-suite/declare.s b/programs/sub-suite/declare.s index 36a4f15..f61b3a2 100644 --- a/programs/sub-suite/declare.s +++ b/programs/sub-suite/declare.s @@ -881,13 +881,13 @@ ct_rtb: ; Jump table for print_char's control codes. ct_jtb: - .word printc ; Everything else (print it). .word nl ; Newline. .word bs ; Backspace. .word clr_scr ; Ctrl+L. .word en_step ; Ctrl+S. .word dis_step ; Ctrl+R. .word esc ; Escape. + .word printc ; Everything else (print it). ; Jump table for parsing pre-tokens. swtab: @@ -932,3 +932,6 @@ dtab: ; Compare, and return table for isdelm2. dtab2: .byte "),.+<|>-=;\n" +; Control code table for print_char. +ctrl_codes: + .byte "\n\b\x0C\x13\x12\e" diff --git a/programs/sub-suite/subeditor.s b/programs/sub-suite/subeditor.s index 800d565..4723b60 100644 --- a/programs/sub-suite/subeditor.s +++ b/programs/sub-suite/subeditor.s @@ -403,15 +403,17 @@ print_char: phb.q ; Preserve B. phx.q ; Preserve X. phe.q ; Preserve E. + xor s, s ; Reset S. sta rega ; Preserve the character. ldb #2 ; Make sure that set_ptr sets the third pointer. lda.q buffer ; Set the third pointer to the start of the screen buffer. jsr set_ptr ; deb ; Set B to one. tba ; Reset A. -; inc step ; - lda rega ; Get the character back. - jsr get_ctrlidx ; Get the control code jump table index. + lea d, ctrl_codes; Get the pointer to the control codes table. + mov s, rega ; Get the character back. + lea f, 0 ; Set the mode of get_index to increment mode. + jsr get_index ; Get the control code handler index. lea ct_jtb ; Get the pointer to the jump table. mov.w e, (e+2*a); Get the address of the control code handler. deb ; Reset B. -- cgit v1.2.3-13-gbd6f