That's a tricky one, but I'd say we should use the way TVs does it, that is, detect the 6 serration pulses (at double the normal HDRIVE). That should not be too tough. Just detect when PB0 "negative" time is around 500-780 cycles for 6 cycles. After that you know you're at line 7. Don't forget the sync in the first 9 lines of the frame runs at double the normal rate (909 cycles).The current code watches for a "1" going to PORTB and uses that to trigger a new scanline (ie detect calls to hsync_pulse).
Or would it be simpler to just lock the frame traversal to the timer interrupt?
Yes that's the way it works. A line count is maintained before, during and after the rendering. During the rendering the count is maintained per scanline or added in the end depending if its mode 1 or 2. But the result is naturally the same.-- looks like the timer interrupt is every ~1820 cycles, same as the scanline interval. But the main render loop runs for a lot longer than that, so I assume a bunch of timer interrupts are getting ignored every frame since it does the counting internally?
Does the interrupt handler basically count scanlines during vblank (around 29 lines from the looks of it, or 52,780 cycles) and then let the video display run after that?
Again, in the mean time we can always use the reserved port approach to get a steady picture and reference for your vsync code.
Alec