czxspectrum

How can you find the electron gun/scanline position?


How can I find the position of the electron gun (i.e. actively changing pixel/scanline) on the ZX Spectrum?

Different Spectrum models have slightly different timings.

If this is not possible, is there a way of waiting for some form of vertical sync event? (i.e. at the top of the bottom of the screen.)


Solution

  • There is a 3 byte frame counter at address 23672.

    23672 FRAMES 
    3 byte (least significant first), frame counter. Incremented every 20ms.
    

    I'm making the assumption that this is incremented by the 50Hz interrupt. So I'll just poll it in a loop until the least significant byte changes.