Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!psuvax1!psuvm.bitnet!rice.bitnet!storkel From: STORKEL@RICE.BITNET (Scott Storkel) Newsgroups: comp.sys.mac.programmer Subject: Accessing global variables from MPW Message-ID: <1019STORKEL@RICE> Date: 2 May 89 19:09:03 GMT Organization: Rice University - ICSA Lines: 36 I have a question about the way MPW C and Pascal generate code that makes use of the QuickDraw global variables. If I wanted to change the seed for the random number generator, I would do the following from assembly language: MOVE.L (A5),A0 MOVE.L Time, randSeed(A0) Here, randSeed has the value $-7E. If I do something like the following qd.randSeed = (*(long *) 0x20C); the code produced looks like the following: MOVE.L $20C, $FF7E(A5) $FF7E is $-82 by the way. The code that I'm working with is an animation for the Last Screen Saver project I mentioned a while ago. The code gets called when the screen needs to be blanked. Everything works fine if the screen saver comes on while running under the Finder. If an applications is running, the generated code does not work. The reference to $FF7E(A5) is NOT the randSeed global variable, in fact it is usually some random spot in memory. My question is, why isn't the compiler generating code like my first assembly language example? Does the fact that the reference to a global variable doesn't work have anything to do with the fact that the animation code never calls InitGraf or any of the other ToolBox initialization calls? Is there any way to work around this problem? Do MPW 3.0 (I'm using 2.0.2) and the Lightspeed compilers have this problem? I would appreciate some enlightenment. Please respond directly to me, and I will summarize to the net if there is enough interest. Scott Storkel Macintosh Software Development Rice University