home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
Information
/
csmp-v2
/
csmp-v2-018.txt
< prev
next >
Wrap
Text File
|
1994-06-07
|
42KB
|
1,112 lines
C.S.M.P. Digest Thu, 11 Mar 93 Volume 2 : Issue 18
Today's Topics:
help calling assembly from C
Calling external code resources - how?
What's in an unloaded resource handle?
SystemClick neccesary in Sys. 7?
Mac Plus Driver Unit Table
Hints on getting a spinning cursors..
Game Animation
The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
The digest is a collection of article threads from the usenet newsgroup
comp.sys.mac.programmer. It is designed for people who read c.s.m.p. semi-
regularly and want an archive of the discussions. If you don't know what a
newsgroup is, you probably don't have access to it. Ask your systems
administrator(s) for details. If you don't have access to news, you can
post articles to any newsgroup by mailing your article to
newsgroup@cs.utexas.edu
So, to post an article to comp.sys.mac.programmer, mail your article to
comp-sys-mac-programmer@cs.utexas.edu
Note the '-' instead of '.' in the newsgroup name. Be sure to ask that
replies be emailed to you instead of posted to the group, and give your
email address.
Each issue of the digest contains one or more sets of articles (called
threads), with each set corresponding to a 'discussion' of a particular
subject. The articles are not edited; all articles included in this digest
are in their original posted form (as received by our news server at
cs.uoregon.edu). Article threads are not added to the digest until the last
article added to the thread is at least one month old (this is to ensure that
the thread is dead before adding it to the digest). Article threads that
consist of only one message are generally not included in the digest.
The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
[128.223.8.8] in the directory /pub/mac/csmp-digest. Be sure to read the
file /pub/mac/csmp-digest/README before downloading any files. The most
recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
directory /info-mac/digest/csmp. If you don't have ftp capability, the sumex
archive has a mail server; send a message with the text '$MACarch help' (no
quotes) to LISTSERV@ricevm1.rice.edu for more information.
The digest is also available via email. Just send a note saying that you
want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
automatically receive each new issue as it is created. Sorry, back issues
are not available through the mailing list.
Send administrative mail to mkelly@cs.uoregon.edu.
-------------------------------------------------------
From: eapg070@orion.oac.uci.edu (Caroll Elke Pohl)
Subject: help calling assembly from C
Organization: University of California, Irvine
Date: 23 Jan 93 19:13:05 GMT
greetings mac programmers!
i wonder if someone out there can assist me with a small problem.
i'm using MPW (3.2) and want to call an assembly language subroutine
i wrote from a C program _however_ i want to pass the parameters in
A0 and A1 instead of using the stack (much like certain memory
manager traps). how can i get the C compiler to recognize this fact?
on a related matter, can anyone recommend a good book on writing
assembly programs on the mac.
a perfect book would include:
1) writing MC68000 code in general
2) using mac traps, pascal and C stack frames and the like
3) using the MPW assembler. things like:
a) special syntax
b) all the assembler directives and keywords
c) how to do more complicated things like segmenting
and external routines.
any recommendations would be much appreciated.
please e-mail.
- -caroll
*********************************************
) """ (
(Q Q)
Don't spook ( | )
the horse! \ A /
(___)
*********************************************
+++++++++++++++++++++++++++
From: keith@taligent.com (Keith Rollin)
Organization: Taligent
Date: Mon, 25 Jan 1993 01:34:42 GMT
In article <2B6198C1.22487@news.service.uci.edu>, eapg070@orion.oac.uci.edu
(Caroll Elke Pohl) wrote:
>
> i wonder if someone out there can assist me with a small problem.
> i'm using MPW (3.2) and want to call an assembly language subroutine
> i wrote from a C program _however_ i want to pass the parameters in
> A0 and A1 instead of using the stack (much like certain memory
> manager traps). how can i get the C compiler to recognize this fact?
You came really close to answering your own question. You know that there
are Mac OS functions that work like this, so why don't you declare your
function the same way they are? For instance:
#pragma parameter DisposePtr(__A0)
pascal void DisposePtr(Ptr p);
This is an example of a function that simply takes a parameter in A0.
Here's a more complex example:
#pragma parameter __D0 HoldMemory(__A0,__A1)
pascal OSErr HoldMemory(void *address,unsigned long count);
HoldMemory takes the first parameter ("address") in A0, and the second
parameter ("count") in A1. It returns its result in D0 (which will be
treated like a short, because the function is declared to return an OSErr).
- -----
Keith Rollin
Phantom Programmer
Taligent, Inc.
+++++++++++++++++++++++++++
From: absurd@apple.apple.com (Tim Dierks, software saboteur)
Date: Tue, 26 Jan 1993 22:57:21 GMT
Organization: MacDTS Marauders
In article <keith-240193173019@kip-50.taligent.com>, keith@taligent.com
(Keith Rollin) wrote:
>
> In article <2B6198C1.22487@news.service.uci.edu>, eapg070@orion.oac.uci.edu
> (Caroll Elke Pohl) wrote:
> >
> > i wonder if someone out there can assist me with a small problem.
> > i'm using MPW (3.2) and want to call an assembly language subroutine
> > i wrote from a C program _however_ i want to pass the parameters in
> > A0 and A1 instead of using the stack (much like certain memory
> > manager traps). how can i get the C compiler to recognize this fact?
>
> You came really close to answering your own question. You know that there
> are Mac OS functions that work like this, so why don't you declare your
> function the same way they are? For instance:
>
> #pragma parameter DisposePtr(__A0)
> pascal void DisposePtr(Ptr p);
>
> This is an example of a function that simply takes a parameter in A0.
> Here's a more complex example:
>
> #pragma parameter __D0 HoldMemory(__A0,__A1)
> pascal OSErr HoldMemory(void *address,unsigned long count);
>
> HoldMemory takes the first parameter ("address") in A0, and the second
> parameter ("count") in A1. It returns its result in D0 (which will be
> treated like a short, because the function is declared to return an OSErr).
>
> -----
> Keith Rollin
> Phantom Programmer
> Taligent, Inc.
Unfortunately, MPW doesn't currently work this way (please correct me
if I'm wrong). While it does use the #pragma register syntax to specify
register passing, I believe it only works for hex inlined functions;
i.e., it's only useful for specifying Toolbox calls or other code
that doesn't require linking, because you can't specify symbols.
This means that if your assembly routine is short (or even if it's not),
you can assemble it, convert it to a bunch of hex constants, and
define it in the same way MPW defines inline code:
#pragma parameter __D0 MyWackyFunction(__A0)
long MyWackyFunction(char *data) = {0xDEAD, 0xFACE, 0xBABE};
or whatever your hex constants are. This should work as long as your
assembly routine doesn't call other routines or refer to global
variables; i.e., any routine which is entirely self-contained.
Also, your function needs to take its arguments in particular
registers: #pragma parameter can only pass arguments or get
results in the "scratch" registers: D0, D1, D2, A0, and A1.
This approach obviously isn't for all code. You've got two alternatives:
the best one is just to write a little routine in assembly which pulls
the arguments for the function off of the stack and puts them into
registers, then calls the function, or convert your function so it
takes its parameters on the stack. An alternative is to use a hex
inlined function which takes its destination in a register and JSRs
to it:
#pragma parameter __D0 CallMyWackyFunction(__A0,__A1)
long CallMyWackyFunction(char *data,void *myWackyFunctionPtr) = 0x4E91;
(0x4E91 is the hex opcode for a JSR (A1)). You can call this like so:
result = CallMyWackyFunction(data,MyWackyFunction);
By passing a pointer to the routine you wish to call, this avoids the
problem that the hex inline can't call the function itself because
it can't contain symbols that need to be linked.
Hope all this helps;
Tim Dierks
MacDTS, but I speak for myself
---------------------------
From: jochen@blanc.north.de (Jochen Meyer)
Subject: Calling external code resources - how?
Date: 23 Jan 93 11:10:15 GMT
Organization: Jochen & Son
Hello, folks!
I am currently writing a program that I want to be extensible. The
most common way of handling extensibility seems to be using external
code resources, like in Canvas or BBEdit.
Where can I find information on how to do this? The Segment Manager
chapter of IM gives no clues on this. Anyone has got some sample code
on this?
Thanks
Jochen
- -------------------------------------------------------------
| Jochen Meyer | Internet: jochen@blanc.north.de |
| Sandfurter Weg 11a | phone: (+49) -441 / 50 85 47 |
| D-2900 Oldenburg |------------------------------------|
|----------------------|"Features are well-documented bugs."|
+++++++++++++++++++++++++++
Organization: Royal Institute of Technology, Stockholm, Sweden
Date: Mon, 25 Jan 1993 00:52:16 GMT
In <01050014.odph61@blanc.north.de> jochen@blanc.north.de (Jochen Meyer) writes:
>Where can I find information on how to do this? The Segment Manager
>chapter of IM gives no clues on this. Anyone has got some sample code
>on this?
Your extensions can't get at your globals, however,
you're not lost.
Define an interface for the extensions, consisting of ONE
function that takes a lot of interesting parameters,
like a handle to some data and a command, and a handle to
put retusn data in, and returns an err code.
The just load in the resource, lock it, and call the dereferenced
resource as a function pointers with the right arguments.
Something like:
typedef short ( * myFuncType ) ( short code , Handle dataIn , Handle dataOut ) ;
Code resources have a main with the same arguments, and
you call 'em like:
Handle h = GetResource ( 'Xtns' , 128 ) ; /* Whatever */
HLockHi ( h ) ;
result = ( * h ) ( theCode , theInData , theOutData ) ;
ReleaseResource ( h ) ;
Cheers,
/ h+
- --
-- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
There's no sex act that can't be made better with Yell-O.
+++++++++++++++++++++++++++
From: keith@taligent.com (Keith Rollin)
Organization: Taligent
Date: Mon, 25 Jan 1993 01:59:02 GMT
In article <01050014.odph61@blanc.north.de>, jochen@blanc.north.de (Jochen
Meyer) wrote:
>
> I am currently writing a program that I want to be extensible. The
> most common way of handling extensibility seems to be using external
> code resources, like in Canvas or BBEdit.
>
> Where can I find information on how to do this? The Segment Manager
> chapter of IM gives no clues on this. Anyone has got some sample code
> on this?
If you have Technote #256, read it. If you don't, log onto ftp.apple.com,
go to /dts/mac/tn/patforms.tools and download the file called
stand-alone-code.hqx. It will tell you just what you want.
Just to whet your appetite, here's some code that I use to call CDEF's
directly:
typedef pascal long (*CDEFProc)(short varCode, ControlHandle theControl,
short msg, long param);
long CallCDEF(ControlHandle theControl, short msg, long param)
{
CDEFProc* defProcHandle;
GrafPtr oldPort;
char oldState;
long result;
defProcHandle = (CDEFProc*) StripAddress((**theControl).contrlDefProc);
if (defProcHandle != nil) {
if (*defProcHandle == nil) {
LoadResource((Handle) defProcHandle);
}
if (*defProcHandle != nil) {
GetPort(&oldPort);
SetPort((**theControl).contrlOwner);
oldState = HGetState((Handle) defProcHandle);
HLock((Handle) defProcHandle);
result = (*defProcHandle)(GetCVariant(theControl), theControl, msg,
param);
HSetState((Handle) defProcHandle, oldState);
SetPort(oldPort);
return result;
}
}
SysError(dsCDEFNotFound);
}
- -----
Keith Rollin
Phantom Programmer
Taligent, Inc.
+++++++++++++++++++++++++++
From: lari@cs.unc.edu (Humayun Lari)
Date: 25 Jan 1993 12:10:32 -0500
Organization: The University of North Carolina at Chapel Hill
tte) writes:
[deleted]
>you call 'em like:
>
> Handle h = GetResource ( 'Xtns' , 128 ) ; /* Whatever */
> HLockHi ( h ) ;
> result = ( * h ) ( theCode , theInData , theOutData ) ;
[rest deleted]
It's a good idea to StripAddress the pointer first, say:
funcPtr = StripAddress(*h);
result = funcPtr(theCode, theInData, theOutData);
This is really only necessary if the code resource will call SwapMMUMode,
but it's better to be safe...
Humayun Lari
(lari@cs.unc.edu)
+++++++++++++++++++++++++++
From: time@ice.com (Tim Endres)
Date: Mon, 25 Jan 93 15:59:44 EST
Organization: ICE Engineering, Inc.
tte) writes:
> >Where can I find information on how to do this? The Segment Manager
> >chapter of IM gives no clues on this. Anyone has got some sample code
> >on this?
>
> Your extensions can't get at your globals, however,
> you're not lost.
uAccess extensions can get at the globals of uAccess. These globals
have been placed inside of a large data structure inside of uAccess
and uAccess hands a pointer to this structure to the extension. The
globals in this data structure are only those that it is felt the
extension would need to access, and are "stable" enough to be locked
down to a documented data structure. However, it does make for some
very powerful possibilities.
tim endres - time@ice.com (UUCP: heifetz!tbomb!time)
USENET - a slow moving self parody... ph
+++++++++++++++++++++++++++
From: peter@cujo.curtin.edu.au (Peter N Lewis)
Organization: NCRPDA, Curtin University
Date: Tue, 26 Jan 1993 03:10:29 GMT
In article <1993Jan25.005216.12749@kth.se>, d88-jwa@dront.nada.kth.se (Jon
Wtte) wrote:
>
> In <01050014.odph61@blanc.north.de> jochen@blanc.north.de (Jochen Meyer) writes:
>
> >Where can I find information on how to do this? The Segment Manager
> >chapter of IM gives no clues on this. Anyone has got some sample code
> >on this?
> Define an interface for the extensions, consisting of ONE
> function that takes a lot of interesting parameters,
> like a handle to some data and a command, and a handle to
> put retusn data in, and returns an err code.
>
> The just load in the resource, lock it, and call the dereferenced
> resource as a function pointers with the right arguments.
If you want other people to be able to write externals in Pascal, give the
function a Pascal interface.
Another good idea is to pass a single param block containg all the
parmaeters, with a version parameter at the front, so if you decide to add
more parameters later, you don't need to rewrite all the externals, you
just bump the version number, and add the new parameters to the end. An
OSErr is often a good return result.
In Pascal:
type MyExternalParamBlock = record
version:longInt;
{ other stuff }
end;
function External(var pb:MyExternalParamBlock): OSErr;
[
In C, something like this I think
OSErr External(MyExternalParamBlock *pb)
]
Call it something like this:
function CallExternal(var pb:MyExternalParamBlock; proc:Ptr):OSErr;
inline $205F, $4E90;
var h:handle;
h:=GetResource('Xtns',128);
HLockHi(h);
oe:=CallExternal(pb,h^);
ReleaseResource(h)
I did something akin to this in the external tokens for Finger, the source
of which should be on sumex or umich, as well as
redback.cs.uwa.edu.au:/others/peterlewis.
Have fun,
Peter.
_______________________________________________________________________
Peter N Lewis <peter@cujo.curtin.edu.au> Ph: +61 9 368 2055
+++++++++++++++++++++++++++
From: Dave_Burnett@bmug.org
Organization: BMUG, Inc.
Date: Tue, 26 Jan 1993 10:46:54 PST
In article <1993Jan25.005216.12749@kth.se> (comp.sys.mac.programmer),
d88-jwa@dront.nada.kth.se (Jon W%tte) writes:
> >Where can I find information on how to do this? The Segment Manager
> >chapter of IM gives no clues on this. Anyone has got some sample code
> >on this?
In develop 10 there was an application with source that implemented plug-ins.
However, the implementation required that plug-ins be pasted into the app's
resource fork instead of reading it from a "plug-ins folder."
**** From Planet BMUG, the FirstClass BBS of BMUG. The message contained in
**** this posting does not in any way reflect BMUG's official views.
---------------------------
From: thomas@camino.mic.cl (Thomas Fruin)
Subject: What's in an unloaded resource handle?
Organization: El Camino
Date: Mon, 01 Feb 1993 23:28:58 CST
I'm doing some stuff with resources without loading them, and was
wondering what's in an unloaded resource handle. For example, suppose
I do (in C++)
Handle resHndl;
SetResLoad( FALSE );
Handle resHndl = GetResource( myType, myID );
SetResLoad( TRUE );
Is resHndl now a Memory Manager handle? The Resource Manager chapter
of Inside Macintosh tells me I can call routines such as GetResInfo
with this Handle, but what happens if I call ReleaseResource or
RmveResource? What happens if I dereference the "handle"?
Maybe somebody can give some background on what's technically in one
of those handle's?
Thanks,
- -- Thomas Fruin
GroupWare Ltda.
Niebla, Chile
thomas@camino.mic.cl
+++++++++++++++++++++++++++
Organization: Royal Institute of Technology, Stockholm, Sweden
Date: Wed, 3 Feb 1993 20:07:09 GMT
In <0105013E.p3dn57@camino.mic.cl> thomas@camino.mic.cl (Thomas Fruin) writes:
> SetResLoad( FALSE );
> Handle resHndl = GetResource( myType, myID );
> SetResLoad( TRUE );
>Is resHndl now a Memory Manager handle? The Resource Manager chapter
>of Inside Macintosh tells me I can call routines such as GetResInfo
>with this Handle, but what happens if I call ReleaseResource or
>RmveResource? What happens if I dereference the "handle"?
The handle is still exactly the same as if you had
loaded a resource, except the master pointer it points
to is NULL (i.e. DON'T DEREFERENCE IT)
The effect is the same as if the resource had been read
and then purged (i.e. marked purgable and unlocked) All
information about the resource is still intact; you can
get the actual data by calling LoadResource. Note that
when the resource is marked as purgeable (and is not
locked) the same thing can happen.
Cheers,
/ h+
- --
-- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
"Practice random kindness, and senseless acts of beauty."
+++++++++++++++++++++++++++
From: kurisuto@chopin.udel.edu (Sean J. Crist)
Organization: University of Delaware
Date: Wed, 3 Feb 1993 21:32:15 GMT
tte) writes:
>In <0105013E.p3dn57@camino.mic.cl> thomas@camino.mic.cl (Thomas Fruin) writes:
>> SetResLoad( FALSE );
>> Handle resHndl = GetResource( myType, myID );
>> SetResLoad( TRUE );
>>Is resHndl now a Memory Manager handle? The Resource Manager chapter
>>of Inside Macintosh tells me I can call routines such as GetResInfo
>>with this Handle, but what happens if I call ReleaseResource or
>>RmveResource? What happens if I dereference the "handle"?
>The handle is still exactly the same as if you had
>loaded a resource, except the master pointer it points
>to is NULL (i.e. DON'T DEREFERENCE IT)
If I'm not mistaken, it will not always be null. If the resource already
happens to be in memory, I believe that GetResource returns a handle to it
whether resource loading is turned on or off. If you wanted to do
something with this handle you'd have to test it to see whether it were
actually null or not.
- --Kurisuto
---------------------------
Subject: SystemClick neccesary in Sys. 7?
From: seth@physc1.byu.edu
Date: 4 Feb 93 19:43:33 -0700
Organization: Brigham Young University
Hi folks.
In these days of System 7, is it necessary to use the SystemClick function in
our event loops anymore? I have read that DA's don't work like they used to,
and are more like real apps now. If I write a sys 7 only app, is it really
necessary to include a call to SystemClick? What other "system windows" are
there that would require this? The THINK Reference 1.0 doesn't answer my
question.
Seth Leigh
BYU Physics Dept.
PS: I sent off my upgrade form and check about two weeks ago. How long does it
take for them to get me my ugrade to THINK Reference 2.0? I just love the
heck out of 1.0, I'm sure I will adore 2.0 to no end...
+++++++++++++++++++++++++++
Organization: Royal Institute of Technology, Stockholm, Sweden
Date: Fri, 5 Feb 1993 09:13:11 GMT
In <1993Feb4.194334.389@physc1.byu.edu> seth@physc1.byu.edu writes:
>In these days of System 7, is it necessary to use the SystemClick function in
>our event loops anymore? I have read that DA's don't work like they used to,
>and are more like real apps now. If I write a sys 7 only app, is it really
I think SystemClick is used for the switching between application
clicking, and switch-to-finder-in-desktop clicks.
I e all windows that aren't your are "System" windows (to your
app)
Cheers,
/ h+
- --
-- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
Engineering: "How will this work?" Science: "Why will this work?" Management:
"When will this work?" Liberal Arts: "Do you want fries with that?"
-- Jesse N. Schell
---------------------------
From: csuley@cs.cornell.edu (Christopher Suley)
Subject: Mac Plus Driver Unit Table
Organization: Cornell Univ. CS Dept, Ithaca NY 14853
Date: Thu, 4 Feb 1993 02:38:44 GMT
csuley@cs.cornell.edu (Christopher Suley) writes:
>How many entries are there in the driver unit table on a Plus?
>Is it 48 as indicated in Inside Mac IV, or has it expanded to
>64 as indicated in Inside Mac V?
Well? No one knows? Could someone with a Plus break into MacsBug and
type 'du' (dm utablebase unittable) and tell me what the biggest number
on the driver table is? If I had a Plus anywhere around me, I'd do it
myself but I don't so I can't.
- --
*plonk*
This post comes pre-*plonk*ed for your convenience.
+++++++++++++++++++++++++++
From: resnick@cogsci.uiuc.edu (Pete Resnick)
Date: Thu, 4 Feb 1993 20:36:56 GMT
Organization: University of Illinois at Urbana
csuley@cs.cornell.edu (Christopher Suley) writes:
>csuley@cs.cornell.edu (Christopher Suley) writes:
>>How many entries are there in the driver unit table on a Plus?
>>Is it 48 as indicated in Inside Mac IV, or has it expanded to
>>64 as indicated in Inside Mac V?
>Well? No one knows? Could someone with a Plus break into MacsBug and
>type 'du' (dm utablebase unittable) and tell me what the biggest number
>on the driver table is? If I had a Plus anywhere around me, I'd do it
>myself but I don't so I can't.
Checking the driver table on a Plus in Macsbug won't do it since many
INITs expand the Unit Table. As far as I know, the Mac Plus still has
only 48 entries by default. There is a method for increasing that
number to as much as 128. I have code examples which explain this very
nicely and are available by anonymous FTP from several places and are
on Compuserve. The last release version was "driver 2.1.8", but please
look for "driver 2.1.9" which I am about to send out today or
tomorrow; there were some problems with 2.1.8 which I have since
fixed.
pr
- --
Pete Resnick (...so what is a mojo, and why would one be rising?)
Graduate assistant - Philosophy Department, Gregory Hall, UIUC
System manager - Cognitive Science Group, Beckman Institute, UIUC
Internet: resnick@cogsci.uiuc.edu
+++++++++++++++++++++++++++
From: maarten@fwi.uva.nl (Maarten Carels)
Organization: FWI, University of Amsterdam
Date: Fri, 5 Feb 1993 09:26:48 GMT
resnick@cogsci.uiuc.edu (Pete Resnick) writes:
>csuley@cs.cornell.edu (Christopher Suley) writes:
>>csuley@cs.cornell.edu (Christopher Suley) writes:
>>>How many entries are there in the driver unit table on a Plus?
>>>Is it 48 as indicated in Inside Mac IV, or has it expanded to
>>>64 as indicated in Inside Mac V?
>Checking the driver table on a Plus in Macsbug won't do it since many
>INITs expand the Unit Table. As far as I know, the Mac Plus still has
>only 48 entries by default.
There is no need to hardcode any such number. There exists a low mem global,
it's called UnitNtry, a word at 0x1d2, it contains the number of entries in
the Unit table.
Note that the size of the block the unittable is in may be other than 4 times
this value. I've seen the unittable block as large as 96 entries, with UnitNtry
only being 48. If you need more entries, compare UnitNtry against
GetPointerSize (UTableBase).
You can set UnitNtry to GetPointerSize (UTableBase) / sizeof (long).
- --maarten
- --
In real life: Maarten Carels
Computer Science Department
University of Amsterdam
email: maarten@fwi.uva.nl
---------------------------
From: walrath@faw.uni-ulm.de (Wayne K. Walrath)
Subject: Hints on getting a spinning cursors..
Organization: FAW (Research Institute For Applied Knowledge Processing, Ulm, Germany)
Date: Thu, 4 Feb 1993 13:06:33 GMT
Thanks to Jon and Peter (and others) for the sample code and
suggestions on how to get a directory's contents.
>As Jon said, learn to love the PBGetCatInfo call, its very important (less
>important than learning the difference between vrn's and working directory
>numbers and how dirIDs fit in, but still quite important).
After two long evenings in the debugger everything is working beautifully,
and I HAVE learned to love PBGetCatInfo.... But I did have a terrible time
with the data structure for this call (CInfoPBRec or something similiar);
being not such an accomplished C programmer, I didn't fully understand how
to work with Unions, and kept getting a member not found error message. In
Think C the record is defined as having a ParamBlockHeader, then the union
of a hFileInfo and dirInfo structures.
I need to get my cursor to spin now, and I presume that I can define a
number of different cursors myself, then call a SpinCursor routine which
cycles through all them. Is this basically correct? If I just want to spin
the watch cursor, how is that done?
What is the best way to deal with these resources? Load each cursor from
the resource file right before the call to SetCursor, or should I attempt
to keep them all locked in memory.
Suggestions appreciated.
- -wayne
/ Wayne K. Walrath \
/ walrath@faw.uni-ulm.de \
\ The Rsrch. Institute for Applied /
\ Knowledge Processing & AI-Ulm, Germany /
+++++++++++++++++++++++++++
From: casgrain@ERE.UMontreal.CA (Casgrain Philippe)
Date: 4 Feb 93 14:43:33 GMT
Organization: Universite de Montreal
In article <1993Feb4.130633.21433@wega.rz.uni-ulm.de> walrath@faw.uni-ulm.de (Wayne K. Walrath) writes:
>
>I need to get my cursor to spin now, and I presume that I can define a
>number of different cursors myself, then call a SpinCursor routine which
>cycles through all them. Is this basically correct? If I just want to spin
>the watch cursor, how is that done?
>
>What is the best way to deal with these resources? Load each cursor from
>the resource file right before the call to SetCursor, or should I attempt
>to keep them all locked in memory.
>
I would suggest installing the SpinCursor routine as a VBL (i.e. asynchronous)
task. This means that the cursor will spin at the same speed regardless
of the current task.
It is well documented in Knaster 'n Rollin's "Mac. Programming Secrets, 2nd ed."
(yeah, I know, I liked it so much that I bought the company! ;-).
I have followed their advice, and created a little library that you can link
to anything (Pascal, C, even Fortran!). If you want it, let me know
Philippe
- --
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Philippe Casgrain Etudiant-Chercheur Casgrain@ERE.UMontreal.CA
Departement des Sciences Biologiques Universite de Montreal
#define disclaimer(caught) (caught ? "I wasn't even there!" : "I didn't do it!")
+++++++++++++++++++++++++++
From: keith@taligent.com (Keith Rollin)
Organization: Taligent
Date: Fri, 5 Feb 1993 01:10:41 GMT
In article <1993Feb4.144333.10555@cc.umontreal.ca>,
casgrain@ERE.UMontreal.CA (Casgrain Philippe) wrote:
>
> In article <1993Feb4.130633.21433@wega.rz.uni-ulm.de> walrath@faw.uni-ulm.de (Wayne K. Walrath) writes:
> >
> >I need to get my cursor to spin now, and I presume that I can define a
> >number of different cursors myself, then call a SpinCursor routine which
> >cycles through all them. Is this basically correct? If I just want to spin
> >the watch cursor, how is that done?
> >
> >What is the best way to deal with these resources? Load each cursor from
> >the resource file right before the call to SetCursor, or should I attempt
> >to keep them all locked in memory.
> >
> I would suggest installing the SpinCursor routine as a VBL (i.e. asynchronous)
> task. This means that the cursor will spin at the same speed regardless
> of the current task.
There was discussion on this on the net about a year ago. I think that the
general consensus was that it was better to spin the cursor by calling
SpinCursor from various spots within the program. That way, it conveys to
the user that the process is proceeding from one stage to another (first it
hits a slow algorithm, then it hits a fast one, now it's writing data to
disk so the cursor has stopped spinning altogether, etc.).
I don't like the VBL approach because it gives no indication that the
program has hung (important to us developers). There have been articles
suggesting how to feed the VBL task tickle messages from the application so
that it knows the application hasn't hung, but now your program is
sprinkled with calls to TickleCursorVBL instead of SpinCursor.
>
> It is well documented in Knaster 'n Rollin's "Mac. Programming Secrets, 2nd ed."
> (yeah, I know, I liked it so much that I bought the company! ;-).
So that's who bought all my stock!
- -----
Keith Rollin
Phantom Programmer
Taligent, Inc.
+++++++++++++++++++++++++++
From: lari@cs.unc.edu (Humayun Lari)
Date: 5 Feb 1993 10:35:40 -0500
Organization: The University of North Carolina at Chapel Hill
In article <keith-040293165323@kip-50.taligent.com> keith@taligent.com (Keith Rollin) writes:
>There was discussion on this on the net about a year ago. I think that the
>general consensus was that it was better to spin the cursor by calling
>SpinCursor from various spots within the program. That way, it conveys to
>the user that the process is proceeding from one stage to another (first it
>hits a slow algorithm, then it hits a fast one, now it's writing data to
>disk so the cursor has stopped spinning altogether, etc.).
One problem with this method is that the speed of the spinning is dependent
on the speed of the Mac. In some programs, the cursor is changed so often on
fast machines that it flickers, making the program look rather unpolished.
And machines are getting faster all the time.
A possible solution is to set some kind of threshold, so, for instance, the
cursor's only changed if *at least* 1/10 of a second has gone by.
>I don't like the VBL approach because it gives no indication that the
>program has hung (important to us developers). There have been articles
>suggesting how to feed the VBL task tickle messages from the application so
>that it knows the application hasn't hung, but now your program is
>sprinkled with calls to TickleCursorVBL instead of SpinCursor.
IMHO, this can be better, if only because it matches the constant rate used by
the spinning hands on Finder 7.x's watch cursor.
It would be nice to have a HIN on this. Does anyone know if there's an
"official" way to propose a HIN topic?
Humayun Lari
(lari@cs.unc.edu)
---------------------------
From: david.wareing@insane.apana.org.au (David Wareing)
Subject: Game Animation
Date: Wed, 03 Feb 1993 08:30:00
There has been some discussion in recent months about the suitability of QD to
efficiently handle fast, clean animation - of the type required for
action/arcade games. Several people have claimed that a game such as Prince
of Persia *could* be written with QD, others have protested this.
Can someone please clarify this. I am in the process of writing a game. I
need to know if it is possible to animate (say at the the POP level) with QD
or do I HAVE to start learning assembly real fast?
thanks,
David Wareing
Seacliff, South Australia.
+++++++++++++++++++++++++++
From: zobkiw@world.std.com (Joe Zobkiw)
Organization: The World Public Access UNIX, Brookline, MA
Date: Fri, 5 Feb 1993 14:58:37 GMT
In article <728841576.AA00368@insane.apana.org.au> david.wareing@insane.apana.org.au (David Wareing) writes:
>
>There has been some discussion in recent months about the suitability of QD to
> efficiently handle fast, clean animation - of the type required for
> action/arcade games. Several people have claimed that a game such as Prince
> of Persia *could* be written with QD, others have protested this.
>
>Can someone please clarify this. I am in the process of writing a game. I
> need to know if it is possible to animate (say at the the POP level) with QD
> or do I HAVE to start learning assembly real fast?
>
No matter what anyone says...some games will do fine with QuickDraw...
others need custom routines. It entirely depends on how much action
you have in the game. You should probably perform some timing tests
yourself to see how QuickDraw works for YOU :)
- --
- -------------------------------------------------------------
joe zobkiw zobkiw@world.std.com
- -------------------------------------------------------------
+++++++++++++++++++++++++++
From: werner@dewey.soe.berkeley.edu (John Werner)
Date: 5 Feb 1993 19:45:19 GMT
Organization: School of Education, U.C. Berkeley
In article <C1zDLp.FCJ@world.std.com> zobkiw@world.std.com (Joe Zobkiw) writes:
>
>No matter what anyone says...some games will do fine with QuickDraw...
>others need custom routines. It entirely depends on how much action
>you have in the game. You should probably perform some timing tests
>yourself to see how QuickDraw works for YOU :)
I agree. Write it first using QuickDraw. There's no sense in
worrying about writing the game code and your own custom graphics
routines at the same time; it just gives you more things to debug at
once. If it's a sprite-based game, concentrate on making your
algorithm clever enough to minimize the amount of CopyBitsing that has
to go on for each frame. Some of the recent posts on "Arcade-style
game animation" had some good hints that I incorporated into the
simulation program I'm working on.
If you still can't get it fast enough, then it's time to start
worrying about rewriting the low-level bit-blasting routines in
assembler.
This is a bit over-simplified, of course. If your initial QuickDraw
version is WAY too slow, then you might want to start doing some
detailed timing tests and experiments with assembler before you get
too far along.
- --
John Werner werner@soe.berkeley.edu
UC Berkeley School of Education (510) 596-5868 (new number)
+++++++++++++++++++++++++++
From: mssmith@afterlife.ncsc.mil (M. Scott Smith)
Date: 5 Feb 93 21:48:10 GMT
Organization: The Great Beyond
In article <728841576.AA00368@insane.apana.org.au> david.wareing@insane.apana.org.au (David Wareing) writes:
>
>There has been some discussion in recent months about the suitability of QD to
> efficiently handle fast, clean animation - of the type required for
> action/arcade games. Several people have claimed that a game such as Prince
> of Persia *could* be written with QD, others have protested this.
>
>Can someone please clarify this. I am in the process of writing a game. I
> need to know if it is possible to animate (say at the the POP level) with QD
> or do I HAVE to start learning assembly real fast?
>
>thanks,
>
>David Wareing
>Seacliff, South Australia.
>
David,
I have been working on learning the fundamentals for writing Mac games
for the past year or so, albeit not at any great pace. I had heard that
fast, smooth animation required direct-screen drawing, and believed it,
but concluded that since I didn't know assembly I wouldn't be able to do it.
And so I concentrated on learning about GWorlds and CopyBits and how to do
the fastest graphics possible using QuickDraw.
And it was a pain. I won't say it would be impossible to write something
like Prince of Persia using QuickDraw -- well, OK, I will -- it probably
would be pretty close to impossible. Quickdraw can be Quick -- but while
I can't authoritatively say that it can't be used to write fast-action games
(since I don't know how to do fast-action games with it), I do point to all
the fast action games that have been written for the Mac, and none, to my
knowledge, have used QuickDraw.
So at some point I resolved that I would learn how to write directly to
the screen. And I did. And I do. And I wouldn't do it any other way now.
You *don't* need to know assembly to do it, although it certainly would
help. I've developed a pretty thorough library of routines that write to the
screen very quickly, handle sprites, etc. I've still got some work to do;
I'm working on a fast masking algorithm suited specifically for my types of
sprites, etc., but I've been able to demonstrate that I will be able to have
very fast, arcade-action graphics. Definitely comparable with Prince of
Persia and just about anything else out there. (Now, if I only had the
artistic talent..)
And I still don't know Assembly. However, I'm pretty good at bit
manipulations and it's definitely helpful if you can think in bases other
than 10. If you want to sync your game with the monitor, then you would
need to know assembly, although there's several Think C snippets floating
around (that use assembly) that accomplish this task for you. There's
also handy code around that fades the monitor in and out.
So how can you learn how to write directly to the screen? If you go
back and look at some of the comp.sys.mac.programmer/games archives,
there's been threads in the past related to it. Some very smart people
have divulged some helpful pointers, like Ben Staller and Joe Holt.
Also, issue 11 of Develop (Apple's programming journal) contains an
article (and sample code) titled "Graphical Truffles," written by Brigham
Stevens and Bill Guschwan, that contains basically all the info. you need
to know to successfully write to the screen. (For example, it tells you
things to do to keep your program from breaking -- such as changing to
32-bit mode before you go messing around with the video RAM, etc.)
Writing directly to the screen is dangerous and hard to do "right". You
have probably heard a lot of people warning not to do it, and this might
have scared you away -- don't let it. I've got three pages of source code
which seem to safely implement direct-drawing on just about any system.
(In 8-bit color, at least. Monitor size doesn't matter.) (And those three
pages contain routines to draw points, fills, lines, etc., very quickly.
Even scroll the screen horizontally -- not slow at all, but definitely not
Sonic the Hedgehog.)
It's a challenge, it's fun, and you get to learn a lot.. I'm starting
from the ground up, trying to build my own library that's equivilent in many
ways to QuickDraw, except without the speed barrier.
So, to sum up this long message: You probably *can't* write a game like
Prince of Persia with Quickdraw. However, there's lots of games you CAN
write with Quickdraw -- in which case you should definitely use Quickdraw.
(For example, strategy games, games like Tetris that don't have a lot
of sprites moving at once, etc.)
But if you want to write a fast-action arcade game, don't hesitate to
investigate looking into the direct-screen approach. At the least, you'll
learn something from it -- you'll have a better understanding of how graphics
work on computers. (And you might gain an appreciation for something like
CopyMask!)
It's not as hard as it's rumored to be. It's not as imcompatible as it's
rumored to be, either, although you might want to focus on working in one
bit depth, such as 8-bit, at least as a starter until you get up to speed.
There are now a collection of references available that will help you
learn it -- the Graphics Truffles article being an excellent start (you
can get it from ftp.apple.com), as well as some hints filed away in the
archives of the internet.
And you can keep my name around if you have questions.. I'm not an expert
on this, but I'm learning quickly and know the fundamentals.
There's also source available from cool people like Juri Munki (I hope I got
his name right), such as the Arashi demo (and I hope I got THAT name right,
too! ;) that implement direct screen graphics. However, it was done mostly
in assembly and was over my head.
But you can get away without knowing assembly.
Hope this helps!
M. Scott Smith
(mssmith@afterlife.ncsc.mil)
(umsmith@mcs.drexel.edu)
+++++++++++++++++++++++++++
From: sjked@ritvax.isc.rit.edu ("Sgt. Kleper")
Organization: Rochester Institute of Technology
Date: Mon, 8 Feb 1993 03:35:49 GMT
I think (that's THINK) that Pararena has an option of using Quick
Draw. I recall trying it once, and it worked about the same from
all that I could tell.
---------------------------
End of C.S.M.P. Digest
**********************