Article View: comp.sys.mac
Article #15970Vertical Retrace Task in Pascal
From: Richard Siegel
Date: Wed, 06 May 1987 18:03
Date: Wed, 06 May 1987 18:03
76 lines
2356 bytes
2356 bytes
Following is a short Lightspeed Pascal program that does a vertical retrace
task.
The program should be commented well enough, but if you've any comments,
send 'em to rs4u@andrew.cmu.edu or {ucbvax, decvax, seismo}!andrew.cmu.edu!rs4u
--Rich
PROGRAM Retrace;
{Puts up a vertical retrace task that inverts the menu bar and beeps twice per
second.}
{This is a really quick and dirty program; the task itself calls SetUpA5 so that
the system}
{doesn't risk a crash. This is because we modify "mytask" (an application
global) directly}
{to keep the task running. Recall that a task has to reset its own VBLCount
field}
{in order to keep running. This is the simplest (but not the best) way to do
that}
{Richard Siegel. May 6, 1987}
{Comments to rs4u@andrew.cmu.edu}
VAR
myTask : VBLTask;
PROCEDURE TheTask;
VAR
task : VBLTask;
BEGIN
{Do our thing}
SysBeep(2); {beep for 2 ticks}
FlashMenuBar(0); {invert the menu bar}
SetUpA5; {get application globals boundary so we get the right pointer to
"myTask"}
mytask.vblCount := 30; {we need to reset this so the task will keep executing}
RestoreA5; {restore A5 to what it was before}
END;
PROCEDURE InstallTask;
VAR
err : OSErr;
BEGIN
WITH myTask DO
BEGIN
qType := Ord(vType); {A vertical retrace task!}
vblAddr := @TheTask; {our task procedure}
vblCount := 30; {30 ticks between invocations}
vblPhase := 0; {no timing shift}
END;
err := VInstall(@myTask); {Install it}
END;
PROCEDURE RemoveTask;
VAR
err : OSErr;
BEGIN
err := VRemove(@MyTask); {fields are already set up; remove the task}
END;
BEGIN
InstallTask;
WHILE NOT Button DO {wait for mouse click}
;
RemoveTask; {if we don't remove it the system's likely to crash when we exit}
END.
Technical Details
Message-ID:
<MUbrfUy00UhTyhk0LK@andrew.cmu.edu>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-lcc!styx!ames!ucbcad!ucbvax!ANDREW.CMU.EDU!rs4u#Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-lcc!styx!ames!ucbcad!ucbvax!ANDREW.CMU.EDU!rs4u# From: rs4u#@ANDREW.CMU.EDU (Richard Siegel) Newsgroups: comp.sys.mac Subject: Vertical Retrace Task in Pascal Message-ID: <MUbrfUy00UhTyhk0LK@andrew.cmu.edu> Date: Wed, 6-May-87 14:03:12 EDT Article-I.D.: andrew.MUbrfUy00UhTyhk0LK Posted: Wed May 6 14:03:12 1987 Date-Received: Sat, 9-May-87 01:00:17 EDT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 76