Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!well!smoke From: smoke@well.sf.ca.us (Nicholas Jackiw) Newsgroups: comp.sys.mac.programmer Subject: Re: Has AppleSoundChip? Gestalt? How? Message-ID: <24147@well.sf.ca.us> Date: 11 Apr 91 16:13:15 GMT References: <1991Apr9.011011.29542@kuhub.cc.ukans.edu> Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 87 In article <1991Apr9.011011.29542@kuhub.cc.ukans.edu> 2fmlcalls@kuhub.cc.ukans.edu writes: > >LINK_ERROR - Gestalt not implemented {or some such} > >So, how does one use Gestalt with THINK Pascal 3.0? Or how can one determine >if the ASC is present without a call to Gestalt? (And, related, like calling >WNEvent, do you need to check for a TrapAvail before even considering a call to >Gestalt?) I haven't been able to find the necessary glue for Gestalt on any of the 7 beta cds, either. I must not be looking in the right place. At any rate, try this: function Gestalt (selector: OSType; var response: LONGINT): OSErr; inline $202f, $0004, $A1AD, $225f, $2288, $584f, $3E80; This glue pops the parameters off the stack and puts them into the appropriate registers before making the call. It works under 7; I have no idea how _Gestalt's implemented under 6.x, but I imagine this'll work too. As to your related question, yes you must make sure Gestalt's implemented beforehand. The latest Officially Recommended Way to do this: const Unimplemented = $A89F; function GetTrapType (theTrap: integer): TrapType; const TrapMask = $0800; begin if Band(theTrap, TrapMask) > 0 then GetTrapType := ToolTrap else GetTrapType := OSTrap end; function NumToolboxTraps: integer; begin if NGetTrapAddress($A86E, ToolTrap) = NGetTrapAddress($AA6E, ToolTrap) then {InitGraf=Unimplemented?} NumToolboxTraps := $200 else NumToolboxTraps := $400 end; function TrapAvailable (theTrap: integer): boolean; var tType: TrapType; begin tType := GetTrapType(theTrap); if tType = ToolTrap then begin theTrap := Band(theTrap, $07FF); if theTrap >= NumToolBoxTraps then theTrap := Unimplemented end; TrapAvailable := NGetTrapAddress(theTrap, tType) <> NGetTrapAddress(Unimplemented, ToolTrap) end; begin {Your code begins here} hasGestalt := TrapAvailable($A1AD); {Determine whether Gestalt is implemented} ... end; I love this stuff. With the new edition manager, or any other OS package that requires initialization, you now have to write code that checks to see (TrapAvailable) whether you can check to see (Gestalt) whether you can check to see (InitEditionMgr) whether you can use editions. Fortunately, the code to check to see whether your user has forgotten to turn the Mac's power on is much simpler. > >john calhoun -- --- * --- Nicholas Jackiw Smoke@well.sf.ca.us | Jackiw@cs.swarthmore.edu Key Curriculum Press, Inc. Applelink: D3970 | (415) 548-2304 --- * ---