c9c ;Function prototypes: ; int init_mouse(void) returns 0 if mouse driver not installed ; void exit_mouse(void) ; void show_mouse(void) ; void hide_mouse(void) ; void set_mouse_pos(int x, int y) ; void set_mouse_horiz(int xmin, int xmax) ; void set_mouse_vert(int ymin, int ymax) ; void set_mouse_sens(int xsens, int ysens ; int get_mouse_event(void); returns bits for mouse events ; int get_button_status(void); checks if buttons currently pressed down ; void exit_mouse(void); ;MOUSEMOVE = 1 ;LEFTBPRESS = 2 ;LEFTBRELEASE = 4 ;RIGHTBPRESS = 8 ;RIGHTBRELEASE = 16 DOSSEG .MODEL SMALL .386 .DATA PUBLIC _mousex, _mousey _mousex word 0 _mousey word 0 .DATA? event_flags word ? mousefreeze byte ? .CODE PUBLIC _init_mouse, _exit_mouse PUBLIC _get_mouse_event, _get_button_status PUBLIC _set_mouse_horiz, _set_mouse_vert, _set_mouse_sens PUBLIC _show_mouse, _hide_mouse mousehandler PROC FAR push ax push dx push ds push DGROUP pop ds cmp byte ptr[mousefreeze], 1 jz exit_handler shr cx, 3 ; 640/8 = 80 Columns shr dx, 3 ; 200/8 = 25 Rows mov _mousex, cx ;update mouse coordinates mov _mousey, dx mov event_flags, ax ; Save event bits exit_handler: pop ds pop dx pop ax retf mousehandler ENDP _init_mouse PROC mov ax, 0 ;Mouse driver function 0 -- reset and detect int 33h cmp ax, 0 jz no_driver_installed mov mousefreeze, 1 ;Freeze handler until installation completed mov ax, 7 ; Set horiz limits mov cx, 0 ; Min mov dx, 639 ; Max int 33h mov ax, 8 ; Set vertical limits mov cx, 0 ; Min mov dx, 199 ; Max int 33h ; Now install user routine mov ax, _TEXT mov es, ax mov dx, offset mousehandler mov cx, 31 ;Bits for calling routine mov ax, 12 ;Function 12 -- set user routine int 33h mov cx, 0 ;xcoord mov dx, 0 ;ycoord mov ax,4 ;set mouse position int 33h mov mousefreeze, 0 ;Now the handler can start its work mov ax, 1 no_driver_installed: ret _init_mouse ENDP _exit_mouse PROC mov ax, 0 int 33h ret _exit_mouse ENDP _show_mouse PROC mov ax, 1 int 33h ret _show_mouse ENDP _hide_mouse PROC mov ax, 2 int 33h ret _hide_mouse ENDP _set_mouse_pos PROC push bp mov bp, sp mov cx, [bp + 4] mov dx, [bp + 6] mov ax, 4 int 33h pop bp ret _set_mouse_pos ENDP _set_mouse_horiz PROC push bp mov bp, sp mov ax, 7 mov cx, [bp + 4] mov dx, [bp + 6] int 33h pop bp ret _set_mouse_horiz ENDP _set_mouse_vert PROC push bp mov bp, sp mov ax, 8 mov cx, [bp + 4] mov dx, [bp + 6] int 33h pop bp ret _set_mouse_vert ENDP _set_mouse_sens PROC push bp mov bp, sp mov ax, 0fh mov cx, [bp+4] mov dx, [bp+6] int 33h mov ax, 13h mov dx, [bp+8] int 33h pop bp ret _set_mouse_sens ENDP _get_mouse_event PROC mov ax, event_flags mov event_flags, 0 ret _get_mouse_event ENDP _get_button_status PROC mov ax, 3 int 33h mov ax, bx ret _get_button_status ENDP END . 0