InitGrafprocedure to initialize QuickDraw.
PROCEDURE InitGraf (globalPtr: Ptr);
- A pointer to the global variable
thePort, which from Pascal can be passed as
InitGrafprocedure before initializing any other Toolbox managers, such as the Menu Manager and Window Manager. The
InitGrafprocedure initializes the global variables listed in Table 2-1 (as well as some private global variables for QuickDraw's own internal use). The
InitGrafprocedure also initializes Color QuickDraw on computers with Color QuickDraw capabilities.
Table 2-1 QuickDraw global variables (Continued) Variable Type Initial setting thePort GrafPtr NIL white Pattern All-white pattern black Pattern All-black pattern gray Pattern 50% gray pattern ltGray Pattern 25% gray pattern dkGray Pattern 75% gray pattern arrow Cursor Standard arrow cursor screenBits BitMap Entire main screen randSeed LongInt 1
ASSEMBLY-LANGUAGE INFORMATIONThe QuickDraw global variables are stored in reverse order, from high to low memory as listed in Table 2-1, and require the number of bytes specified by the global constant
grafSize. Most development systems preallocate space for these global variables immediately below the location pointed to by register A5. Since
thePortis 4 bytes, you would pass the
globalPtrparameter as follows:
PEA -4(A5) _InitGrafThe
InitGrafprocedure stores this pointer to
thePortin the location pointed to by A5.
This value is used as a base address when accessing the other QuickDraw global variables, which are accessed using negative offsets (the offsets have the same names as the Pascal global variables). For example:
MOVE.L (A5),A0 ;point to first QuickDraw global MOVE.L randSeed(A0),A1 ;get global variable randSeed
InitGrafprocedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.
SEE ALSOListing 2-1 on page 2-14 illustrates the use of
To initialize the cursor, call the
InitCursorprocedure, which is described in the chapter "Cursor Utilities."