|
|
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 - metrics - download
Length: 9088 (0x2380)
Types: TextFile
Names: »MOUSE1B.A86«
└─⟦7ea4c8a73⟧ Bits:30004203 GSX driver sourcer disk 2
└─⟦this⟧ »MOUSE1B.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
;
sio1b_baud equ 582h
pit_cmd_reg equ 586h
pit_1_mode_byte equ 76h
pit_1_cnt equ 41h ;1200 baud
sio1a_ctrl equ 404h
sio1b_ctrl equ 406h
sio1b_data equ 402h
sio1_eoi equ 38h
wr1_byte equ 1e01h
wr2_byte equ 0002h
wr3_byte equ 0c103h
wr4_byte equ 4404h
wr5_byte equ 0ea05h
mouse_int_vector_offset equ 4*4ch
;
;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_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,pit_cmd_reg
mov al,pit_1_mode_byte
out dx,al
mov dx,sio1b_baud
mov ax,pit_1_cnt
out dx,al
mov al,ah
out dx,al
mov dx,sio1b_ctrl
call sio_init
; 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 cs:ÆbxÅ,ax ;save the int offset
mov ax,es:W_2ÆsiÅ
mov cs: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
popf
ret
;--------
sio_init:
;--------
mov al,18H ;reset twice
out dx,al
mov al,10h
out dx,al
mov al,30h
out dx,al
mov ax,wr4_byte
call sendout
mov ax,wr3_byte
call sendout
mov ax,wr5_byte
call sendout
mov ax,wr2_byte
call sendout
mov ax,wr1_byte
call sendout
ret
;-------
sendout:
;-------
;
out dx,al ! nop ! nop
push ax
mov al,ah
out dx,al ! nop ! nop
pop ax
ret
;
;mouse_deinit
; turn off the recieve interrupts
; put back interrupt vector
;
mouse_deinit:
pushf
cli
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,cs:ÆbxÅ
mov es:ÆsiÅ,ax ;save the int offset
mov ax,cs:W_2ÆbxÅ
mov es:W_2ÆsiÅ,ax ;save the int segment
pop es
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,sio1b_ctrl
mov al,2
out dx,al
in al,dx
cmp al,8
je my_int
pop ax
pop bx
pop dx
pop ds
jmpf cs:dword ptr old_int_jmp
my_int:
mov dx,sio1b_data
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:
mov al,sio1_eoi
mov dx,sio1a_ctrl
out dx,al
mov dx,sio1b_ctrl
out dx,al
pop ax
pop bx
pop dx
pop ds
iret
old_int_jmp rs 0 ;double word ptr to old int
mouse_int_vec_save dw 0 ;storage for old interrupt vec offset
dw 0 ;storage for old interrupt vec segment
;******************************************************************************
;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»