[comp.sys.apple2] Code resources

hartkopf@spot.Colorado.EDU (Jeff Hartkopf) (03/18/91)

I have a few questions about generating and using code resources on the IIGS.

1) How do I generate a code resource of, say, some C code?  Do I have to use
   the tools sold by APDA, or can it be done with Genesys (or some other way)?

2) Once I have the code resource, how do I load it from my program, and then
   call it?  Can it be called from C?  If not, what assembly code do I need   
   to call it?  Is it possible to create a code resource with several 
   functions that can be called from C, or do code resources only have one 
   entry point?

Thanks much for any help.


Jeff Hartkopf
University of Colorado at Boulder
Internet: hartkopf@spot.colorado.edu

JWANKERL@UTCVM.BITNET ("Josef W. Wankerl") (03/18/91)

On Sun, 17 Mar 91 20:44:38 GMT Jeff Hartkopf said:
>I have a few questions about generating and using code resources on the IIGS.
>
>1) How do I generate a code resource of, say, some C code?  Do I have to use
>   the tools sold by APDA, or can it be done with Genesys (or some other way)?
It really helps to use Rez, but Genesys can do it as well.  Simply
create your object code and then Import it (you can do this with 1.2).

>2) Once I have the code resource, how do I load it from my program, and then
>   call it?  Can it be called from C?  If not, what assembly code do I need
>   to call it?  Is it possible to create a code resource with several
>   functions that can be called from C, or do code resources only have one
>   entry point?

You load is just as you would any other - with the LoadResource call.
You have to set up a resource converter for it, however.  It's easy
to do - just make the GetCodeConverter miscellaneous tool call (I think
that's what it's called) and then install it as an application
converter for your code resource type.  Yes, it can be called from C...
The LoadResource gives you a handle, you convert it to a pointer and then
make your JSL equivalent.  Yes, you can create a code resource with
multiple functions, but there is only one entry - the first function
should be an information function which returns pointers to all the
different routines in the code resource, or it could possibly call
the routines itself based on a number for which routine you want to
call.

>Jeff Hartkopf
>University of Colorado at Boulder
>Internet: hartkopf@spot.colorado.edu

--
===> Josef W. Wankerl, Technical Editor for GS+ Magazine
  BITNET:  JWANKERL@UTCVM.BITNET       | America Online:  JWankerl
 ProLine:  jwankerl@pro-gsplus         |--------------------------------
Internet:  jwankerl@pro-gsplus.cts.com | "I am a Viking"  -Y. Malmsteen