eject ;History ;Name Date Descriptiton ; DH 9/26/83 Modified mouse init code to not use ros calls ; DH 12/24/83 Modified to handle all mice/ports ; DH 3/3/84 Modified to put interrupt controller mask back (turn off int) ; ;Mouse Systems Corp. ;Driver ;12/24/83 ;****************************************************************************** ;mouse_function * ; Entry point for all mouse code * ; * ; Entry cl = function number * ; * ; bl = 0 Reserved * ; * ; bl = 1 Initialize mouse * ; Set's baud rate, parity, stop bits * ; Initializes the interrupt vector location * ; * ; Exit none * ; * ; bl = 2 Deinitialize the mouse * ; Puts interrupt vector location back * ; Turns off receive interrupt * ; * ; Exit none * ; * ; bl = 3 Return mouse status/coordinates * ; * ; Exit * ; * ; al = 0 nothing happened * ; * ; al = 1 button press * ; ah = character information * ; * ; al = 2 coordinate information * ; bx = delta x * ; cx = delta y * ; * ; * ;****************************************************************************** ; mouse_function: cmp bl,4 jc mouse_function_branch xor al,al ret mouse_function_branch: dec bl ;make 0-2 xor bh,bh mov cl,4 shl bx,cl ;index into table by function type mov al,mouse_type shl al,1 ;each type takes 2 bytes or bl,al call mscjtb[bx] ret dseg ; ;mouse patch point ;the following bytes will be patched by ginstall mouse_patch db 'zyxg' mouse_port db 0 ;default is com1 mouse_type db 0 ;default is none ; ;the following bytes are global variables which are initialized by mouse init ; mouse_recieve_port dw 03f8h ;default comm port address mouse_mask_byte db 11101111b ;default mouse mask byte mouse_int_vector_offset dw 4*(0ch) mouse_int_vec_save dw 0 ;storage for old interrupt vec offset dw 0 ;storage for old interrupt vec segment ; ;the following are variables for the microsoft mouse ; ms_mouse_avail db 0 ;default is no ms_mouse_int_status db 0 ; ;the following are variables for the pc/summa mice ; mscjtb dw offset no_mouse_init ;no_mouse initialization dw offset pc_mouse_init ;mouse systems initialization dw offset ms_mouse_init ;microsoft mouse initialization dw offset su_mouse_init ;summa graphics mouse init dw offset no_mouse_init dw offset no_mouse_init dw offset no_mouse_init dw offset no_mouse_init ; dw offset no_mouse_deinit ;no mouse de initialization dw offset pc_mouse_deinit ;mouse systems de init dw offset ms_mouse_deinit ;microsoft mouse de init dw offset su_mouse_deinit ;summa graphics mouse deinit dw offset no_mouse_deinit dw offset no_mouse_deinit dw offset no_mouse_deinit dw offset no_mouse_deinit ; dw offset no_mouse_status ;no mouse status dw offset pc_mouse_status ;pc mouse status / delta x, delta y dw offset ms_mouse_status ;ms mouse status dw offset su_mouse_status dw offset no_mouse_status dw offset no_mouse_status dw offset no_mouse_status dw offset no_mouse_status ; pc_mouse_int_table dw offset pc_mouse_int_byte2 dw offset pc_mouse_int_byte5 dw offset pc_mouse_int_byte4 dw offset pc_mouse_int_byte3 dw offset pc_mouse_int_byte2 dw offset pc_mouse_int_byte2 ;the following bytes are common to any rs232 mouse ; mouse_count db 5 ;byte count for mouse mouse_status_byte db 0 ;status byte for mouse mouse_switch_byte db 0 ;switch byte for mouse mouse_deltax dw 0 ;mouse delta x value mouse_deltay dw 0 ;mouse delta y value mouse_int_status db 0 ;interrupt routine status byte tmous1 dw 0 ;temporary storage for deltax tmous2 dw 0 ;temporary storage for deltay ; ;this equate does not require change ; pc_mouse_byte_count equ 5 ;pc mouse bytes / string su_mouse_byte_count equ 3 ;summa mouse bytes/string cseg ; ;no_mouse_init ; initializes the mouse ; ; entry none ; exit ; mouse_status_byte cleared ; mouse_switch_byte cleared ; deltax,deltay = 0 ; mouse port baud rate, stop bits,parity set ; mouse port interrupt vector inited ; mouse port recieve interrupt turned on ; no_mouse_init: xor al,al ret ; ;pc_mouse_init ; initializes a mouse systems compatible mouse ; ; entry none ; exit ; mouse_status_byte cleared ; mouse_switch_byte cleared ; deltax,deltay = 0 ; mouse port baud rate, stop bits,parity set ; mouse port interrupt vector inited ; mouse port recieve interrupt turned on ; pc_mouse_init: pushf ;turn off interrupts cli call clear_mouse_status_bytes mov mouse_count,pc_mouse_byte_count ;init byte count mov al,00000011b ;8 data bits no parity 1 stop call init_mouse_port mov ax,offset pc_mouse_int_vector ;point to the int routine call init_mouse_int_vector popf ret ; ;ms_mouse_init ; initializes a microsoft compatible mouse ; ; entry none ; exit ; ms_mouse_init: xor ax,ax push es mov ms_mouse_int_status,al mov ms_mouse_avail,al mov es,ax ;test if mouse is installed mov bx,0cch mov ax,es:[bx] pop es and ax,ax jz ms_mouse_init_done xor ax,ax int 33h ;init the mouse mov ms_mouse_avail,0ffh ms_mouse_init_done: ret ; ;su_mouse_init ; initializes a summa graphics compatible mouse ; ; entry none ; exit ; mouse_status_byte cleared ; mouse_switch_byte cleared ; deltax,deltay = 0 ; mouse port baud rate, stop bits,parity set ; mouse port interrupt vector inited ; mouse port recieve interrupt turned on ; su_mouse_init: pushf ;turn off interrupts cli call clear_mouse_status_bytes mov mouse_count,su_mouse_byte_count ;init byte count mov al,00001011b ;8 data bits odd parity 1 stop call init_mouse_port mov ax,offset su_mouse_int_vector ;point to the int routine call init_mouse_int_vector mov dx,mouse_recieve_port mov al,20h out dx,al ;send a space for baud rate popf ret clear_mouse_status_bytes: xor ax,ax mov mouse_status_byte, al ;clear mouse status byte. mov mouse_switch_byte, al ;clear switch status byte. mov mouse_deltax,ax ;init delta x mov mouse_deltay,ax ;init delta y ret ; ;initialize the mouse comm port to 1200 baud,8 data,no parity,1 stop ; init_mouse_port: push ax mov al,mouse_port ;get the mouse port # 0,1 and al,al mov mouse_recieve_port,3f8h mov mouse_mask_byte,11101111b mov mouse_int_vector_offset,4*(0ch) jz set_mouse_baud mov mouse_recieve_port,2f8h mov mouse_mask_byte,11110111b mov mouse_int_vector_offset,4*(0bh) set_mouse_baud: ; init baud rate pop ax ;save line control byte push ax mov dx,mouse_recieve_port add dx,3 ;point at line_control or al,80h ;set the divisor access bit out dx,al ;set divisor access bit push dx mov dx,mouse_recieve_port mov al,60h out dx,al mov al,0 inc dx out dx,al ;set to 1200 baud pop dx ;dx = line control port pop ax ;get the line control byte back out dx,al ret init_mouse_int_vector: ; init interrupt vector push es ;save extra segment push ax ;save mouse_int_vector mov ax,0 mov es,ax mov bx,offset mouse_int_vec_save mov si,mouse_int_vector_offset mov ax,es:[si] mov [bx],ax ;save the int offset mov ax,es:W_2[si] mov W_2[bx],ax ;save the int segment pop ax ;get the vector back mov es:[si],ax ;load the new offset mov ax,cs mov es:W_2[si],ax ;load the new segment pop es ; init recieve interrupt mov dx,mouse_recieve_port inc dx mov al,1 out dx,al ;enable rx int of 8250 add dx,3 ;int_enable_port+3 mov al,8 out dx,al ;enable interrupts to board mov dx,21h in al,dx and al,mouse_mask_byte ;make sure the 8259 is on out dx,al ;init the 8259 comm interrupt ret EJECT ; ;no_mouse_deinit ;none required no_mouse_deinit: ret ; ;pc_mouse_deinit ; turn off the recieve interrupts ; put back interrupt mask ; pc_mouse_deinit: pushf cli mov dx,mouse_recieve_port inc dx ;int enable port xor al,al out dx,al ;turn off interrupts mov dx,21h in al,dx mov ah,mouse_mask_byte not ah or al,ah out dx,al ;deinit the 8259 comm interrupt popf ret ; ;ms_mouse_deinit ; none required ms_mouse_deinit: ret ; ;su_mouse_deinit ; turn off the recieve interrupts ; put back interrupt vector ; su_mouse_deinit: jmps pc_mouse_deinit EJECT ;no_mouse_status ; routine returns the current state of the mouse ; no_mouse_status: xor ax,ax ret ;pc_mouse_status ; routine returns the current state of the mouse ; pc_mouse_status: pushf cli mov al, mouse_status_byte ;get the status of the mouse mov ah, mouse_switch_byte mov mouse_status_byte,0 mov bx, mouse_deltax mov cx, mouse_deltay mov mouse_deltax,0 mov mouse_deltay,0 popf ret ;ms_mouse_status ; routine returns the current state of the mouse ; ms_mouse_status: pushf cli mov al,ms_mouse_avail and al,al jz no_mouse_installed push dx mov ax,11 int 33h mov bx,cx ;get the current delta x mov cx,dx ;get the current delta y neg cx ;flip it over push cx push bx mov ax,3 int 33h ;get the button status and bl,3 jnz ms_mouse_switch ;if button pressed handle it mov ms_mouse_int_status,0 pop bx pop cx mov dx,bx or dx,cx ;test if delta value returned mov al,0 jz ms_mouse_int_exit mov al,2 ;flag coord infor returned ms_mouse_int_exit: pop dx popf ret no_mouse_installed: mov ax,0 popf ret ms_mouse_switch: mov al,0 ;set the status to nothing pop cx pop cx ;clear the stack mov ah,21h test bl,2 jnz ms_mouse_switch_exit dec ah ms_mouse_switch_exit: cmp ms_mouse_int_status,1 ;was switch pressed last time jz ms_mouse_int_exit ;if so don't process string mov al,1 mov ms_mouse_int_status,al ;switch avail jmps ms_mouse_int_exit ;su_mouse_status ; routine returns the current state of the mouse ; su_mouse_status: jmp pc_mouse_status eject ;****************************************************************************** ;pc_mouse_int_vector * ; Mouse Systems Corp Mouse interrupt vector routine * ; * ; Exit * ; mouse_status_byte * ; = 0 nothing happened * ; * ; = 1 button press * ; mouse_switch_byte * ; = character information * ; * ; = 2 coordinate information * ; mouse_deltax = delta x * ; mouse_deltay = delta y * ; * ; ;****************************************************************************** pc_mouse_int_vector: push ds push dx push bx push ax mov ax,seg mouse_count mov ds,ax ;load of data segment mov dx,mouse_recieve_port in al,dx ;get byte from mouse mov ah,al ;save the new byte cmp mouse_count, pc_mouse_byte_count ;test if first byte of sequence jnz pc_other_mouse_bytes ;if not then process others and al,0f8h ;make sure it is first one cmp al,80h jnz pc_mouse_int_exit ;wait till first byte not ah ;make a closeure = 1 and ah,7 ;mask off the switch bits jnz pc_mouse_switch ;handle swithches if set mov mouse_int_status,2 ;set flag saying coord info dec mouse_count ;was first byte jmps pc_mouse_int_exit pc_other_mouse_bytes: cbw ;get the delta value (16 BITS) mov bl,mouse_count xor bh,bh shl bx,1 jmp pc_mouse_int_table[bx] pc_mouse_int_byte2: mov tmous1,ax ;save delta x1 jmps pc_mouse_int_exit0 pc_mouse_int_byte3: mov tmous2,ax ;save delta y1 jmps pc_mouse_int_exit0 pc_mouse_int_byte5: add ax, tmous2 ;get y value add mouse_deltay,ax mov ax, tmous1 ; get x value add mouse_deltax,ax mov al,mouse_int_status mov mouse_status_byte,al mov mouse_count,pc_mouse_byte_count jmps pc_mouse_int_exit pc_mouse_int_byte4: add tmous1,ax pc_mouse_int_exit0: dec mouse_count pc_mouse_int_exit: mov al,20h out 20h,al ;send 8259 an eoi pop ax pop bx pop dx pop ds iret ;****************************************************************************** ;mouse_switch ; mouse switch handling routine ; ; entry ah = 00000sss ; where s=switch bit ; ; exit to mouse_int_exit ; uses ax ;****************************************************************************** pc_mouse_switch: cmp mouse_int_status,1 ;was switch pressed last time jz pc_mouse_int_exit ;if so don't process string mov mouse_switch_byte,20h test ah,4 jnz pc_mouse_switch_exit inc mouse_switch_byte test ah,2 jnz pc_mouse_switch_exit inc mouse_switch_byte pc_mouse_switch_exit: mov mouse_int_status,1 ;switch avail dec mouse_count jmps pc_mouse_int_exit ;****************************************************************************** ;su_mouse_int_vector * ; SummaGraphics Mouse interrupt vector routine * ; * ; Exit * ; mouse_status_byte * ; = 0 nothing happened * ; * ; = 1 button press * ; mouse_switch_byte * ; = character information * ; * ; = 2 coordinate information * ; mouse_deltax = delta x * ; mouse_deltay = delta y * ; * ; ;****************************************************************************** su_mouse_int_vector: push ds push dx push cx push bx push ax mov ax,seg mouse_count mov ds,ax ;load of data segment mov dx,mouse_recieve_port in al,dx ;get byte from mouse mov ah,al ;save the new byte cmp mouse_count, su_mouse_byte_count ;test if first byte of sequence jnz su_other_mouse_bytes ;if not then process others test al,80h ; is it the first byte ? jz su_mouse_int_exit ;wait till first byte mov cl,3 mov tmous2,ax ;save the sign bits rol tmous2,cl and ah,7 ;mask off the switch bits jnz su_mouse_switch ;handle swithches if set mov mouse_int_status,2 ;set flag saying coord info dec mouse_count ;was first byte jmps su_mouse_int_exit su_other_mouse_bytes: xor ah,ah rol tmous2,1 jc su_no_neg neg ax ;get the delta value (16 BITS) su_no_neg: cmp mouse_count,2 jz su_mouse_int_byte2 add mouse_deltay,ax mov ax,tmous1 add mouse_deltax,ax mov al,mouse_int_status mov mouse_status_byte,al mov mouse_count,su_mouse_byte_count jmps su_mouse_int_exit su_mouse_int_byte2: mov tmous1,ax ;save delta x1 dec mouse_count su_mouse_int_exit: mov al,20h out 20h,al ;send 8259 an eoi pop ax pop bx pop cx pop dx pop ds iret ;****************************************************************************** ;mouse_switch ; mouse switch handling routine ; ; entry ah = 00000sss ; where s=switch bit ; ; exit to mouse_int_exit ; uses ax ;****************************************************************************** su_mouse_switch: cmp mouse_int_status,1 ;was switch pressed last time jz su_mouse_int_exit ;if so don't process string mov mouse_switch_byte,20h test ah,4 jnz su_mouse_switch_exit inc mouse_switch_byte test ah,2 jnz su_mouse_switch_exit inc mouse_switch_byte su_mouse_switch_exit: mov mouse_int_status,1 ;switch avail dec mouse_count jmps su_mouse_int_exit