home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / mac / programm / 19706 < prev    next >
Encoding:
Text File  |  1992-12-11  |  2.5 KB  |  51 lines

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