Changes

CRTC

608 bytes added, 6 July
/* HSYNC and VSYNC */
'-------------------------------> Video Page : note (2)
note (1) note (2)
.--.--.--------------. .--.--.---------------. |11|10| Video Buffer | |13|12| Video Page | |--|--|--------------| |--|--|---------------| | 0| 0| 16Ko | | 0| 0| 0000 - 3FFF | |--|--|--------------| |--|--|---------------| | 0| 1| 16Ko | | 0| 1| 4000 - 7FFF | |--|--|--------------| |--|--|---------------| | 1| 0| 16Ko | | 1| 0| 8000 - BFFF | |--|--|--------------| |--|--|---------------| | 1| 1| 32Ko | | 1| 1| C000 - FFFF | '--'--'--------------' '--'--'---------------'
<br>
The DISPTMG signal is composited from its 3 internal subcomponents: HBORDER (Horizontal), VBORDER (Vertical), IBORDER (Immediate) by using the NOR function.
 
=== Immediate border ===
DISPTMG can be immediately forced to 0 by using R8 (DISPTMG Skew) on CRTCs 0/3/4 or by setting R6=0 on CRTC 1. It is not possible to force DISPTMG on CRTC 2.
== HSYNC and VSYNC ==
On CPC, HSYNC and VSYNC from Bit0 of port B of the CRTC are passed PPI is directly connected to the [[Gate Array]] for further modification. See its wiki pageVSYNC pin of the CRTC.
The HSYNC width value is interpreted differently between CRTCs. On CRTCs 0/1, if 0 is programmed no HSYNC is generated. On CRTCs 2/3/4, if 0 is programmed this gives a HSYNC width of 16.
CRTCs 1/2 have a fixed VSYNC width value of 16. VSYNC width can be configured with Register 3 R3 on CRTCs 0/3/4. If 0 is programmed this gives 16 lines of VSYNC. On CRTCs 0/1/2, the sole condition to trigger a VSYNC is that VCC=R7. While on CRTCs 3/4, it is necessary to have VCC=R7 and HCC=0 and VLC=0 to trigger a VSYNC. On all CRTCs, the comparison between VCC and R7 is disabled during a VSYNC. So, even if R7 is changed, a new VSYNC cannot be triggered during a VSYNC. The HSYNC and VSYNC signals from the CRTC are passed to the [[Gate Array]] for further modification. See its wiki page. === Ghost VSYNC ===
On CRTC 2, if a VSYNC is triggered during an HSYNC, the CRTC produces a ghost VSYNC. The bit 0 of port B of CRTC then counts the PPI changes to 1 lines as soon as the if a VSYNC signal is produced were taking place by preventing a new VSYNC from occurring, but without the CRTCVSYNC pin being enabled.
<br>
|}
No matter its type, the CRTC never buffers any of its counters, except for the video pointer MA. A buffer MA' is needed because MA has to be reloaded at each the beginning of every raster line start.
<br>
=== MA reload ===
On CRTCs 0/3/4, at the beginning of the first raster line start of the frame, MA and MA' are loaded with R12/R13. Otherwise, MA is loaded with MA'.
On CRTC 2, at any the beginning of every raster line start of the frame (including the first one), MA is loaded with MA'.
On CRTC 1, at the beginning of every raster line start of the first character line of the frame (ie. when VCC=0), MA is loaded with R12/R13 instead of MA'. This discrepancy is a major source of incompatibility if the programmer does not take care. In demos and games, to be compatible with all CRTCs, program R12/R13 when VCC!=0. This will then take effect at the next frame start.
<br>
At the end of the display of the last raster line of each character line (ie. when HCC=R1 and VLC=R9), MA' captures the current value of MA.
CRTC 2 is the exception: at the end of the display of the last raster line of the frame, where MA' captures R12/R13 instead of MA at the last line of the frame.
<br>
=== VSC (C3h) overflow ===
During a VSYNC on CRTCs 0/3/4, if VSYNC Width (R3h) is changed with a value less than the current VSC, then VSC overflows and will continue to count up to its maximum value (15) before looping back and counting up again until it reaches the new value of R3h.
On CRTCs 1/2, the VSYNC width is fixed to 16 characters. It is not possible to modify it. Therefore, VSC cannot be overflowed.
=== HSC (C3l) overflow ===
During an HSYNC, if HSYNC Width (R3l) is changed with a value less than the current HSC, then HSC overflows and will continue to count up to its maximum value (15) before looping back and counting up again until it reaches the new value of R3l.
The only exception is for CRTC 1 with a value of 0, which immediately cancels the current HSYNC.
On all CRTCs, if Vertical Total (R4) is changed with a value less than VCC, then:
* if this update was done when VCC < R4, then VCC overflows and will continue to count up to its maximum value (127) before looping back and counting up again until it reaches the new value of R4
* if this update was done when VCC = R4, the current character line was already decided to be the last one of the current frame. No update to R4 will make the CRTC change its mind for the current frame
During vertical adjustment mode, if Vertical Total Adjust (R5) is changed with a value less than the current VTAC, then:
* on CRTCs 0/1/2, VTAC overflows and will continue to count up to its maximum value (31) before looping back and counting up again until it reaches the new value of R5
* on CRTCs 3/4, the current line is considered the last one of the current frame and vertical adjustment will end
6,172
edits