q4kx@vax5.cit.cornell.edu (Joel Sumner) (10/15/90)
Actually, there really is nothing mysterious about writing a PIF or TIF file.
I wrote BlankINIT in TML Pascal v1.5 with no problems. A PIF is no more
than a program that gets executed at boot time and then stays in memory. A
TIF is the same but it gets dumped from memory when it is finished.
Sample PIF
Program MyPIF;
type TaskRecord = Record
nextTask:=longint;
interval:=integer;
signature:=integer;
somecode:=array[1..3] of byte;
myProcPtr:=ProcPtr;
end;
var MyMemoryID:integer;
TaskRec:TaskRecord;
Function CheckSomething:Boolean;
begin
end;
Procedure DoSomething;
begin
end;
Procedure TheInterrupt;
begin
if CheckSomething then DoSomething;
TaskRec.interval:=1; {Reset the interval}
end;
begin {main program, gets executed at boot time}
MyMemoryID:=MMStartUp;
MTStartup;
with TaskRec do
interval:=1; {1/60th of a sec, 60:=1 sec, etc..}
signature:=$a55a;
someCode[1]:=$C2; {REP}
someCode[2]:=$30;
someCode[3]:=$5c; {JMP Long}
myProcPtr:=@TheInterrupt;
end;
SetHeartBeat(@TaskRec);
MTShutDown;
MMShutDown(MyMemoryID);
end;
The TaskRec/SetHeartBeat code is courtesy of Dave Lyons. I have not had
success with this using ORCA/Pascal and I cannot determine why. It may
have to do with the range checking. It tends to trash the stack. But it
may just be me (more likely <grin>).
Now, you are probably saying to yourself, "This looks just like a regular
application, what is the difference?" Exactly, there isn't much difference.
There are three things you MUST do.
1 - Change the filetype to PIF (STR)
2 - Move it to the */SYSTEM/SYSTEM.SETUP subdir
3 - Use Block Warden, etc.. to change the QUIT command to an RTL. When this
code is compiled with TML, it seems to consistently be placed at $54
but this may not be 100% certain.
That's all there is to it. For a TIF, you DON'T want to install an interrupt
(because the Interrupt procedure will be dumped from memory) but it is just
like a regular application. Again, you have to change the filetype to
TIF, copy the file, and change the QUIT to an RTL.
Have I missed anything?
--
Joel Sumner GENIE:JOEL.SUMNER These opinions are
q4kx@cornella.ccs.cornell.edu q4kx@cornella warranted for 90 days or
q4kx@vax5.cit.cornell.edu q4kx@crnlvax5 60,000 miles. Whichever
.................................................... comes first.
Never test for an error condition that you can't handle.