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