[comp.sys.mac] C problem

shap@sfsup.UUCP (J.S.Shapiro) (09/28/87)

Now that we have different screen sizes, it no longer suffices to hardwire
things like the screen width. A DA is not really allowed to call InitGraf.
What can I do (assembler is ok) to find out the values of the screenBits
rect?

I have tried going indirect via register a5 to get at the host
application's quickdraw globals structure, and that doesn't seem to work.
This may be a MANX bug. If I simply say 'qd.screenBits', I get the
diagnostic:

Undefined symbol: _main

which, let me tell you, was a bitch to isolate.

How does one do this?

Jds aondimo

oster@dewey.soe.berkeley.edu (David Phillip Oster) (10/01/87)

In article <2120@sfsup.UUCP> shap@sfsup.UUCP (J.S.Shapiro) writes:
>I have tried going indirect via register a5 to get at the host
>application's quickdraw globals structure, and that doesn't seem to work.
>If I simply say 'qd.screenBits', I get the a diagnostic.

What you need to do is:

func(){
  qdVarsType *qd; /* I don't know the real name for this type.
		It is not defined in LightSpeed C */

		/* CurrentA5 is a system low-mem global */
		/* it holds a pointer that points to the last qdVar, not 
			the first like everything else does. */
  qd = (qdVarsType *) (CurrentA5 + sizeof(qdVarsType));  

  qd->screenBits  ... /* will access the globals */
...
}

The above trick will also work for LightSpeed C programmers, if they have an
appropriate definition of qdVarsType.

This is all from memory, and may be slightly wrong.

--- David Phillip Oster            --A Sun 3/60 makes a poor Macintosh II.
Arpa: oster@dewey.soe.berkeley.edu --A Macintosh II makes a poor Sun 3/60.
Uucp: {uwvax,decvax,ihnp4}!ucbvax!oster%dewey.soe.berkeley.edu

rae@unicus.UUCP (Clith de T'nir a.k.a. Reid Ellis) (10/06/87)

In article <2120@sfsup.UUCP> shap@sfsup.UUCP (J.S.Shapiro) writes:

	Now that we have different screen sizes, it no longer suffices to
	hardwire things like the screen width. A DA is not really allowed to
	call InitGraf. What can I do (assembler is ok) to find out the values
	of the screenBits rect?

DA's (and any non-'CODE' code, I think) are not allowed to access
Quickdraw's global variables. (thePort etc, or qd.* if you are using
MPW or Aztec C) (I didn't know Aztec used 'qd.' like MPW.  Is this
new?) If you consider multiple screen environments, there are two
possible things you want.
a) just "this" screen's rectangle
b) the bounding rectangle for all screens.

You can use 'GetWMGrPort(&grafptrVar);' which gives you
grafptrVar->portRect, which is a Rect that encloses the entire
multi-screen display space.

And I'm not sure, but I *think* that grafptrVar->portBits.bounds is be
the rectangle for just the "this" screen.

	This may be a MANX bug.

Nope, it's the way DAs work.

	Jds aondimo

---
Reid Ellis	mnetor!unicus!rae@seismo.css.gov