Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: spud2451 on May 30, 2011, 02:47:56 pm

Title: can someone help me
Post 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 
Title: Re: can someone help me
Post by: Munchor on May 30, 2011, 02:48:51 pm
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.
Title: Re: can someone help me
Post by: spud2451 on May 30, 2011, 02:50:30 pm
thanks
Title: Re: can someone help me
Post by: Munchor on May 30, 2011, 02:51:29 pm
thanks

No problem, you're welcome. Just keep in mind that text was written by Deep Thought.
Title: Re: can someone help me
Post by: spud2451 on May 30, 2011, 02:57:46 pm
i read it 2 1/2 times and still don't get it  :banghead: i've never used pointers before 
Title: Re: can someone help me
Post by: turiqwalrus on May 30, 2011, 03:11:39 pm
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.
Code: (example) [Select]
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
Title: Re: can someone help me
Post by: DJ Omnimaga on May 30, 2011, 03:13:41 pm
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.
Title: Re: can someone help me
Post by: turiqwalrus on May 30, 2011, 03:15:59 pm
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]
Title: Re: can someone help me
Post by: Ashbad on May 30, 2011, 03:27:46 pm
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 :)
Title: Re: can someone help me
Post by: AngelFish on May 30, 2011, 03:37:52 pm
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:

Code: [Select]
[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.
Title: Re: can someone help me
Post by: Munchor on May 30, 2011, 03:40:32 pm
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).
Title: Re: can someone help me
Post by: spud2451 on May 30, 2011, 04:19:27 pm
 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
Title: Re: can someone help me
Post by: ben_g on May 30, 2011, 04:25:34 pm
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}
Title: Re: can someone help me
Post by: spud2451 on May 30, 2011, 04:35:07 pm
i know that but i want to be able to draw sprites
Title: Re: can someone help me
Post by: BrownyTCat on May 30, 2011, 04:54:55 pm
i know that but i want to be able to draw sprites
Use the hex converter bundled with Axe.
Title: Re: can someone help me
Post by: spud2451 on May 30, 2011, 04:59:05 pm
omg i'm an idiot
Title: Re: can someone help me
Post by: Deep Toaster on May 30, 2011, 05:01:49 pm
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

Code: (Axe) [Select]
:[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 :)
Title: Re: can someone help me
Post by: spud2451 on May 30, 2011, 05:17:45 pm
thank you all a lot
Title: Re: can someone help me
Post by: turiqwalrus on May 30, 2011, 07:28:34 pm
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