Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Hayleia on June 06, 2011, 07:23:32 am

Title: Text Data
Post by: Hayleia on June 06, 2011, 07:23:32 am
Is there any way to store text data in Axe and to recall it to display it ? (like bcall(_vputs) or bcall(_puts) in ASM ).
The aim is not only to display text (or I'll do Text(?,?,"?")
The aim is to "choose" the text to display in fonction of a number.
With text data, it would be possible.
Code: [Select]
  ;example of text data
   .db "lol",0
   .db "yes",0
Here, if a=1 it displays "lol" and if a=2 it displays "yes" (if we add the display code). See what I mean ?
Title: Re: Text Data
Post by: Aichi on June 06, 2011, 07:54:20 am
Code: [Select]
"Text 1" -> Str1
"Txt2" -> Str2
"T 003" -> Str3
Data(Str1r,Str2r,Str3r) -> Gbd0
ClrHome
rand^3 -> A
Output(0,,{A*2+Gbd0}

Did you mean that?
Title: Re: Text Data
Post by: aeTIos on June 06, 2011, 09:09:11 am
He's right, but I don't recommend the Data( command. You store text that way.
Title: Re: Text Data
Post by: Deep Toaster on June 06, 2011, 09:40:49 am
He's right, but I don't recommend the Data( command. You store text that way.

Why not? In Aichi's code it's used to store the pointers to the strings in a list.
Title: Re: Text Data
Post by: aeTIos on June 06, 2011, 09:43:53 am
Oops! Then its waaay better with Aichi's method. I thought it stored the data. Excuse me.
Title: Re: Text Data
Post by: Aichi on June 06, 2011, 09:46:32 am
aeTIos, it stores the pointers to get all pointers in a list and work more efficient with it, it doesn't store the same strings of course. :P
Pointer list are extremly useful in some cases.
Title: Re: Text Data
Post by: aeTIos on June 06, 2011, 09:49:09 am
Argh...

***Goes headbang himself :banghead:
Title: Re: Text Data
Post by: BrownyTCat on June 06, 2011, 09:50:24 am
He's right, but I don't recommend the Data( command. You store text that way.
Is Data() highly volatile?
Title: Re: Text Data
Post by: aeTIos on June 06, 2011, 09:51:23 am
Check next posts. I thought that Aichi copied everything into GDB1 which is not really efficient.
Title: Re: Text Data
Post by: Hayleia on June 06, 2011, 10:39:06 am
Hey, thanks to all for your (very) fast answers.
But I'm bothering you all again with another question :
How do I do to store lots and lots of words ? Because with your method, I need a pointer for each word but if I have 200 words   ???
Title: Re: Text Data
Post by: Aichi on June 06, 2011, 10:49:16 am
Yeah, I think you have to type in all 200 pointers by yourfelf, but notice that setting a pointer won't affect the size after compiling. Axe Parser replaces the pointer usages with the real data locations in the program plus 9D95h, so you don't have to spare on setting pointers.
Title: Re: Text Data
Post by: Hayleia on June 06, 2011, 10:53:22 am
Okay but I wasn't wondering about the size but the number: does the TI have more than 200 names of pointers ? (offtopic: how do you do to make your avatar color changing  :hyper: ?)
Title: Re: Text Data
Post by: Quigibo on June 06, 2011, 10:54:15 am
The Data command needs the r modifier after each entry if you're using pointers since each entry needs to be 2 bytes large.  But there is a more memory efficient way to store the text, which is to just have each entry right after each other like this:

Code: [Select]
:"Text1"[00]->Str1
:"Text2"[00]
:"More Text"[00]
:.etc

And then to get the Nth string, just write a routine that starts at Str1 and scans until it has read N-1 zeros

Code: [Select]
:Lbl NTH
:Str1->r2
:While r1
: While {r2}
:  r2++
: End
: r2++
: r1--
:End
:Return r2
Title: Re: Text Data
Post by: Hayleia on June 06, 2011, 10:57:04 am
Once again, thank you.
So "Text1" is at Str1 and "Text2" is at Str1+2 ?
Another question: even "lolcoopuhstoretoAAAwtfloveomnimaga"[00] takes 2 bytes ?
Title: Re: Text Data
Post by: Aichi on June 06, 2011, 10:57:41 am
Okay but I wasn't wondering about the size but the number: does the TI have more than 200 names of pointers ? (offtopic: how do you do to make your avatar color changing  :hyper: ?)

The TI OS doesn't support that much pointers, but Axe Parser does. You can use Gbd08A as a pointer for example.

The random color is generated through PHP. :)
Title: Re: Text Data
Post by: Quigibo on June 06, 2011, 11:00:20 am
@Hayleia
Not quite, you can't read the pointers like that unless all the strings are the same length.  You have to scan the text each time since you don't know how far apart each text entry is from one another.  Text1 is at sub(NTH,0), Text2 is at sub(NTH,1), etc...
Title: Re: Text Data
Post by: Hayleia on June 06, 2011, 11:04:39 am
AH I UNDERSTOOD !!!! Sorry for being French and for being a noob at non-Basic. In fact, you store a 0 between each words and you just have to count the zeros to find the text you want !!!
Thank you very very much Quigibo, and thanks to the others too.
Edit:
What ? and how do I do to write at X,Y the text located in sub(NTH,1) ?
Title: Re: Text Data
Post by: Quigibo on June 06, 2011, 11:10:13 am
Text(X,Y,sub(NTH,1)) :)

By the way I edited the NTH routine to make a correction.
Title: Re: Text Data
Post by: Hayleia on June 06, 2011, 11:16:42 am
I told you I was a noob at non-Basic.
I first thought the answer was Text(X,Y,sub(NTH,1)) but I soon thought "no, it is impossible you idiot (me the idiot not you)". That was forgetting how wonderful was Axe. You made a fantastic work man, it's amazing how it makes the transition between Basic and ASM. Thanks for your hard work, and for your answers. If I finish my game (also have to begin it before), I'll give you credits, and I'll give Omnimaga credits too.
Title: Re: Text Data
Post by: Deep Toaster on June 06, 2011, 01:02:18 pm
Quote from: Aichi
The TI OS doesn't support that much pointers, but Axe Parser does. You can use Gbd08A as a pointer for example.

The random color is generated through PHP. :)

You're still limited to (I think) around 150 pointers though. It's the max that Axe can keep track of.

And off-topic: Is each color in a separate image or does the script itself tell you what color to add?
Title: Re: Text Data
Post by: Aichi on June 06, 2011, 01:18:52 pm
And off-topic: Is each color in a separate image or does the script itself tell you what color to add?

There are about 12 pre-recolored pictures. PHP randomly picks one of them.
Recoloring directly through PHP would be quite awkward.