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 tsint2f.pub
- ENDIF
-
- .MODEL small
-
- EXTRN TSRUSERPROC:FAR
-
- .CODE
-
- ;
-
- EXTRN _TESSSTOREKEYS:near
- EXTRN newint8:dword
- EXTRN newint9:dword
- EXTRN newint13:dword
- EXTRN newint16:dword
- EXTRN newint1C:dword
- EXTRN newint21:dword
- EXTRN newint28:dword
- EXTRN _TESSBACKGROUND:near
- ;
- ; external declarations for popup interrupt vectors
- ;
- EXTRN _TESS_INTERRUPTRETURN:near
- EXTRN newint24:dword
-
-
- PUBLIC TESS_GLOBALS, newint2F, TESS_USERPARMS, _TESS_CPYRT, _TESS_ENDOFDATA
- ;PUBLIC oldint8, oldint9, oldint13, oldint16, oldint1C, oldint21, oldint28
- ;PUBLIC oldint2F, oldint1B, oldint24
-
- ENDIF
-
- ;-----------------------------------------------------------------------------
-
- stopsnoops db 1bh,'[2J',1ah,0 ;ANSI Clear Screen
-
- TESS_GLOBALS equ this byte
-
- RevLvl db 1 ;revision level of TesSeRact Product
-
- SaveIndosPop db 0 ;Type of Popup in use
-
- Was8 db 0 ;Int 8 occurred
-
- Was13 db 0 ;Int 13 occurred
-
- intflags db 0 ;which interrupts are active
-
- Soft_Int_flags db 0 ;Soft interrupts are active
-
- dosversion db 0 ;current version of DOS
-
- waitcount db 0 ;wait to activate count
-
- InDosflag dd 0 ;Pointer to INDOS flag
-
- DosCritErr dd 0 ;Pointer to DOS Critical Error Flag
-
- UserPSP dw 0 ;PSP segment of interrupted program
-
- User28PSP dw 0 ;PSP segment of interrupted program
-
- UserDTA dd 0 ;DTA of interrupt program
-
- User28DTA dd 0 ;DTA of interrupt program
-
- UserSS dw 0 ;Interrupted Stack Segment
-
- UserSP dw 0 ;Interrupt Stack Pointer
-
- ss28 dw 0 ;interrupt stack segment during INT 28
-
- sp28 dw 0 ;interrupt stack pointer during INT 28
-
- UserInt24 dd 0 ;location to store pointer to user's INT 24
-
- ; ***************************************************************************
- ; It is necessary to temporarily steal the INT 9 vector on popup
- ; to work in the Microsoft QuickBasic and QuickC Programming
- ; environments.
- ;
-
- ;SavedInt9 dd 0 ;additional interrupt 9 vector
- ;
- OldExtErr dw 3 dup (0) ;AX,BX,CX of ext err ;v0.51
-
- OldBreak db 0 ;Saved Ctrl Break setting ;v0.51
-
- OldVerify db 0 ;Saved Write Verify setting ;v0.51
-
- InWord4 db 0 ;flag to indicate in Word 4.0!!
-
- WasWord4 db 0 ;flag to indicate word 4.0 popup
-
- New_kybd_flag db 0 ; x'10' indicates an enhanced keyboard function
-
- Word4Delay db 0 ;delay counter for second popup during word 4
-
- ;
- ; ***************************************************************************
- ; These are the bios interrupt vectors
- ; ***************************************************************************
- ;
- ; ***************************************************************************
- ; We take Interrupts 08h, 09h, 13h, 16h, 1Ch, 21h, 28h and 2Fh
- ; when we initialize for the first time.
- ;
-
- oldint8 dd 0 ;BIOS Hardware Timer Interrupt
- db BIOSI8
- dw offset newint8 ;replacement vector
- oldint9 dd 0 ;BIOS Hardware Keyboard Interrupt
- db BIOSI9
- dw offset newint9 ;replacement vector
- oldint13 dd 0 ;BIOS Disk Interrupt
- db BIOSI13
- dw offset newint13 ;replacement vector
- oldint16 dd 0 ;BIOS Software Keyboard Interrupt
- db BIOSI16
- dw offset newint16 ;replacement vector
- oldint1C dd 0 ;BIOS Software Timer interrupt
- db BIOSI1C
- dw offset newint1C ;replacement vector
- oldint21 dd 0 ;DOS Services Interrupt
- db DOSI21
- dw offset newint21 ;replacement vector
- oldint28 dd 0 ;DOS Idle Interrupt
- db DOSI28
- dw offset newint28 ;replacement vector
- oldint2F dd 0 ;DOS Multiplex Interrupt
- db DOSI2F
- dw offset newint2F ;replacement vector
- ;
- ; ***************************************************************************
- ; We take Interrupts 1Bh, 23h, 24h on popup, and restore them on
- ; popdown.
- ;
-
- oldint1B dd 0 ;control-C vector
- db BIOSI1B
- dw offset _TESS_INTERRUPTRETURN ;replacement vector
- oldint23 dd 0 ;control-C vector
- db DOSI23
- dw offset _TESS_INTERRUPTRETURN ;replacement vector
- oldint24 dd 0 ;critical error vector
- db DOSI24
- dw offset newint24 ;replacement vector
-
- ;
- ; ***************************************************************************
- ; These interrupts are taken if the user requests additional
- ; interrupt servicing: 05h, 10h, 14h, 15, 17h
- ;
-
- ;oldint5 dd 0 ;BIOS PrintScreen Interrupt
- ; db BIOSI5
- ; dw offset newint5 ;replacement vector
- ;oldint10 dd 0 ;BIOS Video Interrupt
- ; db BIOSI10
- ; dw offset newint10 ;replacement vector
- ;oldint14 dd 0 ;BIOS Communications Interrupt
- ; db BIOSI14
- ; dw offset newint14 ;replacement vector
- ;oldint15 dd 0 ;BIOS Cassette and Misc. Interrupt
- ; db BIOSI15
- ; dw offset newint15 ;replacement vector
- ;oldint17 dd 0 ;BIOS Printer Interrupt
- ; db BIOSI17
- ; dw offset newint17 ;replacement vector
- ;
-
- ;
- ;
-
- newint2F proc far
-
- ASSUMENODS
- jmp overparms
-
- ; ***************************************************************************
- ; The UserParms vector points to structure that contains individual
- ; information about the TSR vectors used by this program.
- ; The format of this structure is as follows:
- ; IDCODE db 8 dup (0);eight-byte unique ASCII identification code
- ; IDNUM dw 0 ;internal identification number
- ; FUNCFLG dd 0 ;Bit-map of supported functions
- ; HOTKEY db 0 ;scan code of TSR Activation Key
- ; SHIFTST db 0 ;shift state of TSR Activation
- ; EXTHOT dd 0 ;pointer to extra hot keys
- ; STATUS dw 0 ;TSR Status Flags
- ; OURPSP dw 0 ;TSR's PSP segment
- ; OURDTA dd 0 ;TSR's DTA region
- ; DSEG dw 0 ;Default Data Segment of TSR Program
- ; SSSP dd 0 ;TsrMain Stack Segment & Pointer
- ; SS28SP dd 0 ;TsrBackProc Stack Segment & Pointer
- ;
- ;
- ; The 'FUNCFLG' variable contains a bit map of all supported
- ; functions using this multiplex interrupt. This is primarily
- ; designed to be used by TSRs that do not use the TESS library,
- ; but intend to support the standard method of TSR communication
- ; through INT 2fh. The FUNCFLG variable is mapped as follows:
- ;
- ; Bit 0 Function 0h (check install -- REQUIRED)
- ; Bit 1 Function 1h (return userparms -- REQUIRED)
- ; Bit 2 Function 2h (check hotkey)
- ; Bit 3 Function 3h (replace INT 24h)
- ; Bits 4-7 Undefined -- reserved for future use
- ; Bit 8 Function 10h (enable TSR)
- ; Bit 9 Function 11h (disable TSR)
- ; Bit 10 Function 12h (release TSR from RAM)
- ; Bit 11 Function 13h (restart TSR)
- ; Bit 12 Function 14h (get current status)
- ; Bit 13 Function 15h (set TSR status)
- ; Bit 14 Function 16h (get popup type)
- ; Bit 15 Undefined -- reserved for future use
- ; Bit 16 Function 20h (Call user procedure)
- ; Bit 17 Function 21h (stuff keyboard)
- ; Bits 18-31 Undefined -- reserved for future use
- ;
- ; The 'WAS8' and 'WAS13' bytes are for the developer's convenience.
- ; They are set by the TesSeRact Interrupt Handlers, but are never
- ; cleared. It is the developer's resposibility to clear these
- ; bytes if they are to be used.
- ;
- TESS_USERPARMS equ this byte
-
- UserParms db 8 dup (0)
- IdNum dw 0 ;TSR Identification Number
- FuncFlg dd 0ffffffffh ;supported functions
- HotKey db 0 ;Scan code of hotkey to use
- ShiftSt db 0 ;shift state to use for popup
- HotFlag db 0 ;Which hotkey is in use
- ExtCnt db 0 ;number of extra hotkeys
- ExtHot dd 0 ;pointer to extra hot keys
- Status dw 0 ;TSR status flags
- OurPSP dw 0 ;our PSP segment
- OurDTA dd 0 ;our DTA region
- DSeg dw 0 ;User's Default Data Segment
- sssp dd 0 ;TsrMain Stack Segment & Pointer
- ss28sp dd 0 ;TsrBackProc Stack Segment & Pointer
-
- IFNDEF NOCKSUM
-
- _TESS_ENDOFDATA equ this byte
-
- cpyrt db 'TesSeRact(tm) Library, Version ',VER
- IFDEF TP4
- IFNDEF ASMCOM
- db ' (TP4)'
- ELSE
- db ' (ASM)'
- ENDIF
- ELSE
- db ' (LIB)'
- ENDIF
- db 0dh,0ah
-
- _TESS_CPYRT equ this byte
-
- cpyrt1 db 'Copyright (c) 1986, 1987, 1988 TesSeRact Development Team'
- db 0dh,0ah,'All Rights Reserved',0dh,0ah,0
- ELSE
-
- _TESS_ENDOFDATA equ this byte
- _TESS_CPYRT equ this byte
-
- ENDIF
-
- jmptbl:
- ;
- ; Functions 00h through 0fh are initialization & information
- ; routines
- ;
- dw offset check_install ;fn 00h
- dw offset return_userparms ;fn 01h
- dw offset check_hotkey ;fn 02h
- dw offset replace_int24 ;fn 03h
- dw offset return_data ;fn 04h
- dw offset setextrahot ;fn 05h
- dw offset get_out_2f ;fn 06h
- dw offset get_out_2f ;fn 07h
- dw offset get_out_2f ;fn 08h
- dw offset get_out_2f ;fn 09h
- dw offset get_out_2f ;fn 0ah
- dw offset get_out_2f ;fn 0bh
- dw offset get_out_2f ;fn 0ch
- dw offset get_out_2f ;fn 0dh
- dw offset get_out_2f ;fn 0eh
- dw offset get_out_2f ;fn 0fh
-
-
- ;
- ; Functions 10h through 1fh are TSR manipulation & status routines
- ;
- dw offset enable_tsr ;fn 10h
- dw offset disable_tsr ;fn 11h
- dw offset release_tsr_mem ;fn 12h
- dw offset restart_tsr ;fn 13h
- dw offset get_tsr_stat ;fn 14h
- dw offset set_tsr_stat ;fn 15h
- dw offset get_popup_type ;fn 16h
- dw offset get_out_2f ;fn 17h
- dw offset get_out_2f ;fn 18h
- dw offset get_out_2f ;fn 19h
- dw offset get_out_2f ;fn 1ah
- dw offset get_out_2f ;fn 1bh
- dw offset get_out_2f ;fn 1ch
- dw offset get_out_2f ;fn 1dh
- dw offset get_out_2f ;fn 1eh
- dw offset get_out_2f ;fn 1fh
-
-
- ;
- ; Functions 20h through 2fh are TSR utility routines
- ;
- dw offset call_user_proc ;fn 20h
- dw offset stuff_keyboard ;fn 21h
- dw offset trigger_pop ;fn 22h
- dw offset trigger_back ;fn 23h
- dw offset get_out_2f ;fn 24h
- dw offset get_out_2f ;fn 25h
- dw offset get_out_2f ;fn 26h
- dw offset get_out_2f ;fn 27h
- dw offset get_out_2f ;fn 28h
- dw offset get_out_2f ;fn 29h
- dw offset get_out_2f ;fn 2ah
- dw offset get_out_2f ;fn 2bh
- dw offset get_out_2f ;fn 2ch
- dw offset get_out_2f ;fn 2dh
- dw offset get_out_2f ;fn 2eh
- dw offset get_out_2f ;fn 2fh
-
-
- MAXENT equ 2fh
-
- ;
- ; exit routines
- ;
- finish_2f:
- add sp,4 ;get rid of two words on stack
- xor ax,ax ;clear AX to show we got it
- done_2f:
- iret
-
- next_one:
- inc cx ;try next higher ID code
- get_out_2f:
- pop bx
- pop ax
-
- not_our_2f:
- jmp DPTR [oldint2F]
-
-
- overparms:
- cmp ax,5453h ;ax = 5453h for TesSeRact multiplex
- jne not_our_2f
-
- cmp bx,MAXENT
- ja not_our_2f
-
- push ax
- push bx
-
- or bx,bx ;do check for install first,
- jz check_install ;so we can check ID number only
- ;one time!
-
- cmp bx,2
- je check_hotkey ;also skip ID check for hotkey
-
- cmp cx,WPTR [IDNUM] ;if it's not for us, don't
- jne get_out_2f ;even bother going through jump
- ;table!
-
- shl bx,1
- add bx,offset jmptbl
-
- jmp cs:[bx]
-
- check_install:
- ;DS:SI points to ID string
- ;DI contains hotkey for check
- ;CX is current number in chain
- ; must be 0 from caller
- push cx
-
- push si ;save SI for next one
-
- lea di,[USERPARMS]
- push cs
- pop es
- mov cx,8
-
- rep cmpsb
-
- pop si
-
- pop cx
- jnz next_one ;no match, not us
-
- pop bx
- pop ax
-
- mov cx,es:[di] ;return ID number in CX
-
- test WPTR [STATUS],TSRRELEASED
- jz return_idnum
-
-
- or cx,0ff00h ;say we're released!
-
- return_idnum:
-
- xor ax,ax
- dec ax ;AX=-1 means already here
- jmp short done_2f
-
- ;
- ; Function 01h
- ;
- return_userparms:
- lea bx,[USERPARMS]
- push cs
- pop es ;ES:BX points to UserParms
- jmp finish_2f
- ;
- ; function 02h
- ;
- check_hotkey:
- cmp cl,BPTR HOTKEY ;is it our hotkey?
- jne get_out_2f ;nope -- try next one down
- xor ax,ax
- dec ax ;AX=-1 means key is in use
- add sp,4 ;get rid of two words on stack
- jmp done_2f
-
- ;
- ; Function 03h
- ;
- replace_int24: ;DS:SI points to user routine
- mov WPTR [USERINT24],si
- mov ax,ds
- mov WPTR [USERINT24+2],ax
- or WPTR [STATUS],EXTRAINT24 ;turn on the flag
- jmp finish_2f
-
- ;
- ; Function 04h
- ;
- return_data:
- lea bx,[REVLVL]
- push cs
- pop es ;ES:BX points to TESS_GLOBALS
- jmp finish_2f
-
- ;
- ; Function 05h
- ;
- setextrahot: ;ds:si points to new keys
- ;dl contains count of keys
- mov WPTR [EXTRAHOTK],si
- mov ax,ds
- mov WPTR [EXTRAHOTK+2],ax
- mov BPTR [HOTCOUNT],dl
- or WPTR [STATUS],EXTRAHOTSET ;turn on the flag
- jmp finish_2f
-
- ;
- ; function 10h
- ;
- enable_tsr:
- or WPTR [STATUS],TSRENABLED
- jmp finish_2f
-
- ;
- ; function 11h
- ;
- disable_tsr:
- and WPTR [STATUS],NOT TSRENABLED
- jmp finish_2f
-
- ;
- ; function 12h
- ;
- release_tsr_mem:
- and WPTR [STATUS],NOT TSRENABLED
- test WPTR [STATUS],TSRACTIVE
- jnz was_active
-
- or WPTR [STATUS],HOTKEYON+POPUPSET
- was_active:
- or WPTR [STATUS],TSRRELEASED
- jmp finish_2f
-
- ;
- ; function 13h
- ;
- restart_tsr:
- and WPTR [STATUS],NOT TSRRELEASED+HOTKEYON
- or WPTR [STATUS],TSRENABLED
- jmp finish_2f
-
- ;
- ; function 14h
- ;
- get_tsr_stat:
- mov bx,WPTR [STATUS]
- jmp finish_2f
-
- ;
- ; function 15h
- ;
- set_tsr_stat:
- mov WPTR [STATUS],dx
- jmp finish_2f
- ;
- ; function 16h
- ;
- get_popup_type:
- test WPTR [STATUS],TSRACTIVE
- jnz get_type_2
- jmp get_out_2f
-
- get_type_2:
- mov bl,BPTR [SAVEDINDOSFLG]
- xor bh,bh
- jmp finish_2f
-
- ;
- ; function 20h
- ;
- call_user_proc:
- test WPTR [STATUS],USERPROCON
- jnz skip1
- jmp get_out_2f
- skip1:
- test WPTR [STATUS],INT28ACTIVE ;wait until INT28 is finished
- jnz call_user_proc
-
- or WPTR [STATUS],INT28ACTIVE ;say int28 is busy
-
- cli
- mov WPTR [USER28SS],ss ;save user's stack segment
- mov WPTR [USER28SP],sp ;... and stack pointer
-
- mov ss,WPTR [OUR28SP+2] ;load TSR stack segment ...
- mov sp,WPTR [OUR28SP] ;... and stack pointer
-
- sti
-
- push ds
- mov ax,WPTR [OURDSEG]
- mov ds,ax
-
- IFNDEF ASMCOM
- push es
- push di ;push user pointer on stack
- ENDIF
-
- IFDEF TP4
- IFNDEF ASMCOM
- call DPTR PUSERPROC ;call user routine (TP4 version)
- ELSE
- call TSRUSERPROC ;call user routine
- ENDIF
-
- ELSE
- call TSRUSERPROC ;call user routine
- ENDIF
-
- pop ds
-
- cli
- mov ss,WPTR [USER28SS] ;restore user's stack segment
- mov sp,WPTR [USER28SP] ;... and stack pointer
- sti ;enable interrupts again
-
- and WPTR [STATUS],NOT INT28ACTIVE ;say int28 is finished
-
- jmp finish_2f
-
- ;
- ; Function 21h
- ;
- stuff_keyboard:
- call _TESSSTOREKEYS
-
- add sp,4 ;get rid of two words on stack
- jmp done_2f ;return with value from _TESSSTOREKEYS
- ; 0 if stuffed, -1 if no room
-
- ;
- ; function 22h
- ;
- trigger_pop:
- or WPTR [STATUS],HOTKEYON + SHIFTSON
- jmp finish_2f
-
- ;
- ; function 23h
- ;
- trigger_back:
- call _TESSBACKGROUND
- add sp,4 ;get rid of two words on stack
- jmp done_2f ;return with value from _TESSBACKGROUND
- ; 0 if called, -1 if not safe
-
-
- newint2F endp
-
- ENDIT
-