CS-220, Sec.90, Week 12-B R. Eckert MOUSE INPUT The mouse is an input device that, when moved, sends data on how far it has moved in the horizontal (x) direction and the vertical (y) direction. The mouse also has buttons that can be pressed or released. When the user presses or releases any of these buttons, an interrupt is generated. A terminate-and-stay-resident (TSR) program called the mouse driver, which is normally loaded by the operating system when the computer is booted, receives data sent by the mouse. The mouse driver causes a small image, called the mouse cursor, to move on the computer's screen. The number of pixels moved by the mouse cursor is proportional to the change in position of the physical mouse. The operating system provides a series of "mouse services" through software interrupt 33h. We can use these services in our assembly language programs to receive input information from the mouse and control it and the mouse cursor. Some of the more inportant services are given in the table below. (See pp. 383-396 of the Abel text book for a complete listing of the int 33h mouse services.) In each case the service is selected by placing a "function number" in AX register prior to executing the int 33h. Function In Register Values Out Register Values -------------------------------------------------------------------------- Reset mouse AX=0 AX=0FFFFh if mouse is supported BX=number of buttons Show mouse cursor AX=1 Hide mouse cursor AX=2 Poll mouse cursor, AX=3 BX[bit-0]=1==>Left button pressed position & button- BX[bit-1]=1==>Right button pressed press status BX[bit-2]=1==>Middle button pressed CX=Current x virtual screen coord. DX=Current y virtual screen coord. Set mouse cursor AX=4 position CX=x, DX=y Button press info AX=5 AX[bit-0]=1==>Left button pressed BX=Button (L=0, AX[bit-1]=1==>Right button pressed R=1, M=2) AX[bit-2]=1==>Middle button pressed BX=# of button presses since last call CX=x, DX=y at posn of last button press Button release info AX=6 Same as button press, but for button BX=Button releases DRAWING A LINE BETWEEN 2 POINTS LEFT-CLICKED WITH MOUSE 2nd point flag = 0 | | Initialize (reset) mouse (AX=0, int 33h) | | Show mouse cursor (AX=1, int 33h) | | <-------------------------<------------------------- | ^ ^ Was Left button pressed? | | (AX=5, BX=0, int 33h) | | (Is BX != 0?) --------------------> | | no | | yes | | | Is 2nd point flag = 1? -----> 2nd point flag = 1 ----->Save x,y coords | no | yes | Call line-drawing procedure (1st point coords from stored value, 2nd point coords in CX,DX)