|
DataMuseum.dkPresents historical artifacts from the history of: CP/M |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about CP/M Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - download
Length: 7808 (0x1e80) Types: TextFile Names: »MOUSEPC.A86«
└─⟦7ea4c8a73⟧ Bits:30004203 GSX driver sourcer disk 2 └─ ⟦this⟧ »MOUSEPC.A86«
eject ;Modificeret til pc com1: på CR16 af Erling Skjoldborg ;History ;Name Date Descriptiton ; DH 9/26/83 Modified mouse init code to not use ros calls ; ;Mouse Systems Corp. ;Driver ;9/3/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 * ; * ; * ;****************************************************************************** ;these two equates must be changed for a different comm port ; port_number equ 0 ;selects port 0,1 recieve_port equ 3f8h ;port 0 ; int_enable_port equ recieve_port+1 line_control equ recieve_port+3 mouse_int_vector_offset equ 4*45h ; ;this equate does not require change ; mouse_byte_count equ 5 ;number of bytes per mouse string mouse_function: cmp bl,4 jc mouse_function_branch xor al,al ret mouse_function_branch: xor bh,bh shl bx,1 ;index by 2 into table call mscjtbÆbxÅ ret dseg mscjtb dw offset mouse_inquire ;inquire mouse available dw offset mouse_init ;mouse initialization dw offset mouse_deinit ;de initialize the mouse dw offset mouse_status ;mouse status / delta x, delta y mouse_int_table dw offset mouse_int_byte2 dw offset mouse_int_byte5 dw offset mouse_int_byte4 dw offset mouse_int_byte3 dw offset mouse_int_byte2 dw offset mouse_int_byte2 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_vec_save dw 0 ;storage for old interrupt vec offset dw 0 ;storage for old interrupt vec segment mouse_int_status db 0 ;interrupt routine status byte tmous1 dw 0 ;temporary storage for deltax tmous2 dw 0 ;temporary storage for deltay cseg ; ;mouse_inquire ; returns whether a mouse is available or not ; ; entry none ; exit al = 0 no mouse ; al > 0 mouse ; mouse_inquire: mov al, mouse ;0-mouse off, 0ffh-mouse on ret ; ;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 ; mouse_init: pushf ;turn off interrupts cli xor ax,ax mov mouse_status_byte, al ;clear mouse status byte. mov mouse_switch_byte, al ;clear switch status byte. mov mouse_count,mouse_byte_count ;init byte count mov mouse_deltax,ax ;init delta x mov mouse_deltay,ax ;init delta y ; init baud rate mov dx,line_control ;init the baud rate mov al,10000011b out dx,al ;set divisor access bit mov dx,recieve_port mov al,60h out dx,al mov al,0 inc dx out dx,al ;set to 1200 baud mov dx,line_control mov al,00000011b ;8 bit/char no parity 1 stop out dx,al ; init interrupt vector push es ;save extra segment 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 mov ax,offset mouse_int_vector 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,int_enable_port mov al,1 out dx,al ;enable rx int of 8250 mov dx,int_enable_port+3 mov al,8 out dx,al ;enable interrupts to board mov dx,602h in al,dx and al,11011111b ;enable comm 1 interrupt out dx,al ;init the 8259 comm interrupt popf ret ; ;mouse_deinit ; turn off the recieve interrupts ; put back interrupt vector ; mouse_deinit: pushf cli mov dx,int_enable_port ;turn off interrupts xor al,al out dx,al popf ret ; ;mouse_status ; routine returns the current state of the mouse ; 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 ;****************************************************************************** ;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 * ; * ; ;****************************************************************************** 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,recieve_port in al,dx ;get byte from mouse mov ah,al ;save the new byte cmp mouse_count, mouse_byte_count ;test if first byte of sequence jnz other_mouse_bytes ;if not then process others and al,0f8h ;make sure it is first one cmp al,80h jnz mouse_int_exit ;wait till first byte not ah ;make a closeure = 1 and ah,7 ;mask off the switch bits jnz mouse_switch ;handle swithches if set mov mouse_int_status,2 ;set flag saying coord info dec mouse_count ;was first byte jmps mouse_int_exit other_mouse_bytes: cbw ;get the delta value (16 BITS) mov bl,mouse_count xor bh,bh shl bx,1 jmp mouse_int_tableÆbxÅ mouse_int_byte2: mov tmous1,ax ;save delta x1 jmps mouse_int_exit0 mouse_int_byte3: mov tmous2,ax ;save delta y1 jmps mouse_int_exit0 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,mouse_byte_count jmps mouse_int_exit mouse_int_byte4: add tmous1,ax mouse_int_exit0: dec mouse_count mouse_int_exit: 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 ;****************************************************************************** mouse_switch: cmp mouse_int_status,1 ;was switch pressed last time jz mouse_int_exit ;if so don't process string mov mouse_switch_byte,20h test ah,4 jnz mouse_switch_exit inc mouse_switch_byte test ah,2 jnz mouse_switch_exit inc mouse_switch_byte mouse_switch_exit: mov mouse_int_status,1 ;switch avail dec mouse_count jmps mouse_int_exit «eof»