home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!wupost!gumby!kzoo!k044477
- From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
- Subject: Re: Using VBL for animation
- Message-ID: <1992Dec12.023632.20351@hobbes.kzoo.edu>
- Organization: Kalamazoo College
- References: <1gb41eINNqe4@function.mps.ohio-state.edu>
- Date: Sat, 12 Dec 1992 02:36:32 GMT
- Lines: 40
-
- gregt@function.mps.ohio-state.edu (Gregory M Ferrar) writes:
- >I'm trying to create fast, flicker-free animation. I'm using a Quadra 700
- >with a 16" monitor, which is my startup screen, and two 12" monitors.
- >
- >The task itself simply restores A5, sets the Boolean global, resets its
- >counter, gets the old A5 back, and quits.
- >
- >Judging by the way the animation looks, the redraws are correctly SPACED but
- >are offset from where they should be-- the vbl lines are always in the same
- >places, indicating that animation is in fact in synch with VBL but not in
- >phase.
- >
- >The time taken to draw is extremely small-- roughly 150,000 move.l instructions
- >on a Quadra 700.
-
- Well, lessee. 150,000 instructions, let's assume about five cycles each.
- (You're going to RAM each time, that's your bottleneck, and the Quadra
- uses, what, 70 ns RAM? OK, that's 7 Mhz max, which means the absolute
- best you can do is just under four cycles each. No data cache hitting
- here, I presume.) 150,000 instructions times 5 cycles divided by
- 25,000,000 cycles per second is 3/100 seconds. Your monitor probably
- refreshes every 1.5/100 seconds or so. So I'd expect that you'll have to
- take two "ticks," more or less, to draw this.
-
- The good news is, you _can_ do a two-tick refresh without tearing if you
- work at it a little. The trick is to start your refresh just _behind_,
- not ahead, of the electron beam--that way, you run along as fast as you
- can right behind it, and by the time it finishes, starts again, and
- finishes again, you're done too.
-
- Trouble is, there's no sure-fire way to know exactly where the electron
- beam is. (Even the Apple II had a way to do this, sigh.) You have to
- wait for the VBL task to fire, then wait as long as you think it'll take
- for the beam to get around to the top of the screen again and start
- down, minus the time that the VBL tasks (yours included) take. As far
- as I know, it really is just a guessing game; tweak it until it works.
- --
- Jamie McCarthy Internet: k044477@kzoo.edu AppleLink: j.mccarthy
- "This sounds like a semantico-psychological backwardization of the
- real world image." - Dave Bloom (bloomda@ctrvax.vanderbilt.edu)
-