Mouse stuff
This commit is contained in:
parent
7e0b8ad4e1
commit
750e9a73f5
3 changed files with 77 additions and 5 deletions
3
main.asm
3
main.asm
|
@ -33,10 +33,11 @@ main:
|
||||||
|
|
||||||
|
|
||||||
cli
|
cli
|
||||||
|
|
||||||
mov bx, [mouseX]
|
mov bx, [mouseX]
|
||||||
sti
|
sti
|
||||||
|
|
||||||
call print_hex
|
call print_sint
|
||||||
call print_nl
|
call print_nl
|
||||||
|
|
||||||
jmp lp
|
jmp lp
|
||||||
|
|
|
@ -98,6 +98,42 @@ mouse_disable:
|
||||||
pop es
|
pop es
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
clamp_mouse_bounds:
|
||||||
|
pusha
|
||||||
|
|
||||||
|
cli
|
||||||
|
mov ax, [mouseX]
|
||||||
|
mov bx, [mouseY]
|
||||||
|
sti
|
||||||
|
|
||||||
|
test ax, 0x8000
|
||||||
|
jnz .x0
|
||||||
|
mov ax, 0
|
||||||
|
.x0:
|
||||||
|
|
||||||
|
test bx, 0x8000
|
||||||
|
jnz .y0
|
||||||
|
mov bx, 0
|
||||||
|
.y0:
|
||||||
|
|
||||||
|
cmp bx, 320
|
||||||
|
jle .x1
|
||||||
|
mov bx, 320
|
||||||
|
.x1:
|
||||||
|
|
||||||
|
cmp ax, 200
|
||||||
|
jle .y1
|
||||||
|
mov ax, 200
|
||||||
|
.y1:
|
||||||
|
|
||||||
|
cli
|
||||||
|
mov [mouseX], ax
|
||||||
|
mov [mouseY], bx
|
||||||
|
sti
|
||||||
|
|
||||||
|
popa
|
||||||
|
ret
|
||||||
|
|
||||||
; Function: mouse_callback (FAR)
|
; Function: mouse_callback (FAR)
|
||||||
; called by the interrupt handler to process a mouse data packet
|
; called by the interrupt handler to process a mouse data packet
|
||||||
; All registers that are modified must be saved and restored
|
; All registers that are modified must be saved and restored
|
||||||
|
@ -143,6 +179,28 @@ mouse_callback:
|
||||||
mov cx, [mouseX]
|
mov cx, [mouseX]
|
||||||
add ax, cx ; AX = new mouse X_coord
|
add ax, cx ; AX = new mouse X_coord
|
||||||
|
|
||||||
|
; clamp values
|
||||||
|
|
||||||
|
test ax, 0x8000
|
||||||
|
jz .x0
|
||||||
|
mov ax, 0
|
||||||
|
.x0:
|
||||||
|
|
||||||
|
test bx, 0x8000
|
||||||
|
jz .y0
|
||||||
|
mov bx, 0
|
||||||
|
.y0:
|
||||||
|
|
||||||
|
cmp ax, 320
|
||||||
|
jle .x1
|
||||||
|
mov ax, 320
|
||||||
|
.x1:
|
||||||
|
|
||||||
|
cmp bx, 200
|
||||||
|
jle .y1
|
||||||
|
mov bx, 200
|
||||||
|
.y1:
|
||||||
|
|
||||||
; Status
|
; Status
|
||||||
mov [curStatus], bl ; Update the current status with the new bits
|
mov [curStatus], bl ; Update the current status with the new bits
|
||||||
mov [mouseX], ax ; Update current virtual mouseX coord
|
mov [mouseX], ax ; Update current virtual mouseX coord
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
%macro print_ch 1
|
%macro print_ch 1
|
||||||
push ax
|
push ax
|
||||||
|
push bx
|
||||||
|
|
||||||
|
mov bx, 0x000F
|
||||||
mov al, %1
|
mov al, %1
|
||||||
mov ah, 0x0e
|
mov ah, 0x0e
|
||||||
int 0x10
|
int 0x10
|
||||||
|
|
||||||
|
pop bx
|
||||||
pop ax
|
pop ax
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
|
@ -14,6 +19,7 @@
|
||||||
int 0x10 ; Graphics services
|
int 0x10 ; Graphics services
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
|
; bx = string to print
|
||||||
print:
|
print:
|
||||||
pusha
|
pusha
|
||||||
|
|
||||||
|
@ -74,8 +80,11 @@ print_hex_digit:
|
||||||
.skip_alpha:
|
.skip_alpha:
|
||||||
add al, 0x30 ; Add ASCII '0'
|
add al, 0x30 ; Add ASCII '0'
|
||||||
|
|
||||||
|
push bx
|
||||||
|
mov bx, 0x000F
|
||||||
mov ah, 0x0e
|
mov ah, 0x0e
|
||||||
int 0x10
|
int 0x10
|
||||||
|
pop bx
|
||||||
|
|
||||||
popa
|
popa
|
||||||
ret
|
ret
|
||||||
|
@ -136,6 +145,7 @@ print_bin:
|
||||||
popa
|
popa
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; bx = number to print
|
||||||
print_uint:
|
print_uint:
|
||||||
pusha
|
pusha
|
||||||
|
|
||||||
|
@ -160,7 +170,10 @@ print_uint:
|
||||||
pop ax ; 16-bit value
|
pop ax ; 16-bit value
|
||||||
mov ah, 0x0e
|
mov ah, 0x0e
|
||||||
;add al, 0x30
|
;add al, 0x30
|
||||||
|
push bx
|
||||||
|
mov bx, 0x000F
|
||||||
int 0x10
|
int 0x10
|
||||||
|
pop bx
|
||||||
|
|
||||||
cmp bx, 0
|
cmp bx, 0
|
||||||
jnz .print_loop
|
jnz .print_loop
|
||||||
|
|
Loading…
Add table
Reference in a new issue