Questions About Mouse

advertisement
Mouse Question #1
• Which INT number is used for the mouse?
Mouse Question#1
• Which INT number is used for the mouse?
33h
Question #1A
• Unlike DOS INT 21h, or BIOS INT10h,
with the mouse BIOS functions, the
function number is selected through the
_________ register.
Question #1A
• Unlike DOS INT 21h, or BIOS INT10h,
with the mouse BIOS functions, the
function number is selected through the
____AL_____ register.
Question #2
• Write ASM statements that reset the mouse
and get the mouse status.
Need to find out…
• Which INT 33h function handles resetting
the mouse and getting the status?
– Look at slides
– Look in book – page 566-574
Resetting Mouse Returns
• If mouse is found,
– AX = FFFFh
– BX = number of mouse buttons
• If no mouse found,
– AX = 0
Question #2 Solutions
Write ASM statements that reset the mouse and get
the mouse status.
• Mov
• Int
• Cmp
ax, 0
33h
ax, 0
;int 33h, function 0
;status returned in ax
;if ax=0, mouse not available
Comments about resetting mouse
• If mouse is found:
–
–
–
–
–
–
It is centered on the screen
It’s display page is set to video page 0
It’s pointer is hidden
It’s mickey’s are set to pixels ratio
It’s speed is set to default values
It’s range of movement is set to the entire
screen area.
Question #3
• Which INT 33h function shows and hides
the mouse pointer?
Question #3 Solutions
• Which INT 33h function shows and hides
the mouse pointer?
Function 1 – show
Function 2 - hide
Question #4
• Write ASM statements that hide the mouse
pointer.
Question #4
• Write ASM statements that hide the mouse
pointer.
Mov ax, 2
Int 33h
Comments about mouse pointer
• Mouse driver keeps a counter
– Incremented (if nonzero) by calls to function 1
– Decremented by calls to function 2
• When counter is 0, pointer is displayed
• Function 0 (reset mouse pointer) sets
counter to –1.
Question #5
• Which INT 33h function gets the mouse
position and status?
Question #5
• Which INT 33h function gets the mouse
position and status?
Function 3
Question #6
• Write ASM statements that get the mouse
position and store it in the variables
mouseX and mouseY.
Before Answering,
Need to Know…..
• What is returned
• BX = mouse button status
• If bit 0 is set, left button is down
• If bit 1 is set, right button is down
• If bit 2 is set, middle button is down
• CX = X-Coordinate
• DX = Y-Coordinate
Question #6 Solutions
• Write ASM statements that get the mouse
position and store it in the variables
mouseX and mouseY.
mov ax, 3
int 33h
mov mouseX, CX
mov mouseY, DX
Question #7
• Which INT 33h function sets the mouse
position?
Question #7
• Which INT 33h function sets the mouse
position?
Function 4
Question #8
• Write ASM statements that set the mouse
pointer to X=100 and Y = 400.
Before Answering
Need to know…
What to send…
• CX = X-Coordinate
• DX = Y-Coordinate
Question #8
• Write ASM statements that set the mouse
pointer to X=100 and Y = 400.
Mov ax, 4
mov cx, 100
mov dx, 400
int 33h
Question #9
• Which INT 33h function gets the mouse
button press information?
Question #9
• Which INT 33h function gets the mouse
button press information?
Function 5
Question #10
• Write ASM statements that jump to label
Button1 when the left mouse button has
been pressed.
Before Answering,
Need to know …
• What to send…
• BX = Button ID (0=left, 1=right, 2=center)
•
•
•
•
•
What is returned….
AX = button status
BX = button press counter
CX = X-coordinate of last button press
DX = Y-coordinate of last button press
Question #10 Solutions
• Write ASM statements that jump to label Button1
when the left mouse button has been pressed.
mov ax, 5
mov bx, 0
int
33h
tst
ax, 0
jz
Button1
Comments about Button Press
• In an event-driven programming
environment, a drag event always begins
with a button press.
• Once a call is made to this function for a
particular button, the button’s state is reset,
and a second call to the function returns
nothing.
Question #11
• Which INT 33h function gets button release
information?
Question #11
• Which INT 33h function gets button release
information?
Function 6
Question #12
• Write ASM statements that get the mouse
position at the point when the right button
was released, and store the position in the
variables mouseX and mouseY.
Question #12
• Write ASM statements that get the mouse position
at the point when the right button was released,
and store the position in the variables mouseX and
mouseY.
mov ax, 6
mov bx, 1
int
33h
mov mouseX, CX
mov mouseY, DX
Question #13
• Write ASM statements that set the vertical
limits of the mosue to 200 and 400.
Question #13
• Write ASM statements that set the vertical
limits of the mouse to 200 and 400.
mov ax, 8
mov CX, 200
mov DX, 400
int 33h
Question #14
• Write ASM statements that set the
horizontal limits of the mouse to 300 and
600.
Question #14
• Write ASM statements that set the
horizontal limits of the mouse to 300 and
600.
mov ax, 7
mov cx, 300
mov dx, 400
int 33h
Download