Author Topic: Making a list of sprites  (Read 4890 times)

0 Members and 1 Guest are viewing this topic.

Offline tehalynn

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 12
  • Rating: +0/-0
    • View Profile
Making a list of sprites
« 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.

Offline tehalynn

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 12
  • Rating: +0/-0
    • View Profile
Re: Making a list of sprites
« Reply #1 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.
« Last Edit: November 30, 2010, 02:07:19 am by tehalynn »

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Making a list of sprites
« Reply #2 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)
« Last Edit: November 30, 2010, 02:08:09 am by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline tehalynn

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 12
  • Rating: +0/-0
    • View Profile
Re: Making a list of sprites
« Reply #3 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.
« Last Edit: November 30, 2010, 02:17:13 am by tehalynn »

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Making a list of sprites
« Reply #4 on: November 30, 2010, 03:08:56 am »
do this instead
[FFFF000000000000FFFFFFFFFFFFFFFF->Pic1
Pt-On(0, 0, {Pic1})
Pt-On(10, 0, {Pic1+8})

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Making a list of sprites
« Reply #5 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}ʳ)
« Last Edit: November 30, 2010, 10:36:29 am by Runer112 »

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Making a list of sprites
« Reply #6 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.




Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Making a list of sprites
« Reply #7 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
« Last Edit: November 30, 2010, 12:37:08 pm by calc84maniac »
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline tehalynn

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 12
  • Rating: +0/-0
    • View Profile
Re: Making a list of sprites
« Reply #8 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.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Making a list of sprites
« Reply #9 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

Offline JosJuice

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1344
  • Rating: +66/-14
    • View Profile
Re: Making a list of sprites
« Reply #10 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.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Making a list of sprites
« Reply #11 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).




Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Making a list of sprites
« Reply #12 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).
« Last Edit: December 04, 2010, 06:30:42 pm by DJ Omnimaga »