Unify the x/y handling in the mouse handler a bit more
This commit is contained in:
parent
45b4f8f3e1
commit
c4dc87c8fd
30
ponydos.asm
30
ponydos.asm
|
@ -390,11 +390,15 @@ Y_MAX_VALUE equ 4*ROWS-1
|
|||
; bx = status
|
||||
; cl = negative bit # in ah
|
||||
; dx = MAX_VALUE
|
||||
; zf = tested against overflow
|
||||
; out
|
||||
; [mouse_x]/[mouse_y] updated appropriately
|
||||
; si = updated [mouse_x]/[mouse_y]
|
||||
; di = di + 2
|
||||
; clobbers ax
|
||||
xy_handler:
|
||||
jnz .overflow_return
|
||||
|
||||
; X and Y coördinates are stored as 9-bit signed integers
|
||||
; using two's complement notation. The high bits are called
|
||||
; "X negative" and "Y negative".
|
||||
|
@ -421,6 +425,10 @@ xy_handler:
|
|||
.not_overflow:
|
||||
|
||||
mov [cs:di], si
|
||||
|
||||
.overflow_return:
|
||||
inc di
|
||||
inc di
|
||||
ret
|
||||
|
||||
mouse_handler:
|
||||
|
@ -430,32 +438,28 @@ mouse_handler:
|
|||
|
||||
mov bx, [bp+2*8+10] ; status
|
||||
|
||||
.x:
|
||||
xor si, si
|
||||
mov di, mouse_x
|
||||
mov dx, X_MAX_VALUE
|
||||
|
||||
test bl, X_OVERFLOW
|
||||
jnz .x_end
|
||||
.x:
|
||||
mov ax, [bp+2*8+8]
|
||||
mov cl, 3
|
||||
call xy_handler
|
||||
.x_end:
|
||||
inc di
|
||||
inc di ; mouse_y
|
||||
|
||||
test bl, Y_OVERFLOW
|
||||
jnz .y_end
|
||||
test bl, X_OVERFLOW
|
||||
call xy_handler
|
||||
|
||||
.y:
|
||||
inc si ; will be non-zero
|
||||
mov ax, [bp+2*8+6]
|
||||
mov cl, 2
|
||||
;mov dx
|
||||
mov dl, Y_MAX_VALUE
|
||||
|
||||
test bl, Y_OVERFLOW
|
||||
call xy_handler
|
||||
.y_end:
|
||||
|
||||
and bl, BUTTONS
|
||||
mov [cs:di - mouse_y + mouse_buttons], bl
|
||||
mov [cs:di], bl
|
||||
|
||||
popa
|
||||
retf
|
||||
|
@ -482,7 +486,7 @@ resb 8 ; Rest of the memory allocation map
|
|||
|
||||
mouse_x resw 1
|
||||
mouse_y resw 1 ; mouse_x + 2, do not touch
|
||||
mouse_buttons resb 1
|
||||
mouse_buttons resb 1 ; mouse_y + 2
|
||||
|
||||
mouse_column resb 1
|
||||
mouse_row resb 1 ; mouse_column + 1
|
||||
|
|
Loading…
Reference in New Issue