UUCP@vu-vlsi.UUCP (04/14/87)
Have you ever missed that TV show that you wanted to see,
or perhaps you were late for an appointment because you lost track
of time while "playing" with your model-4?
>>>>> Have I got a program for you <<<<<
ALARM/CMD...an alarm clock that resides in backround while you
do other work(?). Just set it and forget it. You never know it's there
until it 'goes off' by making noise in the model-4's speaker. It takes only
88 bytes from high memory and installs in seconds. It requires a 64k model-4
running TRSDOS/LDOS 6.x and also requires that no routines be in high memory.
You can tell if your memory is clear by typing (from dos):
MEMORY<cr>
if High=FFFF then you can run ALARM. To do so type (from dos):
ALARM hh:mm:ss<cr>
(yes, all 8 characters of the time are required, as are COLONS seperating the
time and the SPACE after ALARM and before the time. DO NOT type any extra)
If ALARM was successful in setting itself it responds 'OK' and returns to
DOS. You can then do (almost) anything you want in the system. Alarm
clock operates invisably (via the interrupt task system) until it rings.
Even then, it 'self-destructs' by removing itself from the task area and
releasing high memory. (Test it by typing MEMORY while its running and
after it rings)
If ALARM could not install itself (and there was no system error), it
responds 'Failed' and returns to dos. You either have no task slots
available, HIGH$ is not FFFFh or you goofed on the command.
Below is the source code written in MICROSOFT M80 macro-assembler.
Note: it was relocated to FF1Fh during the LINKER phase. You can relocate
it lower (because of high memory routines) if you have the assembler &
linker. Just subtract 233 bytes from your current HIGH$. (The extra
144 bytes is the installation routine which goes away after ALARM is
set. BE SURE to alter the TASK section of the code to reset HIGH$ to
YOUR value (not FFFFh) if you have relocated the program elsewhere!
enjoy.....................Mark Gustitis
NAME('ALARM')
;
; Backround alarm clock (interrupt task)
; (bonus...fetch command string subroutine GETST)
;
; Mark Gustitis REV870221
; Riddle Glen B-7
; 1016 W. Baltimore Pike
; Media , PA 19063................(No phone calls please)
;
PG: DS 2 ;TEMP STORAGE FOR COUNTER ADDRESS
GETST: EX DE,HL ;SWAP COUNT ADDR INTO HL
LD (PG),HL ;STORE IT IN PG
LD HL,1055D ;PUT PEEK ADDR(-1) IN HL
LD B,0D ;SET CHARA COUNTER AT 0
GET2: INC HL ;INCREMENT PEEKER
LD A,H ;HL=1136? YES=OVERLOAD=GOTO GETE
CP 04H
JR NZ,GET3
LD A,L
CP 70H
JR Z,GETE
GET3: LD A,(HL) ;GET CHARA PEEKER POINTS AT
CP 32D ;SPACE?
JR Z,GET1 ;YES=GOTO GET1
CP 13D ;<CR>?
JR NZ,GET2 ;NO=GOTO GET2
DEC HL ;YES=RESET PEEKER TO RE-READ IT
GET1: INC HL ;INCREMENT PEEKER
LD A,(HL) ;GET CHARA IT POINTS AT
EX DE,HL ;SWAP BFR PNTR INTO HL
LD (HL),A ;STUFF CHARA IN BFR
INC HL ;INCREMENT BFR PNTR
CP 13D ;<CR>?
JR Z,GETE ;YES=GOTO GETE
INC B ;ELSE INCREMENT COUNTER
LD A,B ;PUT COPY OF COUNTER IN A
CP 255D ;255?
JR Z,GETE ;YES=OVERLOAD=GOTO GETE
EX DE,HL ;SWAP PEEKER BACK INTO HL
JR GET1 ;GOTO GET1
GETE: LD HL,(PG) ;PUT COUNTER ADDRESS IN HL
LD (HL),B ;PUT CHARA COUNT IN LOW ORDER ADDR
INC HL ;INCREMENT TO HIGH ORDER ADDRESS
XOR A ;CLEAR A REGISTER
LD (HL),A ;PUT IT IN HIGH ORDER ADDRESS
LD H,A ;CLEAR H REGISTER
LD L,B ;PUT CHARA COUNT IN L
RET ;RETURN
P1: DS 2
M1: DB 'OK',13D
M2: DB 'Failed',13D
START: LD HL,ENDT ;FETCH TIME TO ALARM
LD DE,P1
CALL GETST
LD A,(P1) ;DID USER TYPE 8 CHARA?
CP 8D
JR NZ,FAILED ;NO=FAILED
LD C,-1D
LOOP: INC C ;FIND FIRST FREE SLOT < #7
LD A,C
CP 7D
JR Z,FAILED ;NO SLOTS= FAILURE
LD A,28D
RST 28H
JR NZ,LOOP
LD A,C ;INFORM TASK OF ITS #
LD (TSKN),A
LD A,100D ;SET HIGH$ BELOW IT
LD B,0D
LD HL,$H
RST 28H
JR NZ,FAILED
LD DE,TASK ;AND PUT THE TASK IN SLOT
LD A,(TSKN)
LD C,A
LD A,29D
RST 28H
LD A,10D ;TELL USER OK & EXIT
LD HL,M1
RST 28H
JR XIT
FAILED: LD A,10D ;TELL USER FAILED & EXIT
LD HL,M2
RST 28H
XIT: LD A,22D
LD HL,0D
RST 28H
$H: NOP
TASK: DEFW STASK ;TASK TCB
TNUM: DB 3D
TSKN: DS 1
ENDT: DS 8 ;TIME TO ALARM AT
WK: DS 8 ;TIME TESTED AGAINST