forked from offtopia/ponydos
Add keyboard events
This commit is contained in:
parent
744da780f3
commit
13c69db33d
3 changed files with 27 additions and 15 deletions
37
ponydos.asm
37
ponydos.asm
|
@ -13,6 +13,12 @@ ROWS equ 25
|
||||||
|
|
||||||
jmp 0:start
|
jmp 0:start
|
||||||
|
|
||||||
|
initialize_mouse_error:
|
||||||
|
; https://www.ctyme.com/intr/rb-1601.htm
|
||||||
|
mov ax, 0xc201
|
||||||
|
int 0x15
|
||||||
|
jmp initialize_mouse
|
||||||
|
|
||||||
start:
|
start:
|
||||||
cld
|
cld
|
||||||
|
|
||||||
|
@ -89,7 +95,7 @@ mainloop:
|
||||||
call draw_wallpaper
|
call draw_wallpaper
|
||||||
|
|
||||||
; Draw windows
|
; Draw windows
|
||||||
xor ax, ax ; WM_PAINT
|
xor al, al ; WM_PAINT
|
||||||
call window_event
|
call window_event
|
||||||
|
|
||||||
call flip_mouse_cursor
|
call flip_mouse_cursor
|
||||||
|
@ -113,26 +119,32 @@ mainloop:
|
||||||
|
|
||||||
mov dl, [di - mouse_column + mouse_buttons]
|
mov dl, [di - mouse_column + mouse_buttons]
|
||||||
|
|
||||||
mov ax, WM_MOUSE
|
mov al, WM_MOUSE
|
||||||
call window_event
|
call window_event
|
||||||
.mouse_change_end:
|
.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
|
hlt
|
||||||
jmp mainloop
|
jmp mainloop
|
||||||
|
|
||||||
initialize_mouse_error:
|
|
||||||
; https://www.ctyme.com/intr/rb-1601.htm
|
|
||||||
mov ax, 0xc201
|
|
||||||
int 0x15
|
|
||||||
jmp initialize_mouse
|
|
||||||
|
|
||||||
; requires:
|
; requires:
|
||||||
; ds = 0
|
; ds = 0
|
||||||
; di = mouse_column
|
; di = mouse_column
|
||||||
; in:
|
; in:
|
||||||
; ax = event
|
; al = event
|
||||||
; out:
|
; out:
|
||||||
; clobbers bx
|
; clobbers bx
|
||||||
|
; clobbers bp
|
||||||
window_event:
|
window_event:
|
||||||
push cs ; Return segment
|
push cs ; Return segment
|
||||||
push word draw_wallpaper.ret ; Return offset
|
push word draw_wallpaper.ret ; Return offset
|
||||||
|
@ -314,10 +326,10 @@ shell_name db 'shell.bin', 0
|
||||||
|
|
||||||
; in:
|
; in:
|
||||||
; ds:si = file name
|
; ds:si = file name
|
||||||
|
; dx = non-zero => do not create new file
|
||||||
; out:
|
; out:
|
||||||
; ax = LBA of first sector, 0 if no space left
|
; ax = LBA of first sector, 0 if no space left
|
||||||
; cx = length in sectors
|
; cx = length in sectors
|
||||||
; dx = non-zero => do not create new file
|
|
||||||
; di = dirent address (in GLOBAL_DIRENTS)
|
; di = dirent address (in GLOBAL_DIRENTS)
|
||||||
; [Far calls only]
|
; [Far calls only]
|
||||||
open_file:
|
open_file:
|
||||||
|
@ -478,10 +490,9 @@ mouse_handler:
|
||||||
test bl, Y_OVERFLOW
|
test bl, Y_OVERFLOW
|
||||||
call xy_handler
|
call xy_handler
|
||||||
|
|
||||||
|
mov bh, 1
|
||||||
and bl, BUTTONS
|
and bl, BUTTONS
|
||||||
mov [cs:di], bl
|
mov [cs:di], bx
|
||||||
|
|
||||||
mov byte [cs:di + 1], 1 ; Mark that mouse state has updated
|
|
||||||
|
|
||||||
popa
|
popa
|
||||||
retf
|
retf
|
||||||
|
|
|
@ -8,6 +8,7 @@ FS_FILE_MAX_SIZE equ 128
|
||||||
|
|
||||||
WM_PAINT equ 0
|
WM_PAINT equ 0
|
||||||
WM_MOUSE equ 1
|
WM_MOUSE equ 1
|
||||||
|
WM_KEYBOARD equ 2
|
||||||
|
|
||||||
MOUSE_PRIMARY equ 0x01
|
MOUSE_PRIMARY equ 0x01
|
||||||
MOUSE_SECONDARY equ 0x02
|
MOUSE_SECONDARY equ 0x02
|
||||||
|
|
|
@ -91,12 +91,12 @@ process_event:
|
||||||
mov ds, bp
|
mov ds, bp
|
||||||
mov es, bp
|
mov es, bp
|
||||||
|
|
||||||
cmp ax, WM_PAINT
|
cmp al, WM_PAINT
|
||||||
jne .not_paint
|
jne .not_paint
|
||||||
call paint
|
call paint
|
||||||
.not_paint:
|
.not_paint:
|
||||||
|
|
||||||
cmp ax, WM_MOUSE
|
cmp al, WM_MOUSE
|
||||||
jne .not_mouse
|
jne .not_mouse
|
||||||
call mouse
|
call mouse
|
||||||
.not_mouse:
|
.not_mouse:
|
||||||
|
|
Loading…
Reference in a new issue