home *** CD-ROM | disk | FTP | other *** search
- IFNDEF TP4
- PAGE 60,132
- ;----------------------------------------------------------------------------
- SUBTTL TesSeRact Revision Level 1
- ;-----------------------------------------------------------------------------
- ; TesSeRact(tm) -- A Library of Routines for Creating Ram-Resident (TSR)
- ; programs for the IBM PC and compatible Personal
- ; Computers.
- ;
- ;The software, documentation and source code are:
- ;
- ; Copyright (C) 1986, 1987, 1988 Tesseract Development Team
- ; All Rights Reserved
- ;
- ; c/o Chip Rabinowitz
- ; Innovative Data Concepts
- ; 2084 Woodlawn Avenue
- ; Glenside, PA 19038
- ; 1-215-884-3373
- ;
- ;-----------------------------------------------------------------------------
- ; This product supports the TesSeRact Standard for Ram-Resident Program
- ; Communication. For information about TesSeRact, contact the TesSeRact
- ; Development Team at:
- ; Compuserve: 70731,20
- ; MCIMAIL: 315-5415
- ; This MCIMAIL Account has been provided to the TesSeRact Development
- ; Team by Borland International, Inc. The TesSeRact Development Team
- ; is in no way associated with Borland International, Inc.
- ;-----------------------------------------------------------------------------
-
-
- INCLUDE TESS.INC
- IFDEF ALLPUBLIC
- INCLUDE tsint8.pub
- ENDIF
-
- .MODEL small
-
- .CODE
-
- EXTRN _TESSDOPOPUP:near
- EXTRN TESSBEEP:FAR
- EXTRN _TESSSTUFFKEYS:near
-
- EXTRN TESS_GLOBALS:byte
- EXTRN TESS_USERPARMS:byte
-
- PUBLIC newint8, _TESSSTOREKEYS, _TESSCLEARKEYS
-
- ENDIF
-
- KbdCount dw 0
- StuffSpeed db 0
- StuffCount dw 0
-
- KBDBEGIN equ $
-
- KbdBuffer dw 80 dup(?)
-
- KBDEND equ $-2
-
- MAXKBDSIZE equ (KBDEND - KBDBEGIN) / 2
-
- KbdHead dw KBDBEGIN
- KbdTail dw KBDBEGIN
-
- wait8 db 8
- KbdCleared db 0
-
- _TESSCLEARKEYS proc near
-
- ASSUMEDS
-
- push ax
-
- xor ax,ax
- mov KbdCount,ax ;say no more keys are waiting
- mov ax,offset KBDBEGIN ;reset buffer pointers
- mov KbdHead,ax
- mov KbdTail,ax
-
- mov KbdCleared,18 ;flag value
-
- pop ax
-
- ret
- _TESSCLEARKEYS endp
-
- _TESSSTOREKEYS proc near
- ;
- ; on entry, es:di points to buffer, SI contains number of
- ; chars to stuff, dl has speed, dh = 0 to stuff words, 1
- ; to stuff just chars
- ;
- ;
- ASSUMENODS
-
- push ds
-
- push cs
- pop ds
-
- ASSUMEDS
-
-
- mov al,KbdCleared ;did we get a ^C?
- or al,al
- jnz clear_buffer ;yep ... signal on return
-
- or si,si ;if no chars, just exit
- jz not_enough_room
-
- cli
-
- mov ax,MAXKBDSIZE
- sub ax,[KbdCount] ;how many are already there?
-
- cmp ax,si ;is there room?
- jbe not_enough_room
-
- mov cx,si
-
- mov StuffSpeed,dl
- store_them:
- mov bx,[KbdTail] ;load pointer
-
- or dh,dh
- jz store_both
-
- mov al,es:[di] ;store the ascii code
- xor ah,ah
- cmp al,0dh ;is it a CR
- jne done_fetch
-
- mov ah,1ch ;yep, add scan code
- jmp short done_fetch
-
- store_both:
- mov ax,es:[di] ;load the word
- inc di
- done_fetch:
- inc di
- mov [bx],ax ;store it in buffer
-
- inc bx ;advance buffer, and wrap if needed
- inc bx
- cmp bx,offset KBDEND
- jne dont_wrap1
-
- mov bx,offset KBDBEGIN
-
- dont_wrap1:
- mov [KbdTail],bx ;save end of buffer away
- inc [KbdCount]
-
- loop store_them
-
- xor ax,ax
- jmp short store_out
-
- clear_buffer:
- mov ax,0f0f0h ;signal ^C
- mov KbdCleared,0
- jmp short store_out
- not_enough_room:
- xor ax,ax
- dec ax
- store_out:
- sti
- pop ds
- ret
-
- _TESSSTOREKEYS endp
-
- ;---------------------------------------------------------------------;
- ; Interrupt 8 pops an application over a running program ;
- ;---------------------------------------------------------------------;
- newint8 proc far
-
- ASSUMENODS
-
- ; IF TIMER CODE IS STILL BUSY, GO DIRECTLY TO BIOS TIMER CODE
-
- push ds
-
- pushf
-
- push cs
- pop ds ;recover our Datasegment address
-
- ASSUMEDS
-
- mov BPTR [WASINT8],1
-
- ;---------------------------------------------------------------------;
- ; NOTE: We don't want to be releasing a TSR from inside an INT8
- ; popup routine!
- ;---------------------------------------------------------------------;
- ; test WPTR [STATUS],TSRRELEASED
- ; jnz dorel8
-
- test WPTR [STATUS],TSRENABLED
- jz do_old8
-
- dorel8:
- test BPTR [SOFTINTFLAGS],ININT08 ;See if recursion has taken place
- jz start_new_int8 ;If not continue with new int 8
- do_old8:
- POPFF
- pop ds
-
- ASSUMENODS
-
- jmp DPTR [OLDINT8] ;Jump to original int 8
-
- start_new_int8:
-
- ASSUMEDS
-
- POPFF
- or BPTR [SOFTINTFLAGS],ININT08 ;Set the int 8 active flag
-
- push dx
- push cx ;save regs
- push bx
- push ax
- push di
-
- ; call the original Timer interrupt to avoid timer tick misses
-
- pushf ;simulate interrupt ...
- call DPTR [OLDINT8] ;do the original
-
- sti ;make sure INTs are ON!!
- Start_8:
-
- mov al,KbdCleared
- or al,al
- jz checkword
-
- dec [KbdCleared]
-
- checkword:
- mov al,BPTR [WORD4DELAY]
- or al,al
- jz noword
-
- dec BPTR [WORD4DELAY]
- jnz noword
-
- or WPTR [STATUS],HOTKEYON
- noword:
- mov ax,WPTR [STATUS]
- test ax,POPUPSET
- jz again_8_2
- test ax,HOTKEYON
- jz again_8_2
- test ax,TSRACTIVE+INT28ACTIVE ;are we already running?
- jnz again_8_2
-
- wait_8:
- call Checkstatus_8
-
- jnz end_8
-
- call _TESSDOPOPUP
-
- reset_8:
- mov wait8,8
- jmp short again_8_2
- end_8:
- dec wait8
- jnz again_8_2
-
- test WPTR [STATUS],TSRRELEASED
- jnz reset_8
- and WPTR [STATUS],NOT HOTKEYON
-
- IFDEF TP4
- IFNDEF ASMCOM
- call FAR PTR TESSBEEP
- ELSE
- call TESSBEEP
- ENDIF
- ELSE
- call TESSBEEP
- ENDIF
-
- jmp short reset_8
-
- again_8_2:
- mov ax,[KbdCount]
- or ax,ax
- jz no_keys
-
- mov al,StuffSpeed
- xor ah,ah ;store speed
- mov di,ax ; in DI register
-
- mov bx,[KbdHead]
- mov ax,[bx]
-
- call _TESSSTUFFKEYS
- cmp ax,-1
- je no_keys ;no room in BIOS buffer -- try again!
-
- inc bx
- inc bx
- cmp bx,offset KBDEND
- jne dont_wrap
-
- mov bx,offset KBDBEGIN
-
- dont_wrap:
- mov [KbdHead],bx
- dec [KbdCount]
- inc [StuffCount]
-
- mov ax,di ;recover speed
- or al,al ;slow speed
- jz no_keys
-
- dec al
- jnz again_8_2
-
- cmp StuffCount,4
- jne again_8_2
-
- no_keys:
- xor ax,ax
- mov StuffCount,ax
-
- and BPTR [SOFTINTFLAGS], NOT ININT08 ;Clear the INT08 active flag
-
- ASSUMENODS
-
- pop di
- pop ax ;get back registers
- pop bx
- pop cx
- pop dx
-
- exit_8:
- pop ds
- iret
-
- newint8 endp
-
- ; --------------------------------------------------------------------;
- ; Check for occurance of non INT 8 interrupts in progress ;
- ; --------------------------------------------------------------------;
- ; Returns al containing In Service Register except Int 8 flag
- Checkstatus_8 proc near ;See if any interrupts are being serviced
-
- ASSUMEDS
-
- push ds ;check if dos critical error in effect
- push si
- push DX
- mov DX,OCW3_8259 ;Address of 8259 OCW3
- ;;
- ;; NOTE: Leaving in the next two lines to read Port 20 and OR it with
- ;; the appropriate mask for hte 8259 causes a nasty and subtle
- ;; bug conflicting with the MS-MOUSE version 6.0 driver.
- ;; changing to a MOV AL,0bh fixes the problem, and still gets
- ;; the 8259 programmed to the appropriate state.
- ;;
- ; in al,dx
- ; or AL,000001011b ;Set the In-Service Reg. read
- ;;
- ;; this is correct
- ;;
- mov AL,000001011b ;Set the In-Service Reg. read
- ;bits IRR=1 and ISR=1
- out DX,AL ;Tell 8259 to OUT ISR on next read
- nop ;let the 8259 settle down
- nop
- nop
- status_8259_2:
- in AL,DX ;Get the ISR (clear int 8)
- and al,0FEh ;Set zero flag if no active interrupts
- pop DX
-
- lds si,DPTR [DOSCRITERR] ;zero says dos is interruptable
-
- ASSUMENODS
-
- or al,[si] ;NOT zero says dos is in a critical state
- lds si,DPTR [INDOSFLAG] ;add in second status byte
- or al,[si]
- or al,BPTR [INTFLAGS] ;any flags says we're busy
-
- ; -- check to see if a print screen is in progress ;v0.51
- BiosExtraSegment equ 50h ;Bios extra data area ;v0.51
- PrintScreenFlag equ 00h ;offset of PrintScreen flag ;v0.51
- ;v0.51
- ASSUMENODS
- mov si,BiosExtraSegment ;Checkout the PrintScrn flag ;v0.51
- mov ds,si ;1=inprogress, -1=print error ;v0.51
- or al,ds:PrintScreenFlag ;v0.51
-
- pop si
- pop ds
- ret
- Checkstatus_8 endp
-
- ENDIT
-