Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: tehalynn on November 30, 2010, 02:00:50 am

Title: Making a list of sprites
Post by: tehalynn on November 30, 2010, 02:00:50 am
What's a good method for making a list of sprites in Axe?

I tried Data(Pic1, Pic2), but it wasn't working the way I thought it would.
Title: Re: Making a list of sprites
Post by: tehalynn on November 30, 2010, 02:05:07 am
I guess I could store put all the sprites into one block of memory, then do Pic1+8, Pic1+16, etc.

I'm still would like to hear what other people have to say though.
Title: Re: Making a list of sprites
Post by: AngelFish on November 30, 2010, 02:05:50 am
Double posting isn't well looked upon on these forums. You should edit your post.

By the way, the Data( command takes numbers as arguments and the value has to be stored to the variable.

For example, an easy way to use the Bitmap command is to do:
:Data(Columns,Rows)->Pic1
:[0123456789ABCDEF]
:Bitmap(X,Y,Pic1)
Title: Re: Making a list of sprites
Post by: tehalynn on November 30, 2010, 02:07:39 am
Double posting isn't well looked upon on these forums. You should edit your post.

My apologies. Will do in the future.

What I tried was:
Code: [Select]
[FFFF000000000000]->Pic1
[FFFFFFFFFFFFFFFF]->Pic2
Data(Pic1,Pic2)->GDB1
Pt-On(0, 0, {GDB1})
Pt-On(10, 0, {GDB1+1})
But {GDB1} and {GDB1+1} didn't seem to be pointers to Pic1 and Pic2.
Title: Re: Making a list of sprites
Post by: shmibs on November 30, 2010, 03:08:56 am
do this instead
[FFFF000000000000FFFFFFFFFFFFFFFF->Pic1
Pt-On(0, 0, {Pic1})
Pt-On(10, 0, {Pic1+8})
Title: Re: Making a list of sprites
Post by: Runer112 on November 30, 2010, 10:34:06 am
As shmibs suggested, the most basic way to access an array of sprites is to simply put the data for the sprites all in succession and then access the sprite you want by adding an offset to the base pointer. For example:
Code: [Select]
[FFFF000000000000]→Pic1
[FFFFFFFFFFFFFFFF]
... Lots of sprites formatted like above and below
[A5229EFF667DCB00]
.Draw sprite 0
Pt-On(0,0,Pic1)
.Draw sprite 1
Pt-On(10,0,8+Pic1)
.Draw sprite 8
Pt-On(20,0,64+Pic1)
.Draw sprite N (0-indexed)
Pt-On(30,0,N*8+Pic1)

What I demonstrated above is probably the preferable method for displaying sprites from an array of sprites. However, if there's no way you can have the sprites occupy a contiguous array in memory and you require a list of pointers, you would do something like this:
Code: [Select]
.For this example, you have sprites at Pic1, L₁, and 64+L₁
[FFFF000000000000]→Pic1
Data(Pic1ʳ,L1ʳ,64+L1ʳ)→GDB1
.Draw sprite 0
Pt-On(0,0,{GDB1}ʳ)
.Draw sprite 1
Pt-On(10,0,{2+GDB1}ʳ)
.Draw sprite N (0-indexed)
Pt-On(20,0,{N*2+GDB1}ʳ)
Title: Re: Making a list of sprites
Post by: Deep Toaster on November 30, 2010, 11:13:25 am
Double posting isn't well looked upon on these forums. You should edit your post.

My apologies. Will do in the future.

What I tried was:
Code: [Select]
[FFFF000000000000]->Pic1
[FFFFFFFFFFFFFFFF]->Pic2
Data(Pic1,Pic2)->GDB1
Pt-On(0, 0, {GDB1})
Pt-On(10, 0, {GDB1+1})
But {GDB1} and {GDB1+1} didn't seem to be pointers to Pic1 and Pic2.

That's because pointers are two-byte numbers. Use Data(Pic1r,Pic2r) instead of Data(Pic1,Pic2) and it should work. Remember to count in multiples of two when you're accessing it, though, since they're now stored two bytes each sprite.
Title: Re: Making a list of sprites
Post by: calc84maniac on November 30, 2010, 12:36:57 pm
Double posting isn't well looked upon on these forums. You should edit your post.

My apologies. Will do in the future.

What I tried was:
Code: [Select]
[FFFF000000000000]->Pic1
[FFFFFFFFFFFFFFFF]->Pic2
Data(Pic1,Pic2)->GDB1
Pt-On(0, 0, {GDB1})
Pt-On(10, 0, {GDB1+1})
But {GDB1} and {GDB1+1} didn't seem to be pointers to Pic1 and Pic2.

That's because pointers are two-byte numbers. Use Data(Pic1r,Pic2r) instead of Data(Pic1,Pic2) and it should work. Remember to count in multiples of two when you're accessing it, though, since they're now stored two bytes each sprite.
You'll also have to read the bytes using the r symbol, by the way. {GDB1}r and {GDB1+2}r
Title: Re: Making a list of sprites
Post by: tehalynn on November 30, 2010, 01:41:25 pm
Thanks everyone, that was very helpful.

I think I should be able to get the sprites in contiguous memory. I like this method, because it makes it easy to see where sprites begin and end in the code.
Code: [Select]
[FFFF000000000000]→Pic1
[FFFFFFFFFFFFFFFF]

It's good to also know the method for non-continiguous sprites too.
Title: Re: Making a list of sprites
Post by: Munchor on December 04, 2010, 08:49:31 am
Thanks everyone, that was very helpful.

I think I should be able to get the sprites in contiguous memory. I like this method, because it makes it easy to see where sprites begin and end in the code.
Code: [Select]
[FFFF000000000000]→Pic1
[FFFFFFFFFFFFFFFF]

It's good to also know the method for non-continiguous sprites too.

That code can be optimized, right?

Code: [Select]
[FFFF000000000000→Pic1
[FFFFFFFFFFFFFFFF]

Not sure if it works in listed sprites, though
Title: Re: Making a list of sprites
Post by: JosJuice on December 04, 2010, 09:42:20 am
Closing a bracket in Axe does not save any space. It just makes the parser become confused.
Title: Re: Making a list of sprites
Post by: Deep Toaster on December 04, 2010, 11:51:17 am
Thanks everyone, that was very helpful.

I think I should be able to get the sprites in contiguous memory. I like this method, because it makes it easy to see where sprites begin and end in the code.
Code: [Select]
[FFFF000000000000]→Pic1
[FFFFFFFFFFFFFFFF]

It's good to also know the method for non-continiguous sprites too.

That code can be optimized, right?

Code: [Select]
[FFFF000000000000→Pic1
[FFFFFFFFFFFFFFFF]

Not sure if it works in listed sprites, though


Always close parenthese, quotes, and brackets in Axe unless you know what you're doing. It's not like in BASIC, where taking off the closing bracket saves space. And also unlike in BASIC, parentheses, braces, and brackets don't get closed at a store symbol. For example,

Code: (TI-BASIC) [Select]
:3*(1+2→A

in BASIC stores 3*(1+2) to A (so A is 9), whereas

Code: (Axe) [Select]
:3*(1+2→A

in Axe stores 1+2 to A, then multiplies it by 3 (so A is 3).
Title: Re: Making a list of sprites
Post by: DJ Omnimaga on December 04, 2010, 06:29:44 pm
Can't you use the following instead?

[FFFF000000000000FFFFFFFFFFFFFFFF]->Str1 With extremely large amount of sprites it might be easier to read without all those brackets, although it's a bit risky since you can accidentally press CLEAR and delete everything at once.

Also even in BASIC there's one place where not closing parenthesizes can cause some issues, although it's minor (a slow down).