Hey,

I was wondering how to make AppVars for Highscores in game.

I decided to check a tutorial at Omnimaga, by FinaleTI, which can be found here.

From what I got, I can create an Appvar by doing this:


Code:
GetCalc("appvAPPVAR",Size)->Pointer


So, for my I used:


Code:
GetCalc("appvHSpng",16)->C


Now, if I save data to C, for example:


Code:
20->C


Will it be stored in my Appvar?

If not, how to?


Thanks very much!!

Also, sorry for making so many questions, but I'm still getting used to Axe game making Smile
Is C a pointer? I don't really know Axe, but I was under the impression that r1-r6 were used as pointers.
KermMartian wrote:
Is C a pointer? I don't really know Axe, but I was under the impression that r1-r6 were used as pointers.


Exactly!!!


Code:
GetCalc("appvHSpng",16)->r1


I need to know how to point r1 to C :S
Do 20->{C}, because C is a pointer Smile
Ok, to try and help with the confusion between pointers and such in Axe: Str1 is a pointer, A-Theta, r1-r6 are variables. When you do something like:
Code:
"ABC->Str1
[123412->Pic1
Data(0,1,2,3->GDB1
Str1, Pic1, and GDB1 are all pointers to the data that you "Stored" to them. It is synonymous to having labels point to .db statements in ASM. Here is some code that would be accessed the same way, whether from ASM or Axe:
Code:
Str1:
.db "I am a string!",0

Code:
"I am a string!->Pic1
When you try and access it, you can;t do something like: Str1+1->Str1. You can't do it in Axe, nor ASM. Another example using the above ASM and Axe examples would be to use them as pointers, and store them to variables.
Code:
ld hl,Pic1
add hl,100
ld a,(hl)

Code:
Pic1->A
A+100->A
{A}->B
I hope that helps some with the confusion.

In terms of the original question:

Code:
GetCalc("appvHSpng",16)->C
1->{C}
2->{C+1}
That will make the appvar "HSpng", size 16 bytes, where the first 2 bytes are 1 and 2, and the rest are presumed random. You said you wanted to point r1 to C? Depends what you mean. You could do:
Code:
r1->C
But if you want r1 to point the the literal location of C, you could do:
Code:
C{o}->r1
The "{o}" is the angle symbol. Don't really do this unless you actually know what you are doing (Not to be harsh, but I don't think you need to use that).
That was very helpful. So, now I can define a highscore that is saved in the calculator even when the program is closed.

How to access it so that the Highscore is displayed?
Thanks much
Does Axe lets you move pointers around with something like Str1+1->Str1, or no? If you're saying they're the same as the label above a .db/.dw statement in ASM, then I tend to think not.
Yes, I believe you can.
c.sprinkle wrote:
Yes, I believe you can.
Ah, so they're more like pointers stored in registers than literal pointers. Thanks c.sprinkle.
ScoutDavid wrote:
That was very helpful. So, now I can define a highscore that is saved in the calculator even when the program is closed.

How to access it so that the Highscore is displayed?
Thanks much


Well, I tried:


Code:
GetCalc("appvPONGhs",16)->N
S->{N}


No APPVAR was created (neither in calc or emulator).

What's wrong?
Try this:

Code:
GetCalc("appvPONGhs",16)->N
S->{N}


The appv is not just the lowercase letters; it is a special token accessed by pressing 2ND-8.
Also, if your score is more than 255, it would be best to use:

Code:
S->{N}r

Smile
Thanks much!

I already managed to create an appvar Smile

Now, here's how I tried with no success:


Code:

GetCalc("appvPONGhs",Y0)
{Y0}->W

GetCalc("appvPONGhs",Y1)
{Y1}->K


This one reads the bytes and stores them in W and K to be displayed.


Code:

GetCalc("appvPONGhs",16)->C
S->{C+1}

This one saves one highscore in C+1.


Code:
GetCalc("appvPONGhs",16)->C
S->{C}

This one sabes the other highscore in C (0).

Any ideas? THANKS

I am using the special token accessible by 2ND + 8, Very Happy
If there's a problem, you might want to try:

Code:
GetCalc("appvPONGhs",16)->C
S->{C}
T->{C+1}

where S and T are the scores. This is due to the fact that if you use the GetCalc( command with a (size) argument i.e.

Code:
GetCalc("appvPONGhs",16)->C

it overwrites any existing data in the appvar or creates a new one.
If you just code:

Code:
GetCalc("appvPONGhs")->C

it stores the scores' address to C.
The only time you need to se GetCalc( with a size argument is if you are (re)defining the pointer. It's similar to the BASIC

Code:
17->dim(⌊SCORE

which initiates a list.
So if you want to store two values to consecutive addresses, you don't need to use GetCalc( again.
Whew. That's the long reason. Smile
That makes perfect sense, c.sprinkle; thanks for explaining that. If you redefine the size when it already exists, does that erase the contents, or simply re-size it, leaving the existing content?
Unlike resetting the dimensions of a list, a (size) argument resets the address as well, erasing the data. Because RAM is always being added and subtracted from, the address changes from use to use, so resetting it will rearrange the RAM and put it in a new location.
Okay, I got it: when I try to create an Appvar that has already been created, it is destroyed.

So, how can I turn this around?

In the beginning of the code I should check if it exists and if it does, continue, if it doesn't, create it and continue.


Code:
GetCalc("appvPONGhs",16)->C


This would create it.

How to that 'if' check?
If PONGhs is not on the calculator, then GetCalc("appvPONGhs") will return zero.

Code:
Getcalc(NAME)->H
!If H
Getcalc(NAME,SIZE)->H
For(A,0,SIZE)
0->{H+A}
End


I've been given this code in Omnimaga, which I think will do that.

Right?

So, right now I understood how to store the highscore.


Now, I need to read it and display it, which I think I can do like this:


Code:

{H}->W
Text(0,0,W
{H+1}->C
Text(0,10,C


Is it done like that? Or like this:


Code:

GetCalc("appvNAME",Y0)->W
Text(0,0,W
GetCalc("appvNAME",Y1)->C
Text(0,10,C


Thanks!
1) This will work.

2) The first chunk of code will work.
souvik1997 wrote:
1) This will work.

2) The first chunk of code will work.


it didn't, the appvar was created, but the values are always 0 :S
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement