Changes

CRTC

1,667 bytes added, 3 July
/* Reading from CRTC registers on ASIC/Pre-ASIC */
<br>
== The 6845 Registers CRTC registers ==
The Internal registers of the 6845 are:
<br>
== CRTC Differences register differences == In this section I will attempt to identify all the differences between each CRTC.
The following tables list the functions that can be accessed for each type:
* See the document "Extra CPC Plus Hardware Information" for more details.
 
<br>
 
=== 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.
 
The only exception is for CRTC 1 with a value of 0, which cancels the current HSYNC.
 
<br>
 
=== VLC (C9) overflow ===
 
If Number of Scan Lines (R9) is updated with a value less than the current VLC, then:
* on CRTCs 0/1/2, VLC overflows and will count up to its maximum value (31) before looping back
* on CRTCs 3/4, the current line is considered the last one of this CRTC character and VLC changes to 0 on the next line
 
<br>
 
=== VTAC overflow ===
 
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
* on CRTCs 3/4, the current line is considered the last one of the current frame and vertical adjustment ends
 
<br>
 
=== VCC (C4) overflow ===
 
On all CRTCs, during the vertical display period (ie. when VCC <= R4), if Vertical Total (R4) is updated with a value less than VCC:
* 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
* if this update was done when VCC = R4, the decision was already made to switch to vertical adjust mode and no update to R4 will make the CRTC change its mind for the current frame
 
The only exception is for CRTC 1 with a value of 0 when VCC = R4, which will cause the VCC to overflow.
<br>
* In interlace sync and video mode, alternating lines are displayed in the even and odd field to double the resolution. In this mode, it is necessary to reprogram the CRTC as if we were building a frame of 624 lines. The 625th line is managed automatically by the CRTC
[[File:CRTC Interlace modes.png]]
 
<br>
 
=== Vertical Displayed (R6) ===
 
On CRTCs 0/1/2, the condition VCC=R6 is considered immediately to activate the VBORDER. The only exception is for CRTC 1 with a value of 0, which triggers an immediate BORDER without the condition VCC=R6 being required.
 
On CRTCs 3/4, the condition VCC=R6 is tested only at new character line start. The update of R6 during the character line is therefore not considered.
<br>
R31 doesn't exist on types 0,2,3,4.
 
<br>
 
=== R12/R13 on Type 1 ===
 
The UM6845R differs to other CRTC in respect of R12/R13.
 
When VCC=0, R12/R13 is re-read at the start of each line. R12/R13 can therefore be changed for each scanline when VCC=0.
 
Just like other CRTCs when RC==(R9-1), the current MA is captured for the next char-line.
 
In demos to make a display compatible with all CRTCs, program R12/R13 when VCC!=0. This will then take effect at the next frame start.
<br>
=== Reading from CRTC registers on ASIC/Pre-ASIC ===
On CRTC Types CRTCs 3 and /4, only the 3 least significant bits of the selected register number are considered to read a register according to the following table:
{|{{Prettytable|width: 700px; font-size: 2em;}}
== Internal Counters ==
 
{| class="wikitable sortable"
! Counter name
No matter its type, the CRTC never buffers its counters.
The only value that is saved in a buffer in the CRTC is the video pointer MA because it is reloaded at each raster line start.  R12/R13 is loaded only once per frame, in MA and MA', at the first raster line start of the frame. The counter MA is then reloaded with the value of MA' at each raster line start. And at each new character line start, MA' captures the current value of MA. The exception is the CRTC 1 for which the MA is reloaded at each raster line start with R12/R13 instead of MA' as long as VCC=0. This is a major source of incompatibility if the programmer does not take care of this discrepancy. In demos and games, to make a display compatible with all CRTCs, program R12/R13 when VCC!=0. This will then take effect at the next frame start. <br> == CRTC counter differences == === 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. <br> === 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. <br> === VCC (C4) overflow === 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 The only exception when VCC = R4 is for CRTC 1 with a value of 0, which will cause VCC to overflow. <br> === HCC (C0) overflow === If Horizontal Total (R0) is changed with a value less than the current HCC, then:* on CRTCs 0/1/2, HCC overflows and will count up to its maximum value (255) before looping back and counting up again until it reaches the new value of R0* on CRTCs 3/4, the current line is considered finished and HCC is immediately reset to 0 on the next line <br> === VLC (C9) overflow === If Number of Scan Lines (R9) is changed with a value less than the current VLC, then:* on CRTCs 0/1/2, VLC overflows and will count up to its maximum value (31) before looping back and counting up again until it reaches the new value of R9* on CRTCs 3/4, the current line is considered the last one of this CRTC character and VLC will reset to 0 on the next line <br> === VTAC (C5/C9) overflow === 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 <br> === Vertical Adjustment mode === On CRTCs 0/1/2, this mode increments VCC and so VCC goes beyond R4. On CRTCs 3/4, this mode does not increment VCC and so VCC stays equal to R4.
<br>
7,944
edits