Mike Harris Posted June 26, 2019 Share Posted June 26, 2019 (edited) So now that I have an animated bat running around. The wings flap so fast as they are a blur but if I put in a resting routine it slows down the whole game. Anyone else figure this one out with sprite animation within a game? I am reminded of Montezuma's revenge with rolling skulls and what not but is there a way to animate sprites in Z80 like after a scan line? All input is welcome. Like I've said from the beginning, this game is my learning curve. Edited June 26, 2019 by Mike Harris Quote Link to comment Share on other sites More sharing options...
Ikrananka Posted June 26, 2019 Share Posted June 26, 2019 Not sure if this will help, but..... https://www.youtube.com/watch?v=0b9Cj7UuAiQ 1 Quote Link to comment Share on other sites More sharing options...
Mike Harris Posted June 26, 2019 Author Share Posted June 26, 2019 Thanks. I've followed Tony's entire series. He's the one who got me started. Helped me out of a few jams but unfortunately my thirst for knowledge has outgrown what his series has to offer. What I really would like is Coleco Z80 source code. I can find games for all kinds of z80 based systems but not a whole lot for Colecovision so it's a crawl but I have found that if I work really hard at it then I really retain that knowledge. Take a break and rethink it, sit on the toilet and have a breakthrough. I started last year around Thanksgiving then stopped the project for about a month and when I started up again double my code because I took a break. Quote Link to comment Share on other sites More sharing options...
Tursi Posted June 27, 2019 Share Posted June 27, 2019 I'm not going to give you source code, but just a pointer for how I do it. Add a frame count variable that you increment once every frame. Then you can tie your animation to this frame counter. For instance, if you have two animation frames, it's straightforward to change frames every frame, every 2 frames, every 4 frames, etc, by just masking out one bit of the frame counter. In C you'd do this: animframe = (frame_counter>>2) & 0x01; (In assembly, two right shifts and an AND). The shifting specifies the resolution you want. By shifting twice, you divide the frame count by 4 (and so, at 60fps, it animates at 15fps). The AND gives you the number of frames. A mask of '1' gives you two frames (0 and 1). A mask of '3' gives you 4 frames (0,1,2,3). You are limited to powers of two when you use shift-and-mask, but it's very fast compared to dividing or comparing. Another thing you can do is maintain two variables for each animated object - one tracks the current frame, and one counts down until the next frame (when it reaches zero, increment your current frame and reset the counter). But due to the extra cost of additional variables and additional compares, I prefer to just mask off a generic frame counter. 1 Quote Link to comment Share on other sites More sharing options...
Tony Cruise Posted July 6, 2019 Share Posted July 6, 2019 On 6/27/2019 at 8:05 AM, Mike Harris said: Thanks. I've followed Tony's entire series. He's the one who got me started. Helped me out of a few jams but unfortunately my thirst for knowledge has outgrown what his series has to offer. What I really would like is Coleco Z80 source code. I can find games for all kinds of z80 based systems but not a whole lot for Colecovision so it's a crawl but I have found that if I work really hard at it then I really retain that knowledge. Take a break and rethink it, sit on the toilet and have a breakthrough. I started last year around Thanksgiving then stopped the project for about a month and when I started up again double my code because I took a break. My series actually covers exactly what you are asking for i.e. the concept of shared timers, the example code uses the timer code built into the Coleco BIOS. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.