home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.update.uu.se
/
ftp.update.uu.se.2014.03.zip
/
ftp.update.uu.se
/
pub
/
rainbow
/
msdos
/
decus
/
RB140
/
grlib03a.arj
/
MSINT.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-12-08
|
8KB
|
255 lines
TITLE MSINT.ASM Microsoft Mouse interrupt service
PAGE ,132
;***********************************************
; *
; Microuse Mouse hardware dependent code *
; Copyright (C) 1983,1984 by Microsoft Inc. *
; Copyright (C) 1984 by Digital Equipment Co.*
; *
;***********************************************
include asmms.h
include asmc.h
;**********************************************
; Static data internal to interrupt handler *
;**********************************************
int_cond DW 0 ; temp store - state check
tdelta_x DB 0
tdelta_y DB 0
mstate DB 0 ; zero means looking for sync bit
m_buffer DD 0 ; ADR Communications input circular buffer
Mpacket DD 0 ; ADR MOUSE control packet "MOUSE_PACKET"
Cpacket DD 0 ; ADR MOUSE int. cond. "CONDITION_PACKET"
SUBTTL Comms Port Interrupt Handler
PAGE
;**********************************************
; Serial Mouse hardware interrupt service *
;**********************************************
PUBLIC MSint_, _Chaddr
Msint_ PROC FAR
Cld ;preserve machine state
Push DS
Push ES
Push AX
Push BX
Push CX
Push DX
Push DI
Push SI
;
; get a delta x in bx, delta y in cx
;
call getchar ;get a character from ring buffer
Lds SI,CS:Mpacket ;DS:SI = MOUSE_PACKET
Les DI,CS:Cpacket ;ES:DI = CONDITION_PACKET
test al,01000000b ;sync bit set?
jnz first_byte
jmp xory
;------------------------------------
; first byte of new 3 byte packet
; process button information
;------------------------------------
;
; first byte
;
; +----+----+----+----+----+----+----+----+
; | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
; +----+----+----+----+----+----+----+----+
; | | | | | | | |
; | | | | | | | +---- X6
; | | | | | | +--------- X7
; | | | | | +-------------- Y6
; | | | | +------------------- Y7
; | | | +------------------------ RIGHT MOUSE BUTTON
; | | +----------------------------- LEFT MOUSE BUTTON
; | +---------------------------------- 1 = FIRST BYTE (SYNCHRONIZE)
; +--------------------------------------- 7 BIT ASCII (MUST MASK)
;
first_byte:
xor dx,dx ; indicate primary button up
mov CS:[int_cond],dx ; zero interrupt conditions
mov dl,al ; get local copy of button state
mov cl,5 ; isolate the left mouse button
shr dl,cl ; low bit has p button state
mov cx,1 ; set up mask
and dx,cx ; mask off low bit
not cx ; invert
and cx,[SI].Bstate ; get all other bits
or dx,cx ; dx = new button states
xchg [SI].Bstate,dx ; move in current state get old state
cmp [SI].Bstate,dx ; has it changed?
sti ;INTS OFF while we update
jz no_pb_change
ja pb_down
;
; primary button just released
;
or CS:byte ptr [int_cond],00000100b
inc ES:WORD PTR [DI].P_button_rel
jmp short no_pb_change
;
; primary button just pressed
;
pb_down:
or CS:byte ptr [int_cond],00000010b
inc ES:WORD PTR [DI].P_button_dep
no_pb_change:
cli ;INTS ON now done
mov dl,al ; get local copy of button state
mov cl,3
shr dl,cl ; low bit has s button state
mov cx,2 ; mask off low bit
and dx,cx
not cx ; invert
and cx,[SI].Bstate ; get all other bits
or dx,cx ; dx = new button states
xchg [SI].Bstate,dx ; move in current state get old state
cmp [SI].Bstate,dx ; has it changed
sti ;INTS OFF while we update
jz no_sb_change
ja sb_down
;
; secondary button just released
;
or CS:byte ptr [int_cond],00010000b
inc ES:WORD PTR [DI].S_button_rel
jmp short no_sb_change
;
; secondary button just pressed
;
sb_down:
or CS:byte ptr [int_cond],00001000b
inc ES:WORD PTR [DI].S_button_dep
no_sb_change:
cli ;INTS ON now done
mov bx,ax ; save first byte info
mov cl,4
shl ax,cl
and al,11000000b
mov CS:[tdelta_y],al ; save hibits of delta Y
mov cl,6
shl bx,cl
and bl,11000000b
mov CS:[tdelta_x],bl ; save hibits of delta X
mov CS:[mstate],1 ; now we are looking for x...
jmp short ignore
;------------------------------------
;Process non SYNC byte
;------------------------------------
xory:
and al,00111111b
cmp CS:[mstate],1 ; are we looking for x (byte 2)
jb ignore ; if zero, ignore, we want sync
ja do_tdelta_y ; if above, must be for y (byte 3)
or CS:[tdelta_x],al
mov CS:[mstate],2 ; now we are looking for y...
ignore:
xor ax,ax
jmp short ack
;------------------------------------
;Process end of packet
;------------------------------------
do_tdelta_y:
or al,CS:[tdelta_y]
cbw
mov cx,ax ;Delta Y in CX
mov al,CS:[tdelta_x]
cbw
mov bx,ax ;Delta X in BX
mov CS:[mstate],0
mov ax,bx ; get horizontal motion
or ax,cx ; or in vertical motion
jz nomove ; if zero, cursor didnt move
sti ;INTS OFF while we update
add [SI].Deltax,bx ; update Delta X
add [SI].Deltay,cx ; update delta Y
or CS:byte ptr [int_cond],00000001b ; cursor moved..remember
cli ;INTS ON now done
nomove: mov ax,CS:[int_cond] ; ax=reason for calling MS-WIN
ack:
Pop SI ;restore state
Pop DI
Pop DX
Pop CX
Pop BX
Pop AX
Pop ES
Pop DS
ret
;GETCHAR - routine to fetch next character out of m_buffer
getchar PROC NEAR
Lds SI,CS:m_buffer ;DS:SI = M_buffer
mov ax,[SI].count ;pick up char count
and ax,ax ;any char avail?
jz getcha3
sti ;INTS OFF while we update
dec ax ;decrement char count
mov [SI].count,ax ;update buffer count
mov BX,[SI].opntr ;character pntr
mov ax,[BX]
cmp BX,[SI].tail ;at end?
jnz getcha1
mov BX,[SI].head ;yes - point at head
jmp short getcha2
getcha1:
inc BX ;step to next char
inc BX
getcha2:
mov [SI].opntr,BX ;save new pntr
cli ;INTS ON now done
getcha3:
ret ;return (char in AX)
getchar ENDP
MSint_ ENDP
SUBTTL establish links with C program
PAGE
ASSUME ES:NOTHING
;***********************************************
;Return Address for C program
;***********************************************
; CS:OFFSET = _Chaddr(mptr,cptr,buffer);
; CONDITION_PACKET *mptr;
; MOUSE_PACKET *cptr
; char *buffer;
PROCDEF _Chaddr
Push BP
Mov BP,SP
Mov AX,@AB[BP] ; Mpacket = mptr
Mov CS:WORD PTR Mpacket,AX
Mov CS:WORD PTR Mpacket+2, DS
Mov AX,@AB+2[BP] ; Cpacket = cptr
Mov CS:WORD PTR Cpacket,AX
Mov CS:WORD PTR Cpacket+2, DS
Mov AX,@AB+4[BP] ; m_buffer = buffer
Mov CS:WORD PTR m_buffer,AX
Mov CS:WORD PTR m_buffer+2, DS
Mov AX, CS:Cloc ; return interrupt offset
Mov SP,BP
Pop BP
Ret
Cloc Dw MSint_
PROCEND _Chaddr
include epilogue.h
END