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 tsint16.pub ;public definitions (uses Periscope PUBLIC.COM /E)
- ENDIF
-
- .MODEL small
- .CODE
-
- EXTRN _TESSKEYSTAT:near
-
- EXTRN TESS_GLOBALS:byte
-
- PUBLIC newint16, _TESSSTUFFKEYS
-
- ENDIF
-
- BUFFER_TAIL equ 1ch
- BUFFER_HEAD equ 1ah
- BUFFER_START equ 80h
- BUFFER_END equ 82h
-
-
- _TESSSTUFFKEYS proc near
- ;
- ; on entry, AX contains ASCII/SCAN CODE pair to stuff
- ; on exit, AX contains FFFF if keyboard is full, else
- ; AX is 0
- ; DI contains the stuffing speed. If DI is zero, then a keystroke
- ; is only placed into the buffer if the buffer is empty!
- ;
- ;
- ASSUMENODS
-
- push es
- push si
- push bx
-
- pushf
- cli
-
- push ax
- xor ax,ax
- mov ax,40h
- mov es,ax
- pop ax
-
- mov bx,es:[BUFFER_TAIL] ;get tail of kbd buffer
- mov si,bx ;save it for later
-
- or di,di ;if SLOW speed, then ....
- jnz not_slow
-
- cmp bx,es:[BUFFER_HEAD] ;if head=tail then
- jne bad_stuff ;buffer is empty and
- ;we can continue
- not_slow:
- inc bx
- inc bx ;advance to next position
- cmp bx,es:[BUFFER_END] ;check for warap-around
- jne no_wrap
-
- mov bx,es:[BUFFER_START] ;start from beginning again
- no_wrap:
- cmp bx,es:[BUFFER_HEAD] ;is the buffer full?
- je bad_stuff ;yep -- return right away!
-
- mov es:[si],ax ;store the character
- mov es:[BUFFER_TAIL],bx ;move the tail pointer up
- xor ax,ax
- jmp short stuff_out
-
- bad_stuff:
- xor ax,ax
- dec ax
- stuff_out:
- POPFF
- pop bx
- pop si
- pop es
- ret
-
- _TESSSTUFFKEYS endp
-
-
- newint16 PROC FAR
-
- ASSUMENODS
-
- ; ..lf -- we may have to go thru here and check for flag modifications
- ; ..cr - yep -- we're blowing the flags -- fix ASAP
- ;
- start_again: ; ..lf
- or BPTR [SOFTINTFLAGS],ININT16 ;indicate our int16 is active
-
- cmp ax,55ffh ;is it msword?
- je check_word ;yes!!
-
- test ah,10h ;check for new bios function ..lf
- jz gobios16 ;if zero, then have char request.
-
- mov BPTR [NEWKBDFLAG],10h ;say new_bios function involved
- and ah,0EFh ;just clear out the one bit
- ;force test w/o new_bios flag
-
- gobios16:
- cmp ah,00 ;if char request,
- je func00 ;loop for character
- cmp ah,01 ;if character availability test
- je func01 ;go check for char
-
- bios16:
- and BPTR [SOFTINTFLAGS],NOT ININT16 ;say our 16 deactivated
- or ah,BPTR [NEWKBDFLAG]
- mov BPTR [NEWKBDFLAG],00 ;clear the enyucked flag
- jmp DPTR [OLDINT16]
-
-
- check_word:
- cmp bx,4
- jne bios16
-
- or cx,cx
- jz start_word
- mov BPTR [INWORD4],0
- jmp bios16
-
- start_word:
- mov BPTR [INWORD4],1
- jmp bios16
-
-
- ; -- USER REQUEST FOR KEYBOARD STATUS / KEY AVAILABILITY
-
- func01:
- push ds ;save regs, set our Dseg
- push cs
- pop ds
-
- ASSUMEDS
-
- func01A:
- call _TESSKEYSTAT ;look at key buffer
- pushf ;save return flags
-
- fret01: ;return INT 16h information
- mov BPTR [NEWKBDFLAG],0 ;clear any "new bios" conditions ..lf
- and BPTR [SOFTINTFLAGS],NOT ININT16 ;Say INT16 is done
- POPFF ;return bios int 16 status flags
-
- pop ds
-
- ASSUMENODS
-
- push ax ;save return value
-
- pushf
- pop ax ;get FLAGS to AX
- push bp
-
- mov bp,sp
-
- or ax,200h ;make sure INTs are enabled (on stack)
-
- mov [bp+8],ax
-
- pop bp
- pop ax ;get return value back
-
- iret ;return (flags modified in place)
-
- ; -- REQUEST TO READ/WAIT FOR KEY FROM KEYBOARD
-
- func00:
- push ds
- push cs
- pop ds
-
- ASSUMEDS
-
- func00A:
- call _TESSKEYSTAT ;Read & wait until key available
- jz func00A ;loop 'till key from keyboard or TSR
-
-
- pushf ;simulate INT 16
-
- mov ah,0 ;get the waiting key
- or ah,BPTR [NEWKBDFLAG] ;re-insert new_bios flags ..lf
-
-
- call DPTR [OLDINT16] ;do bios read
-
- out_16A:
- pushf ;save return flags
- ;stack now holds FLAGS,SI,DI,IP,DS,CS,FLAGS
- jmp fret01 ;restore and return
-
- newint16 endp
-
- ENDIT
-