Omnimaga

Calculator Community => Major Community Projects => The Axe Parser Project => Topic started by: aeTIos on December 09, 2010, 03:29:35 pm

Title: Programs written with an Axe program
Post by: aeTIos on December 09, 2010, 03:29:35 pm
Hi, its not about making sources for Axe, but about making programs with Axe.

I know how to create a program:
Code: [Select]
GetCalc("prgmAAAA",1000)->P
But how do I fill it with tokens???

NOTE: something like
Code: [Select]
"Disp"->{P}
does not work :/

anyone help me out???
Thanks!

btw it is for a program in the very future for ppl that dont know how to program to let them easy make programs, and just for my knowledge (and others too)

Edit:
I found that this works a little:
Code: [Select]
{8} (or any value between 0 and 65535) ->{P}
I guess it has something to do with RAM addresses?
Title: Re: Making programs???
Post by: nemo on December 09, 2010, 03:42:22 pm
this table (http://tibasicdev.wikidot.com/one-byte-tokens) will help you greatly.
Copy([656667686970717273747576777879808182838485868788899091],P,26)
^should copy the alphabet into whatever's at P.
Title: Re: Making programs???
Post by: aeTIos on December 09, 2010, 03:43:12 pm
Yay, nice!
Title: Re: Making programs???
Post by: nemo on December 09, 2010, 03:44:12 pm
oh, or you could do this: TDisp->{P}
Title: Re: Making programs???
Post by: Happybobjr on December 09, 2010, 03:51:41 pm
I suggest when your program is finished,  you take the number of bytes you used (as n)  and do this n->{P-2}r

I have never had negative effect with this.
Title: Re: Making programs???
Post by: Builderboy on December 09, 2010, 03:54:49 pm
I suggest when your program is finished,  you take the number of bytes you used (as n)  and do this n->{P-2}r

I have never had negative effect with this.

That is exceedingly dangerous if your program grows in size from when you first created it, it can overwrite other things in RAM, including your source if you have it unarchived
Title: Re: Making programs???
Post by: Happybobjr on December 09, 2010, 04:46:18 pm
oh crap, nevermind.

I am going off to change some programs.
Title: Re: Making programs???
Post by: yunhua98 on December 09, 2010, 05:14:05 pm
so basically Axe can write to Programs now?  :D
yeah, I haven't been following the discussion that much.  XD
Title: Re: Making programs???
Post by: DJ Omnimaga on December 09, 2010, 06:55:16 pm
Yeah I am confused, are you trying to create a program editor?
Title: Re: Making programs???
Post by: Deep Toaster on December 09, 2010, 08:00:12 pm
oh, or you could do this: TDisp->{P}

Yep, for tokens just use T.

You can store an array of tokens to use, like

Data(TIf ,TThen,TElse,TFor(,TWhile ,TRepeat ...

Might be hard to use, though.
Title: Re: Making programs???
Post by: DJ Omnimaga on December 10, 2010, 01:53:01 am
That works? That would be cool if it did. It makes it easier to store tokens without having to grab the hex value if it works.
Title: Re: Making programs???
Post by: Builderboy on December 10, 2010, 02:31:19 am
I believe it works, and its pretty useful :D I have been using Hex equivalents in programs like my optimizer and my small font editor x.x and its a pain
Title: Re: Making programs???
Post by: aeTIos on December 10, 2010, 09:44:43 am
so basically Axe can write to Programs now?  :D
yeah, I haven't been following the discussion that much.  XD
I think Axe has been able to write programs as long that it has the getCalc( command

Yeah I am confused, are you trying to create a program editor?
maybe a little bit, but I wanted to know it too, just for Axe knowledge

Edit: how to add quotes in the programs???
Title: Re: Programs written with an Axe program
Post by: yunhua98 on December 10, 2010, 12:36:08 pm
no, When I asked a long time ago, people said it can read but not write to other programs.
Title: Re: Programs written with an Axe program
Post by: aeTIos on December 10, 2010, 12:37:53 pm
oh. nevermind, Axe can handle them now, so be happy! (like me, its my 15th birthday!! :w00t: )
Title: Re: Programs written with an Axe program
Post by: Munchor on December 10, 2010, 12:39:42 pm
oh. nevermind, Axe can handle them now, so be happy! (like me, its my 15th birthday!! :w00t: )

Congratulations, you keep on telling that to everybody xD
Title: Re: Programs written with an Axe program
Post by: yunhua98 on December 10, 2010, 01:51:45 pm
Happy birthdfay!  have a big slice of CAKE: (http://technabob.com/blog/wp-content/uploads/2008/06/f034yq8ff7ihf10medium.jpg)

anyway, so the {^T} is the token prefix?  then how would you add something like "A+1->A"?
Title: Re: Programs written with an Axe program
Post by: aeTIos on December 10, 2010, 01:54:16 pm
using a string then copy

i want to know how to add quotes ( " [alpha][ +] ) and sto> symbol

Title: Re: Programs written with an Axe program
Post by: Deep Toaster on December 10, 2010, 02:14:33 pm
All the tokens are listed here: http://tibasicdev.wikidot.com/tokens

You'll have to store the hex yourself, though.
Title: Re: Programs written with an Axe program
Post by: Munchor on December 10, 2010, 02:17:43 pm
All the tokens are listed here: http://tibasicdev.wikidot.com/tokens

You'll have to store the hex yourself, though.


I would use this token file:

http://brandonw.net/calcstuff/ti83plus.txt (http://brandonw.net/calcstuff/ti83plus.txt)
Title: Re: Programs written with an Axe program
Post by: aeTIos on December 10, 2010, 02:20:59 pm
i wont use a token file :P
in axe, you can store tokens using T(token here)-> {location of token}
so, in case of an quote it woud be T" -> {P+2}

Edit:
yay, finally got a very simple Basic program working!
code:
Code: [Select]
Getcalc("prgmTEST",20)->P
[suprscrpt] T [/supr]Disp->{P}
[sup]T[/sup]"->{P+1}
"I"->Str1
Copy(Str1,P+2,3)
[sup]T[sup]"->{P+3}

It just displays an I on the homescreen, but it works!!
Yay, i discovered something really cool!! :w00t:
Comments?
Post!
Title: Re: Programs written with an Axe program
Post by: matthias1992 on December 10, 2010, 05:17:41 pm
Optimized:
Code: [Select]
GetCalc("prgmTest",4)->P
tDisp->{P
t"->{P+1
"I"->Str1
Copy(Str1,P+2,3
t"->{P+3
[code]

just some brackets + the program is only 4 bytes, not 20 (name excluded)
[/code]
Title: Re: Programs written with an Axe program
Post by: nemo on December 10, 2010, 05:19:25 pm
Code: [Select]
Copy(Data(tDisp,t",'I',t")),GetCalc("prgmTEST",4),4)
Title: Re: Programs written with an Axe program
Post by: aeTIos on December 11, 2010, 01:41:05 am
O.O thats a much optimizing, nemo!
Title: Re: Programs written with an Axe program
Post by: DJ Omnimaga on December 11, 2010, 01:44:48 am
Lol nice, I didn't knew Getcalc could be used that way. ;D
Title: Re: Programs written with an Axe program
Post by: Quigibo on December 11, 2010, 06:37:31 am
I wouldn't recommend using it that way because the routine can fail.  If there were not enough memory to create the program, the pointer would be null and trying to copy data to the zero address would result in a crash.
Title: Re: Programs written with an Axe program
Post by: aeTIos on December 11, 2010, 06:54:14 am
ah, okay. so not copy(A,getcalc(""prgmB",8)
but
Getcalc("prgmB",8)->P
check for enough ram
copy(data to program

am I right??
Title: Re: Programs written with an Axe program
Post by: Quigibo on December 11, 2010, 07:05:05 am
Yeah, something like that. But I'm really only talking about for a 'public' release.  The odds of having less than 15ish bytes left on your calculator is probably very rare.  Any triple digit of bytes is rare for me at least.  If you're just doing this to quickly test out the features or to generate a file like from a map editor then you really don't need the error checking since you're aware of the problem and know how to avoid it.  Its only if other people use your program that you would want to check for errors.
Title: Re: Programs written with an Axe program
Post by: aeTIos on December 11, 2010, 07:13:24 am
^thats clear.
is there any way for easier storing tokens into strings??
like
Code: [Select]
Data(tDisp t")->str1
"I"->str1+2
Data(t")->str1+3
copy(str1,P,length(str1)
does this work?
Title: Re: Programs written with an Axe program
Post by: Quigibo on December 11, 2010, 07:32:40 am
The easiest way *not available until the next version* is to absorb them directly into the program.

Recall that when you have a title screen that takes up the whole screen, you don't want to have to type out the entire 1536 hex characters:
[123ABC...]

Instead, you can absorb an OS picture into the program simply by doing this:
[Pic1]

The same thing applies for tokens.  If you want a string of tokens, then instead of doing:
Data(t1,t2,t3,tA,tB,tC,...)

You can do any of these:
[Ans]
[Str1]
[prgmABC]
[appvABC]


And the data will be directly absorbed into the program, depending on where you have your tokens stored (The one with Ans is kinda volatile, I wouldn't recommend that).  To find the length of some data of unknown size, you can't use length() because its not necessarily zero terminated, and you shouldn't use it anyway since its a slow routine and you already know the pointers are static.  Instead you can just subtract the start from the end of the data pointer.

:[Str1]->Str1
:[]->Str1E
:Copy(Str1,L1,Str1E-Str1)
Title: Re: Programs written with an Axe program
Post by: aeTIos on December 11, 2010, 08:29:22 am
wow thats nice, cant wait until next version!
Title: Re: Programs written with an Axe program
Post by: Munchor on December 11, 2010, 09:17:24 am
The easiest way *not available until the next version* is to absorb them directly into the program.

Recall that when you have a title screen that takes up the whole screen, you don't want to have to type out the entire 1536 hex characters:
[123ABC...]

Instead, you can absorb an OS picture into the program simply by doing this:
[Pic1]

The same thing applies for tokens.  If you want a string of tokens, then instead of doing:
Data(t1,t2,t3,tA,tB,tC,...)

You can do any of these:
[Ans]
[Str1]
[prgmABC]
[appvABC]


And the data will be directly absorbed into the program, depending on where you have your tokens stored (The one with Ans is kinda volatile, I wouldn't recommend that).  To find the length of some data of unknown size, you can't use length() because its not necessarily zero terminated, and you shouldn't use it anyway since its a slow routine and you already know the pointers are static.  Instead you can just subtract the start from the end of the data pointer.

:[Str1]->Str1
:[]->Str1E
:Copy(Str1,L1,Str1E-Str1)


That will be great in Sprite Editors which give us the HEX code in Str1, we will then absorb it and save it as a program-variable.
Title: Re: Programs written with an Axe program
Post by: Deep Toaster on December 11, 2010, 12:50:46 pm
Does Str1E-Str1 optimize to the actual number of bytes?
Title: Re: Programs written with an Axe program
Post by: guy6020665 on December 11, 2010, 01:33:21 pm
I was considering doing this a while ago, but I had to delete everything off my calc. Irritating test, and when i got back home my computer crashed and has yet to be fixed, and I had to find number values for everything, and unfortunately no one at my school has Axe :'(
Title: Re: Programs written with an Axe program
Post by: DJ Omnimaga on December 11, 2010, 01:40:57 pm
Yeah, something like that. But I'm really only talking about for a 'public' release.  The odds of having less than 15ish bytes left on your calculator is probably very rare.  Any triple digit of bytes is rare for me at least.  If you're just doing this to quickly test out the features or to generate a file like from a map editor then you really don't need the error checking since you're aware of the problem and know how to avoid it.  Its only if other people use your program that you would want to check for errors.
Ah, right, what if the programmer checks how much RAM is left prior the game execution and exit if it's too low, though?
Title: Re: Programs written with an Axe program
Post by: nemo on December 11, 2010, 03:39:01 pm
yeah i didn't include error checking because i would hope that people have at least 10 bytes to spare on their calculator. that is neat though, absorbing other variables directly into your program. why are you taking it out next version?