Re: A89: Save while Archived?


[Prev][Next][Index][Thread]

Re: A89: Save while Archived?




Saving while archived is only a side-effect of the save game method I
use in Phoenix.  I originally developed Phoenix on a TI-92, in which
memory is very limited (only about 60K free after installing Fargo, the
shell, and basic libraries).  Phoenix originally allocated a little
more than 6K of memory for it's variables and display buffer.  This was
quite significant to me, so I decided to put them all on the stack.
The stack was 16K in size.  When the program is started, up to 3K of
stack might have been used by the various OS and Fargo stuff.  I also
had to leave a little bit free for the calls inside my program (just a
few bytes) and whatever ROM calls I make might take.  However, I could
expect 12K of stack to be available.

Then I later thought about implementing saving the game.  I thought
that since the variable were already on the stack, I might be able to
just leave them there and hope they would remain.  This has the
advantage of saving memory;  I wouldn't need an extra 1K of space in
the program file to store the data.  I did decide to reorganize the
data when it's saved, however.  Normally, the game had the variables
at the highest address on the stack and the display buffer at the
lowest, but I switch the variables to the bottom when to "protect"
them.  I also put a checksum of the data at the end to ensure that it
won't be corrupted.  If a program uses a lot of stack space, it can
destroy a saved game, but I've never seen that happen.  I suppose the
TI-OS must use a lot of stack in some circumstances (why else would
there be that much stack?).  If a program does use memory low enough
on the stack, some of the game data would be overwritten (and there's
nothing wrong with such a program) and a restored game would likely
crash.  However, the checksum test will just ignored the saved game
when this happens.

Since the stack is always part of the regular memory, it doesn't
matter at all whether the game is archived.  Since this is only for
the saved game, high scores will not be saved when the game is
archived.  Also, sending the game between calculators can't copy the
saved game.

> Anyone else notice that Phoenix 3.0 saves to itself while archived - WITHOUT
> an external file?  I was finally got myself the Quad Plasma Cannon, Deluxe
> Rapid Fire, Radar Jammer, and a Horizontal Speed Boost, and I accidentally
> hit Apps (the teacher key).  Phoenix was archived and I thought I'd lose the
> game - but it resumed =)  After another half-hour of being nearly invincible
> with all those powerups, I quit and did some experimenting -- Phoenix is
> saving while archived?!?  What the heck?


References: