forked from offtopia/ponydos
Fixed a bunch of bugs in mouse_handler; memoized mouse_column in main loop
This commit is contained in:
parent
5c3580e9b5
commit
e900a60d4a
47
ponydos.asm
47
ponydos.asm
|
@ -93,16 +93,18 @@ draw:
|
|||
pop es
|
||||
|
||||
call draw_wallpaper
|
||||
|
||||
mov di, mouse_column
|
||||
call flip_mouse_cursor
|
||||
|
||||
mainloop:
|
||||
mov bx, [mouse_x]
|
||||
mov bx, [di - mouse_column + mouse_x]
|
||||
shr bx, 1
|
||||
mov cx, [mouse_y]
|
||||
mov cx, [di - mouse_column + mouse_y]
|
||||
shr cx, 2
|
||||
cmp [mouse_column], bl
|
||||
cmp [di], bl
|
||||
jne .update_cursor
|
||||
cmp [mouse_row], cl
|
||||
cmp [di - mouse_column + mouse_row], cl
|
||||
jne .update_cursor
|
||||
|
||||
hlt
|
||||
|
@ -110,8 +112,8 @@ mainloop:
|
|||
|
||||
.update_cursor:
|
||||
call flip_mouse_cursor
|
||||
mov [mouse_column], bl
|
||||
mov [mouse_row], cl
|
||||
mov [di], bl
|
||||
mov [di - mouse_column + mouse_row], cl
|
||||
call flip_mouse_cursor
|
||||
jmp mainloop
|
||||
|
||||
|
@ -183,6 +185,7 @@ draw_wallpaper:
|
|||
ret
|
||||
|
||||
; requires:
|
||||
; di = mouse_column
|
||||
; ds = 0
|
||||
; es = 0xb800
|
||||
flip_mouse_cursor:
|
||||
|
@ -190,11 +193,11 @@ flip_mouse_cursor:
|
|||
|
||||
; Column
|
||||
xor bh, bh
|
||||
mov bl, [mouse_column]
|
||||
mov bl, [di]
|
||||
shl bx, 1
|
||||
|
||||
; Row
|
||||
mov al, [mouse_row]
|
||||
mov al, [di - mouse_column + mouse_row]
|
||||
mov cl, COLUMNS*2
|
||||
mul cl
|
||||
add bx, ax
|
||||
|
@ -377,10 +380,9 @@ Y_MAX_VALUE equ 4*ROWS-1
|
|||
; cl = negative bit # in ah
|
||||
; dx = MAX_VALUE
|
||||
; out
|
||||
; mouse_x/mouse_y updated appropriately
|
||||
; [mouse_x]/[mouse_y] updated appropriately
|
||||
; si = updated [mouse_x]/[mouse_y]
|
||||
; di = di + 1
|
||||
; clobbers ah
|
||||
; clobbers ax
|
||||
xy_handler:
|
||||
; X and Y coördinates are stored as 9-bit signed integers
|
||||
; using two's complement notation. The high bits are called
|
||||
|
@ -408,7 +410,6 @@ xy_handler:
|
|||
.not_overflow:
|
||||
|
||||
mov [cs:di], si
|
||||
inc di
|
||||
ret
|
||||
|
||||
mouse_handler:
|
||||
|
@ -418,32 +419,32 @@ mouse_handler:
|
|||
|
||||
mov bx, [bp+2*8+10] ; status
|
||||
|
||||
xor si, si
|
||||
mov di, mouse_x
|
||||
mov dx, X_MAX_VALUE
|
||||
|
||||
test bl, X_OVERFLOW
|
||||
jnz .x_end
|
||||
.x:
|
||||
|
||||
.x_end:
|
||||
xor si, si
|
||||
mov di, mouse_x
|
||||
mov ax, [bp+2*8+8]
|
||||
mov cl, 3
|
||||
mov dx, X_MAX_VALUE
|
||||
call xy_handler
|
||||
.x_end:
|
||||
inc di
|
||||
inc di ; mouse_y
|
||||
|
||||
test bl, Y_OVERFLOW
|
||||
jnz .y_end
|
||||
.y:
|
||||
inc si ; won't be zero
|
||||
inc di ; mouse_y
|
||||
inc si ; will be non-zero
|
||||
mov ax, [bp+2*8+6]
|
||||
mov cl, 2
|
||||
;mov dx
|
||||
mov dl, Y_MAX_VALUE
|
||||
call xy_handler
|
||||
.y_end:
|
||||
|
||||
and bl, BUTTONS
|
||||
mov [cs:di], bl ; mouse_buttons
|
||||
mov [cs:di - mouse_y + mouse_buttons], bl
|
||||
|
||||
popa
|
||||
retf
|
||||
|
@ -467,8 +468,8 @@ section .bss
|
|||
_bss_start:
|
||||
|
||||
mouse_x resw 1
|
||||
mouse_y resw 1 ; mouse_x + 2
|
||||
mouse_buttons resb 1 ; mouse_y + 1
|
||||
mouse_y resw 1 ; mouse_x + 2, do not touch
|
||||
mouse_buttons resb 1
|
||||
|
||||
mouse_column resb 1
|
||||
mouse_row resb 1
|
||||
|
|
Loading…
Reference in New Issue