[comp.sys.atari.st.tech] two RSC files?

jeroen@ruuinf.cs.ruu.nl (Jeroen Fokker) (01/03/91)

I am writing a program that uses a lot of dialogues.
The size of the RSC-file is approaching the 32000 byte-limit.
Can I split up the RSC-file in two parts?

I would write the following program:

    rsrc_load(file1);
    rsrc_gaddr(...forms from file1...);
    rsrc_load(file2);
    rsrc_gaddr(...forms from file2...);
    ...main program...
    rsrc_free();
    rsrc_free();

Is this possible?
Does the Atari keep track of the different areas of memory
to be released by subsequent rsrc_free() calls?

I would appreciate any help.
I will summarize replies made by email to the net.
--

Jeroen Fokker                                 |  jeroen@cs.ruu.nl
dept.of Computer Science, Utrecht University  |  tel.+31-30-534129
PObox 80089, 3508TB Utrecht, the Netherlands  |  fax.+31-30-513791

kilian@seas.gwu.edu (Jens Kilian) (01/04/91)

Yes, there IS a way to use multiple resource files in an application.
Unfortunately, it involves a trick using undocumented GEM variables.
The technique was demonstrated in a German ST journal, but I don't
remember which one and when.

Apparently, GEM stores the root of the resource tree in an entry in
the  global[]  array, which can be found via the GEM parameter block
passed on an AES call. You should be able to use more than one resource
file if you do the following:

	1.	rsrc_load() the first file
	2.	rsrc_gaddr() all your pointers
	3.	save the global[] entry in a variable
	4.	repeat 1. and 2. for the second file

When your program is finished, you  rsrc_free()  the resources loaded
from the second file, restore the pointer saved in step 3, and repeat
the  rsrc_free()  call for the resources from the first file.

So. What is that entry in  global[]  that I've been talking about ?
Sorry, but I don't remember, and I can't check now because my ST is
5000 miles away from me at the moment. I suggest you look in some
recent book on GEM.

			Hoping to have helped you.

				Jens Kilian

--
------------------------------------------------------------------------
Internet: kilian@seas.gwu.edu		SnailMail: 4715 MacArthur Blvd.
(I don't know any other addresses ...)		   Washington, DC 20007

fiebelko@maria.informatik.uni-dortmund.de (Dieter Fiebelkorn) (01/04/91)

Dear Jeroen,

> I am writing a program that uses a lot of dialogues.
> The size of the RSC-file is approaching the 32000 byte-limit.
You have a 64kB-limit (supported by Kuma-RCS 2.x & Digital RCS 2.x)

> Can I split up the RSC-file in two parts?
Yes, you can!


> I would write the following program:
> rsrc_load(file1);
> rsrc_gaddr(...forms from file1...);
> rsrc_load(file2);
> rsrc_gaddr(...forms from file2...);
> ...main program...
> rsrc_free();
> rsrc_free();
NEARLY right. Atari don't keep free the memory of the first resource-file.
You must save the address for the full resource tree from global[5,6].
This address points to the __first__ OBJECT of the loading resource file.
In most cases it's the IBOX for the menu-tree.


Two little routines, which will help you:
------------
void *rsrc_get (void)
{
	extern int *global /* = _GemParBlk.global (for Turbo C) */ ;
	OBJECT **rsc;

	rsc = (OBJECT **) &(global[5]);
	return (*rsc);
}

void rsrc_put (void *addr)
{
	extern int *global /* = _GemParBlk.global (for Turbo C) */ ;
	OBJECT **rsc;

	rsc = (OBJECT **) &(global[5]);
	*rsc = addr;
}

main()
{
	void *save_resorce;

	rsrc_load(file1);
	rsrc_gaddr(...forms from file1...);
	save_resorce = rsrc_get();
	rsrc_load(file2);
	rsrc_gaddr(...forms from file2...);
	...main program...
	rsrc_free();
	rsrc_put(save_resorce);
	rsrc_free();
}
------------
I hope it's right !!!! and would help you.


Ciao  ---  Dieter

--------------------------------------------------------------------------------
|   Dieter Fiebelkorn                           |   With a rubber duck   :-)   |
|   fiebelko@petra.informatik.uni-dortmund.de   |   one's never alone!   :^{   |
--------------------------------------------------------------------------------

haacke@exunido.uucp (Ralf Haacke) (01/04/91)

From fiebelko@maria.informatik.uni-dortmund.de Fri Jan  4 10:58:23 1991
Received: by exunido.irb.informatik.uni-dortmund.de id AA04108 (0); Fri, 4 Jan 91 10:58:18 +0100
From: Dieter Fiebelkorn <fiebelko@maria.informatik.uni-dortmund.de>
Date: Fri, 4 Jan 91 10:58:34 +0100
Message-Id: <9101040958.AA17860@maria.informatik.uni-dortmund.de>
To: haacke@exunido.informatik.uni-dortmund.de
Subject: Re: two RSC files?
Status: R

Dear Jeroen,

> I am writing a program that uses a lot of dialogues.
> The size of the RSC-file is approaching the 32000 byte-limit.
You have a 64kB-limit (supported by Kuma-RCS 2.x & Digital RCS 2.x)

> Can I split up the RSC-file in two parts?
Yes, you can!


> I would write the following program:
> rsrc_load(file1);
> rsrc_gaddr(...forms from file1...);
> rsrc_load(file2);
> rsrc_gaddr(...forms from file2...);
> ...main program...
> rsrc_free();
> rsrc_free();
NEARLY right. Atari don't keep free the memory of the first resource-file.
You must save the address for the full resource tree from global[5,6].
This address points to the __first__ OBJECT of the loading resource file.
In most cases it's the IBOX for the menu-tree.


Two little routines, which will help you:
------------
void *rsrc_get (void)
{
	extern int *global /* = _GemParBlk.global (for Turbo C) */ ;
	OBJECT **rsc;

	rsc = (OBJECT **) &(global[5]);
	return (*rsc);
}

void rsrc_put (void *addr)
{
	extern int *global /* = _GemParBlk.global (for Turbo C) */ ;
	OBJECT **rsc;

	rsc = (OBJECT **) &(global[5]);
	*rsc = addr;
}

main()
{
	void *save_resorce;

	rsrc_load(file1);
	rsrc_gaddr(...forms from file1...);
	save_resorce = rsrc_get();
	rsrc_load(file2);
	rsrc_gaddr(...forms from file2...);
	...main program...
	rsrc_free();
	rsrc_put(save_resorce);
	rsrc_free();
}
------------
I hope it's right !!!! and would help you.


Ciao  ---  Dieter

--------------------------------------------------------------------------------
|   Dieter Fiebelkorn                           |   With a rubber duck   :-)   |
|   fiebelko@petra.informatik.uni-dortmund.de   |   one's never alone!   :^{   |
--------------------------------------------------------------------------------