From 7f6eeb10c7976e839208ff6347e71aecc4084dd7 Mon Sep 17 00:00:00 2001 From: Ry Date: Fri, 25 Nov 2022 17:20:03 -0800 Subject: [PATCH] terminal: Only draw the line upon LF or when requested --- terminal/text.asm | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/terminal/text.asm b/terminal/text.asm index 6da9208..d26e403 100644 --- a/terminal/text.asm +++ b/terminal/text.asm @@ -6,6 +6,11 @@ const TERMINAL_Y_SIZE: 25 const TEXT_COLOR: 0xFFFFFFFF const BACKGROUND_COLOR: 0xFF000000 +const FILL_TERM: 0xF0 +const MOVE_CURSOR: 0xF1 +const REDRAW_LINE: 0xFE +const REDRAW: 0xFF + ; print a single character to the terminal ; inputs: ; r0: ASCII character or control character @@ -61,6 +66,8 @@ print_character_to_terminal_cr: mov.8 [terminal_x], 0 jmp print_character_to_terminal_end print_character_to_terminal_lf: + ; draw the line + call redraw_terminal_line ; return to the beginning of the line and increment the line mov.8 [terminal_x], 0 inc.8 [terminal_y] @@ -73,7 +80,6 @@ print_character_to_terminal_bs: cmp.8 [terminal_x], 0 ifnz dec.8 [terminal_x] print_character_to_terminal_end: - call redraw_terminal_line pop r2 pop r1 pop r0 @@ -98,13 +104,21 @@ handle_control_character: ifz mov.8 [terminal_state], 0 ; fill terminal - cmp.8 [terminal_control_char], 0xF0 + cmp.8 [terminal_control_char], FILL_TERM ifz jmp handle_control_character_fill_term ; set cursor position - cmp.8 [terminal_control_char], 0xF1 + cmp.8 [terminal_control_char], MOVE_CURSOR ifz jmp handle_control_character_set_cursor_pos + ; redraw line + cmp.8 [terminal_control_char], REDRAW_LINE + ifz jmp handle_control_character_redraw_line + + ; redraw + cmp.8 [terminal_control_char], REDRAW + ifz jmp handle_control_character_redraw + ret handle_control_character_fill_term: push r0 @@ -120,9 +134,16 @@ handle_control_character_fill_term_loop: pop r0 ret handle_control_character_set_cursor_pos: + call redraw_terminal_line mov.8 [terminal_x], [terminal_control_parameter_1] mov.8 [terminal_y], [terminal_control_parameter_2] ret +handle_control_character_redraw_line: + call redraw_terminal_line + ret +handle_control_character_redraw: + call redraw_terminal + ret ; scroll the terminal ; inputs: