It is currently Sun Oct 22, 2017 6:00 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Sep 19, 2016 2:55 pm 
Offline
User avatar

Joined: Wed Aug 03, 2005 3:15 pm
Posts: 393
Just thought I'd share my revised animation engine with everyone. This is a pretty basic version of it. It is only configured for a single entity right now, but is easily configurable.

Here is a link to the pastebin of it: http://pastebin.com/yKxcqJ4H

The idea is pretty simple. Every frame in your loop you jsr to p_anim. You use p_anim_state as the offset into the tables of p_anim_start_lo and p_anim_start_hi. Then you set bit 7 of p_anim_state so that it will no longer go through the initialization process. It jumps to load the bytes from the animation frame you set, returns, and decrements p_anim_count, which is how many frames that the animation will last. Since it is initialized already and bit 7 is set, it will skip the init and process what is in p_anim_addy. Once p_anim_count reaches zero, the code in p_anim_load (which I tend to keep its sections unrolled) will make sure to grab the name of the next frame and also how many frames it will last.

Currently, this has the offset for each sprite to add from your base sprites position during each frame so that they tie together. Doing it this way allows more flexibility with the sprites and how they're arranged, rather than just being together all the time. It also helps if you need to have some flipped sprites that might not line up properly if you just tied the sprites together into a constant block. But of course this is configurable, so you could get rid of those bytes in the frames if you wanted to and do the norm (where 'sprites' is the beginning of your player):

Code:
p_tie_sprites:
   lda sprites+0
   sta sprites+4
   clc
   adc #$10
   sta sprites+8
   sta sprites+12
   lda sprites+3
   sta sprites+11
   clc
   adc #$08
   sta sprites+7
   sta sprites+15
   rts


Anyway, like I said it can be configured in different ways. I haven't expanded it yet to include other objects to animate yet, but shouldn't be too difficult for anyone else to expand it if they need to.

Note that you can put some of the things in the load subroutine in a better order to loop them if you want, change the order of the frame data too, to make looping even more simple.

Anyone may use this how they wish if they like it, hence sharing it haha


Top
 Profile  
 
PostPosted: Sun Sep 25, 2016 3:32 pm 
Offline
User avatar

Joined: Wed Sep 21, 2016 8:55 am
Posts: 54
Location: Calgary.Alberta,Canada
Mine is quite simple also,thanks for sharing as it's always fun looking at other ways.


http://pastebin.com/Qpe4g4Vi


Last edited by OmegaMax on Mon Oct 03, 2016 9:38 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Fri Sep 30, 2016 6:46 pm 
Offline
User avatar

Joined: Wed Aug 03, 2005 3:15 pm
Posts: 393
OmegaMax wrote:
Mine is quite simple also,thanks for sharing as it's always fun looking at other ways.


http://pastebin.com/snJxi7qb


Right on, I agree!

I like the way you put how many sprites there are in the lower and upper nybble of that first byte. Sometimes I find other code to be difficult to read, but yours seems fairly straight forward. Thanks for sharing as well!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Bing [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group