Skip to content

Instantly share code, notes, and snippets.

@antonijn
Last active December 23, 2015 01:29
Show Gist options
  • Save antonijn/6560458 to your computer and use it in GitHub Desktop.
Save antonijn/6560458 to your computer and use it in GitHub Desktop.
ASMINPUT.ASM
; The implementation of INPUT.H for the BIOS
BITS 16
global initmouse
global getmouseinfo
initmouse:
mov ax, 00h
int 33h
cmp ax, 0ffffh
je success
int 20h
success:
ret
getmouseinfo:
push bp
mov sp, bp
mov ax, 03h
int 33h
shr cx, 01h ; cx is doubled in 320x300, correct
mov ax, bx
and ax, 01h
cmp ax, ax
jnz mlefttrue
mov word [bp], 00h ; mouse->left = 0
jmp mleftfalse
mlefttrue:
mov word [bp], 01h ; mouse->left = 1
mleftfalse:
mov ax, bx
and ax, 02h
cmp ax, ax
jnz mrighttrue
mov word [bp + 2], 00h ; mouse->right = 0
jmp mrightfalse
mrighttrue:
mov word [bp + 2], 01h ; mouse->right = 1
mrightfalse:
mov word [bp + 4], cx ; mouse->x = cx
mov word [bp + 6], dx ; mouse->y = dx
pop bp
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment