Skip to content

Commit 2815623

Browse files
author
Ian Seyler
committed
Add backspace support to VGA
1 parent 638db56 commit 2815623

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/drivers/vga.asm

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ vga_clear_screen:
7070
push rax
7171
pushfq
7272

73+
; Set cursor to top left corner
74+
mov word [vga_Cursor_Row], 0
75+
mov word [vga_Cursor_Col], 0
76+
7377
cld ; Clear the direction flag as we want to increment through memory
7478

7579
xor ecx, ecx
@@ -295,7 +299,8 @@ vga_output_chars:
295299
cld ; Clear the direction flag.. we want to increment through the string
296300

297301
vga_output_chars_nextchar:
298-
jrcxz vga_output_chars_done
302+
cmp rcx, 0
303+
jz vga_output_chars_done
299304
dec rcx
300305
lodsb ; Get char from string and store in AL
301306
cmp al, 13 ; Check if there was a newline character in the string
@@ -304,9 +309,32 @@ vga_output_chars_nextchar:
304309
je vga_output_chars_newline ; If so then we print a new line
305310
cmp al, 9
306311
je vga_output_chars_tab
312+
; Check for special characters
313+
cmp al, 0x01 ; Clear Screen
314+
je vga_output_cls
315+
cmp al, 0x02 ; Increment Cursor
316+
je vga_output_inc_cursor
317+
cmp al, 0x03 ; Decrement Cursor
318+
je vga_output_dec_cursor
307319
call vga_output_char
308320
jmp vga_output_chars_nextchar
309321

322+
vga_output_cls:
323+
call vga_clear_screen
324+
call vga_draw_line
325+
jmp vga_output_chars_nextchar
326+
327+
vga_output_inc_cursor:
328+
call vga_inc_cursor
329+
jmp vga_output_chars_nextchar
330+
331+
vga_output_dec_cursor:
332+
call vga_dec_cursor ; Decrement the cursor
333+
mov al, ' ' ; 0x20 is the character for a space
334+
call vga_output_char ; Write over the last typed character with the space
335+
call vga_dec_cursor ; Decrement the cursor again
336+
jmp vga_output_chars_nextchar
337+
310338
vga_output_chars_newline:
311339
mov al, [rsi]
312340
cmp al, 10

0 commit comments

Comments
 (0)