Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: danny90444 on June 30, 2012, 04:57:13 pm
-
So i was reading one of the articles here and it said something about a program saving high scores to itself. Can someone exlpain this/"writeback" to me?
-
Well, it is, that every time a program is run from archive via a shell, a copy of it is stored in ram and then executed. Now, if the program modifies itself to store data it will ONLY modify the copy in ram, leaving the original in archive untouched.
Now, with writeback enabled, the shell will copy the program back from ram to archive when exiting it.
-
To clarify, with writeback enabled, before execution the program is actually unarchived during execution. It is archived upon exit. The good side of that is that it saves your highscores and stuff, but the downside is that your calculator will garbagecollect/reorganize archive every 5 minute or so, which is long and annoying, and if the game crashes, it won't get archived, so you'll lose it upon a RAM clear.
-
I garbage collect on my own so i dnt mind . Could you explain what i need to actually put in my program to save highscores?
-
A section with the initial data following a label:
HScoreData:
.db 100,90,80,70,60,50,40,30,20,10,0
for example. Then modify the memory locations in terms of the label. As an example:
ld hl,(score)
ld (HScoreData+10),hl
ld hl,HScoreData
call SortD
-
A section with the initial data following a label:
HScoreData:
.db 100,90,80,70,60,50,40,30,20,10,0
for example. Then modify the memory locations in terms of the label. As an example:
ld hl,(score)
ld (HScoreData+10),hl
ld hl,HScoreData
call SortD
Sorry but i dont understand any of that :/
-
What language are you writing this in?
-
z80 Assembly. In Axe you might do it this way:
Data(100,90,80,70,60,50,40,30,20,10,0)->GDB1HS
.later...
S->{GDB1HS+10}
sub(SORTD,GDB1HS)
.assume SORTD is a subroutine
-
z80 Assembly. In Axe you might do it this way:
Data(100,90,80,70,60,50,40,30,20,10,0)->GDB1HS
.later...
S->{GDB1HS+10}
sub(SORTD,GDB1HS)
.assume SORTD is a subroutine
And whats in the subroutine? sorry im just really confused because im new to this.
-
Assume that the SORTD subroutine sorts data in descending order.
I also want to correct something:
Data(100^r,90^r,80^r,70^r,60^r,50^r,40^r,30^r,20^r,10^r,0^r)->GDB1HS
.later...
S->{GDB1HS+10}
sub(SORTD,GDB1HS,11)
.assume SORTD is a subroutine. # of items is 11.
-
And whats in the subroutine? sorry im just really confused because im new to this.
If you're new to Axe, I'd suggest using a simple appvar. They are super easy to use, and it's harder to accidentally mess up your calculator.
Check out this tutorial: http://www.omnimaga.org/index.php?action=articles;sa=view;article=58
-
Assume that the SORTD subroutine sorts data in descending order.
I also want to correct something:
Data(100^r,90^r,80^r,70^r,60^r,50^r,40^r,30^r,20^r,10^r,0^r)->GDB1HS
.later...
S->{GDB1HS+10}
sub(SORTD,GDB1HS,11)
.assume SORTD is a subroutine. # of items is 11.
But then, a r is missing after the S->{GDB1HS+10}
Moreover, no need to make a routine if it is only used once. What I suspect is that you wrote sub(SORTD,GDB1HS,11) to say "you must sort it" without giving the proper code :P
I personally do it the other way round in MisterOops!
I check how many scores the current score beats, shift them, then insert the new highscore :)
-
And whats in the subroutine? sorry im just really confused because im new to this.
If you're new to Axe, I'd suggest using a simple appvar. They are super easy to use, and it's harder to accidentally mess up your calculator.
Check out this tutorial: http://www.omnimaga.org/index.php?action=articles;sa=view;article=58
I already know how to use the appvar i just wanted to learn a different way to do it.
Data(100^r,90^r,80^r,70^r,60^r,50^r,40^r,30^r,20^r,10^r,0^r)->GDB1HS
.later...
S->{GDB1HS+10}
sub(SORTD,GDB1HS,11)
.assume SORTD is a subroutine. # of items is 11.
So first 11 items are sent to GDBHS , then the users score is sent to the list and the list is sorted ? And why does r need to be included?
-
^r needs to be included if you are using 16-bit integers (0 to 65535) for your score.
-
If you're new to Axe, I'd suggest using a simple appvar. They are super easy to use, and it's harder to accidentally mess up your calculator.
Nope, it is easier to mess the calc up with apppvars since you can only write to the appvar when it exists (else, you don't know where you are writing) while the program always exists if it wants to save a score.
Of course, checking if the appvar exists is not hard, but writeback is a lot easier.
-
^r needs to be included if you are using 16-bit integers (0 to 65535) for your score.
OK . is this right ?
Data(100^r,90^r,80^r,70^r,60^r,50^r,40^r,30^r,20^r,10^r,0^r)->GDB1HS
.later...
S->{GDB1HS+10}
sub(SORTD,GDB1HS,11)
.assume SORTD is a subroutine. # of items is 11.
So first 11 items are sent to GDBHS , then the users score is sent to the list and the list is sorted ?
-
Assume that the SORTD subroutine sorts data in descending order.
I also want to correct something:
Data(100^r,90^r,80^r,70^r,60^r,50^r,40^r,30^r,20^r,10^r,0^r)->GDB1HS
.later...
S->{GDB1HS+10}
sub(SORTD,GDB1HS,11)
.assume SORTD is a subroutine. # of items is 11.
But then, a r is missing after the S->{GDB1HS+10}
Moreover, no need to make a routine if it is only used once. What I suspect is that you wrote sub(SORTD,GDB1HS,11) to say "you must sort it" without giving the proper code :P
I personally do it the other way round in MisterOops!
I check how many scores the current score beats, shift them, then insert the new highscore :)
Where does that "r" need to be ?
-
Right behind the S->{GDB1HS+10}
It would be S->{GDB1HS+10}r
-
Assume that the SORTD subroutine sorts data in descending order.
I also want to correct something:
Data(100^r,90^r,80^r,70^r,60^r,50^r,40^r,30^r,20^r,10^r,0^r)->GDB1HS
.later...
S->{GDB1HS+10}
sub(SORTD,GDB1HS,11)
.assume SORTD is a subroutine. # of items is 11.
But then, a r is missing after the S->{GDB1HS+10}
Moreover, no need to make a routine if it is only used once. What I suspect is that you wrote sub(SORTD,GDB1HS,11) to say "you must sort it" without giving the proper code :P
I personally do it the other way round in MisterOops!
I check how many scores the current score beats, shift them, then insert the new highscore :)
So could i use "SORTD(" to sort the list ?
-
Right behind the S->{GDB1HS+10}
It would be S->{GDB1HS+10}r
It would be S->{GDB1HS+20}r actually. Thank you for correcting me.
-
Also, here (http://ourl.ca/4129/153698) is a sorting routine.
-
Thanks, could you help me with display? Like how to display the highscores from the list ?
-
Thanks, could you help me with display? Like how to display the highscores from the list ?
Note, that what I will write will not be optimised at all so you understand everything.
To display the first score, you would do
Text(0,0,{GDB1HS}r►Dec)
To display the second one, you would do
Text(0,6,{GDB1HS+2}r►Dec)
Why (0,6) ? because there is already the first score in (0,0).
Why GDB1HS+2 ? because the first score takes 2 bytes, located at GDB1HS and GDB1HS+1, so the second one is at GDB1HS+2
So, to display the third one, you would do
Text(0,12,{GDB1HS+4}r►Dec)
etc...
To display the Ith score, you would do
Text(0,I*6,{I*2+GDB1HS}r►Dec)
Now, to display them all, just put that in a For loop like this
For(I,0,10)
Text(0,I*6,{I*2+GDB1HS}r►Dec)
End
Hope that helps :)
-
Thanks, could you help me with display? Like how to display the highscores from the list ?
Note, that what I will write will not be optimised at all so you understand everything.
To display the first score, you would do
Text(0,0,{GDB1HS}r►Dec)
To display the second one, you would do
Text(0,6,{GDB1HS+2}r►Dec)
Why (0,6) ? because there is already the first score in (0,0).
Why GDB1HS+2 ? because the first score takes 2 bytes, located at GDB1HS and GDB1HS+1, so the second one is at GDB1HS+2
So, to display the third one, you would do
Text(0,12,{GDB1HS+4}r►Dec)
etc...
To display the Ith score, you would do
Text(0,I*6,{I*2+GDB1HS}r►Dec)
Now, to display them all, just put that in a For loop like this
For(I,0,10)
Text(0,I*6,{I*2+GDB1HS}r►Dec)
End
Hope that helps :)
Thanks
-
What's up with the topic title *.* :hyper:
-
What's up with the topic title *.* :hyper:
/me is confused
-
What's up with the topic title *.* :hyper:
/me is confused
If you read the first page I was asking about how to use write back.