[comp.sys.mac.programmer] OpenResFile and high byte

oster@dewey.soe.berkeley.edu (David Phillip Oster) (04/13/88)

Recently, there was a discussion on Delphi about OpenResFile(), and the
necessity of clearing the high byte of the pointer you pass to it. The
correct way of doing this is:

do a SysEnvirons(). If you are running on a 512KE or greater, and are
under System 4.1 or greater, then do a StripAddress() system call to strip
off the flags and get a pure address.

If you are on some other configuration, just clear the byte.  This will
help your code keep working when apple goes to a true 32-bit address
environment, or if you want to port to A/UX.


---------
Getting the address of video memory: Remember that a MacII can have
multiple display adapters installed. To find the address of their screen
memeories, you must scan down the list of graphic devices. See the graphic
devices chapter of Inside Macintosh Vol. 5.  

Writing directly into video
memory will certainly cause you problems: Stars 1.8 does it, and I have
not upgraded it since color quickdraw came out, so it only works right in
1-bit per pixel mode.  (The fade-to-black and the drawing of the small
stars are done with direct video memory access.)  I haven't released an up
updated version, because there are a lot of things I want to put in. I may
just do a simple bug-fix release in the interim though.

--- David Phillip Oster            --When you asked me to live in sin with you
Arpa: oster@dewey.soe.berkeley.edu --I didn't know you meant sloth.
Uucp: {uwvax,decvax,ihnp4}!ucbvax!oster%dewey.soe.berkeley.edu

lsr@Apple.COM (Larry Rosenstein) (04/14/88)

In article <23596@ucbvax.BERKELEY.EDU> oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster) writes:
>
>do a SysEnvirons(). If you are running on a 512KE or greater, and are
>under System 4.1 or greater, then do a StripAddress() system call to strip
>off the flags and get a pure address.

If you are using MPW, StripAddress is implemented by glue code that checks
for the existence of the trap, and cals it if it exists.  Otherwise it does
the stripping itself.  Therefore, you can call StripAddress regardless of
the machine you are running on.

-- 
		 Larry Rosenstein,  Object Specialist
 Apple Computer, Inc.  20525 Mariani Ave, MS 27-AJ  Cupertino, CA 95014
	    AppleLink:Rosenstein1    domain:lsr@Apple.COM
		UUCP:{sun,voder,nsc,decwrl}!apple!lsr