Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!um-math!sharkey!cfctech!teemc!hpftc!zardoz!henry.jpl.nasa.gov!elroy.jpl.nasa.gov!usc!apple!dlyons
From: dlyons@Apple.COM (David Lyons)
Newsgroups: comp.sys.apple
Subject: Re: Tool 30 really is the Resource Mgr; user toolsets
Message-ID: <34457@apple.Apple.COM>
Date: 30 Aug 89 23:34:40 GMT
References: <19273@gryphon.COM>
Organization: Apple Computer Inc, Cupertino, CA
Lines: 55

In article <19273@gryphon.COM> shubbell@pnet02.gryphon.com (Steve Hubbell) writes:
>dlyons@Apple.COM (David Lyons) writes:
>>
>>To call a *system* toolset, you JSL $E10000 or JSL $E10004.
>>To call a *user*   toolset, you JSL $E10008 or JSL $E1000C.
>>     (The toolset # and function # are always in X.)

I should've noted before that the second entry point for each kind of
toolset (the -4 and -C entries) are like the first ones, *except* that
one extra RTL address is expected to have been put onto the stack, after
the parameters were put there.

>[...]
>While we are on this topic, maybe you will also be able to fill me in on
>"SetWAP".  The appendix A of Volume II lacks a "good" description of what the
>call is really used for.  What I dont understand is what (and why) I have to
>use this call for...  Thanks for the help.

You don't *have* to use SetWAP, but for most toolsets it's convenient.  The
"work area pointer" is a 4-byte pointer for each toolset--SetWAP and GetWAP
can set and get that value.

When the tool dispatcher gives control to one of your toolset's functions,
it has already loaded your toolset's current WAP value into the A and Y
registers, with the low word in A.  Typically, a toolset's WAP points to
its direct-page space in bank 0, so that the WAP value is $0000xx00, with
A = $xx00.  On entry to one of your functions, you could do a PHD, TCD to
save the old direct-page-register value on the stack and use your WAP for
direct-page storage (and PLD before you return to the system).

If you're using the WAP like that, your xxxStartUp function will, after
doing anything necessary to make sure it's okay to start up, use SetWAP
to set its own WAP value.  (Set it to what?  Either to the value of a
parameter that was passed to your startup function, or to the address
of some memory your startup function has just allocated using NewHandle.)
Your xxxShutDown function should set your WAP back to 0, and your xxxStatus
function should check the WAP value & return "true" if it's nonzero.

Note that the X register always contains the function number when a function
gets control.  This means it isn't too difficult to write a toolset that
will work *regardless* of what toolset number it is installed as.  (In
other words, you can compute proper error numbers based on the toolset
number in X, and you can use your toolset number "on the fly" as input
to SetWAP when needed.)

>Steve Hubbell - Manhattan Beach, CA

 --Dave Lyons, Apple Computer, Inc.          |   DAL Systems
   AppleLink--Apple Edition: DAVE.LYONS      |   P.O. Box 875
   AppleLink--Personal Edition: Dave Lyons   |   Cupertino, CA 95015-0875
   GEnie: D.LYONS2 or DAVE.LYONS         CompuServe: 72177,3233
   Internet/BITNET:  dlyons@apple.com    UUCP:  ...!ames!apple!dlyons

   My opinions are my own, not Apple's.