diff --git a/src/drivers/lfb/lfb.asm b/src/drivers/lfb/lfb.asm index 51b00d1..7cdc609 100644 --- a/src/drivers/lfb/lfb.asm +++ b/src/drivers/lfb/lfb.asm @@ -61,8 +61,6 @@ render_done: mul ecx mov [Screen_Bytes], eax -; call lfb_clear - ; Calculate display parameters based on font dimensions xor eax, eax xor edx, edx @@ -112,6 +110,7 @@ render_done: mov rax, [os_screen_lfb] mov [LastLine], rax + mov [lfb_last_cursor], rax ; Overwrite the kernel b_output function so output goes to the screen instead of the serial port mov rax, lfb_output_chars @@ -143,7 +142,10 @@ lfb_inc_cursor: cmp ax, [Screen_Rows] ; Compare it to the # of rows for the screen jne lfb_inc_cursor_done ; If not equal we are done mov word [Screen_Cursor_Row], 0 ; Wrap around + lfb_inc_cursor_done: + call lfb_update_cursor + pop rax ret ; ----------------------------------------------------------------------------- @@ -164,12 +166,89 @@ lfb_dec_cursor: lfb_dec_cursor_done: dec word [Screen_Cursor_Col] ; Decrement the cursor as usual + call lfb_update_cursor pop rax ret ; ----------------------------------------------------------------------------- +; ----------------------------------------------------------------------------- +; lfb_update_cursor -- Update the cursor +; IN: Nothing +; OUT: All registers preserved +lfb_update_cursor: + ; Check if cursor is enabled + cmp byte [lfb_cursor_on], 1 ; 1 means enabled + jne lfb_update_cursor_skip ; If not, skip entire function + + push rdi + push rdx + push rcx + push rbx + push rax + + ; Clear old cursor + mov rdi, [lfb_last_cursor] ; Gather the LFB memory address of the start of the cursor + xor ecx, ecx + xor ebx, ebx ; Used for value of bytes per line + mov bx, [os_screen_ppsl] + shl ebx, 2 ; Quick multiply by 4 + mov cl, font_h + sub cl, 2 + sub rdi, 4 + mov eax, [BG_Color] +lfb_update_cursor_line_old: + add rdi, rbx ; Add value of bytes per line + mov [rdi], eax + dec cl + jnz lfb_update_cursor_line_old + + ; Calculate where to put cursor in the Linear Frame Buffer + mov rdi, [os_screen_lfb] + + ; Calculate offset for row into Linear Frame Buffer + xor ecx, ecx + mov eax, [lfb_glyph_bytes_per_row] + mov cx, [Screen_Cursor_Row] + mul ecx ; EDX:EAX := EAX * ECX + add rdi, rax + + ; Calculate offset for column into Linear Frame Buffer + xor ecx, ecx + mov eax, [lfb_glyph_bytes_per_col] + mov cx, [Screen_Cursor_Col] + mul ecx ; EDX:EAX := EAX * ECX + add rdi, rax + + ; Store cursor location + mov [lfb_last_cursor], rdi + + ; Draw new cursor + xor ecx, ecx + xor ebx, ebx + mov bx, [os_screen_ppsl] + shl ebx, 2 ; Quick multiply by 4 + mov cl, font_h + sub cl, 2 + sub rdi, 4 + mov eax, [Cursor_Color] +lfb_update_cursor_line: + add rdi, rbx + mov [rdi], eax + dec cl + jnz lfb_update_cursor_line + + pop rax + pop rbx + pop rcx + pop rdx + pop rdi +lfb_update_cursor_skip: + ret +; ----------------------------------------------------------------------------- + + ; ----------------------------------------------------------------------------- ; lfb_output_chars -- Output text to LFB ; IN: RSI = message location (an ASCII string, not zero-terminated) @@ -524,9 +603,11 @@ align 16 align 16 LastLine: dq 0 +lfb_last_cursor: dq 0 lfb_glyph_next_line: dq 0 FG_Color: dd 0x00FFFFFF ; White BG_Color: dd 0x00404040 ; Dark grey +Cursor_Color: dd 0x00A0A0A0 Line_Color: dd 0x00F7CA54 ; Return Infinity Yellow/Orange Screen_Pixels: dd 0 Screen_Bytes: dd 0 @@ -537,6 +618,7 @@ Screen_Rows: dw 0 Screen_Cols: dw 0 Screen_Cursor_Row: dw 0 Screen_Cursor_Col: dw 0 +lfb_cursor_on: db 1 ; ============================================================================= diff --git a/src/drivers/ps2.asm b/src/drivers/ps2.asm index e203f0f..2c6be8b 100644 --- a/src/drivers/ps2.asm +++ b/src/drivers/ps2.asm @@ -109,6 +109,14 @@ ps2_keyboard_interrupt: in al, PS2_DATA ; Get the scan code from the keyboard cmp al, 0x01 je keyboard_escape + cmp al, 0x48 + je keyboard_up + cmp al, 0x50 + je keyboard_down + cmp al, 0x4B + je keyboard_left + cmp al, 0x4D + je keyboard_right cmp al, 0x1D je keyboard_control cmp al, 0x2A ; Left Shift Make @@ -148,6 +156,22 @@ keyboard_escape: keyup: jmp keyboard_done +keyboard_left: + mov byte [key], 0x03 + jmp keyboard_done + +keyboard_right: + mov byte [key], 0x02 + jmp keyboard_done + +keyboard_up: + mov byte [key], 0x04 + jmp keyboard_done + +keyboard_down: + mov byte [key], 0x05 + jmp keyboard_done + keyboard_control: mov byte [key_control], 0x01 jmp keyboard_done diff --git a/src/drivers/serial.asm b/src/drivers/serial.asm index 7990a5d..ca997bc 100644 --- a/src/drivers/serial.asm +++ b/src/drivers/serial.asm @@ -10,7 +10,7 @@ serial_init: ; Pure64 has already initialized the serial port - ; Check if PS/2 is present via ACPI IAPC_BOOT_ARCH + ; Check if Serial is present via ACPI IAPC_BOOT_ARCH mov ax, [os_boot_arch] bt ax, 0 ; LEGACY_DEVICES jnc serial_init_error