pop ax
endm
.model small
.stack
.data
m1 db 10,13,"Mouse Support Not Available$"
cnt dw ?
hextab db '0123456789ABCDEF'
.code
main proc near
mov ax,@data
mov ds,ax
;initialize video mode
mov ah,00h
mov al,12h ; 640*480 16 color graphics
int 10h
;set background color
mov ah,0bh
mov bh,00h ;subfunction
mov bl,04h ;bck color
int 10h
;initialize mouse and show mouse
call msinit
;restrict horizontal movement
mov ax,07h
mov cx,160
mov dx,480
int 33h
;restrict vertical movement
mov ax,08h
mov cx,120
mov dx,360
int 33h
;show mid-point of the screen
mov ah,0ch ;putpixel
mov bh,00h ;page no.
mov al,0fh ;color of pixel
mov cx,320 ;x coordinate
mov dx,240 ;y coordinate
int 10h
repeat:
mov ah,01h
int 16h
jnz keypress ;zero flag is set when no keyboard input
mov ax,03h ;get mouse status
int 33h
call beeps
push dx
;print x-coord
mov ax,cx
mov dl,20 ;columnno=20
call disp
;print y-coord
pop dx
mov ax,dx
mov dl,28 ;columnno=28
call disp
jmp repeat
keypress:
mov ah,00h ;scan keyboard input
int 16h
cmp al,'s'
je shw
cmp al,'h'
je hide
cmp al,'q'
je door
jmp repeat
shw:
mov ax,01h ;show mouse
int 33h
jmp repeat
hide:
mov ax,02h ;hide mouse
int 33h
jmp repeat
door:
mov ah,01h
int 21h
mov ah,4ch
int 21h
main endp
beeps proc near
cmp cx,320
jne nobeep
cmp dx,240
jne nobeep
mov ah,02h
mov dl,07h
int 21h
nobeep:
ret
endp
msinit proc near
mov ax,00h ;initialize mouse
int 33h
cmp ax,0ffffh
jne nomouse
mov ax,01h ;show mouse
int 33h
jmp door1
nomouse:
print m1
mov ah,4ch
int 21h
door1:
ret
endp
disp proc near
mov cnt,04h
l1:
rol ax,04h
mov di,ax
push ax
and di,000fh
mov al,hextab[di]
mov ah,02h ;set cursor positon
mov bh,00h
mov dh,11h
int 10h
mov ah,0ah ;write character on screen
mov bh,00h
mov bl,0fh ;color
mov cx,01h
int 10h
pop ax
inc dl
dec cnt
cmp cnt,00h
jnz l1
ret
endp
end main
No comments:
Post a Comment