The shoutbox is currently out of service. Join us on Discord instead.
You can help CodeWalrus stay online by donating here.

Axe question: How to read archived appvar?

Started by JWinslow23, October 25, 2015, 08:21:38 pm

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JWinslow23

I'm starting work on an old project that is LONG overdue for some work (don't expect it finished ANYTIME soon, however), and I've run into a bit of a problem.

I plan for this one (pretty huge, and it's gonna be huger) appvar to reside in the archive. It contains all the graphical information of the game inside of it. I need to know what code to do to initialize and refer to this appvar throughout the game. I've tried GetCalc("appvAPPVName",Y0) with {Y0+N} and GetCalc("appvAPPVName",Y0)->M with {M+N} , and neither work. The first gives me an error upon compiling, and the other simply gives me glitchy graphics.

So, what do I need to do? Thanks in advance!

Snektron

October 25, 2015, 08:34:28 pm #1 Last Edit: October 25, 2015, 08:47:44 pm by Cumred_Snektron
What does GetCalc("appvAPPVName",Y0)  return? if its 0, you're doing something wrong.

Also WikiTI has a section on flash storage. Maybe you can do something with it :P
http://wikiti.brandonw.net/index.php?title=83Plus:OS:Variable_Storage_in_the_User_Archive
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


c4ooo

October 25, 2015, 09:13:23 pm #2 Last Edit: October 25, 2015, 09:15:49 pm by c4ooo
None of the axe graphics routines can read from archive, so either way you will have to copy the graphics data to ram (as i do in lazer II). Further more, reading from a file is, IIRC, about 200 times slower then from ram. Lastly you should not use unarchive/archive, since there is no need to write back.

Getcalc("name",Y0)  with {Y0+foo} should work. Remeber, you can only do {Y0+foo}->foo2 and never foo2->{Y0+foo}.

If the appvar has graphics data, your code should look like this:

!if Getcalc("appvGRAPHDATA",Y0)?Getcalc("appvTEMP",S)->P .this should be correct
.error graphics data appvar not found or not enough ram
Return
End
Copy(Y0,P,S)

'S' should contain the size of the graphics data. If you dont know it you should mod your program that creates the graphics data to output the size. After this code, 'P' contains the graphics data.

;)

PS: if you want, i could send over some of the code for lazer I that deals with this.

JWinslow23

Quote from: Cumred_Snektron on October 25, 2015, 08:34:28 pm
What does GetCalc("appvAPPVName",Y0)  return? if its 0, you're doing something wrong.

Also WikiTI has a section on flash storage. Maybe you can do something with it :P
http://wikiti.brandonw.net/index.php?title=83Plus:OS:Variable_Storage_in_the_User_Archive

37170.

Quote from: c4ooo on October 25, 2015, 09:13:23 pm
None of the axe graphics routines can read from archive, so either way you will have to copy the graphics data to ram (as i do in lazer II). Further more, reading from a file is, IIRC, about 200 times slower then from ram. Lastly you should not use unarchive/archive, since there is no need to write back.

Getcalc("name",Y0)  with {Y0+foo} should work. Remeber, you can only do {Y0+foo}->foo2 and never foo2->{Y0+foo}.

If the appvar has graphics data, your code should look like this:

!if Getcalc("appvGRAPHDATA",Y0)?Getcalc("appvTEMP",S)->P .this should be correct
.error graphics data appvar not found or not enough ram
Return
End
Copy(Y0,P,S)

'S' should contain the size of the graphics data. If you dont know it you should mod your program that creates the graphics data to output the size. After this code, 'P' contains the graphics data.

;)

PS: if you want, i could send over some of the code for lazer I that deals with this.

I really wonder, then, how FNAF got away with three >39KB appvars and doing this for each of them :P
That code IS working, though, granted I'm not so sure I'd want the entire appvar to be copied to another appvar that's exactly the same when I could unarchive the appvar and read from it directly to cut out the middle man. Nice to know my options, though.

c4ooo

If you where to unarchive, then you would have to re-archive the appvar. This would mean extra time when exiting, plus the possibility of having to garbage collect. With my method, you have the data safe in the archive (runer112 confirmed that the archived data is never copied to rome), while you also have a copy in ram. About, FNAF, you should ask Hoabo (IIRC his name), as he was the one who made it.

JWinslow23

Quote from: c4ooo on October 25, 2015, 09:49:10 pm
If you where to unarchive, then you would have to re-archive the appvar. This would mean extra time when exiting, plus the possibility of having to garbage collect. With my method, you have the data safe in the archive (runer112 confirmed that the archived data is never copied to rome), while you also have a copy in ram. About, FNAF, you should ask Hoabo (IIRC his name), as he was the one who made it.

Noted. This looks similar to what he used in his FNAF game, looking at the source. However, it appears he doesn't save the pointer to a variable. I'm too lazy to look into it further :P , but thanks for the info. ;)

Hayleia

You don't have to copy the data from your archives appvar to an unarchived appvar by the way. You can also copy it to any safe RAM area ;)
This would have some little advantages here and there, like
  • No need to have free RAM, just use RAM that is always free, and no need for code that detects errors in case of not enough RAM
  • Save a variable (the one you store the pointer to your appvar in) and save variable loading so be a tiny bit faster
  • No risk of appvar name conflict

JWinslow23

Quote from: Hayleia on October 25, 2015, 11:19:49 pm
You don't have to copy the data from your archives appvar to an unarchived appvar by the way. You can also copy it to any safe RAM area ;)
This would have some little advantages here and there, like
  • No need to have free RAM, just use RAM that is always free, and no need for code that detects errors in case of not enough RAM
  • Save a variable (the one you store the pointer to your appvar in) and save variable loading so be a tiny bit faster
  • No risk of appvar name conflict

Not enough. Already, the graphics data is approaching 5KB. :P

Hayleia

Well, maybe you don't need to copy all that data at once.
In Pokemon for example, while in the overworld, you need tilemap sprites but you don't need battle sprites. Conversely, in battle you need battle sprites but you don't need tilemap sprites. And in both cases, you don't need to have the titlescreen background in RAM, etc. So you can partially "unarchive" your data when "changing mode" (actually, Topaze works in a stupider way, it only copies one sprite to RAM at once and everytime it needs it :P). So maybe you can do something like that ?

JWinslow23

Quote from: Hayleia on October 26, 2015, 07:12:08 am
Well, maybe you don't need to copy all that data at once.
In Pokemon for example, while in the overworld, you need tilemap sprites but you don't need battle sprites. Conversely, in battle you need battle sprites but you don't need tilemap sprites. And in both cases, you don't need to have the titlescreen background in RAM, etc. So you can partially "unarchive" your data when "changing mode" (actually, Topaze works in a stupider way, it only copies one sprite to RAM at once and everytime it needs it :P). So maybe you can do something like that ?

Does not make sense for my program, and it would be impractical anyways. All of the graphics in the appvar will go to the board and your character. Besides, the cursor sprite is in there somewhere! :P

Powered by EzPortal