Language…
6 users online: cletus_deletus,  Donut, masl, playagmes169, sinseiga, toady - Guests: 241 - Bots: 307
Users: 64,795 (2,375 active)
Latest user: mathew

Some questions about sprite animation

Hello everybody,

I have another question regarding sprites but this time it's about animation.
I can only do an easy two-frame loop of a 16x16 sprite but I need some knowledge for a sprite I'm working on.

The things I need to know at this moment are:
-how do I make a loop that has as many frames as I want?
- how do I match action to a certain tile displayed (for example when tile $6B is displayed do this)

Some things I would like to know but are not necessary
-how do I animate 32/64 sprites (generally sprites that have a gfx loop)
-how do I make some frames move faster/slower (i could put the same tiles in the pointer to make it slower but maybe there is a fancier way?)
-how do I make a pointer go back and forth? (same thing I could just put the same tiles in reverse order But I suppose there's probably a more efficient way)

that is all, thank you and have a good day!
I suck at ASM and AMK
Originally posted by NerDose
how do I make a loop that has as many frames as I want?

Increase the counter that indicates how many times to loop (and, of course, increase the size of the graphics data tables). Though you shouldn't be looping in the first place if the sprite is only drawing one tile at a time.

Originally posted by NerDose
how do I match action to a certain tile displayed (for example when tile $6B is displayed do this)

It would be cleaner to set the action according to the animation frame instead. Many sprites use sprite table $1602,x to determine this; for instance, values 00 and 01 of $1602,x might indicate two different walking frames, while 02 might be a jumping frame. That also allows you to use the same address as an index to the data tables during the graphics routine.

Originally posted by NerDose
how do I animate 32/64 sprites (generally sprites that have a gfx loop)

Since you'd be drawing more than one tile for each frame, you would (usually) need a loop, yes, and the counter would have to be multiplied by the number of tiles in one frame if it's also being used to index the data tables. Also keep in mind that if a sprite is more than one tile wide, such as if it's 32x32 or 64x64, you usually need separate X offsets for the two directions that it can face.

Originally posted by NerDose
how do I make some frames move faster/slower (i could put the same tiles in the pointer to make it slower but maybe there is a fancier way?)

Another sprite table commonly used for graphics-related code is $1570,x. Usually, this is incremented each frame, then the code uses AND #$xx (most frequently #$07) and increments the frame number ($1602,x) when the result is 0. If the number of in-game frames in one animation frame isn't a power of 2, you can instead increment $1570,x until it reaches a certain number, then reset it to 0 and change $1602,x. For instance, if your animation frames are each only 6 in-game frames long, you can increment $1570,x until it reaches #$06, then when it does, reset it and increment $1602,x. If you want different animation frames to last different amounts of time, you could instead check a table in ROM to determine what number $1570,x has to be to get reset, using $1602,x to index that table.

Originally posted by NerDose
how do I make a pointer go back and forth? (same thing I could just put the same tiles in reverse order But I suppose there's probably a more efficient way)

I'm not sure what you're asking here.

----------------

I'm working on a hack! Check it out here. Progress: 64/95 levels.
I'm afraid i didn't format my questions properly, especially for the last one.
when I meant 2 frame loop i meant an animation, I'm now aware that it can be confused with a gfx loop, i currently know the AND method to animate, but I'm afraid that it only works for two frame animations.

The last questions was about the table and the 1602,x pointer. for now i only know how to jump between two values of a table but i don't know how to increase the pointer and store 0 when it reaches a certain number or to decrease until it hits 0 sort of like a back and forth animation.
I suck at ASM and AMK
Code like that might look something like this:
Code
INC $1570,x
LDA $1570,x
CMP #$08
BCC .NoNextFrame
STZ $1570,x
INC $1602,x
LDA $1602,x
CMP #$03
BCC .NoNextFrame
STZ $1602,x
.NoNextFrame


----------------

I'm working on a hack! Check it out here. Progress: 64/95 levels.
Originally posted by imamelia
Code like that might look something like this:
Code
INC $1570,x
LDA $1570,x
CMP #$08
BCC .NoNextFrame
STZ $1570,x
INC $1602,x
LDA $1602,x
CMP #$03
BCC .NoNextFrame
STZ $1602,x
.NoNextFrame


I can not thank you enough, I didn't even thought about using $1570 and instead used $14, I'm so dumb. My sprite animation finally works
I suck at ASM and AMK