Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!apple!agate!garnet.berkeley.edu!deadman From: deadman@garnet.berkeley.edu (Ben Haller) Newsgroups: comp.sys.mac.programmer Subject: Re: Graphics/Animation Problems (long) Keywords: video, game, color Message-ID: <1991Apr27.193509.19020@agate.berkeley.edu> Date: 27 Apr 91 19:35:09 GMT References: <1991Apr14.011556.23504@santra.uucp> <1991Apr20.200229.805@agate.berkeley.edu> <1991Apr21.073551.14802@santra.uucp> Sender: root@agate.berkeley.edu (Charlie Root) Organization: Stick Software Lines: 75 In article <1991Apr21.073551.14802@santra.uucp> jmunkki@hila.hut.fi (Juri Munkki) writes: >In article <1991Apr20.200229.805@agate.berkeley.edu> deadman@garnet.berkeley.edu (Ben Haller) writes: >>Wrong. Switching processor modes is slow, because the SwapMMUMode routine >>is slow. So you only want to call it if you have to. > >If you would like to be useful, how about showing us how to find out which >cards need the call to SwapMMUMode? I have no idea how this could be done >unless one has full documentation for 32 bit QD. > >Usually when people try to find out about machine features that they really >do not need to know about, they end up shooting themselves in the foot. OK, I'll bite. First you check if color QuickDraw is available. This can be done like: SysEnvRec worldRec; SysEnvirons(1, &worldRec); if (worldRec.hasColorQD) ...CQD is available... else ...CQD is not available... If CQD is available, then you should find out monitor information from the GDevice list, check for 32-Bit QuickDraw, etc. If it's not, then you may find out the monitor information from screenBits and GrayRgn, and you need not check for 32-Bit QuickDraw, swap MMU modes, etc. - all that is guaranteed not to be necessary. So, the next step is checking for 32-Bit QuickDraw. This can be done as follows: #define QD32Trap 0xAB03 #define UnImplTrap 0xA89F if (NGetTrapAddress(QD32Trap, ToolTrap) != NGetTrapAddress(UnImplTrap, ToolTrap)) ...32-Bit QD is available... else ...32-Bit QD is not available... If 32-Bit CQD is available, then you need to check whether you should swap MMU modes or not. If 32-Bit CQD is not available, then you never need to swap the MMU. So the next step is, given that 32-Bit CQD is available, how do you check whether you need to swap the MMU for a given PixMap? I haven't done this yet (I'll be doing it when I get around to the next revision of Solarian II). I believe there is a call in the 32-Bit QuickDraw suite that tells you whether a given PixMap needs to be swapped. But I don't think that's strictly necessary. What I would do is get the base address from the GDevice's PixMap (it *must* be the GDevice's, other PixMaps will probably have the main GDevice's baseAddr, or may even have 0 if I recall correctly). Then do the following comparison: if ((long)baseAddr != StripAddress(baseAddr)) ...need to swap the MMU to write directly to the screen... else ...don't need to swap the MMU... I'm providing this information because it was requested. I do not vouch for it's complete accuracy (such as on strange third-party color monitors for the Plus or SE that hack into QuickDraw in strange ways, etc.) Also, Apple may be recommending other ways of checking for some of these things nowadays, in particular there may be Gestalt calls that Apple recommends using instead of SysEnvirons and comparing trap addresses. But I really doubt that Apple will break these method of checking, since may programs use them. On a slightly different note, I keep posting things like this relating to going direct to screen. I hope someone somewhere is keeping these posts for future integration into a UMPG-type thing, or a FAQ post. I spend a lot of time telling people how to go direct to screen. It's a popular topic. -Ben Haller (deadman@garnet.berkeley.edu) "Soy el galan de las penas Llorando Sin compasion." - David Byrne