Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: danny90444 on June 30, 2012, 04:57:13 pm

Title: Mirage OS usage
Post 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?
Title: Re: Mirage OS usage
Post by: Sorunome on June 30, 2012, 05:13:24 pm
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.
Title: Re: Mirage OS usage
Post by: DJ Omnimaga on June 30, 2012, 06:47:00 pm
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.
Title: Re: Mirage OS usage
Post by: danny90444 on June 30, 2012, 07:45:30 pm
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?
Title: Re: Mirage OS usage
Post by: blue_bear_94 on June 30, 2012, 09:15:27 pm
A section with the initial data following a label:
Code: [Select]
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:
Code: [Select]
ld hl,(score)
 ld (HScoreData+10),hl
 ld hl,HScoreData
 call SortD
Title: Re: Mirage OS usage
Post by: danny90444 on July 01, 2012, 07:12:21 pm
A section with the initial data following a label:
Code: [Select]
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:
Code: [Select]
ld hl,(score)
 ld (HScoreData+10),hl
 ld hl,HScoreData
 call SortD


Sorry but i dont understand any of that :/
Title: Re: Mirage OS usage
Post by: thepenguin77 on July 01, 2012, 08:45:01 pm
What language are you writing this in?
Title: Re: Mirage OS usage
Post by: blue_bear_94 on July 01, 2012, 09:28:13 pm
z80 Assembly. In Axe you might do it this way:
Code: [Select]
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
Title: Re: Mirage OS usage
Post by: danny90444 on July 01, 2012, 09:55:03 pm
z80 Assembly. In Axe you might do it this way:
Code: [Select]
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.
Title: Re: Mirage OS usage
Post by: blue_bear_94 on July 02, 2012, 11:02:09 am
Assume that the SORTD subroutine sorts data in descending order.
I also want to correct something:

Code: [Select]
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.

Title: Re: Mirage OS usage
Post by: parserp on July 02, 2012, 11:09:58 am
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
Title: Re: Mirage OS usage
Post by: Hayleia on July 02, 2012, 11:11:58 am
Assume that the SORTD subroutine sorts data in descending order.
I also want to correct something:

Code: [Select]
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 :)
Title: Re: Mirage OS usage
Post by: danny90444 on July 02, 2012, 12:48:47 pm
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?
Title: Re: Mirage OS usage
Post by: blue_bear_94 on July 02, 2012, 01:25:42 pm
^r needs to be included if you are using 16-bit integers (0 to 65535) for your score.
Title: Re: Mirage OS usage
Post by: Hayleia on July 02, 2012, 02:09:45 pm
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.
Title: Re: Mirage OS usage
Post by: danny90444 on July 02, 2012, 03:08:34 pm
^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 ?
Title: Re: Mirage OS usage
Post by: danny90444 on July 02, 2012, 03:10:21 pm
Assume that the SORTD subroutine sorts data in descending order.
I also want to correct something:

Code: [Select]
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 ?
Title: Re: Mirage OS usage
Post by: Hayleia on July 02, 2012, 03:49:35 pm
Right behind the S->{GDB1HS+10}
It would be S->{GDB1HS+10}r
Title: Re: Mirage OS usage
Post by: danny90444 on July 02, 2012, 04:04:25 pm
Assume that the SORTD subroutine sorts data in descending order.
I also want to correct something:

Code: [Select]
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 ?
Title: Re: Mirage OS usage
Post by: blue_bear_94 on July 02, 2012, 08:57:03 pm
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.
Title: Re: Mirage OS usage
Post by: Hayleia on July 03, 2012, 11:06:12 am
Also, here (http://ourl.ca/4129/153698) is a sorting routine.
Title: Re: Mirage OS usage
Post by: danny90444 on July 03, 2012, 11:10:11 am
Thanks, could you help me with display? Like how to display the highscores from the list ?
Title: Re: Mirage OS usage
Post by: Hayleia on July 03, 2012, 11:35:38 am
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 :)
Title: Re: Mirage OS usage
Post by: danny90444 on July 03, 2012, 12:01:41 pm
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
Title: Re: Mirage OS usage
Post by: aeTIos on July 04, 2012, 02:52:30 pm
What's up with the topic title *.*  :hyper:
Title: Re: Mirage OS usage
Post by: parserp on July 04, 2012, 04:54:41 pm
What's up with the topic title *.*  :hyper:
/me is confused
Title: Re: Mirage OS usage
Post by: danny90444 on July 04, 2012, 08:21:16 pm
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.