Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Processes
Chapter 4 - Vertical Retrace Manager / Using the Vertical Retrace Manager


Accessing a Task Record at Interrupt Time

A repetitive VBL task must access its task record so that it can reset the vblCount field. As explained in "The VBL Task Record" on page 4-6, the Vertical Retrace Manager decrements the vblCount field during each interrupt and executes the task when that field reaches 0. The task is removed from its queue if the value of the vblCount field is left at 0.

When the Vertical Retrace Manager executes the VBL task, it places the address of the VBL task record into the A0 register. Listing 4-4 defines an inline function that moves this value onto the stack.

Note
You should call the inline function in Listing 4-4 only from a VBL task. It will not work if called from your main program. In addition, the call to this function should be the first line of your VBL task, because other processing might change the value in A0. ·
Listing 4-4 Finding the address of the task record from within a VBL task

FUNCTION GetVBLRec: LongInt;
      INLINE $2E88;              {MOVE.L A0,(SP)}
The GetVBLRec function defined in Listing 4-4 returns a long integer specifying the address of the task record. Now that you can access the task record, you can easily reset the value of the vblCount field. Listing 4-5 provides an example of a generic VBL task that accesses the task record and resets the vblCount field.

Listing 4-5 Resetting a VBL task so that it executes again

PROCEDURE DoVBL;
CONST
   kInterval = 6;                   {frequency in interrupts}
TYPE
   VBLTaskPtr = ^VBLTask;           {pointer to a VBLTask record}
VAR
   taskPtr: VBLTaskPtr;
BEGIN
   taskPtr := VBLTaskPtr(GetVBLRec);{get address of task record}

   {Put task-specific code here.}

   taskPtr^.vblCount := kInterval;  {reset vblCount}
END;


Previous Book Contents Book Index Next

© Apple Computer, Inc.
17 JUN 1996