home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Supreme Volume 6 #1
/
swsii.zip
/
swsii
/
167
/
TESRPARK.ZIP
/
TESRPARK.ASM
Wrap
Assembly Source File
|
1988-07-25
|
24KB
|
508 lines
PAGE 60,120
TITLE TeSRpark.ASM -- TesSeRact park "hard" drive heads demonstration
;----------------------------------------------------------------------------
SUBTTL Originally TESSPARK.ASM & TSRPARK.ASM : 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.
;-----------------------------------------------------------------------------
;
; BASED on code originally provided by Jim Mischel
;
; ORIGINAL COPYRIGHT NOTICE:
;
;;;; AUTOPARK.ASM - program to automatically park the drive heads
;;;; at specified time intervals.
;;;;
;;;; Copyright (c) 1988, Jim Mischel
;;;;
;;;; This program has been assembled using MASM 5.0. Changes may be required
;;;; for use with earlier versions.
page
;;;;; TSRPARK.ASM - Rick Housh
;;;;;
;;;;; TSRPARK.ASM - Modifications to TESSPARK.ASM to allow variable timing
;;;;; intervals from 1 to 9 minutes for autopark with use of numerical
;;;;; parameter on command line, to support manual parking with use
;;;;; of hotkey, with popup when on DOS command line, detection of
;;;;; park failure on installation, and communication with the resident
;;;;; program to allow dynamically changing the elapsed time between
;;;;; automatic parks. Assembled using MASM 5.1.
;;;;;
;;;;; Everything is self-explanatory, except perhaps how to reset the
;;;;; timer when resident. Just enter ' TSRPARK # ', where # is any number
;;;;; of minutes between 1 and 9, and the new value will be inserted in the
;;;;; resident portion of the program. A message will confirm the change
;;;;; and even the MAPMEM display of residents will show the new value.
;;;;; Entering ' TSRPARK ' with no parameter will yield a confirming message
;;;;; if TSRPARK is resident, and an instructional message if it has not
;;;;; yet been installed. When the hotkey is pressed from the DOS prompt
;;;;; a message is displayed, in addition to the TESSBEEP sound. Inside
;;;;; a program, the sound will occur, but there will be no message.
;;;;;
;;;;; I have changed the "mysterious" headparking code somewhat, and tried
;;;;; to expand the comments to show how it really works. It's not that
;;;;; complicated, and does NOT care whether the computer is an AT or not,
;;;;; contrary to the comments in the original TESSPARK. I have also found
;;;;; an undocumented and useful function. Tch, tch. TSRCHECKRESIDENT
;;;;; returns the segment of the resident program in the es register if
;;;;; it has found the program installed in memory. The documentation
;;;;; only mentions a result returned in the ax register. I found this
;;;;; very useful, and have implemented it in TSRPARK.
;;;;;
;;;;; TSRPARK Modifications of TESSPARK, Rick Housh, CIS 72466,212 - 7/18/1988
;;;;;
Comment~ Rick's method of communicating with the resident program is
efficient because the actions are performed by non-resident
code; but this version, TeSRpark by Tom Gilbert's Heart and
Mind, permits a command parameter "0" to effectively disable
TeSRpark by setting the delay to 60 minutes and demonstrates
communicating with the resident program through TSRUSERPROC:
Our objective has been to make the demonstration a thorough
one even though we realize that we can give advice; but not
the wisdom to profit by it: - Tom Gilbert's Heart & Mind.~
;;;;;
;;;;; To assemble this TesSeRact version:
;;;;;
;;;;; MASM TESRPARK;
;;;;; LINK TESS_ASM + TESS_BP + TESRPARK + TESS_END,TESRPARK;
;;;;; EXE2BIN TESRPARK TSRPARK.COM
;;;;; DEL TESRPARK.EXE and .OBJ
;;;;;
.model small
.code
page
;
tinkle equ 1
;
;Sound TESSBEEP if set
;set tinkle to 0
;for no sound
;
; Ticks2wait is # of timer ticks to wait between the last drive access
; and parking the drive. There are approximately 18.2 ticks per second.
;
; The maximum possible ticks2wait of 65536 ticks, very close to 1 hour,
; will be set for a command of "0". For 1 - 9 ticks2wait 1092 to 9828.
;
UserPtr equ $
db "1234567890" ;Possible minutes between parks
ticks2wait dw ? ;Ticks to wait:
ticks_min equ 1092 ;1092 = 1 minute
tick_count dw ? ;Current count
do_park db 0 ;Flag set to 1 when wish to park
int13ptr dw 0 ;Saved location of INT 13 flag
; from TesSeRact data area
ParkNum dw 0 ;TeSRpark's TesSeRact ID number
;
;I know the messages below look messy, but they stay resident and take
;up memory, so many of them do double duty. Hence the many labels.
; Rick Housh
;
are_parked label near
db 7 ;A bell to start already parked msg
park_msg label near ;Message to display when popped up
db 13,10 ; AND at DOS prompt
ParkName db 'TeSRpark' ;TeSRpark's Identification string
db ' Status Report of Hard Drive'
more_drives db ' ' ;space if one, 's' if more
db 13,10
db 'Already parked. No action taken.'
are_parked_len equ $ - are_parked ;message ends here
db 13,'Drive'
and_more_drives db ' '
db 'manually parked as requested. '
repark db 13,10,'Will automatically repark drive'
and_still_more db ' ',13,10
TSRminutes label near ;Minutes between parks in ASCII
db 'xx minutes after next access.'
carriage db 13,10
repark_len equ $ - repark
park_msg_len equ repark - park_msg
public topstack
db 48 dup('Back_Gnd') ;BackProcStack - 384 bytes
db 48 dup('TSR_Main') ;MainProcStack - 384 bytes
topstack equ this byte
;
; The parkit routine attempts to park all hard drives.
; Returns with carry set if park was unsuccessful.
;
parkit proc near
mov si,0080h ;Hard drive ID's start at 80h
pk0: mov ah,08h ;Function gets drive parms.
mov dx,si ;DX is drive ID No.
int 13h ;Get drive parms-dl = # drives
jc pkdone ;Error if carry, jump out
xor dh,dh ;Don't need max head-side #
mov di,dx ;Save drive count, dl to di
cmp di,01h ;Is there at least one?
jb pkdone ;If no hard drives, exit
jz pk1 ;Yes? Just set up for park
mov more_drives,'s' ;More than one?
mov and_more_drives,'s' ;Then put plurals
mov and_still_more,'s' ;in message strings
pk1: add di,7fh ;Convert drive # to ID #
inc ch ;CH is now tracks + 1
jnb pk2 ;Don't bump sectors
add cl,40h ;CL is sectors
pk2: mov ax,0c01h ;Seek to cylinder
mov dx,si ;DX is drive ID
int 13h ;Do the seek, park
inc si ;Bump drive count
cmp si,di ;Was it the last? No?
jbe pk0 ;Loop until all parked
pkdone:
if tinkle ;If you don't like it
EXTRN TESSBEEP:NEAR ;set tinkle to 0
;else sound TESSBEEP
call TESSBEEP ;whenever parking
endif
ret
parkit endp
reset_it proc near
mov do_park,0 ;Say not to park
mov bx,int13ptr ;Get INT13 flag and
mov byte ptr [bx],0 ;reset since parked.
mov ax,ticks2wait ;Use our timer to
mov tick_count,ax ;restart wait.
ret
reset_it endp
;
; TesSeRact Entry Points
;
;
PUBLIC TSRUSERPROC, TSRTIMERPROC, TSRBACKCHECK, TSRBACKPROC, TSRMAIN
PUBLIC TSRCLEANUP
TSRUSERPROC proc near ;Perform response to
assume cs:_TEXT,ds:_TEXT,es:_TEXT ;TesSeRact Function 20h
mov si,offset TSRminutes ;When it points the
xchg si,di ;UserPtr {ES:DI} at new
lodsb ;ASCII minutes
cbw ;Extended to AX.
cmp ax,"0" ;If NOT a "0"
jnz twoASC ;Then make "0x"
mov ah,6 ;Else make "60"
twoASC: or ah,"0"
xchg ah,al ;Reverse to Store in
stosw ;TSRminutes as ASCII
mov al,ah ;Restore ASCII and
and ax,0Fh ;Convert to value.
mov cx,ticks_min ;Calculate new
mul cx ;Number of
mov ticks2wait,ax ;Ticks to Wait.
call parkit ;Park the heads.
call reset_it ;Reset tick_count.
ret ;New delay is set.
TSRUSERPROC endp
TSRTIMERPROC proc near
assume cs:_TEXT, ds:_TEXT
mov bx,int13ptr ;Check to see if
cmp byte ptr [bx],1 ;drive has been accessed
jne no_park ;since last parked and
;exit if NOT...!
mov do_park,0 ;Else set park flag off
dec tick_count ;If NOT the Last Tick
jnz no_park ;Then exit
mov do_park,1 ;Else set park flag on
clear_it:
mov ax,ticks2wait ;Use our own parameter
mov tick_count,ax ;to restart wait
mov byte ptr [bx],0 ;and clear flag
no_park:
ret
TSRTIMERPROC endp
TSRBACKCHECK proc near
assume cs:_TEXT, ds:_TEXT
mov al,do_park ;Return flag in AX.
xor ah,ah ;If flag is non-zero
ret ;then TSRBACKPROC happens!
TSRBACKCHECK endp
TSRBACKPROC proc near
assume cs:_TEXT, ds:_TEXT
call parkit ;Attempt to park and
call reset_it ;reset ticks and fleas (flags).
ret
TSRBACKPROC endp
Print_Msg proc near
mov ah,08h ;Read attribute at
int 10h ;current position then
or ah,08h ;turn on intensity bit
mov bl,ah ;and save it in bl
putmsg: mov al,0eh ;Using teletype mode
lodsb ;load ASCII character
cmp al,20h ;Is it lower than space?
jb no_att ;then don't paint attribute
push cx ;else save count
push ax ;Save character
mov ax,0920h ;Paint with a space
mov cx,1 ;With this function
int 10h ;cursor doesn't move.
pop ax ;Restore character
pop cx ;and character count
no_att: mov ah,0eh ;Use teletype mode
int 10h ;to print characters
loop putmsg ;until end of string
ret
Print_Msg endp
TSRMAIN proc near
assume cs:_TEXT, ds:_TEXT ;On hotkey
mov bx,int13ptr ;check if accessed
cmp byte ptr [bx],0 ;since last park
jnz park_now ;If so, park em
mov si, offset are_parked ;else, display
mov cx,are_parked_len ;that already parked,
jmp short display_parked_msg ;skipping park routine
park_now:
call parkit ;Park drive(s) and
call reset_it ;reset flags and ticks.
mov si,offset park_msg ;Point to park message
mov cx,park_msg_len ;and its length
display_parked_msg:
push cx ;Save length of message
mov ax,5453h ;TesSerAct function
mov bx,16h ;to get InDos state
mov cx,ParkNum ;This program's ID #
int 2fh ;Call function 16h
pop cx ;{MUST pop message length}
;{now in case of jump}
cmp bx,1 ;Check if at DOS prompt
jnz mainX ;and end main if not
call print_msg ;else print it
mov si,offset repark ;Now print
mov cx,repark_len ;minutes to go
call print_msg ;between parks
mov ax,5453h ;TesSeRact function to
mov bx,21h ;stuff Keyboard Buffer
mov cx,ParkNum ;from TeSRpark program
mov di,offset carriage ;There's an ASCII 13 here
mov si,1 ;Write one carriage
mov dx,0101h ;return at medium
int 2fh ;speed as ASCII character.
mainX: ret ;DOS prompt should be back.
TSRMAIN endp
TSRCLEANUP proc near
assume cs:_TEXT, ds:_TEXT
or ax,ax
jnz clean_term
clean_init:
mov cx,ParkNum ;Use program's ID num to
mov bx,4h ;Get data area address.
mov ax,5453h
int 2fh
add bx,3h ;Adjust to "Was13" offset.
mov int13ptr,bx ;Store address pointer.
clean_term:
ret
TSRCLEANUP endp
; End of resident program. Initialization section follows:
;
; If TeSRpark already installed, change delay and/or display message.
; If not installed, attempt to park the drives and install the resident
; portion.
;
EXTRN TSDOINIT:NEAR
EXTRN TSCHECKRESIDENT:near
EXTRN TSSETSTACK:near
PUBLIC TESSINITSTART ;Required entry point
TESSINITSTART:
assume cs:_TEXT, ds:_TEXT
jmp start_init ;Jump over data
;
;Non-resident data area
;
;Following are the message strings for the transient part of the program
;They do not go resident and are not available to the TSR portion
;
signon label byte
db 13,10,'TESSPARK.COM Version 1.0, Copyright (c) '
db '1988, TesSeRact(tm) Development Team',13,10
db 'All Rights Reserved',13,10,10
db 'Based on Original Code provided by Jim Mischel:',13,10
db ' AUTOPARK 1.0 Copyright (c) 1988, Jim Mischel',13,10,10
db "TeSRpark revision - Rick Housh with Tom Gilbert's Heart&Mind DPCS"
db 13,10
db ' Hotkey instant park, variable auto park intervals,',13,10
db ' popup message (at DOS prompt), detection of park',13,10
db ' failure on installation, and change of timer while',13,10
db ' resident without removal and reinstallation.'
db 13,10,10
db 7,'Command line error. TeSRpark NOT loaded.',7,13,10,10
db 'Syntax: TESRPARK # (Where # is 1 - 9 [minutes] between parks)'
db 13,10,9,'or 0 to disable TeSRpark by delaying 1 hour.',13,10,'$'
already_installed label byte
db 13,10,'TeSRpark already resident',13,10,7,'$'
tsr_reset label byte
db 13,10,'Resident TeSRpark reset to',13,10,'$'
installed label byte
db 13,10,'TeSRpark installed. '
auto_time label byte
db 'Auto park every '
minutes label byte
db ' '
db ' minutes.',13,10
HotKeyM label byte
db 'Left Shift + Alt + "P" parks hard drive(s) instantly!',13,10,'$'
ding_a_ling label byte
db 'A "tinkle" will sound when heads are parked.',13,10,'$'
bad_park label byte ;BAD PROBLEM, LOTS OF BELLS
db 13,10,7,'Hard drive error. Unable to park hard drive(s).'
db 13,10,7,'Terminating.',13,10,7,'$'
get_cmd_line:
mov si,80h ;Start of command line
mov bx,9 ;Index to numerals
lodsb ;Command length
cmp al,0 ;If no command
jz cmd_err ;or if command
get_1: lodsb ;ends before a
cmp al,13 ;numeric input
jz cmd_err ;then CY exit.
mov di,offset UserPtr ;else scan the
mov cx,10 ;ten numerals.
repne scasb ;If no match
jne get_1 ;then loop
sub bx,cx ;else use index to
mov di,offset UserPtr ;return DI pointer
add di,bx ;for TSRUSERPROC,
cbw ;AX character and
ret ;carry flag clear.
cmd_err:
stc ;Set carry flag
ret ;and return
;
; Although I can't find it in the version 1.00 TesSerAct documentation,
; TSRCHECKRESIDENT, if it finds the code resident, returns not only
; 0ffffh in ax but the segment of the resident version in the es register.
; This makes it unnecessary to call multiplex function 4 to find
; its location. I will use that undocumented feature here, but
; we should have been told. - Rick Housh
;
start_init:
mov si,offset ParkName ;Check to see if resident
mov di,offset ParkNum ;Returns segment of resident
call TSCHECKRESIDENT ;program in es if installed
or ax,ax ;If NOT already installed
jz do_install ;then attempt to install
call get_cmd_line ;else if command invalid
jc just_checking ;just display status and exit
cmp ax,"0" ;If NOT a "0"
jnz ASCtwo ;then make "0x"
mov ah,6 ;else make "60"
ASCtwo: or ah,"0" ;in resident data areas.
mov minutes,ah ;Store Most Significant and
mov minutes[1],al ;Least Significant Bytes in
mov es:[82h],ah ;message and TSR command line
mov es:[83h],al ;but NOT TSRminutes or ticks.
mov ax,5453h ;Use TesSeRact Call User
mov bx,20h ;Function with ES:DI to
mov cx,es:ParkNum ;send the new TSRminutes.
int 2Fh ;Silly, but demonstrates.
mov dx,offset tsr_reset ;Tell em have changed it
mov ah,09h
int 21h
jmp short display_time ;and display new value
just_checking:
mov dx,offset already_installed
mov ah,09h ;Display "already resident"
int 21h
mov ax,word ptr es:[TSRminutes]
mov word ptr minutes,ax ;Move resident value here and
display_time:
mov ah,09h
mov dx,offset auto_time ;Display current minute value
int 21h
term_it:
mov ax,4c01h ;Set error code to 1
int 21h ;and quit
do_install:
mov si,offset topstack ;Divide stack into
mov di,si ;PopUpStack and
sub si,384 ;BackGroundStack
call TSSETSTACK ;Two 384 byte stacks
call get_cmd_line ;If invalid command line
jc cmdline_err ;then display message and exit
cmp ax,"0" ;else if NOT a "0"
jnz ASC_2 ;then make "0x"
mov ah,6 ;else make "60"
ASC_2: or ah,"0" ;in local data areas.
xchg ah,al ;Account for Lo/Hi
mov word ptr minutes,ax ;Store Message and
mov word ptr TSRminutes,ax ;TSR minutes ASCII.
mov al,ah ;Restore minutes to AL and
and ax,0Fh ;Convert ASCII to numeric.
mov cx, ticks_min ;NOTE: 0 counts 65536 ticks.
mul cx ;Multiply by ticks
mov di,offset ticks2wait ;per minute (1092).
stosw ;Initialize wait and
stosw ;current timer counts.
call parkit ;If heads park Ok
jnc good_park ;then set command and report
mov dx,offset bad_park ;else print an error report.
mov ah,09
int 21h
jmp term_it ;and quit with error code
good_park:
mov cx,offset HotKeyM ;Calculate length of
mov si,offset minutes ;minutes message to
sub cx,si ;carriage return.
dec cx
mov di,82h ;Transfer new
mov [di-2],cl ;length and
rep movsb ;new command.
mov dx,offset installed
mov ah,09 ;Show that it's installed
int 21h
mov dx,offset ding_a_ling
mov ah,09 ;and that it tinkles.
int 21h
mov dx,offset TESSINITSTART ;Set last resident byte
mov bx,1170h ;No pop graphics. Background,
;main, user and main procedures
mov ax,0a19h ;Left Shift + Alt + "P" will be
jmp TSDOINIT ;hotkey for manual park.
cmdline_err:
mov dx,offset signon
mov ah,09
int 21h ;Display the signon message
jmp term_it ;and quit with error code
_TEXT ends
END