Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: spud2451 on May 30, 2011, 02:47:56 pm
-
i'm a total noob at axe and i need some help understanding
pointers because you pretty much can't do anything without them
-
i'm a total noob at axe and i need some help understanding
pointers because pretty much can't do anything without them
Hey there, I'd recommend this (http://ourl.ca/9165/180882).
Hope you get it. Read it slowly, perhaps twice.
-
thanks
-
thanks
No problem, you're welcome. Just keep in mind that text was written by Deep Thought.
-
i read it 2 1/2 times and still don't get it :banghead: i've never used pointers before
-
look at it this way:
pointers reference a certain point in your calculator's memory.
For example, L1 points to a 'safe area' of memory which you can use to store stuff.
so the pointer {L1+2} would be 2 bytes after the start of L1
To access a certain point that you previously stored, just use the same pointer again.
1 --> {L1+2} //stores 1 to 2 bytes after L1
//now to check if that byte is 1:
If {L1+2} = 1
[insert code here]
End
-
Hi and welcome on the forums. I would also recommend checking the pointers section of the documentation. It is worded different so it might help a bit too.
-
Yeah... that could help :P
welcome, spud. I hope you enjoy omni ;D
[completely offtopic]we already have a member called potato :P[/completely offtopic]
-
Here's a way you can think of pointers, since it's a harder-to-grasp concept with programming:
pointers can be thought as as 'elements' of a matrix which you may have used in something like math. If not, you can think of them as "arrows" that point to a location in memory. Memory is made up of bytes in successive order, and when you're working with Axe you'll be working with 65536 different locations in memory, each of them a byte. I think once you understand this then the documentation will help from there :)
-
If you're confused about pointers, remember that every piece of memory (called a byte) is assigned an address in hexadecimal by the processor, starting from 0x0000. A pointer is just the address of a particular memory location, meaning that it's a 16 bit number that identifies one byte in memory. They're called pointers because the numbers "point" to that address. Since pointers are numbers, you can do the normal mathematical operations on them like addition and subtraction to change them.
Take this Axe code as an example:
[0123456789ABCDEF00]->Str1
.The contents of Str1 are placed somewhere in the program by Axe and the symbol Str1 becomes a pointer to the memory holding the first value
Text(40,40,Str1>char
.Since characters are hexadecimal, we can print the string
.The pointer that is Str1 tells the text( directive to print the string starting from the address pointed to by Str1
Text(40,40,Str1+4>char
.We can also print only part of the string by adding 4 to the pointer. This means that that value Str1+4 points to the location four bytes after the location pointed to by Str1, which is partway through the string.
-
Imagine the memory of your calculator is this:
Memory: AB0123456789ABCDEF00B0231253210214125124123123123122312AF2131231201012312312
Address: 0123456789...
Str1 is a pointer to the address 2, where the image starts in the memory.
(this is not really what happens, just an example).
-
know that but what i can't figure put is how to identify whats were in the calc and i dont know anything about hex codes
-
Just write on a paper what is were
example:
x position: L1
y position: L1+1
lives: L1+2
health: L1 + 3
...
now, if you want to store the health in A, you do {L1+3}->A
if you want to store B in the lives 'variable', you do B->{L1+2}
-
i know that but i want to be able to draw sprites
-
i know that but i want to be able to draw sprites
Use the hex converter bundled with Axe.
-
omg i'm an idiot
-
omg i'm an idiot
Don't feel that way. It's always hard to start working with a new language.
i know that but i want to be able to draw sprites
The syntax is Pxl-Change(X_POS,Y_POS,PTR_TO_SPRITE). X and Y should be pretty simple -- you can even put a number in there (like Pt-Change(44,28,PTR_TO_SPRITE)).
As for the pointer, you need to first store the sprite somewhere. In Axe, you can store the sprite data as part of the program by doing something like
:[001818187E7E18181800]→GDB1
GDB1 is now a pointer to the data you put there, which you can use as a sprite. Now you can do something like Pt-Change(44,28,GDB1) to display the sprite stored at GDB1 (the data above) at the coordinates (44,28) on the screen.
Hope that helps :)
-
thank you all a lot
-
omg i'm an idiot
don't worry... I was a total n00b at axe a few months ago ;)
thank you all a lot
you're welcome ;D