Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Dreeass on March 23, 2013, 07:15:58 pm

Title: Ti Basic to Axe
Post by: Dreeass on March 23, 2013, 07:15:58 pm
You all do not know me here because this is my first post here so I'll tell you all a bit about myself to start off. I've started to develop Java first a while back and since then I'm more into web development, especially PHP since Ruby and Python aren't really my preference. And since I need my calculator which is a Ti-84 Plus, I was interesting in the built in programming language. After some playing around, I noticed it was a slow and not a very wide language if you know what I mean. So I looked up if some other languages existed for the Ti family and came across some and Axe looked the best.

But the simple programs I got on my calculator give quite a few errors and I looked all across Google to find my answers and I really can't find them. That's why I signed up here, to get my questions answered and get into Axe. My first question is how do I define a list in Axe, I'm used to using dim( in Ti basic and List or Array in Java, but don't know how Axe works yet.
Title: Re: Ti Basic to Axe
Post by: Dapianokid on March 23, 2013, 07:17:32 pm
Oi, welcome to Omnimaga Dreeass!!
I'm not the person to answer your questions, but that's what originally brought me to the calculator programming world!
Title: Re: Ti Basic to Axe
Post by: Streetwalrus on March 23, 2013, 08:00:33 pm
Welcome to omni ! ;) Have some peanuts, straight from the factory. :P
!peanuts
To answer your question, there's no list in axe. You just handle data directly with pointers and stuff. You should look at some tutorials (there are a few here).
Title: Re: Ti Basic to Axe
Post by: Happybobjr on March 23, 2013, 08:35:43 pm
you don't need to define a list in axe.

You have 6 memory locations you can use that vary in size and dangers. L1/L2/L3.../L6
You can access these locations with the "{" and "}"
For example {L1 + 4} would access one byte of RAM at location L1+4

You can easily use this to make a list.
for example. if you wanted to make a list of  10 random one byte numbers, you could do this

For (A,0,9)
Rand^256 -> {L1 + A}
End

hope i explained that well enough.

Rand makes a random number between 0 and 65535 i think.
^256 is modulus (you don't really need it as it'd only save 8 bits to that location anyways, but o added it to... um not sure why i did)
A is a variable
{L1 + A} is a changing memory location as A is changing.
Title: Re: Ti Basic to Axe
Post by: Dreeass on March 23, 2013, 08:41:57 pm
you don't need to define a list in axe.

You have 6 memory locations you can use that vary in size and dangers. L1/L2/L3.../L6
You can access these locations with the "{" and "}"
For example {L1 + 4} would access one byte of RAM at location L1+4

You can easily use this to make a list.
for example. if you wanted to make a list of  10 random one byte numbers, you could do this

For (A,0,9)
Rand^256 -> {L1 + A}
End

hope i explained that well enough.

Rand makes a random number between 0 and 65535 i think.
^256 is modulus (you don't really need it as it'd only save 8 bits to that location anyways, but o added it to... um not sure why i did)
A is a variable
{L1 + A} is a changing memory location as A is changing.
Can you explain to me how I can access it, for example when I would build a snake game I would need to store the locations of the snake to delete and calculate the next position.
Title: Re: Ti Basic to Axe
Post by: ThatTreeOverThere on March 23, 2013, 11:22:23 pm
So to store something into RAM, you simply store into the memory location with a pointer (in code, X -> {L1+4} would store X to that value)

So instead of accessing something like L1(5), you access the fifth byte with {L1+4}. The other stuff carries over from TI-Basic, mostly, except that you're only storing a byte. If you want full 16 bit values (up to 65535) you simply add the r after the curly brackets like this: {L1+4}r
Also, one more thing. L1 is just a pointer to a free piece of RAM. It's not a list, and if you allocate more RAM for yourself or write into program data, you can use that too. I remember seeing something here about pointer arithmetic... see http://axe.eeems.ca/Documentation.pdf, page 13
Title: Ti Basic to Axe
Post by: Dreeass on March 24, 2013, 08:28:18 am
So to store something into RAM, you simply store into the memory location with a pointer (in code, X -> {L1+4} would store X to that value)

So instead of accessing something like L1(5), you access the fifth byte with {L1+4}. The other stuff carries over from TI-Basic, mostly, except that you're only storing a byte. If you want full 16 bit values (up to 65535) you simply add the r after the curly brackets like this: {L1+4}r
Also, one more thing. L1 is just a pointer to a free piece of RAM. It's not a list, and if you allocate more RAM for yourself or write into program data, you can use that too. I remember seeing something here about pointer arithmetic... see http://axe.eeems.ca/Documentation.pdf, page 13
So I cannot define a specific length to it, I need to know how long I will make it? I think I got it.

Can I make an integer or double or whatever in Axe and call it whatever I want?
Title: Re: Ti Basic to Axe
Post by: chickendude on March 24, 2013, 09:03:14 am
Those locations i believe have a specific length. They're generally called saferam areas, they're areas in RAM that you can generally safely use to store data during the execution of your program without worrying about overwriting important data (other programs, etc.). You can also create a space using the free RAM of the calculator. Using the saferam areas won't take up any extra user RAM as that memory has been set aside specifically for that purpose (or for things that you probably won't use while executing your program).

EDIT: But you don't have to use up that much memory, if you only need ten bytes you only need to use ten bytes. Using more or less won't change the amount of free RAM needed to run your program.
Title: Re: Ti Basic to Axe
Post by: ThatTreeOverThere on March 24, 2013, 09:09:08 am
Dreeass: you can store whatever you want, wherever you want. However, if you store something into the TI-OS RAM area or some other unsafe place, or you treat a pointer as an integer or a fixed point number as a float or even a signed as an unsigned, you get no warnings. Everything will just break or act unexpectedly. Java and TI-Basic are at least nice in that respect, but you get something more like C here. (and a good thing too, it's faster :) ) I recommend writing down what you're storing and where.
Title: Re: Ti Basic to Axe
Post by: Dapianokid on March 24, 2013, 07:10:58 pm
The thought process and logic involved in writing games is different in Axe from other languages, because those programs and games are written for and run on much more powerful devices. This is a really low-tech device, so think minimalist!
Title: Re: Ti Basic to Axe
Post by: Dreeass on March 24, 2013, 08:12:17 pm
Can you link me to a basic guide on Axe if there is one?
Title: Re: Ti Basic to Axe
Post by: cooliojazz on March 24, 2013, 11:07:18 pm
First of all: There aren't really any "data types", everything is all about byte arrays and how you use them. And now that I've said that, let me tell you what the data types are :P
There are 8-bit or 1-byte numbers which have a signed range of -128 to 127 (equivalent to a java byte) or an unsigned range of 0-255. Note that unsigned and signed aren't really any different, it's all about what commands you use with them.
Then there are 16-bit or 2-byte numbers which have a signed range of -32,768 to 32,767 (equivalent to a java short) or an unsigned range of 0-65,535. There are also 8.8 fixed point numbers, which are also 16-bit, but have a signed range of -128 to 127 and also have a fractional part with a resolution of 8-bits, for representation of decimal numbers. These are not the huge range floating point numbers you are used to, but they can still be very useful at times.
Next, about the guide, have you read the pdf included in the axe zip?
Title: Re: Re: Re: Ti Basic to Axe
Post by: Streetwalrus on March 25, 2013, 02:37:20 am
I recommend writing down what you're storing and where.
Really ? I never write anything down when coding, could it be Axe, ASM, TI BASIC or computer. :P
Title: Re: Ti Basic to Axe
Post by: Hayleia on March 25, 2013, 02:41:17 am
I used to write things down when coding in Axe, to know where each pointer points to, but since now pointers can have custom (and descriptive) names, I don't need it anymore.
And I always write everything down for ASM, even the code that I first write in pseudo code then in Axe then in ASM, but my programs still don't work :P