Hi, This program should prevent disk power down by reading from drive C every 45 seconds or so. This is generally only an issue on laptops, which have a drive power-down feature which gets irritating after a while. The program works by recording the last track/sector/head read/written and re-reading it if 45 seconds elapse with no activity. This minimizes head movement but if you leave the computer unattended for long periods it will keep reading the same sector over and over. Anyone know if this is too much wear on the disk? I would have fixed it except hard disk sizes vary so much... David ; ; DISKON V1.0 ; ; Refreshes drive C every 45 seconds or so to keep it from powering down ; ; Feb 23, 1996, David Lindauer gclind01@starbase.spd.louisville.edu ; .386 MAXCOUNT EQU 45 * 18 ISIN EQU 1 VECTOR EQU 80h absseg segment word use16 at 0 org 02ch env dw ? ; in PSP; we can free env org 08*4 int08h dd ? ; Timer int org 13h*4 int13h dd ? ; Disk int org VECTOR *4 int80h dd ? ; program loaded int absseg ends cseg segment word use16 'CODE' assume cs:cseg org 100h assume ds:nothing, es:nothing begin: jmp start in13h db 0 ; TRUE if in int 13h old08 dd 0 ; Old 08 old13 dd 0 ; old 13 old80 dd 0 ; old VECTOR counter dw MAXCOUNT ; ticks counter, seconds *18 buffer db 512 DUp (?) ; i/O buffer track db 0 ; Last track read/written sect db 1 ; Last sector read/written head db 0 ; last head read/written ; ; vector to tell if program is loaded ; handler80 proc mov al,0ffh ; Set flag in al push cs pop es iret handler80 endp ; ; Timer vector ; handler08 proc pushf ; Call old int 8 to clear int system; call [old08] ; we may be called recursively so this ; MUST come first dec [counter] ; See how many ticks have gone by jnz short exit8 ; Get out if time not up mov [counter],MAXCOUNT ; Reset counter test [in13h],ISIN ; See if current drive access pending jnz short exit8 ; Get out if so calldirect: call readsect ; Read a sector from the disk exit8: iret ; Get out handler08 endp ; ; Disk handler ; handler13 proc or [in13h],ISIN ; Log that we are in disk handler ; No recursion PLEASE! cmp dl,080h ; See if drive C jnz doint13 ; Just do i/o if not cmp ah,2 ; Else if it is read jz logsect cmp ah,3 ; Or write jnz doint13 logsect: mov [track],ch ; Log the track, sector, head so mov [sect],cl ; we won't get extraneous drive movement mov [head],dh doint13: pushf ; Call the old disk int call [old13] pushf and [in13h], NOT ISIN ; Mark we are out popf retf 02 handler13 endp ; ; Read a sector from a disk, called at HW int level ; readsect proc pusha ; Push all regs push es pushf mov ah,2 ; Set up for a drive C read mov al,1 mov ch,[track] ; Last sector that was accessed mov cl,[sect] mov dh,[head] mov dl,80h mov bx,offset buffer ; Use internal buffer push cs ; pop es int 13h ; Do read popf ; Ignore return status, we tried and ; that is what counts here pop es popa ret readsect endp endtsr label BYTE ; ; Non-resident portion of TSR ; loadmsg db "Loading DiskOn",10,13,'$' unloadmsg db "Unloading DiskOn",10,13,'$' start proc assume ds:cseg, es:absseg push es ; Check if load vector exists sub ax,ax mov es,ax mov ax,word ptr [int80h] or ax,word ptr [int80h+2] pop es jz notloaded ; Go to load routine if not sub ax,ax ; Else call it int VECTOR ; cmp al,0ffh ; Correct return? jnz notloaded ; No, load mov dx,offset unloadmsg ; Display unload message mov ah,9 int 21h push ds push es push es pop ds sub ax,ax mov es,ax cli mov ax,word ptr [old08] ; Unload int 8 mov word ptr [int08h],ax mov ax,word ptr [old08+2] mov word ptr [int08h+2],ax mov ax,word ptr [old13] mov word ptr [int13h],ax ; Unload int 13 mov ax,word ptr [old13+2] mov word ptr [int13h+2],ax mov ax,word ptr [old80] mov word ptr [int80h],ax ; Unload VECTOR mov ax,word ptr [old80+2] mov word ptr [int80h+2],ax sti pop es pop ds push es mov es,es:[env] ; Free environment mov ah,49h int 21h pop es mov ah,49h ; free PSP int 21h mov ah,4ch ; Return to DOS int 21h notloaded: mov dx,offset loadmsg ; Tell them we are loading mov ah,9 int 21h sub ax,ax mov es,ax cli mov ax,word ptr es:[int08h] ; init int 8 mov word ptr [old08],ax mov ax,word ptr es:[int08h+2] mov word ptr [old08+2],ax mov ax,offset handler08 mov word ptr [int08h],ax mov ax,cs mov word ptr [int08h+2],ax mov ax,word ptr es:[int13h] ; init int 13 mov word ptr [old13],ax mov ax,word ptr es:[int13h+2] mov word ptr [old13+2],ax mov ax,offset handler13 mov word ptr [int13h],ax mov ax,cs mov word ptr [int13h+2],ax mov ax,word ptr es:[int80h] ; init VECTOR mov word ptr [old80],ax mov ax,word ptr es:[int80h+2] mov word ptr [old80+2],ax mov ax,offset handler80 mov word ptr [int80h],ax mov ax,cs mov word ptr [int80h+2],ax sti mov dx,offset endtsr ;calculate TSR size and exit add dx,15 shr dx,4 mov ah,31h int 21h start endp cseg ends end begin