Pretty simple once you realize that the video output isn't just there but is built up line by line, from left to right. If you slow down time quite a bit then you can imagine the advancing electron beam hitting the phosphor right behind were the light pen currently points at. The phototransistor sends a pulse back to the video chip (Denise) which actually knows where it's currently at and just freezes the current horizontal and vertical counters to the lightpen register. :-D