I am using assembly-x86 on a DOS emulator (dosbox).
I want to use the graphic mouse on video mode but I can't find a way to access it, in order to find its position and react to clicks.
I have found several examples of using int 33h
but they did not have a proper explanation with the code.
What interrupt or port can I use to access it, and where can I find a documentation of all of its functions?
But without using a mouse driver: For a PS2-mouse (and additional for an USB-mouse with USB lagacy enable in the mainboard bios) i like to use the bios interrupt 15h AX=0C20?h for to use the irq handler like the Cutemouse do, but without to build a TSR with it.
But this IRQhandler (in the example below) need a little modifying, so we have to add some instruction for to store the mouse values to a known ram location, so that our main-routine can get the mouse movement and the mouse clicks from this location.
Additional our main-routine have to draw the mouse pointer to the framebuffer itself, so we have to calculate the address of the position depends on which videomode we are using (with 4,8,15,16,24,or 32 bits per pixel and the lenght of the scanline and the position of the color fields RGB, or BGR).
Example for to use an own PS2-mouse handler (without drawing a mouse pointer):
; main routine
call CHECKPS2
jc NOMOUSE
call PS2ON
jc NOMOUSE
; -------------------
; place your code here
; -------------------
call PS2OFF
mov ax, 0C201h ; Reset PS2
int 15h
NOMOUSE:
; -------------------
; sub routines
; -------------------
checkPS2:
int 11h ; get equipment list
test al, 3
jz noPS2 ; jump if PS/2-Mouse not indicated
mov bh,3
mov ax, 0C205h
int 15h ; initialize mouse, bh=datasize
jc noPS2
mov bh,3
mov ax, 0C203h
int 15h ; set mouse resolution bh
jc noPS2
mov ax, cs
mov es, ax
mov bx, OFFSET PS2dummy
mov ax, 0C207h
int 15h ; mouse, es:bx=ptr to handler
jc noPS2
xor bx, bx
mov es, bx ; mouse, es:bx=ptr to handler
mov ax, 0C207h
int 15h
ret
noPS2:
stc
ret
PS2dummy:
retf
;---------------------------------------------------------
enablePS2:
call disablePS2
mov ax, cs
mov es, ax
mov bx, OFFSET IRQhandler
mov ax, 0C207h ; es:bx=ptr to handler
int 15h
mov bh,1 ; set mouse on
mov ax, 0C200h
int 15h
ret
;-------------------------------
disablePS2:
xor bx, bx ; set mouse off
mov ax, 0C200h
int 15h
xor bx, bx
mov es, bx
mov ax, 0C207h ; es:bx=ptr to handler
int 15h
ret
;---------------------------------------------------------------------------
IRQhandler:
assume ds:nothing,es:nothing
cld
push ds
push es
pusha
mov ax, cs
mov ds, ax
mov bp,sp
mov al,[bp+24+6] ; buttons
mov bl,al
shl al,3 ; CF=Y sign bit
sbb ch,ch ; signed extension 9->16 bit
cbw ; extend X sign bit
mov al,[bp+24+4] ; AX=X movement
mov cl,[bp+24+2] ; CX=Y movement
xchg bx,ax
neg cx ; reverse Y movement
popa
pop es
pop ds
retf