home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / mac / programm / 19687 < prev    next >
Encoding:
Internet Message Format  |  1992-12-11  |  2.3 KB

  1. Path: sparky!uunet!caen!zaphod.mps.ohio-state.edu!not-for-mail
  2. From: gregt@function.mps.ohio-state.edu (Gregory M Ferrar)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Using VBL for animation
  5. Date: 11 Dec 1992 17:17:18 -0500
  6. Organization: Department of Mathematics, The Ohio State University
  7. Lines: 54
  8. Message-ID: <1gb41eINNqe4@function.mps.ohio-state.edu>
  9. NNTP-Posting-Host: function.mps.ohio-state.edu
  10.  
  11. I'm trying to create fast, flicker-free animation.  I'm using a Quadra 700
  12. with a 16" monitor, which is my startup screen, and two 12" monitors.
  13.  
  14. I am currently installing a VBL task in the startup screen's VBL list.  This
  15. task simply sets a variable to TRUE.  The theory is that when I am ready to
  16. draw the screen, I can just set that variable to FALSE, wait for it to become
  17. TRUE, and then draw quickly.  However, when I do this, I STILL get retrace
  18. lines in the middle of my animation.
  19.  
  20. Here's the code:
  21.  
  22. -------------------------------------------------------------------------
  23.  
  24. void install_vbl_task(void)
  25. {
  26.  
  27.     short        error;
  28.     DefVideoRec    video_info;
  29.  
  30.     /* Find the slot number of the video card */
  31.     GetVideoDefault (&video_info);
  32.  
  33.     /* Install the screen refresh interrupt */
  34.     refresh_task.the_vbl_task.qType = vType;
  35.     refresh_task.the_vbl_task.vblAddr = (ProcPtr) set_refresh_flag;
  36.     refresh_task.the_vbl_task.vblCount = VBLS_BETWEEN_FRAMES;
  37.     refresh_task.the_vbl_task.vblPhase = 0; 
  38.     
  39.     /* Save the applications's A5 where the VBL task can find it */
  40.     refresh_task.application_A5 = (long) CurrentA5;
  41.  
  42.     /* Install the task */        
  43.     error = SlotVInstall((QElemPtr)&refresh_task.the_vbl_task,
  44.                 video_info.sdSlot);
  45.  
  46. }    /* install_vbl_task() */
  47.  
  48. -------------------------------------------------------------------------
  49.  
  50. The task itself simply restores A5, sets the Boolean global, resets its
  51. counter, gets the old A5 back, and quits.
  52.  
  53. Judging by the way the animation looks, the redraws are correctly SPACED but
  54. are offset from where they should be-- the vbl lines are always in the same
  55. places, indicating that animation is in fact in synch with VBL but not in
  56. phase.
  57.  
  58. The time taken to draw is extremely small-- roughly 150,000 move.l instructions
  59. on a Quadra 700.
  60.  
  61. Any suggestions?  Am I doing something stupid?  I sincerely appreciate any
  62. suggestions.
  63.  
  64.   -Greg Ferrar (gregt@function.mps.ohio-state.edu)
  65.