From 13c69db33d89efef2dadcb381cd389f6eae8f854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Mon, 20 Mar 2023 20:46:29 +0200 Subject: [PATCH] Add keyboard events --- ponydos.asm | 37 ++++++++++++++++++++++++------------- ponydos_static.inc | 1 + shell.asm | 4 ++-- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/ponydos.asm b/ponydos.asm index 6aaf872..a9e6856 100644 --- a/ponydos.asm +++ b/ponydos.asm @@ -13,6 +13,12 @@ ROWS equ 25 jmp 0:start +initialize_mouse_error: + ; https://www.ctyme.com/intr/rb-1601.htm + mov ax, 0xc201 + int 0x15 + jmp initialize_mouse + start: cld @@ -89,7 +95,7 @@ mainloop: call draw_wallpaper ; Draw windows - xor ax, ax ; WM_PAINT + xor al, al ; WM_PAINT call window_event call flip_mouse_cursor @@ -113,26 +119,32 @@ mainloop: mov dl, [di - mouse_column + mouse_buttons] - mov ax, WM_MOUSE + mov al, WM_MOUSE call window_event .mouse_change_end: + mov ah, 1 + int 0x16 + jz .key_end + .key: + xor ah, ah + int 0x16 + mov cx, ax + mov al, WM_KEYBOARD + call window_event + .key_end: + hlt jmp mainloop -initialize_mouse_error: - ; https://www.ctyme.com/intr/rb-1601.htm - mov ax, 0xc201 - int 0x15 - jmp initialize_mouse - ; requires: ; ds = 0 ; di = mouse_column ; in: -; ax = event +; al = event ; out: ; clobbers bx +; clobbers bp window_event: push cs ; Return segment push word draw_wallpaper.ret ; Return offset @@ -314,10 +326,10 @@ shell_name db 'shell.bin', 0 ; in: ; ds:si = file name +; dx = non-zero => do not create new file ; out: ; ax = LBA of first sector, 0 if no space left ; cx = length in sectors -; dx = non-zero => do not create new file ; di = dirent address (in GLOBAL_DIRENTS) ; [Far calls only] open_file: @@ -478,10 +490,9 @@ mouse_handler: test bl, Y_OVERFLOW call xy_handler + mov bh, 1 and bl, BUTTONS - mov [cs:di], bl - - mov byte [cs:di + 1], 1 ; Mark that mouse state has updated + mov [cs:di], bx popa retf diff --git a/ponydos_static.inc b/ponydos_static.inc index b077515..280b9af 100644 --- a/ponydos_static.inc +++ b/ponydos_static.inc @@ -8,6 +8,7 @@ FS_FILE_MAX_SIZE equ 128 WM_PAINT equ 0 WM_MOUSE equ 1 +WM_KEYBOARD equ 2 MOUSE_PRIMARY equ 0x01 MOUSE_SECONDARY equ 0x02 diff --git a/shell.asm b/shell.asm index a6c4bda..86a4faf 100644 --- a/shell.asm +++ b/shell.asm @@ -91,12 +91,12 @@ process_event: mov ds, bp mov es, bp - cmp ax, WM_PAINT + cmp al, WM_PAINT jne .not_paint call paint .not_paint: - cmp ax, WM_MOUSE + cmp al, WM_MOUSE jne .not_mouse call mouse .not_mouse: