From: Dave Hayden on
I've been asked to add code to the hpobjects HPGCC library to purge a
variable from a directory. When I wrote the library originally,
purging seemed very problematic so I didn't do it. I'm writing now to
see if my assumptions are valid.

Here's my thinking. Please let me know where I have it wrong :)

If you purge a variable, then you change the size of the directory
within it. So you have to rewrite the entire directory image. And if
the directory is a subdir, then you've changed the size of the subdir
and thus you must rewrite the parent directory also. Working up, this
means that you really need to completely rewrite the entire HOME
directory.

And since HOME and port 0 share space, there may be some other
housekeeping variables that need to be rewritten also. Or maybe port0
needs to be rewritten. I'm not sure how the two are layed out.

Finally, if there are any pointers to objects in the HOME directory
tree, then those pointers would need to be readjusted. Yikes! That
sounds like a great way to crash the calculator. You'd only need to
forget one pointer. And what guarantee is there that the list of
pointers is publicly documented?

Thanks in advance,
Dave
From: Andreas Möller on
Hello,

purging/adding is done by moving the data between TEMPOB and USEROB
(aka HOME/Port0) and adjusting the corresponding size fields and yes,
you have to adjust all pointers between TEMPOB and USEROB in this
case, but all of these pointers are documented.

You might consider calling the appropriate ROM routines from HPGCC
instead of coding them all by yourself in HPGCC.

You need to understand the structure of
- HOMEDIR (a special dir that can hold subdirs)
- SUBDIRs
- TEMPOB
- the areas between TEMPOB and USEROB
- the pointers to the various areas, where they stored and how they
calculated

It is quite some work to do it all by yourself.

HTH,
Andreas
http://www.software49g.gmxhome.de
From: Tanguy Briançon on
Dave Hayden wrote:
> I've been asked to add code to the hpobjects HPGCC library to purge a
> variable from a directory. When I wrote the library originally,
> purging seemed very problematic so I didn't do it. I'm writing now to
> see if my assumptions are valid.
>
> Here's my thinking. Please let me know where I have it wrong :)
>
> If you purge a variable, then you change the size of the directory
> within it. So you have to rewrite the entire directory image. And if
> the directory is a subdir, then you've changed the size of the subdir
> and thus you must rewrite the parent directory also. Working up, this
> means that you really need to completely rewrite the entire HOME
> directory.
>

Bad news: you are right..

> And since HOME and port 0 share space, there may be some other
> housekeeping variables that need to be rewritten also. Or maybe port0
> needs to be rewritten. I'm not sure how the two are layed out.
>

In saturn world: the port0 is "at the end" of the memory (after the HOME
directory). So you can do anything in HOME: no problem for PORT0. When
you change (with RPL program...) the HOME directory its addresse change:
(you can get it in #80711) but PORT0 is at the same place (in #80716).

Tanguy





> Finally, if there are any pointers to objects in the HOME directory
> tree, then those pointers would need to be readjusted. Yikes! That
> sounds like a great way to crash the calculator. You'd only need to
> forget one pointer. And what guarantee is there that the list of
> pointers is publicly documented?
>
> Thanks in advance,
> Dave
From: Andreas Möller on
Hello,

> In saturn world: the port0 is "at the end" of the memory (after the
HOME
> directory). So you can do anything in HOME: no problem for PORT0.
When
> you change (with RPL program...) the HOME directory its addresse
change:
> (you can get it in #80711) but PORT0 is at the same place (in
#80716).

Your information is a little bit misleading.

USEROB/Port0 is at the end of the memory and they share the same
addresses.

The address #80711 and #80716 contain pointers which lead to the true
address area of either USEROB and Port0.

#80711 does not change because it is a fixed pointer, whereas the
address of USEROB can change. Note that directly behind the end of
USEROB the Port0 starts (if it contains an object.)

address (also valid for 49G)
GX name nibbles description
80711 USEROB 5 ptr to HOME user object area
80716 ROMPARTS 5 ptr to Romparts (Port 0)

For a list of all GX pointers search for
Updated RAMVARS table
and then add the 49G pointers to this list (those that where added and
those that may have changed).

HTH,
Andreas
http://www.software49g.gmxhome.de
From: Dave Hayden on
Thanks Andreas and Tanguy. You've confirmed what I suspected.

Andreas, it isn't possible to call ROM functions from within C code,
so I can't call the ROM purge function.

Dave