home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / UTILITY / DISK / TIMEP37E.ZIP / TIMEPRK7.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-06-15  |  19.0 KB  |  603 lines

  1. ;       TIMEPRK7.ASM    Version 3.70 *** 11 JUN 90 *** T.D. Cobb
  2. ;------------------------------------------------------------------------------
  3. PAGE 60,132
  4. ;
  5. ;       Assembles Under Tubro Asm Ver 1.0 
  6. ;
  7. ;       This TSR uses 73% Less Resident Memory (364% more efficient)
  8. ;       (176 bytes verses 640) Than Mr. Zelkovitz's Vers 1.1
  9. ;    Uses 32 bytes more if equated to save stack space (This should not
  10. ;    be needed.)
  11. ;
  12. ; ******************************************************************************
  13. ; * Assembled Vers 3.7 HAS to be Converted to a binary file with EXE2BIN.EXE   *
  14. ; * Before it can be load from CONFIG.SYS. (TIMEPARK.SYS already is)           *
  15. ; *           TIMEPARK.SYS HAS LOADED as a Device Driver                       *
  16. ; *                  DEVICE=TIMEPARK.SYS /Tn /S                                *
  17. ; * /Tn is Optional. Where "n" is 1 to 9 minutes & will reduce Display Message *   
  18. ; * /S is Optional.  This will totally suppress all of the Display Message.    *
  19. ; ******************************************************************************
  20. ;
  21. ;       Version 3 Should not lockup the keyboard on none XT class
  22. ;       Machines Like My Pervious Vers 2 or Mr. Zelkovitz's Vers 1.
  23. ;
  24. ;    Version 3.4 User can chose between Seek or Verify. It looks
  25. ;    like some Cache's Do Not Seek if the track is already in cache.
  26. ;    I would set "SEEK equ TRUE" if not using a Cache.
  27. ;
  28. ;    Version 3.6 fixed floppy drive hang problem.
  29. ;
  30. ;    Version 3.7 Put TSR in Device Drivers Clothing.
  31. ;
  32. ;       Use and Enjoy and pass this on.
  33. ;
  34. ;                                               Tom Cobb
  35. ;                                               130 Janice Dr.
  36. ;                                               Athens, Ga 30606
  37. ;                                               (404)543-8017
  38. ;
  39. ;The ARCHED distribution contains the following files:
  40. ;
  41. ;    1) TIMPARK1.ASM     The assembly source
  42. ;    2) TIMEPARK.COM     The load module
  43. ;    3) TIMEPARK.DOC     Original miserable manual
  44. ;    4) TIMEPRK7.ASM     this Assemble source
  45. ;    5) TIMEPRK7.SYS     this Assembled source load module
  46. ;
  47. ;This software is placed in the PUBLIC DOMAIN to be used for NON-COMMERCIAL
  48. ;purposes only. You may  freely copy  and  use  it  without  any charge.
  49. ;       
  50. ;This program  must not be sold for profit. An adaequate fee may be
  51. ;requested for  copying, shipping  and handling when redistributing
  52. ;this program.
  53. ;
  54. ;Also, all five files MUST be passed on.
  55. ;
  56. ;The software is supplied AS IS and absolutely NO guarantees are given or
  57. ;implied about its suitability.
  58. ;
  59. ;
  60. ;  Parts of this source code where written and placed in PUBLIC DOMAIN by
  61. ;
  62. ;                       ALPHA COMPUTER SERVICE
  63. ;                      ( Sanford J. Zelkovitz )
  64. ;                            714-894-6808
  65. ;
  66. ;            Christoph H. Hochstätter
  67. ;            Carl-Strehl-Strasse 20
  68. ;            D-3550 Marburg
  69. ;            West-Germany
  70. ;
  71. ;
  72. ; Vers 2.06
  73. ;       Worked on XT class machines. Used 208 Bytes Resident Memory
  74. ;
  75. ; Vers 3.00
  76. ;       Changed verifys to seeks when parking drives
  77. ;       Now parks on park cyl if roll over from lower 8 bits of Seek cyl
  78. ;       Now enables interrupt Controller Chip so no keyboard lockup
  79. ;       Changed TSR org Address so Code is on even memory boundary
  80. ;
  81. ; Vers 3.40
  82. ;       Changed Int 1C so as not to Reenter it's self and
  83. ;       Keep Better System Time
  84. ;    Setup equate to chose between Seeks and Verifies
  85. ;    Removed redundant park code
  86. ;
  87. ; Vers 3.50
  88. ;    Moved test for already parked to front of TST code
  89. ;
  90. ; Vers 3.60
  91. ;    Trap park code out while in Int 13
  92. ;
  93. ; Vers 3.70
  94. ;    Placed TSR routine in Device driver form
  95. ;    Setup equate to Save Caller Registers while parking drives
  96. ;
  97. ;------------------------------------------------------------------------------
  98. ;
  99. ;       *************************
  100. ;       these are general equates
  101. ;       *************************
  102. FALSE   EQU     0                       ; define logical values
  103. TRUE    EQU     NOT FALSE
  104.  
  105.     ;*************************
  106. SEEKS    EQU    FALSE       ;*        ; Set false for some Caches 
  107.     ;*************************        ; SET True when No Cache in use
  108.                         ; by System
  109.  
  110. sav_stack    EQU    false            ; If true uses 32 bytes more
  111.     ;  bytes of memory and takes some work off the stack while parking 
  112.     ;  drives. This is something to try if you are sure this TSR is
  113.     ;  hanging system. 
  114.     ;  
  115.                         
  116.  
  117. default_time    EQU    '3'            ; Number of minutes delay to 
  118.                         ;  before parking if
  119.                         ;  no "/Tn" Option used.
  120. ;
  121. ;       ------------- Program Output Messages -------------
  122. ;
  123. ;       Some non-display ASCII character values
  124. CR      EQU     0DH             ; ASCII Carriage Return
  125. LF      EQU     0AH             ; Line Feed
  126. BEL     EQU     07H
  127. ;       Graphics characters for borders on the displays
  128. V_BAR   EQU     0BAH
  129. H_BAR   EQU     0CDH
  130. U_LEFT  EQU     0C9H
  131. U_RIGHT EQU     0BBH
  132. L_LEFT  EQU     0C8H
  133. L_RIGHT EQU     0BCH
  134. TOP_T   EQU     0CBH
  135. BOT_T   EQU     0CAH
  136. ;
  137.  
  138. ; ------------  Our Flag Equates
  139.  
  140. parked_flag                 equ     0
  141. ;not_parked_flag         equ     not parked_flag
  142. ;out_of_our_code_flag        equ    0
  143. in_our_code_flag          equ     1
  144. in_int13_flag            equ    80h
  145.  
  146. Cseg            segment word public 'derice_dvr'
  147.                 assume  cs:Cseg, ds:Cseg, es:nothing, ss:nothing
  148.  
  149. ;==============================================================================
  150.  
  151.         org    0
  152.  
  153. ;------------------------------------------------------------------------------
  154. resident_park   proc    far
  155.  
  156.         dd        -1                ; No other device drivers
  157.         dw        1000000000000000b        ; Character-Device
  158. stra        dw        strategy            ; Strategy-Routine
  159. entr        dw        entry                ; Interrupt-Routine
  160.         db        '&TPARK37'            ; Dummy-Name
  161.  
  162. error        proc      far
  163.         mov       word ptr es:[bx+3],8103h            ; Return ERROR status 
  164.         retf                                          ; if called twice 
  165. error        endp                          ; by this Dummy-Device
  166.  
  167. ;------------------------------------------------------------------------------
  168. ;    if    sav_stack
  169.     even                            ; make next address even
  170. ;    endif
  171. count           dw      0                            ; time delay counter
  172.  
  173. ;==============================================================================
  174.  
  175. Ourint1c    proc    far
  176.     if    sav_stack
  177.         mov    word ptr cs:ax_sav,ax
  178.     else
  179.         push    ax
  180.     endif
  181.         xor    al,al
  182.  
  183.             cmp    al,0ffh                
  184. parked        equ    $-1            ; parked when set to zero
  185.                 jz      by_pass                 ; jmp if all ready parked
  186.  
  187.                 dec     word ptr cs:count    ; decrement time counter
  188.                 jns     by_pass                 ; now jmp if time left on counter
  189.  
  190.             cmp     al,0
  191. busy        equ    $-1
  192.                 jnz     by_pass                 ; JMP so as not to
  193.                                                 ; reenter our code and 
  194.                         ; don't park while int13 busy
  195.  
  196. ;       park both Hard drives
  197.  
  198.     if     sav_stack
  199.                 or    byte ptr cs:busy,in_our_code_flag          
  200.                             ; Set to not Zero when
  201.                         ; in our park code
  202.     sti
  203.         mov    word ptr cs:ds_sav,ds    ; save regs to local area
  204. ;        mov    word ptr cs:ax_sav,ax
  205.         mov    ax,cs
  206.         mov    ds,ax
  207.         mov    word ptr cx_sav,cx
  208.         mov    word ptr bx_sav,bx
  209.         mov    word ptr dx_sav,dx
  210.         mov    word ptr si_sav,si
  211. else
  212.                 push    ds            ; save caller DS reg
  213.     sti
  214.         push    cs
  215.         pop    ds            ;ds = this seg
  216.  
  217.                 or    byte ptr busy,in_our_code_flag          
  218.                             ; Set to not Zero when
  219.                         ; in our park code
  220.                 push    cx
  221.                 push    bx                      ; save regs
  222.                 push    dx
  223.         push    si
  224.  
  225.     endif
  226.  
  227.     cli
  228.                 mov     al,20h                  ; Enable interrupt
  229.         out     20h,al                  ; Controller chip
  230.     sti
  231.         mov    si,80h            ; first hard disk 
  232.  
  233. parkloop:       mov     ah,08
  234.                 mov     dx,si
  235.                 int     13h                     ; get max cyl of hard disk
  236.  
  237.                 mov     dx,si
  238.                 inc     ch
  239.                 jnc     less_512_cys_0
  240.                 add     cl,40h                  ; adjust upper 2 bits of cyl
  241.                                                 ;  in bits 6-7
  242. less_512_cys_0:
  243.     if    seeks
  244.         mov     ax,0c01h        ; go Verify sec on max cyl +1    
  245.     else
  246.                 mov     ax,0401h        ; go seek to max cyl + 1
  247.         endif
  248.             int     13h                     ; (park cyl)
  249.  
  250.         inc    si
  251.         cmp    si,82h            ; (84h would park 4 drives)             
  252.         jb    parkloop                ; park both C & D drives                              
  253.  
  254.  
  255.     if    sav_stack            ; Use Local space to store
  256.         mov    cx,0            ;  user regs while parking
  257. cx_sav        equ    $-2
  258.         mov    bx,0
  259. bx_sav        equ    $-2
  260.         mov    dx,0
  261. dx_sav        equ    $-2
  262.         mov    si,0
  263. si_sav        equ    $-2
  264.  
  265.                 xor     al,al
  266.                 mov     byte ptr parked,al               ; mark as parked
  267.                 mov     byte ptr busy,al             ; mark as out of Our park code
  268.  
  269.         mov    ax,0
  270. ds_sav        equ    $-2
  271.         mov    ds,ax
  272. by_pass:                                         ; goto real int1C
  273.         mov    ax,0
  274. ax_sav        equ    $-2
  275.     else    
  276.         pop    si            ; restore user regs after parking
  277.                 pop     dx            ;  drives
  278.                 pop     bx
  279.                 pop     cx
  280.  
  281.                 xor     al,al
  282.                 mov     byte ptr parked,al               ; mark as parked
  283.                 mov     byte ptr busy,al             ; mark as out of Our park code
  284.  
  285.         pop     ds
  286. by_pass:                                         ; goto real int1C
  287.         pop    ax
  288.     endif
  289.     cli    
  290. ;            jmp     OldInt1c
  291.         db    0EAh        ; far jmp
  292. OldInt1COff     dw    0
  293. OldInt1CSeg     dw    0
  294. Ourint1c    endp
  295.  
  296. even                            ; make next address even
  297.  
  298. Ourint13    proc    far
  299.         assume ds:nothing, es:nothing, ss:nothing
  300.  
  301.     sti
  302.                 test    dl,80h          ; Msb set if Hard
  303.                 jz      floppy
  304.  
  305.                 push    ax
  306.                 mov     ax,07fffh
  307. value        equ    $-2        ; time delay value for reload    
  308.                 mov     word ptr count,ax
  309.  
  310.                 mov     byte ptr parked,ah    ; mark not parked (none zero)
  311.                 pop     ax
  312. floppy:
  313.  
  314.     ; MARK when in Int13 calls so we know when it's safe to park drives
  315.  
  316.         or    byte ptr busy,in_int13_flag    ;(none zero)
  317.  
  318.         pushf            ; setup to fake int13
  319.     cli                ; enable interrupts
  320.  
  321. ;               call     OldInt13         ;goto real int13
  322.         db    09Ah        ; Far Call 
  323. OldInt13Off     dw    0
  324. OldInt13Seg     dw    0
  325.  
  326.         and    byte ptr busy,not in_int13_flag
  327.         ret    2
  328. Ourint13    endp
  329.  
  330. resident_park   endp
  331.  
  332. tsr_end         equ     $
  333.  
  334. ;=======================================================================
  335. TsrCurtain      equ     $
  336. ;=======================================================================
  337.  
  338. savreq        label     dword                               
  339. savreq_o    dw        ?        ;...Save the ...
  340. savreq_s    dw        ?             ;...Request Headers
  341.  
  342. strategy    proc      far                   ;Strategy-Routine
  343.         mov       cs:[savreq_o],bx    ; BX saved
  344.         mov       cs:[savreq_s],es      ; ES saved
  345.         ret                                           
  346. strategy    endp
  347.  
  348. entry        proc      far        ; Entry to Device Driver Routines 
  349.         assume    cs:cseg
  350.  
  351.         push      ax        ; All Register and Flags saved
  352.         push      cx
  353.         push      dx
  354.         push      di
  355.         push      si
  356.         push      ds
  357.         push      es
  358.         push      bx
  359.         pushf
  360.         les       bx,cs:[savreq] ; load Request-Header pointer
  361.         mov       al,es:[bx+2]  ; Get command code from header
  362.         cmp       al,0          ; Is it Init command code (0)
  363.         jnz       unkwn_com     ; No, then return with Error
  364.         jmp       short init    ; Go do (TSR) Code Initialization
  365. entry        endp
  366.  
  367. rout        proc      far
  368. exit1:        mov       ax,100h    ; (Done) status
  369. jmp        short exgem
  370. unkwn_com:    mov       ax,8103h    ; (ERROR DONE UNKNOWN-COMMAND) status
  371. exgem:        mov       es:[bx+3],ax    ; Place status word in request header    
  372.         popf            ; All Register Restored
  373.         pop       bx
  374.         pop       es
  375.         pop       ds
  376.         pop       si
  377.         pop       di
  378.         pop       dx
  379.         pop       cx
  380.         pop       ax
  381.         ret
  382. rout        endp            ; return to device caller
  383.  
  384. Get_next_char    proc    near
  385. Dumpit:        lodsb
  386.         cmp    al,0Dh        ; cr or lf?
  387.         jbe    ajust_stack    ; yes
  388.         cmp    al,20h        ; less than space?
  389.         jbe    Dumpit        ; yes, ignore
  390.         ret
  391.         
  392. ajust_stack:    pop    ds        ; clear return address
  393.         jmp    Line_end    ; end of command line
  394. Get_next_char    endp
  395.  
  396. Init            proc    near
  397.                 assume  cs:Cseg, ds:Cseg
  398.  
  399.         xor    cx,cx        ; used to save config.sys options
  400.     
  401.         push    ds        ; save our ds pointer
  402.         lds    si,es:[bx+dword ptr 12h] ;get ds:si=ptr config.sys options
  403.  
  404. Scanname:    lodsb            ; scan to end of name
  405.         cmp    al,0Dh        ; end of line?
  406.         je    Line_end    ; yes, no options, use default
  407.         cmp    al,20h        ; end of driver name?
  408.         ja    Scanname    ; no
  409.  
  410. parc        proc    near
  411.         call    Get_next_char
  412.         cmp    al,'/'
  413.         jne    parc
  414.  
  415.         call    Get_next_char
  416.         and    al,0dfh        ; Make upper case
  417.         cmp    al,'S'        
  418.         jne    test_4_T    ; /S
  419.         not    ch        ; Mark to surpress output Message
  420.         jmp    parc
  421.  
  422. test_4_T:    cmp    al,'T'
  423.         jne    parc        ; /T
  424.         call    Get_next_char
  425.         cmp    al,'1'        
  426.         jb    parc        ; Greater than /T0
  427.         cmp    al,'9'
  428.         ja    parc        ; Less than /T:
  429.         mov    cl,al
  430.         jmp    parc
  431. parc        endp
  432.  
  433. Line_end:
  434.         mov    al,default_time
  435.         or    cl,cl        ; zero if not valid park time
  436.         jz    default        ; if zero use default
  437.         mov    al,cl        ; use valid time
  438. default:    
  439.  
  440. good_time:    pop    ds        ; restore our seg to DS
  441.         cmp     al,'1'        
  442.                 je      nochangemsg
  443.  
  444.                 mov     timemsg,al    ; fix message if not 1 minute
  445.                 mov     smsg,'s'
  446.  
  447. nochangemsg:
  448.                 and     ax,0fh        ; change ansi to bin
  449.                 mov     dx,1091        ; 1 second of ticks
  450.                 mul     dx
  451.                 mov     word ptr value,ax ; save for loading 
  452.                 mov     count,ax    ; load count down counter
  453.  
  454. ; ------------  DISLAY MSG ABOUT HOW WELL THIS IS ALL RUNNING
  455.         
  456.         or    ch,ch            ; test for display suppression
  457.         jnz    no_mesg
  458.         
  459.                 mov     dx,offset BannerMsg    ; display banner
  460.                 mov     ah,9
  461.                 int     21h 
  462.  
  463.         or    cl,cl
  464.         jnz    no_default_mesg
  465.  
  466.                 mov     dx,offset DefaultMsg    ; Using default message
  467.                 mov     ah,9
  468.                 int     21h
  469.  
  470. no_default_mesg:
  471.                 mov     dx,offset ParkMsg    ; display park message
  472.                 mov     ah,9
  473.                 int     21h 
  474. no_mesg:
  475. ;-------------
  476.     ; setup return ofAddress of first free memory above driver
  477.  
  478.         mov    word ptr es:[bx+16],cs            
  479.         mov    word ptr es:[bx+14],offset tsr_end    
  480.  
  481.     ; This will dummy the device driver to return  error if called.
  482.     ;  (Our TSR is never Called)                              
  483.  
  484.         mov    word ptr [stra],offset error        
  485.         mov    word ptr [entr],offset error        
  486.  
  487. ; ------------  SAVE VECTORS FOR OUR MONITOR INTERRUPTS
  488.  
  489.         push    es            ;save our es
  490.  
  491.     ; Setup to work on Interrupt vectors (SEG 0000) 
  492.     ; Can't use Int21h calls above 0Ch (except 30) in device drivers
  493.  
  494.         xor    ax,ax
  495.         mov    es,ax            
  496.  
  497.         lds    ax,es:[13h*4]           ;BIOS Disk Sevice
  498.                 mov     cs:[OldInt13Off],ax
  499.                 mov     cs:[OldInt13Seg],ds
  500.  
  501.         lds    ax,es:[1ch*4]           ;BIOS User ticker
  502.                 mov     cs:[OldInt1COff],ax
  503.                 mov     cs:[OldInt1CSeg],ds
  504.  
  505. ; ------------  load VECTORS FOR OUR MONITOR INTERRUPTS
  506.  
  507.     ; to set our INT13h handler
  508.  
  509.                 mov     word ptr es:[13h*4],offset Ourint13                
  510.                 mov     es:[13h*4+2],cs
  511.  
  512.     ;to set our INT1Ch handler
  513.  
  514.         cli
  515.                 mov     word ptr es:[1ch*4],offset Ourint1c                
  516.                 mov     es:[1ch*4+2],cs
  517.     sti
  518.         pop    es        ; point ES back to header 
  519.         jmp    exit1
  520.  
  521. Init            endp
  522. ;
  523. ;==============================================================================
  524. ;==============================================================================
  525. ; NON-RESIDENT MESSAGES FOR INIT
  526. ;==============================================================================
  527.  
  528. BannerMsg    label   byte
  529. db      cr,lf
  530. ;                 1                2         3         4         5         6
  531. ;        1234567890       123456789012345678901234567890123456789012345678901234567890
  532. db      '        ',U_LEFT, 59 DUP (H_BAR), U_RIGHT,cr,lf
  533. db      '        ',V_BAR,'                                                           ', V_BAR, cr,lf
  534. db      '        ',V_BAR,'         <<<<<<<  Timed Hard Disk Parker   >>>>>>>         ', V_BAR, cr,lf
  535. db      '$'
  536.  
  537. DefaultMsg     label   byte
  538. db      '        ',V_BAR,'                                                           ', V_BAR, cr,lf
  539. db      '        ',V_BAR,'         Version 3.70'
  540.  
  541. if (not seeks and not sav_stack)
  542.     db    '  '    
  543. endif
  544. if (seeks and not sav_stack)
  545.     db    's '
  546. endif
  547. if (not seeks and sav_stack)
  548.     db    't '
  549. endif
  550. if (seeks and sav_stack)
  551.     db    'ts'
  552. endif
  553.  
  554. db    ' *** 11 MAY 90 ** T.D. COBB         ', V_BAR, cr,lf
  555. db      '        ',V_BAR,'    Parts of this Code placed in the PUBLIC DOMAIN by      ', V_BAR, cr,lf
  556. db      '        ',V_BAR,'           C. Hochstätter, Sanford J. Zelkovitz            ', V_BAR, cr,lf
  557. db      '        ',V_BAR,'                                                           ', V_BAR, cr,lf
  558.  
  559. ;b      '        ',V_BAR,'      The Default Setting of 1 Minute is in effect.        ', V_BAR, cr,lf
  560. ;b      '        ',V_BAR,'      The Default Setting of X Minutes is in effect.       ', V_BAR, cr,lf
  561.  
  562. db      '        ',V_BAR,'      The Default Setting of ',default_time,' '
  563. if    (default_time EQ '1')
  564. db    'Minute is in effect.        ', V_BAR, cr,lf
  565. else
  566. db    'Minutes is in effect.       ', V_BAR, cr,lf
  567. endif
  568.  
  569. db      '        ',V_BAR,'                                                           ', V_BAR, cr,lf
  570. db      '        ',V_BAR,'             Use: DEVICE=TIMEPARK.SYS [/Tn /S]             ', V_BAR, cr,lf
  571. db      '        ',V_BAR,'                                                           ', V_BAR, cr,lf
  572. db      '        ',V_BAR,'       Where "n" is 1 to 9 minutes and will cause          ', V_BAR, cr,lf
  573. db      '        ',V_BAR,'        Part Suppression of this Display Message.          ', V_BAR, cr,lf
  574. db      '        ',V_BAR,'                                                           ', V_BAR, cr,lf
  575. db      '        ',V_BAR,'   Where "/S" will Suppress all Display Message Output.    ', V_BAR, cr,lf
  576. db      '        ',V_BAR,'                                                           ', V_BAR, cr,lf
  577. DB      '$'
  578.  
  579. ParkMsg        label   byte
  580. db      '        ',V_BAR,'          This Routine has been made Resident and          ',V_BAR, cr,lf
  581. db      '        ',V_BAR,'        Will Park both drive C: and D:, if present.        ',V_BAR, cr,lf
  582. db      '        ',V_BAR,'     Drives will be Parked '
  583.  
  584. timemsg label   byte
  585. db      '1'
  586. db      ' minute'
  587. Smsg    label   byte
  588. db      ' '
  589. db      ' after last Access.    ',V_BAR,cr,lf
  590.  
  591. memsize=((((Tsr_end - Resident_park) +15) SHR 4) *16)
  592. db      '        ',V_BAR,'               '
  593. db      (memsize/100)+30h
  594. db      ((memsize-((memsize/100)*100))/10)+30h
  595. db      (memsize-(((memsize/100)*100)+(((memsize-((memsize/100)*100))/10)*10)))+30h
  596. db      ' Bytes of Memory Consumed                ', V_BAR, cr,lf
  597.  
  598. db      '        ',V_BAR,'                                                           ', V_BAR, cr,lf
  599. db      '        ',L_LEFT, 59 DUP (H_BAR), L_RIGHT
  600. db      cr,lf,'$'
  601. Cseg            ends
  602.                 end
  603.