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
- INCLUDE mixed.inc
-
- IFDEF ALLPUBLIC
- INCLUDE tsinit.pub ;public definitions (uses Periscope PUBLIC.COM /E)
- ENDIF
-
- .MODEL small
-
- EXTRN TSRCLEANUP:FAR
-
- .CODE
-
- EXTRN _TESSSETUPINTS:near
- EXTRN _TESSGETPSP:near
- EXTRN _TESS_TEMPPARMS:byte
- EXTRN _TESS_CPYRT:byte
- EXTRN TESSBEEP:FAR
-
- EXTRN TESS_GLOBALS:byte
- EXTRN TESS_USERPARMS:byte
-
- ENDIF
-
- IFNDEF ASMCOM
-
- hProc <TSDOINIT FAR>, <USES SI,DI>, HotKeyScan:byte, ShiftStateFlag:byte, TSRFlags:word, MemoryTop:word
-
- ELSE
-
- ;
- ; In the assembler version, parameters are passed in registers; note
- ; that this function should not return unless there was a major
- ; problem!
- ;
- ; On entry:
- ; AH = Scan Code of hotkey
- ; AL = Shift State of hotkey
- ; BX = TSR Activation Flags
- ; DX = offset of Top of Memory
- ;
-
- PUBLIC TSDOINIT
- TSDOINIT proc near
-
- ENDIF
-
- IFNDEF ASMCOM
-
- ASSUMENODS
- mov ax,ds
- push ds ;save data segment
-
- mov WPTR [OURDSEG],ax ;save default data segment
-
- push cs
- pop ds ;address our segments
-
- ASSUMEDS
-
- ELSE
-
- ASSUMEDS
-
- mov WPTR [OURDSEG],cs ;save default data segment
-
- push dx
- push bx
- push ax ;save parameters for later!
- ENDIF
-
- mov ax,3000h ;get DOS version number
- int 21h
- mov BPTR [DOSVERSION],al ;0=1+,2=2.0+,3=3.0+
-
- push cs
- pop es ;address our segments
-
- lea si,_TESS_TEMPPARMS
- lea di,[USERPARMS]
- mov cx,0ah
-
- rep movsb
-
- mov ax,3400h ;find the DOS Indos Byte
- int 21h
-
- mov WPTR [INDOSFLAG],bx ;offset returned in BX
- mov WPTR [INDOSFLAG+2],es ;segment returned in ES
-
-
- cmp BPTR [DOSVERSION],4 ;if we're running OS/2
- ja criterr_not_needed ;fake the criterr byte
-
- mov WPTR [DOSCRITERR+2],es ;as well as the segment for the critical flag
-
- mov cx,8000h ;search for instruction: CMP [crit flag],00
-
- mov bx,0 ;start search at beginning of segment
- Find_Critical_flag:
- mov ax,3e80h ;3e80 is opcode to search for
- mov di,bx ;start search here
- repnz scasw ;search until a match is found
-
- jz save_critical
- jmp short next_try ;couldn't find critical byte
-
- save_critical:
-
- ;now we're going to search for the
- ;address of the critical flag
-
- ;es:[di-2] now points to:
- ; CMP [crit flag],00
- ; JNZ ...
- ; MOV SP,indos stack address
-
- mov al,BPTR es:[di+5] ;MOV SP,xxxx
- cmp al,0bch ;opcode for MOV SP
- je Found_Critical
- ;..lf ;not right opcode, seach again
- mov bx,di ;restart search from last byte
- next_try:
- push bx
- rcr bx,1 ;see if first or second time
- pop bx
- jc try_again
- jcxz bump_bx ;make sure we have more to search for
- jmp short Find_Critical_flag
- bump_bx:
- mov bx,1 ;start on odd boundary
- mov cx,8000h ;odd bytes of segment
- try_again:
- jcxz skip2 ;make sure we have more to search for
- jmp short Find_Critical_flag
- skip2:
- jmp no_crit_found
-
- criterr_not_needed:
- mov WPTR [DOSCRITERR+2],cs ;fake everyone out by setting
- ;criterr to a known zero value
- mov WPTR [DOSCRITERR],offset TESS_GLOBALS - 1
- jmp short init_continue
-
- Found_Critical:
- mov ax,WPTR es:[di] ;here's the critical byte address
- mov WPTR [DOSCRITERR],ax
- init_continue:
-
- IFNDEF ASMCOM
- mov al,HotKeyScan
- mov BPTR [HOTKEY],al
- mov al,ShiftStateFlag
- mov BPTR [SHIFTST],al
-
- ELSE
- pop ax ;recover hotkey stuff
- mov BPTR [HOTKEY],al
- mov BPTR [SHIFTST],ah
- ENDIF
- xor ax,ax
- mov WPTR [STATUS],ax ;clear status flags
-
- get_psp_dta:
-
- getdta <[OURDTA]>
-
- call _TESSGETPSP
- mov WPTR [OURPSP],bx
-
- set_popup:
-
- IFNDEF ASMCOM
- mov ax,TSRFlags
- ELSE
- pop ax ;recover Tsr Activation info
- ENDIF
- mov WPTR [STATUS],ax ;turn on appropriate flags
-
- IFNDEF NOCKSUM
- push cs
- pop ds ;our segment
- mov si,offset _TESS_CPYRT ;address to check
-
- xor ax,ax
-
- CK equ 0e0h
-
- ck_1:
- lodsb ;get the byte
- or al,al ;are we at end?
- jz c_ck ;yep
-
- add ah,al ;add it in
- jmp ck_1
-
- c_ck:
-
- cmp ah,CK
- je ck_ok
-
- call TESSBEEP
- jmp c_ck
- ck_ok:
- ENDIF
-
- save_hdl:
- push ds
- mov ax,WPTR [OURPSP] ;get our PSP segment
- mov ds,ax
- mov bx,18h ;offset of handle table
- mov cx,3
- save_hdl_loop:
- push [bx] ;save each handle on stack
- inc bx
- inc bx
- loop save_hdl_loop
-
- mov cx,5
- close_loop:
- push cx ;close the DOS pre-opened
- mov bx,cx ;handles
- dec bx
- mov ah,03eh
-
- int 21h
-
- pop cx
- loop close_loop
-
- restore_hdl_tbl:
-
- mov bx,1Ch ;restore the handles
- mov cx,3
- rest_hdl_loop:
- pop [bx]
- dec bx
- dec bx
- loop rest_hdl_loop
-
- pop ds
-
- ;
- ;This patch courtesy of Brian Foley of TurboPower Software
- ;
- patch_sidekick:
-
- mov ax,3508h
- int 21h
-
- cmp WPTR es:[bx-4],4b53h
- jne go_resident
-
- cmp WPTR es:[bx-2],4942h
- jne go_resident
-
- mov cx,100d ;it's early in the handler
-
- mov al,1fh ;1f8c is opcode to search for
- mov di,bx ;start search here
-
- not_this_opcode:
- repnz scasb ;search until a match is found
- jz found_sk
-
- jcxz go_resident ;must be SK+
-
- found_sk:
- cmp BPTR es:[di+4],74h ;is it the JZ code?
- jne not_this_opcode ;already changed!
-
- mov BPTR es:[di+4],0ebh
-
- go_resident:
-
- push ds
- mov ax,40h
- mov ds,ax
-
- ASSUMENODS
-
- mov si,80h ;check the BIOS data area
- lodsw ;to make sure it supports
- or ax,ax ;the points to the keyboard
- jnz ok_kbd ;buffer
-
- mov di,80h ;not OK, so
- push ds ;load the pointers in
- pop es ;the correct place
-
- cli
- mov ax,1eh
- stosw
- add ax,20h
- stosw
- mov di,1ah
- sub ax,20h
- stosw
- stosw
- sti
- ok_kbd:
- pop ds
- ASSUMEDS
-
- xor ax,ax ;start with our interrupts
- inc ax
- call _TESSSETUPINTS ;setup interrupts
-
- mov ax,5453h ;call multiplex
- mov bx,10h ; to enable TSR
- mov cx,WPTR [IDNUM] ; our ID Number
- int 2fh
-
- push ds
- mov ax,WPTR [OURDSEG]
- mov ds,ax
-
- ASSUMENODS
-
- xor ax,ax
-
- IFNDEF ASMCOM
- push ax ;AX=0, initialize routine
- ENDIF
-
- IFDEF TP4
- IFNDEF ASMCOM
- call DPTR PCLEANUP ;call user routine (TP4 version)
- ELSE
- call TSRCLEANUP ;call user routine
- ENDIF
- ELSE
- call TSRCLEANUP ;call user routine
- ENDIF
-
- pop ds
-
- ASSUMEDS
-
- IFNDEF ASMCOM
- mov dx,MemoryTop
- ELSE
- pop dx ;recover top of memory
- shr dx,1
- shr dx,1
- shr dx,1
- shr dx,1 ;convert to paragraphs (DX / 16)
- inc dx ;round up!!
- ENDIF
-
- xor al,al ; no errors
- mov ah,31h ; load terminate & stay resident code
- int 21h
-
- no_crit_found: ;exiting 'cause we couldn't find the critical
- ;error flag byte
- abort_out:
- IFNDEF ASMCOM
- mov ax,-1
- pop ds
- hRet
- hEndp
-
- ELSE
- ret
- TSDOINIT endp
-
- ENDIF
-
- ENDIT
-