Page 1 of 1
rsrc_gaddr read back selected tree ?
Posted: 17 Apr 2020 11:47
by exxos
Does anyone know, when I use
junk=rsrc_gaddr(type_tree,treeno,formaddr&)
to select a tree number, if I can use that formaddr& value to read back what tree number is actually selected ?
I could store "treeno" in a external variable and keep track of selected tree that way, but seems a little crap in storing the treeno externally, rather than just reading back from the tree address itself...
Re: rsrc_gaddr read back selected tree ?
Posted: 17 Apr 2020 12:05
by thorsten.otto
First off, i wonder why you need to do that? The tree number is usually only needed for rsrc_gaddr(), after that you just use the returned OBJECT tree pointer.
And no, there is no direct way to read the number back. You could loop over all the tree numbers in your resource, calling rsrc_gaddr() on them until you get back the same address, but storing just the number seems to be much easier.
Another option would be to not use rsrc_gaddr() at all, and fetch the array of tree pointers from the header of the resource file. It is available in the AES global array after a successfull rsrc_load() call.
Re: rsrc_gaddr read back selected tree ?
Posted: 17 Apr 2020 12:13
by exxos
thorsten.otto wrote: 17 Apr 2020 12:05
First off, i wonder why you need to do that?
It comes from another problem that when I have a tree like this.. (BH file)
Code: Select all
CONST BOOTROM%= 0
CONST ROMSELECT%= 2
CONST RADIO1%= 3
CONST RADIO2%= 4
CONST RADIO3%= 5
CONST RADIO4%= 6
CONST RADIO5%= 7
CONST BANK1INFO%= 8
CONST BANK2INFO%= 9
CONST BANK3INFO%= 10
CONST BANK4INFO%= 11
CONST MBROM%= 12
CONST RTC2%= 2
CONST RTCRESET%= 3
CONST YEARUP%= 6
CONST MONTHUP%= 7
CONST DAYUP%= 8
CONST SECSUP%= 9
BOOTROM% is a menu, RTC2% is a menu... So if I select RTC2% menu, I then check buttons like RTCRESET% (=3).. The problem is, when changing menus, such as to ROMSELECT%, that number (3) is also RADIO1%... So I can't check for the buttons based on number only.. Which is why I need to keep track of what menu I am actually in...
EDIT: The only other way would be to disable the buttons somehow in each menu tree.. but that seems like a faff really.
Re: rsrc_gaddr read back selected tree ?
Posted: 17 Apr 2020 14:36
by exxos
Or is there some better method to get button clicks ?
Currently I have to use..
FOB=objc_find(tree&,0,7,mx,my)
Where FOB will return the button clicked on, but it doesn't return which tree that button is on..
So if I have
FORM1 =0
BUTTON1 =0
BUTTON2 =1
FORM2 =1
BUTTON1 =0
BUTTON2 =1
FOB will return 0 or 1, but that click could be on FORM1 or FORM2.. hence the problem.
For the moment I will just use a global "treeitem" variable to store which tree I displayed on screen..
The code would then be:
If treeitem = FORM1 AND BUTTONPRESS = BUTTON0...
If treeitem = FORM2 AND BUTTONPRESS = BUTTON0...
I don't think its supposed to be done like that, but I cannot find any other way around the problem.
Re: rsrc_gaddr read back selected tree ?
Posted: 18 Apr 2020 07:41
by thorsten.otto
But you are passing the address of the tree to objc_find(), so you certainly know which tree the button belongs to? There is no need to handle cases for any other object tree.