****************************************************************************

ProggyTimer V1.0 Olly Koenders 31-07-97


This little (!) util is CLI only and will call any specified program that
can be run via CLI/Shell before entering a delay loop that will call it
recursively using timed intervals.

----------------------------------------------------------------------------

Template:

ProggyTimer [x] [path/filename]

Where x is: 0 -> 15 minute intervals
          : 1 to 9 -> 1 to 9 hour intervals.

If any of the above is omitted then the results will be undefinable!

"ProggyTimer 5 C:Avail FLUSH" will set the timed intervals to 5 hours between
flushes.

----------------------------------------------------------------------------

ProggyTimer will begin a background process when called so won't require to
be called with "Run <>NIL: ProggyTimer".

The assembler source follows and requires no "includes" or "x-refs" and
should assemble straight up without modification.  Original assembly was
with Maxon 4.5/5.0.  This is a 10 minute hack and works without fault on
any processor and KS 1.2+.

You are free to change the code and reassemble as you see fit, just don't
fuck it up and pass it on as a bug of mine!

Any changes to the code should be added to the line below and then some
explanatory text about the changes before reassembling and distributing.

----------------------------------------------------------------------------

V1.0 31-07-97 Original assembly by Olly koenders - Australia.
No bugs.  Executable size: 328 bytes.

****************************************************************************
	section detach,code,public

execbase=4
openlib=-408
findtask=-294
createproc=-138
mode_new=1006
open=-30
execute=-222
delay=-198


code:
	move.l execbase,a6
	clr.b -1(a0,d0.w)
	move.b (a0)+,number+3	;store timer value
	addq.w #1,a0
	move.l a0,proggy	;store path/filename parameter
	lea dosname,a1
	jsr openlib(a6)		;open dos.lib
	move.l d0,dosbase
	move.l d0,a6
	lea code(pc),a0
	move.l -4(a0),d3
	clr.l -4(a0)		;change starting address
	move.l #name,d1
	moveq #0,d2
	move.l #4096,d4
	jsr createproc(a6)	;start process from "task"
	moveq #0,d0
	rts

	section task,code,public	;<-- DO NOT REMOVE!  Necessary!

task:
	move.l dosbase,a6
	move.l #outhandle,d1
	move.l #mode_new,d2
	jsr open(a6)		;open NIL: output
	move.l d0,d5
	lea table(pc),a0
	move.l number(pc),d0
	sub.b #$30,d0
	add.b d0,d0
	add.b d0,d0
	move.l (a0,d0.w),d6	;get delay from table and store

loopit:
	move.l proggy(pc),d1	;string to call
	move.l d5,d2		;<NIL:
	move.l d5,d3		;>NIL:
	jsr execute(a6)		;run it
	move.l d6,d1		;the delay value
	jsr delay(a6)		;and wait - no processor time wasted
	bra.b loopit		;do it endlessly

dosname:
	dc.b "dos.library",0
	even

outhandle:
	dc.b "NIL:",0
	even

dosbase:
	dc.l 0

number:
	dc.l 0

table:
	dc.l 45000	;15 min
	dc.l 180000	;1 hour
	dc.l 360000	;2 hours
	dc.l 540000	;3
	dc.l 720000	;4
	dc.l 900000	;5
	dc.l 1080000	;6
	dc.l 1260000	;7
	dc.l 1440000	;8
	dc.l 1620000	;9

name:
	dc.b "ProggyTimer",0
	even

proggy:
	dc.l 0
	end

