Important: The information in this document is obsolete and should not be used for new development.
Accessing a Task Record at Interrupt Time
A repetitive VBL task must access its task record so that it can reset thevblCount
field. As explained in "The VBL Task Record" on page 4-6, the Vertical Retrace Manager decrements thevblCount
field during each interrupt and executes the task when that field reaches 0. The task is removed from its queue if the value of thevblCount
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.
Listing 4-4 Finding the address of the task record from within a VBL task
- 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. ·
FUNCTION GetVBLRec: LongInt; INLINE $2E88; {MOVE.L A0,(SP)}TheGetVBLRec
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 thevblCount
field. Listing 4-5 provides an example of a generic VBL task that accesses the task record and resets thevblCount
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;