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 / Vertical Retrace Manager Reference
Application-Defined Routine / VBL Tasks


MyVBLTask

A VBL task has the following syntax:

PROCEDURE MyVBLTask;
DESCRIPTION
The vblAddr field of a VBL task record contains the address of a VBL task that is executed after the number of interrupts specified in the vblCount field of the task record. The task can be set to execute at any frequency (up to once per vertical retrace interrupt). If the task uses application global variables or calls routines in another code segment, it must ensure that register A5 contains the address of the boundary between the application global variables and the application parameters. In addition, if your task calls routines in another code segment, that segment must already be loaded in memory.

Because of the optimizations performed by some compilers, the actual work of the VBL task and the setting and restoring of the A5 register might have to be placed in separate procedures. See Listing 4-9 and Listing 4-10 for an example of how you can do this.

Your VBL tasks shouldn't call VRemove or SlotVRemove to remove its entry from the queue. Instead, either your application should call one of those functions at noninterrupt time or your task should simply not reset the vblCount of the task record.

SPECIAL CONSIDERATIONS
Because a VBL task is executed at interrupt time, it should not allocate, move, or purge memory (either directly or indirectly) and should not depend on the validity of handles to unlocked blocks.

The code of the VBL task and any data accessed during its execution must be locked into physical memory if virtual memory is in operation.

Unless directed to do otherwise, some compilers insert code into your compiled application to facilitate debugging operations. This additional code can, however, cause trouble for VBL tasks and other interrupt processing. You might need to disable the generation of debugging code by enclosing the interrupt code between the appropriate compiler directives. Here's an example:

{$PUSH}
{$D-}
{Don't generate debugging code for this procedure.}
PROCEDURE DoVBL;
BEGIN
   ...
END;
{$POP}
Consult the documentation for your development system to see whether this is necessary and, if it is, how to do it.

ASSEMBLY-LANGUAGE INFORMATION
When the VBL task is called, register A0 contains a pointer to the VBL task record associated with that procedure.

A VBL task must preserve all registers other than A0-A3 and D0-D3. It must exit with an RTS instruction.

SEE ALSO
See the section "Accessing Application Global Variables in a VBL Task" beginning on page 4-13 for instructions on how to access your application's global variables in a VBL task.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
17 JUN 1996