ADC Home > Reference Library > Technical Notes > Legacy Documents > Tools >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

InitGraf with MPW Assembly

CONTENTS

The Macintosh Programmer's Workshop (MPW) requires assembly-language programmers to allocate their own QuickDraw global variables rather than use the default record as indicated in Inside Macintosh.

[Feb 01 1989]






In the Beginning...

Early Macintosh assembly-language development systems automatically allocated a set of QuickDraw global variables (a QuickDraw record) on the application's stack. The assembly-language note in Inside Macintosh, I-163 indicates that the programmer should use the following code to specify that automatically allocated record to _InitGraf:

        PEA        -4(A5)

Back to top

Here and Now

Despite the note in Inside Macintosh, MPW does not automatically allocate a set of QuickDraw global variables for the programmer; it is the responsibility of the programmer to allocate this record for QuickDraw's use.

Back to top

An Example...

Here is an example of creating a QuickDraw global variables template taken from Sample.a, V1.01, which is distributed with MPW 3.0 and on Developer Technical Support's sample source code disk:

    QDGlobals    RECORD    0,DECREMENT
    GrafPort    DS.L    1
    White        DS.B    8
    Black        DS.B    8
    Gray        DS.B    8
    LtGray        DS.B    8
    DkGray        DS.B    8
    Arrow        DS.B    cursRec
    ScreenBits    DS.B    BitMap
    RandSeed    DS.L    1
            ORG    -GrafSize

Here is an example, again from Sample.a, of how to use the above template.

First we use the template to allocate an occurrence of our record:

Next we set up for and make our call:

        PEA        QD.GrafPort

The declaration of QD with a DS creates an occurrence of our record in the application's global variable space and the assembler implicitly provides the reference to A5 as the base register .

Back to top

Truth or Consequences

If you use the MPW assembler and also use the code specified by the note in Inside Macintosh, you are telling QuickDraw (by calling _InitGraf) to use an inappropriate area of memory as global variables space. QuickDraw will happily initialize this area of memory to the correct values for its use, but in doing so, it will also be blasting information that is probably important to some other part of the system.

Back to top

References

Inside Macintosh, Volume I-135, QuickDraw

Back to top

Downloadables

Acrobat gif

Acrobat version of this Note (K).

Download



Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.