|
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 :
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:
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 version of this Note (K).
|
Download
|
|