Jump to content
IGNORED

Graphics Timing


Recommended Posts

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 by Mike Harris
Link to comment
Share on other sites

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.
 

Link to comment
Share on other sites

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.

 

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...