Main - About - Tutorials - Articles - Files - Opcodes - Links  

Untitled Document

Mouse: Int 33h

Author: InternetNightmare

 

In this tutorial I'll cover mouse usage in DOS applications. If you want to test the program in real DOS mode (without windows running) you'll need CuteMouse drivers that can be downloaded here.

mov ax,0
int 33h ; mouse interrupt
; (ifi AX=FFFFh mouse is installed, if 0000 not, DX - number of mouse buttons)

cmp ax,0
ja pmouse ; if AX > 0 lets start!

mov ah,4ch
int 21h ;else just exit

pmouse:
mov ax,03 ; function to get mouse position and buttons
int 33h

mov ax,dx ; Y coord to AX
mov dx,320

mul dx ; multiply AX by 320
add ax,cx ; add X coord

; (Now currsor position is in AX, lets draw the pixel there)

mov di,ax
mov ax,0A000h
mov es,ax
mov dl,12 ; red color ;)
mov es:[di],dl ; and we have the pixel drawn

By default mouse resolution is 640x200, lets set it to 320x200 (monitor height is already set, lets just set the width)

mov ax, 7
mov cx,0 ; min pos
mov dx,320 ; max pos
int 33h

And height can be set:

mov ax, 8
mov cx,0
mov dx,200
int 33h

The source for this tutorial can be found here.


Copyright InternetNightmare © - 2004-2009