[comp.sys.mac] Synchronize Image Display With Monitor's Video Scanning

jinli@gpu.utcs.utoronto.ca (Jin Tonic Li) (08/27/89)

I am programming in Turbo Pascal on a Mac IIx to display rectangular grey scale
patterns(256 levels) on the screen.  I used the off screen bit map technique in
an attempt to reduce flickering.  Each pattern has the same dimension and is
drawn to the same location on the screen.  Also, the critical requirement is
that each pattern is only shown on screen for X units of time and they are
repeated for Y units of time without any pauses.(usually in microseconds)

However, display of the patterns is not synchronized with the video scanning. 
The net effect is that every few microseconds, a glitch appears.  That is,
portion of the image on the screen belongs to pattern M, the rest belongs to
pattern N.  This can be easily observed by holding down the interrupt button
when the glitch appears.

In an attempt to synchronize the display with video retrace, I inserted the 
procedure that does CoypBits into VBL queue using vblInstall with vblCount = 0.
I hoped that each pattern would be shown on the screen at the same video scan
position.(ie. right after the vertical retrace) Unfortunately, the glitch is
still there.  So, I experimented with the following options:

   - insert the procedure as the first event in vbl queue;
   - set the vblCount of queue events 4-6 to zero(ie. dequeue them);
   - set the vblCount of queue events 4-6 to one(ie. execute all queue events
     on every vbl interrupt to synchronize delays);
   - leave only queue event 1(update tickCount) and the procedure in the queue;

To no avail, all of the above failed to get rid of the glitch.  In fact, in a
couple of the cases, the glitch appeared more frequently than before.

As the last try, I disabled all system events in the vbl queue but only have
the procedure in the queue.  However, I have to reboot the system to get out of
the execution and the image just flashes.

I am wondering if anyone has tried to accomplish this before.  What is the 
solution if exists?  Any suggestion as to how to solve or get around this?

If you have any programs on this, I would like to check them out. 
C, Pascal, Assembly codes are all fine with me.

Thank you in advance.

-- 
  		    Jin Li		      >>    Gin & Tonic mix well
   University of Toronto Computing Services  <<       No bugs, no bucks
jinli@gpu.utcs.utoronto.ca   uunet!utgpu!jinli>>   More greed, more green