Author Topic: Holding variables in program data  (Read 7262 times)

0 Members and 1 Guest are viewing this topic.

Offline Aichi

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +76/-3
    • View Profile
    • Devrays
Holding variables in program data
« 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

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Holding variables in program data
« Reply #1 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.
« Last Edit: October 01, 2010, 05:22:20 pm by Runer112 »

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: Holding variables in program data
« Reply #2 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.

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Holding variables in program data
« Reply #3 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

Offline Aichi

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +76/-3
    • View Profile
    • Devrays
Re: Holding variables in program data
« Reply #4 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.
« Last Edit: October 02, 2010, 08:00:46 am by Aichi »

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Holding variables in program data
« Reply #5 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
« Last Edit: October 02, 2010, 12:43:26 pm by Runer112 »

Offline Aichi

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +76/-3
    • View Profile
    • Devrays
Re: Holding variables in program data
« Reply #6 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

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Holding variables in program data
« Reply #7 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.

∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Holding variables in program data
« Reply #8 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.
« Last Edit: October 02, 2010, 09:53:31 pm by Runer112 »

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Holding variables in program data
« Reply #9 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?
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Holding variables in program data
« Reply #10 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.