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 tspopup.pub
- ENDIF
-
- .MODEL small
-
- EXTRN TSRMAIN:FAR
- EXTRN TSRBACKPROC:FAR
-
- .CODE
-
- EXTRN _TESSGETPSP:near
- EXTRN _TESSSETPSP:near
- EXTRN _TESSSETUPINTS:near
- EXTRN _TESSRESTOREINTS:near
-
- EXTRN newint9:dword
- EXTRN _TESSRELEASETSR:near
- EXTRN TESSBEEP:FAR
-
- EXTRN TESS_GLOBALS:byte
- EXTRN TESS_USERPARMS:byte
-
- PUBLIC _TESSDOPOPUP, _TESSDOBACK, _TESS_VIDMODE, _TESS_VIDPAGE
-
- ENDIF
-
- ;
- ;
- ; ***************************************************************************
- ; This is the main popup routine. It is converted from STAYSAVE.INC
- ; and STAYRSTR.INC, from STAY42.ARC, Copyright 1985, 1986,
- ; Lane Ferris, The Hunter's Helper. This was adapted from
- ; Version 4.15.
-
-
- AltF9 db 0,70h
-
- _TESS_VIDMODE db 0
- _TESS_VIDPAGE db 0
-
- _TESSDOPOPUP proc near
-
- ASSUMEDS
-
- cli ;no interrupts now!!!
-
- or WPTR [STATUS],TSRACTIVE ;set active bit
-
- mov WPTR [USERSS],ss ;save user's stack segment
- mov WPTR [USERSP],sp ;... and stack pointer
- ;DS was saved in INT8 or INT28
-
- mov ss,WPTR [OURSSSP+2] ;load TSR stack segment ...
- mov sp,WPTR [OURSSSP] ;... and stack pointer
-
- sti
-
- push bp ;save all registers except for
- push di ;...AX,BX,CX,DX,DS are restored on exit
- push si ;...from this procedure
- push es
-
- stack_pop:
-
- test WPTR [STATUS],TSRRELEASED
- jz get_mode
- jmp save_regs
-
- get_mode:
- mov ah,0fh ;get current video mode
- int 10h
-
- and al,7fh ;mask off nonsequitor high bit
-
- mov _TESS_VIDMODE,al
- mov _TESS_VIDPAGE,bh ;save them
-
- cmp al,7
- jne not_mono
-
- call HerculesMode ;if carry flag set, we're in text mode
-
- jc not_mono
-
- xor al,al
- dec al
-
- mov _TESS_VIDMODE,al
- mov _TESS_VIDPAGE,al
-
- not_mono:
- test WPTR [STATUS],NOPOPGRAPH
- jz check_cmdline ;if not flagged, don't worry about it
-
- mov al,_TESS_VIDMODE
-
- cmp al,3
- jbe check_cmdline ; 0-3 are valid
-
- cmp al,7
- je check_cmdline ; we're in mono text!
-
- no_graphics:
- mov al,BPTR [INWORD4]
- or al,al
- jz notmsword
-
- mov al,BPTR [WASWORD4] ;did we already do this?
- or al,al
- jz flip_word ;nope -- send the char
-
- mov BPTR [WASWORD4],0
- jmp short notmsword
-
- flip_word:
- mov ax,5453h
- mov bx,21h
- mov cx,WPTR [IDNUM]
- mov si,1
- mov di,offset AltF9
- mov dx,0
- push cs
- pop es
- int 2fh
-
- mov BPTR [WORD4DELAY],32
- mov BPTR [WASWORD4],1
- jmp back_popup
-
- notmsword:
- IFDEF TP4
- IFNDEF ASMCOM
- call FAR PTR TESSBEEP
- ELSE
- call TESSBEEP
- ENDIF
- ELSE
- call TESSBEEP
- ENDIF
- jmp back_popup ;anything else is graphics -- go away
-
- check_cmdline:
- test WPTR [STATUS],NOPOPCOMMAND
- jz save_regs ;if not flagged, don't worry about it
-
- mov al,BPTR [SAVEDINDOSFLG]
- or al,al
- jz save_regs ;if zero, not at command line
-
- IFDEF TP4
- IFNDEF ASMCOM
- call FAR PTR TESSBEEP
- ELSE
- call TESSBEEP
- ENDIF
- ELSE
- call TESSBEEP
- ENDIF
- jmp back_popup
-
- save_regs:
-
- getdta <[USERDTA]> ;save current DTA
-
- call _TESSGETPSP ;get current PSP segment
- mov WPTR [USERPSP],bx ;...returned in BX
-
- mov bx,WPTR [OURPSP] ;set TSR's PSP in BX
- call _TESSSETPSP ;...and do it
-
- setdta <[OURDTA]>
-
- call SaveExtendedErr ;save DOS extended err info ;v0.51
- call SaveBreak ;save Ctrl Break status ;v0.51
- call SaveVerify ;save current verify state ;v0.51
-
- test WPTR [STATUS],TSRRELEASED
- jz no_rel_pop
-
- call _TESSRELEASETSR
-
- jmp short not_released_pop
-
- no_rel_pop:
-
- xor ax,ax ;popup-interrupts (1B, 23 and 24)
- call _TESSSETUPINTS ;replace with our handler
-
- push ds ;save DS for after popup
- push es
-
- mov ax,WPTR [OURDSEG] ;load user's data segment
- push ax
- push ax
- pop ds
- pop es
-
- ASSUMENODS
-
- call_popup:
-
- IFDEF TP4
- IFNDEF ASMCOM
- call DPTR PMAIN ;call the user routine!! (TP ver)
- ELSE
- call TSRMAIN ;call the user routine!!
- ENDIF
- ELSE
- call TSRMAIN ;call the user routine!!
- ENDIF
-
- done_pop:
- pop es
- pop ds
-
- ASSUMEDS
-
- xor ax,ax ;restore interrupts (1B, 23 and 24)
- call _TESSRESTOREINTS
-
- not_released_pop:
- mov al,BPTR [WASWORD4]
- or al,al
- jz wasnotword
-
- mov ax,5453h
- mov bx,21h
- mov cx,WPTR [IDNUM]
- mov si,1
- mov di,offset AltF9
- mov dx,0
- push cs
- pop es
- int 2fh
-
- mov BPTR [WASWORD4],0
-
- wasnotword:
- call RestoreVerify ;restore Verify setting ;v0.51
- call RestoreBreak ;restore CtrlBreak status ;v0.51
- call RestoreExtendedErr ;restore Extended error info ;v0.51
-
- setdta <[USERDTA]> ;restore interrupted DTA
-
-
- mov bx,WPTR [USERPSP] ;replace interrupted PSP
- call _TESSSETPSP
-
- ASSUMEDS
-
- ;
- ; ***************************************************************************
- ;
- ; CAUTION!!!! THE USER ROUTINE MUST RETURN SS:SP WITH THE SAME
- ; VALUES AS ON ENTRY. OTHER REGISTERS WILL BE RESTORED
- ; BY THIS ROUTINE.
- ;
- ; ***************************************************************************
- ;
- back_popup:
-
- ASSUMEDS
-
- pop es
- pop si
- pop di
- pop bp
-
- cli
-
- mov ss,WPTR [USERSS] ;restore user's stack segment
- mov sp,WPTR [USERSP] ;... and stack pointer
- ;DS will be restored in INT8 or INT28
- and WPTR [STATUS],NOT HOTKEYON+TSRACTIVE+SHIFTSON
-
- test WPTR [STATUS],TSRRELEASED
- jz b1
-
- or WPTR [STATUS],HOTKEYON+POPUPSET
- and WPTR [STATUS],NOT TSRENABLED
-
- b1: ;clear hot-key and inuse bits
- sti ;enable interrupts again
- dopopup_end:
- ret
-
- _TESSDOPOPUP endp
-
- took_ints db 0
-
- _TESSDOBACK proc near
-
- ASSUMEDS
-
- cli ;no interrupts now!!!
-
- mov WPTR [USER28SS],ss ;save user's stack segment
- mov WPTR [USER28SP],sp ;... and stack pointer
- ;DS was saved in INT8 or INT28
-
- mov ss,WPTR [OUR28SP+2] ;load TSR stack segment ...
- mov sp,WPTR [OUR28SP] ;... and stack pointer
-
- stack_28:
- sti
-
- push bp ;save all registers except for
- push di ;...AX,BX,CX,DX,DS are restored on exit
- push si ;...from this procedure
- push es
-
- mov took_ints,0
-
- test WPTR [STATUS],TSRACTIVE ;did we already take them?
- jnz no_ints_1
-
- mov took_ints,1
-
- xor ax,ax ;popup-interrupts (1B, 23 and 24)
- call _TESSSETUPINTS ;replace with our handler
-
- no_ints_1:
- getdta <[USER28DTA]> ;save current DTA
-
- call _TESSGETPSP ;get current PSP segment
- mov WPTR [USER28PSP],bx ;...returned in BX
-
- mov bx,WPTR [OURPSP] ;set TSR's PSP in BX
- call _TESSSETPSP ;...and do it
-
- setdta <[OURDTA]>
-
- push ds ;save DS for after popup
- push es
-
- mov ds,WPTR [OURDSEG] ;load user's data segment
- mov es,WPTR [OURDSEG] ;load user's extra segment
-
- ASSUMENODS
-
- call_28:
-
- IFDEF TP4
- IFNDEF ASMCOM
- call DPTR PBACKPROC ;call the user routine!! (TP4 ver)
- ELSE
- call TSRBACKPROC ;call the user routine!!
- ENDIF
- ELSE
- call TSRBACKPROC ;call the user routine!!
- ENDIF
-
- done_28:
- pop es
- pop ds
-
- ASSUMEDS
-
- setdta <[USER28DTA]> ;restore interrupted DTA
-
- mov bx, WPTR [USER28PSP] ;replace interrupted PSP
- call _TESSSETPSP
-
- cmp took_ints,0
- je no_ints_2
-
- xor ax,ax ;restore interrupts (1B, 23 and 24)
- call _TESSRESTOREINTS ;restore interrupts
-
- no_ints_2:
-
- ASSUMEDS
-
- pop es
- pop si
- pop di
- pop bp
-
- back_28:
- ASSUMEDS
- cli
- mov ss,WPTR [USER28SS] ;restore user's stack segment
- mov sp,WPTR [USER28SP] ;... and stack pointer
- ;DS will be restored in INT8 or INT28
- sti ;enable interrupts again
-
- do28_end:
- ret
-
- _TESSDOBACK endp
-
-
- LpSet equ 03B9h ;Set light pen address
- LpReset equ 03BBh ;Reset light pen address
- Lpff equ 2 ;Flip-flop suitable for s/w query
- Our6845 equ 03B4h ;6845 index register
- OurStat equ 03BAh ;Display Status Port
- NotVSync equ 80h ;This bit 0 during vertical
- ; retrace
- UseHerc db 0ffh
-
- HerculesMode PROC NEAR
- ASSUMEDS
-
- ;****************** Mode Detection ******************
-
- cmp UseHerc,0ffh
- jne AlreadyTested
-
- inc UseHerc ;assume no herc
-
- call HerculesPresent
- jc AlreadyTested ;if carry, no herc found
-
- inc UseHerc ;say we have a herc
-
- AlreadyTested:
- cmp UseHerc,0
- je textmode
-
- xor al,al
- mov dx,OurStat
- wait1: ;test for v-sync transition
- in al,dx
- test al,NotVSync
- jz wait1
- wait2:
- in al,dx
- test al,NotVSync
- jnz wait2
-
- xor al,al ;Reset and Set Light Pen.
- mov dx,LpReset
- out dx,al
- mov dx,LpSet
- out dx,al
-
- mov al,16 ;Look in the 6845 for the offset into
- mov dx,Our6845 ; buffer when the light pen is
- out dx,al ; tripped - high byte.
- inc dx
- in al,dx
-
- cmp al,0dh ;threshold value is 0dh
- jb test_modeval
-
-
- ; Otherwise, must be graphics mode
- GraphicsMode:
- clc
- jmp short R0
-
- test_modeval:
- xor ax,ax ;secondary test for some
- mov es,ax ;clone herc cards
- mov al,es:[465h]
- test al,2
- jnz GraphicsMode
-
- textmode:
- ; Not in hercules graphics mode, set carry flag.
- stc
-
-
-
- R0:
-
- ret
- HerculesMode ENDP
-
- ; ==========================================================================
-
- ; Determines if a Hercules Graphics Card is present.
-
- status_port equ 03BAh ; To detect the presence of a Hercules
- ; Graphics Card, look for bit 7 of the
- ; Display Mode Status Port to change.
- ; On the HGC this bit goes low on
- ; vertical retrace. The IBM boards do
- ; not utilize this bit.
-
- ID_mask equ 01110000b ; To detect the presence of a Hercules
- Plus_ID equ 00010000b ; Graphics Card Plus or InColor Card,
- InColor_ID equ 01010000b ; look at bits 4, 5, and 6 in the
- ; status port. These bits are held in a
- ; particular state on the Graphics Card
- ; Plus and InColor Card and are
- ; undefined (floating) on the earlier
- ; Hercules card.
-
-
- HerculesPresent proc near
-
- ; * * * Test for the presence of a Hercules Graphics Card
- ; or not currently active - quit
- HGC_test:
- mov dx, status_port ; Display Status Port
-
- xor bl, bl ; clear counter
- in al, dx ; take a reading
- and al, 80h ; save bit seven
- mov ah, al ; and keep it handy
-
- mov cx, 8000h ; a nice big loop
- examine:
- in al, dx ; get another reading
- and al, 80h ; isolate bit seven
- cmp al, ah ; is it the same ?
- je no_change ; no - keep trying
- inc bl ; yes, bit toggled - increment counter
-
- cmp bl, 10 ; if we see a change 10 times
- jae Hercules ; then we assume that a Hercules
- ; Graphics Card is present. The check
- ; for 10 positive tests is done
- ; just to be on the safe side.
- no_change:
- loop examine ; continue until CX = 0
- ; if the loop expires without
- ; 10 successes we assume that
- ; something besides a HGC is present
- jmp short No_Hercules
-
- ; * * * * End of test for Hercules Graphics Card * * * * * * * * *
-
- Hercules:
-
- ;******* Makes sure light pen is present and working before loading *********
- ; If the light pen is not present or not working, then even if it is a
- ; a hercules we can't test for graphics mode, so return a false.
-
- mov dx,LpSet
- out dx,al
- mov dx,OurStat
- in al,dx
- test al,Lpff
- jz No_Hercules ;If light pen stuck low, can't do
- ;mode test - abort.
- mov dx,LpReset
- out dx,al
- mov dx,OurStat
- in al,dx
- test al,Lpff
- jnz No_Hercules ;If light pen stuck high, can't do
- ;mode test - abort.
- ; We made it! Hercules present.
- clc
- jmp short R1
-
-
- No_Hercules:
- stc
-
- R1:
- ret
- HerculesPresent endp
-
- ;-----------------------------------------------------------------; ;v0.51
- ; SAVE/RESTORE CURRENT BREAK STATE, RELAX BREAK CHECKING ; ;v0.51
- ;-----------------------------------------------------------------; ;v0.51
- ; Routines Courtesy of Thomas Brandenborg ;v0.51
- SaveBreak proc near ;v0.51
- ASSUMEDS
- mov ax,3302h ;to swap DL with BREAK value ;v0.51
- xor dl,dl ;DL=0=relax checking ;v0.51
- int 21h ;current level in DL ;v0.51
- mov BPTR [OLDBREAK],dl ;save current level ;v0.51
- ret ;v0.51
- ; ------------ RESTORE SAVED BREAK CHECKING LEVEL ;v0.51
- RestoreBreak: ;v0.51
- mov ax,3301h ;to set break check level ;v0.51
- mov dl,BPTR [OLDBREAK] ;get saved break state ;v0.51
- int 21h ;v0.51
- ret ;v0.51
- SaveBreak endp ;v0.51
- ;----------------------------------------------------------------; ;v0.51
- ; SAVE/RESTORE DOS EXTENDED ERROR INFO (Int21.59) ; ;v0.51
- ;----------------------------------------------------------------; ;v0.51
- ; Routines Courtesy of Thomas Brandenborg ;v0.51
- SaveExtendedErr proc near ;v0.51
- ASSUMEDS
- push di ;v0.53 - CR
- cmp BPTR [DOSVERSION],3 ;Verify version is DOS 3+ ;v0.51
- jb DosExtSaved ;NO - skip if if not 3.x ;v0.51
- mov ah,59h ;to get err info from DOS ;v0.51
- xor bx,bx ;BX must be zero ;v0.51
- push ds ;save DS (clobbered by DOS) ;v0.51
- int 21h ;ext err info in AX,BX,CX ;v0.51
- pop ds ;restore DS ;v0.51
- mov WPTR [OLDEXTERR],ax ;save extended error info ;v0.51
- mov WPTR [OLDEXTERR+2],bx ;v0.51
- mov WPTR [OLDEXTERR+4],cx ;v0.51
- DosExtSaved: ;v0.51
- pop di ;v0.53 - CR
- ret ;v0.51
- ; -- Restore the Dos 3+ extended error information ;v0.51
- RestoreExtendedErr: ;v0.51
- push di ;v0.53 - CR
- cmp BPTR [DOSVERSION],3 ;verify DOS 3.+ ;v0.51
- jb DosExtRestored ;NO - skip this ;v0.51
- mov dx,offset OLDEXTERR ;DS:DX=3 words of ext err ;v0.51
- mov ax,5d0ah ;to set ext err info ;v0.51
- int 21h ;v0.51
- DosExtRestored: ;v0.51
- pop di ;v0.53 - CR
- ret ;v0.51
- SaveExtendedErr endp ;v0.51
- ;-----------------------------------------------------------------; ;v0.51
- ; SAVE/RESTORE CURRENT VERIFY SETTING (int 21.54) ; ;v0.51
- ;-----------------------------------------------------------------; ;v0.51
- ; Routines Courtesy of Thomas Brandenborg ;v0.51
- SaveVerify proc near ;v0.51
- ASSUMEDS
- mov ax,5400h ;Ask for Verify setting ;v0.51
- int 21h ;00=off, 01=on ;v0.51
- mov BPTR [OLDVERIFY],al ;save current setting ;v0.51
- ret ;v0.51
- ;-------- RESTORE Write Verify SETTING ;v0.51
- RestoreVerify: ;v0.51
- mov ah,2Eh ;function to set verify ;v0.51
- mov al,BPTR [OLDVERIFY] ;get saved verify state ;v0.51
- xor dx,dx ;dx = zero to set flag ;v0.51
- int 21h ;v0.51
- ret ;v0.51
- SaveVerify endp ;v0.51
- ;-----------------------------------------------------------------; ;v0.51
- ;v0.51
- ENDIT
-