Alternatively, the current line can be read from VIC register at $D012 and $D011 (9th bit).
So, if a timer counting every clock cycle is once synchronized to the beginning of rasterline 0, then the timer value t tells us the number of the current line with INT(t/63) and (t MOD 63)*8 yields the X coordinate. On a C64 PAL model, the VIC chip processes through 312 lines where each lines takes 63 clock cycles to display (including some time for horizontal and vertical blanking for returning the raster beam).