Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Aichi on October 01, 2010, 02:16:48 pm

Title: Holding variables in program data
Post by: Aichi on October 01, 2010, 02:16:48 pm
Hey Omnimaga Community,
Is there a way to hold variables directly in the program by using Axe?
Its something that is used in Pheonix to store highscore values and strings.
Actually Im using application shell for my game.
Regards,
Aichi
Title: Re: Holding variables in program data
Post by: Runer112 on October 01, 2010, 02:56:10 pm
If you run the program in a shell, writeback should be automatic. Just store your data to a custom pointer, one whose data will be stored inside the program, and the data will be preserved between executions.

EDIT: By the way, I just noticed... when you say "application shell," do you mean that you'll run the program through a shell application like MirageOS? Or that you'll compile the program into an application? Because writeback is not possible for applications.
Title: Re: Holding variables in program data
Post by: jnesselr on October 01, 2010, 04:59:19 pm
If you don't use a shell, you will need to find the program in ram and edit it.
Title: Re: Holding variables in program data
Post by: ztrumpet on October 01, 2010, 05:08:31 pm
Here: http://ourl.ca/4129/80259
The discussion runs onto the next page of the topic too, so you may want to keep reading until you figure out how it works. :)  Make sure to thank Sir for the awesome routine! ;D
Title: Re: Holding variables in program data
Post by: Aichi on October 02, 2010, 07:35:28 am
@ Runer
Yes, Im compiling my axe code to an app. :/

@ zrtrumpet
I got RAM Clears, when I used the second routine part. Can I also overwrite GDB1 in an app or is it just possible in programs?

Edit: It works without app shell. I will look for another way to hold variables in my code.
Title: Re: Holding variables in program data
Post by: Runer112 on October 02, 2010, 12:39:33 pm
Aichi: with Applications, writeback/self-modifying code is impossible (or at least extremely difficult). Applications are stored in flash memory, which unlike RAM, can only be in one mode at a time: read or write. When you're running your Application, you're in read mode, so you cannot write anything to flash memory, which is where your program and any internal data reside. That's why there are AppVars. They're Vars for Apps :P
Title: Re: Holding variables in program data
Post by: Aichi on October 02, 2010, 01:16:31 pm
@ Runer
Ok, thanks for the information.
I wont integrate a highscore feature for the moment.
I wanted to have my vars in the code,
because that is very safety. Appvars arent suitable
to store highscores in it. Maybe I can hide the highscores somewhere,
so the OS will ignore it by showing data. This is used by Mirage.
Regards,
Aichi
Title: Re: Holding variables in program data
Post by: AngelFish on October 02, 2010, 09:13:54 pm
I'm not terribly familiar with Appvars because I haven't needed them yet, but I'm fairly sure you can write and read data from them.

Title: Re: Holding variables in program data
Post by: Runer112 on October 02, 2010, 09:39:00 pm
Just wondering, why are appvars not suitable for your purposes? It sounds like you want the data to be invisible to users. If you want, you can just store the data in an appvar with a name containing an invalid character. The appvar will still exists and work like a normal appvar, but it won't be visible in the memory management menu.

Honestly, though, most people who play calculator games wouldn't even know how to actually access/edit the data, even if it was stored in a visible appvar. And for those who do, they could probably find your invisible appvar anyways if they wanted to.
Title: Re: Holding variables in program data
Post by: AngelFish on October 03, 2010, 12:32:30 am
No matter where you store your data in the RAM, it'll be listed in the VAT (variable allocation table). Most experienced calculators users can see the contents of the VAT through a program such as Calcsys. Do I have that right?
Title: Re: Holding variables in program data
Post by: DJ Omnimaga on October 03, 2010, 04:15:15 am
I don't think you should worry that much about people seeing your data. Anyone can just disassemble the APP and examine the code to cheat anyway, same as with video games for consoles. In BASIC we don't even need editors to change game save files and people still play them. Those who cheat ruin their fun anyway, if they don't bother beating the game first.

That said, to write data in an appvar it has to be unarchived. However, you can read data from it regardless of if it's in RAM or Archive. The method is slightly different when it's archived I think, though.