rsrc_saddr where are some examples

GFA, ASM, STOS, ...

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
Desty
Atari God
Atari God
Posts: 1951
Joined: Thu Apr 01, 2004 2:36 pm
Location: 53 21N 6 18W
Contact:

Re: rsrc_saddr where are some examples

Postby Desty » Thu Nov 23, 2017 11:36 pm

It's "in the same boat", and it doesn't matter which one either of us is in. Go check out Stack Overflow, if someone asks a coding question and doesn't share code that demonstrates where they got stuck, then the question is generally closed and deleted because helping them turns into a guessing game... a bit like this thread, which is why you're still asking the same question after almost 9 years.
tá'n poc ar buile!

User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 683
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: rsrc_saddr where are some examples

Postby mfro » Fri Nov 24, 2017 4:16 am

charles wrote:no desty becAUSE
I am asking for an example code of rsrc saddr not a huge belittling ...


To me, the problem appears to be that you are asking for example code of a specific function (rsrc_saddr()) in the context of using multiple resource files per application. Two things that aren't even remotely related. Like "I have a solution, can you tell me what the problem could be?".

It would be probably a lot more productive for all parties if you'd describe the specific problem you want to solve and we could then talk about how it could be approached best.

joska
Hardware Guru
Hardware Guru
Posts: 3668
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: rsrc_saddr where are some examples

Postby joska » Fri Nov 24, 2017 10:42 am

charles wrote: I am asking for an example code of rsrc saddr not a huge belittling ...


Sorry to say this charles, but you have a long history of confusing constructive critisism with belittling... To make matters worse your posts are mostly not possible to understand, and you don't understand the replies. If you actually want advice then I suggest you read the answers closely, because your questions has been answered very clearly several times in this thread.

To sum this up - no, rsrc_saddr does not relocate the RSC tree. Not sure why you want to do that, but I think this is the core of the problem:

charles wrote:what if you have three different rsc loaded?
how does it know which object tree im trying to address?


Problem: You have several RSC's loaded and wonders how the AES functions knows which one to operate on. The answer to this was given by mfro early on: The pointer to the current RSC is in the AES global array at index 5 and 6 (two 16-bit words that each contains half of the 32-bit adress).

When you load an RSC with rsrc_load, this function will allocate memory for the new RSC and convert the RSC to a proper object tree with pixel-based positions. The RSC contains one or several trees, the addresses to these trees are retrieved by rsrc_gaddr. rsrc_gaddr use the pointer in the AES global array to find the RSC!. The same applies to rsrc_saddr and rsrc_free. If you have several RSC's loaded and need to use one of these functions - rsrc_gaddr, rsrc_saddr and rsrc_free - you must first set the AES global array RSC pointer to point at the RSC you operate on. These are the only functions that requires this! All other AES functions that deals with OBJECTs take an OBJECT pointer and does not care about the global array RSC pointer.

So what you do is simply this:

1. Load RSC using rsrc_load.
2. Store the AES global array RSC pointer in a variable/table/whatever.
3. Repeat until all RSC's have been loaded.

Then you have an indes/table/set of pointers to all the loaded RSC's, and can update the AES global array RSC pointer when needed.

But as I said earlier - unless you need to free (i.e. calling rsrc_free) a specific RSC then it's easier to just store the RSC object tree pointers after each rsrc_load and then forget about the AES global array.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

ThorstenOtto
Captain Atari
Captain Atari
Posts: 165
Joined: Sun Aug 03, 2014 5:54 pm

Re: rsrc_saddr where are some examples

Postby ThorstenOtto » Fri Nov 24, 2017 1:18 pm

joska wrote:The pointer to the current RSC is in the AES global array at index 5 and 6 (two 16-bit words that each contains half of the 32-bit adress).


To be more precise, index 5+6 store a pointer to the array of object tree pointers. These are used when doing a rsrc_gaddr(R_TREE, ...)

Index 7+8 stores a pointer to the resource file header. This is set by rsrc_load(), used for all other rsrc_gaddr() calls, and also used by rsrc_free(). Index 9 has the filesize (one word only, so on AES that are capable of loading larger files this will be truncated if the file is larger than 64K, but it is only informational and not otherwise used by AES).

So when managing multiple resources, you have to save at least indices 5-8 after rsrc_load(), and restore them before calling rsrc_free() or using one of rsrc_gaddr()/rsrc_saddr(). Or, as already suggested, just retrieve all pointers you need immediately after rsrc_load. You can even omit the rsrc_free() call, if you only do it before program termination, since all it does it to free the memory, which will also be done automatically by GEMDOS. However, if you *do* call rsrc_free(), you have to make sure that those variables are set up correctly, otherwise you will free the same memory twice, which might confuse GEMDOS.

joska
Hardware Guru
Hardware Guru
Posts: 3668
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: rsrc_saddr where are some examples

Postby joska » Fri Nov 24, 2017 6:54 pm

ThorstenOtto wrote:So when managing multiple resources, you have to save at least indices 5-8 after rsrc_load(),...


Yes, you are completely right. I should have looked at my code instead of trusting my memory :)

ThorstenOtto wrote:However, if you *do* call rsrc_free(), you have to make sure that those variables are set up correctly, otherwise you will free the same memory twice, which might confuse GEMDOS.


GEMDOS does not care if you free the same memory twice. But if you make such a mistake, you're also likely to make the same mistake when switching between RSC's, ending up with getting pointers from (or freeing!) the wrong RSC. So again, unless you really have to unload/free a loaded RSC it's easiest (and safest) to store the tree pointers after loading each RSC.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2058
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: rsrc_saddr where are some examples

Postby charles » Fri Nov 24, 2017 11:36 pm

this is a landslide of usefull information ..
thanks guys .
give me some time to catch up ....
basically my initial intent was to utilize one object tree , but two different sets of teds,strings , buttons for the object ...
this is what I felt rsrc saddr would do , set the address of new ted,string,button into existing rsc , being identical in size , length items ...
but couldn't find how to use rsrc saddr
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

ThorstenOtto
Captain Atari
Captain Atari
Posts: 165
Joined: Sun Aug 03, 2014 5:54 pm

Re: rsrc_saddr where are some examples

Postby ThorstenOtto » Sat Nov 25, 2017 5:29 am

charles wrote:basically my initial intent was to utilize one object tree , but two different sets of teds,strings , buttons for the object ...
this is what I felt rsrc saddr would do


Thats true, you *could* do that using rsrc_saddr() (sry no example at hand, i never felt the need for it). But it's much easier to just directly manipulate the ob_spec accordingly:

Code: Select all

tree[INPUTFIELD].ob_spec.tedinfo = tedinfo1;
...
tree[INPUTFIELD].ob_spec.tedinfo = tedinfo2;

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2058
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: rsrc_saddr where are some examples

Postby charles » Sat Nov 25, 2017 11:16 am

sorry otto , way past that approach , its a common one ,,,
specifically id like to see gfa and rsrc_saddr
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

ThorstenOtto
Captain Atari
Captain Atari
Posts: 165
Joined: Sun Aug 03, 2014 5:54 pm

Re: rsrc_saddr where are some examples

Postby ThorstenOtto » Sat Nov 25, 2017 1:29 pm

charles wrote:specifically id like to see gfa


I'm quite sure you can do similar things in GFA. Your profile states you understand C, so it shouldn't be too hard to understand those two lines.

charles wrote:and rsrc_saddr


What's your business with rsrc_saddr()? People told you a few dozen times that you don't need it. There are other, much easier solutions.

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2058
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: rsrc_saddr where are some examples

Postby charles » Sat Nov 25, 2017 4:53 pm

you have no need for it doesn't mean I have no need for it ..
you are way off topic to otto ,,, this thread is about rsrc_saddr .....
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

ThorstenOtto
Captain Atari
Captain Atari
Posts: 165
Joined: Sun Aug 03, 2014 5:54 pm

Re: rsrc_saddr where are some examples

Postby ThorstenOtto » Sun Nov 26, 2017 5:41 am

charles wrote:you have no need for it doesn't mean I have no need for it ..


You said you want to reuse some object tree with different teds etc, and need to set the addresses of those in the tree, and i just told you how you can achieve that without using rsrc_saddr(). BTW even if you could rsrc_saddr() for this, it is rather impractical, since you would need to pass it the index of the TEDINFO to modify, not the index of the object where it is used. That is some information that is not generated by resource editors.

charles wrote:this thread is about rsrc_saddr .....


Thats a bit stubborn, isn't it? Next time you open a thread about vq_cellarray(), then ppl. tell you that is was never implemented, and you still insist on getting an usage example...

PS.: my first name is Thorsten

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2058
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: rsrc_saddr where are some examples

Postby charles » Sun Nov 26, 2017 9:42 am

but I never said I cant do it other ways , ive only said I want some different examples using rsrc_saddr..??????
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

joska
Hardware Guru
Hardware Guru
Posts: 3668
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: rsrc_saddr where are some examples

Postby joska » Sun Nov 26, 2017 4:09 pm

charles wrote:but I never said I cant do it other ways , ive only said I want some different examples using rsrc_saddr..??????


No, you did not "only" say that... Anyway, you have been explained what rsrc_saddr does (which isn't much!), so you should be able to decide now whether it's suitable for your intended use or not.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: No registered users and 1 guest