From 35a137dea086c338e9cbb7087f28ce7c2ca51e9c Mon Sep 17 00:00:00 2001 From: rs <> Date: Fri, 10 Oct 2025 00:41:43 -0500 Subject: [PATCH] Commit progress on vga_console --- projects/cpu_0/asm/vga_console.asm | 74 +++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 7 deletions(-) diff --git a/projects/cpu_0/asm/vga_console.asm b/projects/cpu_0/asm/vga_console.asm index 3111cc0..8f5345b 100644 --- a/projects/cpu_0/asm/vga_console.asm +++ b/projects/cpu_0/asm/vga_console.asm @@ -21,8 +21,9 @@ vga_reset: ( TODO: Reload tile memory? ) ( Initialize console ) - #8 0x00i8 #32 vga_cursor_loc !32 drop ( Set the cursor to the beginning of the screen ) - #8 0x3bi8 #32 vga_cursor_col !8 drop ( Set the cursor color to light blue on dark blue ) + #8 0x00i8 #32 vga_cursor_x !8 drop ( Set the cursor to the beginning of the screen ) + #8 0x00i8 #32 vga_cursor_y !8 drop + #8 0x3bi8 #32 vga_cursor_col !8 drop ( Set the cursor color to light blue on dark blue ) ( Clear screen ) #32 vga_scr #32 0x00003b20i32 #32 4800i32 call mem_set_16 @@ -33,21 +34,78 @@ vga_reset: ( Print a character to the VGA display ) ( c -- ) vga_console_putc: + dup #8 0x20i8 - jp .ctrl #32 vga_scr #32 vga_cursor_loc @32 + dup >r !8 drop #32 vga_cursor_col @8 r> #8 1i8 + !8 drop #32 vga_cursor_loc dup @32 #8 0x02i8 + swap !32 drop ; +.ctrl: + dup + dup + + #32 .ctrl_lut + + @32 >r ; +.ctrl_nop: ; +.ctrl_bel: ; +.ctrl_bs: + ; +.ctrl_tab: + ; +.ctrl_lf: + ( Fall through to CR ) +.ctrl_cr: + ; +.ctrl_ff: + ; + +align +.ctrl_lut: + .ctrl_nop ( 0x00 - nul ) + .ctrl_nop ( 0x01 ) + .ctrl_nop ( 0x02 ) + .ctrl_nop ( 0x03 ) + .ctrl_nop ( 0x04 ) + .ctrl_nop ( 0x05 ) + .ctrl_nop ( 0x06 ) + .ctrl_bel ( 0x07 - bell ) + .ctrl_bs ( 0x08 - backspace ) + .ctrl_tab ( 0x09 - horizontal tab ) + .ctrl_lf ( 0x0a - line feed ) + .ctrl_nop ( 0x0b - vertical tab ) + .ctrl_ff ( 0x0c - form feed ) + .ctrl_cr ( 0x0d - carriage return ) + .ctrl_nop ( 0x0e ) + .ctrl_nop ( 0x0f ) + .ctrl_nop ( 0x10 ) + .ctrl_nop ( 0x11 ) + .ctrl_nop ( 0x12 ) + .ctrl_nop ( 0x13 ) + .ctrl_nop ( 0x14 ) + .ctrl_nop ( 0x15 ) + .ctrl_nop ( 0x16 ) + .ctrl_nop ( 0x17 ) + .ctrl_nop ( 0x18 - cancel ) + .ctrl_nop ( 0x19 ) + .ctrl_nop ( 0x1a ) + .ctrl_nop ( 0x1b - escape ) + .ctrl_nop ( 0x1c ) + .ctrl_nop ( 0x1d ) + .ctrl_nop ( 0x1e ) + .ctrl_nop ( 0x1f ) + + +( Wrap cursor and scroll screen ) +vga_update_cursor: + ; ( Print an ASCIIZ string out the VGA display ) ( &s -- ) vga_console_puts: -_vga_console_puts_loop: - dup @8 dup jz _vga_console_puts_done +.loop: + dup @8 dup jz .done call vga_console_putc - #8 0x01i8 + jmp _vga_console_puts_loop -_vga_console_puts_done: + #8 0x01i8 + jmp .loop +.done: drop drop ; @@ -55,5 +113,7 @@ _vga_console_puts_done: ( RAM variables ) -vga_cursor_loc=0x01000000 +vga_cursor_x=0x01000000 +vga_cursor_y=0x01000001 +vga_cursor_loc=0x01000008 vga_cursor_col=0x01000004 -- 2.43.0