Node 517
This node generates horizontal sync signal. It also passes clock signal to node 617.
Source code

ticks 00 n for @ ! unext ;
-ticks 02 n for @ - ! unext ;
sync 05 5 ticks !b 30 ticks !b 18 ticks ;
blanks 0D n for sync 199 ticks next ;
lines 13 n for sync 199 -ticks next ;
go 19 44 blanks 479 lines go ; 1E
init io b! 1C5 r--u a! 20000 30000 over over
over over over over over over !b go ; 28
4 d 9 r 2 u ether
Definitions
- ticks
- Count n+1 clock pulses while sending pulses (zeros) to 617.
- -ticks
- Count n+1 clock pulses while sending inverted pulses (-1) to 617.
- sync
- Generate back porch for 6 clock ticks, a negative horizontal sync pulse lasting 31 ticks, and front porch for 19 ticks.
- blanks
- Generate blank line starting with sync pulse and lasting 200 ticks.
- lines
- Generate image line starting with sync pulse and lasting 200 ticks.
- go
- Generate 45 blank lines and 480 image lines repeatedly.
- init
- Set registers A and B, fill stack with alternating values 20000 and 30000, set pin 517.17 high, and jump to go.
Description
Generation of HSYNC signal is based on 8 Mpulses/s clock rate coming from node 516. It is received as a stream of zeros. It is passed to node 617 unchanged during horizontal and vertical blanking by word ticks, and is inverted by word ‑ticks to ‑1 during active video time. One scan line is defined as 256 clock pulses so its duration is exactly 32 µs. It is slightly longer than what corresponds to standard VGA so the frame refresh rate is ~59.5 Hz.
This node generates a negative HSYNC pulse on its GPIO pin at the beginning of each scan line, with duration of 3.88 µs, i.e. 31 clock pulses. The front porch is set to 6 clock pulses (0.75 µs), and back porch to 19 clock pulses (2.38 µs). It is possible to change slightly width of the pulse and length of both porches in order to adjust timing to a particular monitor but the total number of blanking clock pulses must be kept the same, i.e. 56 clock pulses.