From 4ed07ca38b99abdca750c6612c512f30965f1714 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sun, 30 Aug 2020 12:44:21 -0400 Subject: - Did some more work on SuBAsm's lexer. - Optimized the memory read, and write functions. - Made the emulator faster, and cleaner in general. --- programs/sub-suite/subeditor.s | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'programs/sub-suite/subeditor.s') diff --git a/programs/sub-suite/subeditor.s b/programs/sub-suite/subeditor.s index e624990..aec613e 100644 --- a/programs/sub-suite/subeditor.s +++ b/programs/sub-suite/subeditor.s @@ -129,7 +129,9 @@ print_str: tay ; Save it in Y. tba ; Get the character back. inx ; Increment the string index. + phx ; Preserve the string index. jsr print_char ; Print the character. + plx ; Get the string index back. bra @loop ; Keep looping. @end: ldb #0 ; Enable insert mode. @@ -365,29 +367,23 @@ findend: print_char: - sta rega ; Save the typed character for now. + sta rega ; Preserve the character. ldb #2 ; Make sure that set_ptr sets the third pointer. lda.d #buffer ; Set the third pointer to the start of the screen buffer. jsr set_ptr ; - ldb #0 ; Set B to zero. - tba ; Set the Accumulator to zero. - lda rega ; Get back the character. - cmp #$1B ; Did the user type an escape character? - beq esc ; Yes, so go check the escape code. - cmp #'\n' ; No, but did the user type a newline? - beq nl ; Yes, so handle the newline. - cmp #$C ; No, but did the user type Ctrl+L? - beq clr_scr ; Yes, so clear the screen. - cmp #19 ; No, but did the user type Ctrl+S? - beq en_step ; Yes, so enable clock/instruction stepping. - cmp #18 ; No, but did the user type Ctrl+R? - beq dis_step ; Yes, so disable clock/instruction stepping. - cmp #'\b' ; No, but did the user type a backspace? - beq bs ; Yes, so handle the backspace. - cmp #$7F ; No, but did they type Delete? - beq bs ; Yes, so treat it as a backspace. + deb ; Set B to one. + tba ; Reset A. + lda rega ; Get the character back. + jsr get_ctrlidx ; Get the control code jump table index. + lsl #1 ; Multiply the return value by two, to get the index. + tax ; + lda.w ct_jtb, x ; Get the address of the control code handler. + jsr set_ptr ; Set the second pointer to the control code handler. + deb ; Reset B. + tba ; Reset A. + jmp (ptr2) ; Jump to the handler for that control code. printc: - lda #0 ; No, so start trying to print a character. + lda #0 ; start trying to print a character. sta regd ; lda (ptr3), y ; Are we at the end of the string? beq @save ; Yes, so just print the character. @@ -402,9 +398,6 @@ printc: @update1: jsr findend ; Find the end of the line. sta rege ; Use it for redrawing the line. -; sta scr_row ; Set the row position to to the end of the line. -; jsr findst ; Find the start of the line. -; lda scr_row ; Get the start of the line. lda scr_trow ; Get the current row position. @update2: sta regf ; Set the starting line, to the current row position. -- cgit v1.2.3-13-gbd6f