Commodore‎ > ‎C128‎ > ‎

VDC Interlace

The 8563 VDC (works for both NTSC or PAL, with proper programming), produces an RGBI video output (that requires a special video monitor).  This video is normaly 25 rows of 80 column text.  The Commodore 128 (C128) also has circuitry connected to the VDC to produce monochrome video output; this can be connected to the Composite input of common video display devices (but it lacks color; see RGBI to S-Video for a color solution).
 
The vertical resolution of 25 rows (200 rasters) can be doubled, automatically, by the hardware of the VDC.  (This is superior to the software-based interlace mode of the VIC-IIe.)  Actually, the VDC offers two interlace modes: double scan, and real interlace.  This page is about VDC real interlace mode which offers (at least) 50 rows of text (400 rasters).
 
Unfortunately, the internal design of the chip has never been revealed, to my knowledge.  The programming of the chip, documented in the Commodore 128 Programmer's Reference Guide (C128PRG), does not adequately describe how interlace mode works with the VDC.
 
There have been various methods of achieving real interlace mode with the VDC.  For example, a notorious text editor for the C128, called ZED, achieves interlace mode by increasing the "Horizontal Total" and the "Character Total Vertical" registers of the VDC (among other register changes).  An article in an issue of Commodore Hacking also mentions the same method.  From a reading of the C128PRG (or the article), it is not apparent how or why this works!
 
After building my RGBI to S-Video converter, I was curious if VDC real interlace mode would work with my device.  At the time, I was unaware of ZED and the Commodore Hacking article.  So naturally I used the documentation of the C128PRG.  The result was quite bizarre!  In fact, I thought my VDC chip was defective and started a new thread on the C128 Alive! Forums

  Screen shots of VDC Real Interlace Mode  
 
NOTE:  The following screen shots show "garbage" in the bottom of the screen.  This is not a problem with the VDC, but simply due to the fact that the C128 Editor only works with a total of 25 rows and so the extra 25 rows added by real interlace mode can not be controlled by the C128 Editor.  Of course you could write a program to work with all 50 rows (like ZED), but for my experiments I left the "garbage" intact.
 
According to the C128PRG, I needed to double registers 4 (Vertical Total), 6 (Vertical Displayed), 7 (Vertical Sync Position), and also change register 8 (Interlace Mode).  Doing so produces bizarre results!  To make the bizarre artifacts more visible for you, I used Reverse Video mode (on the C128, press [ESC] then [R]) in the following screen shot:

A screen shot of VDC real interlace mode (in reverse video mode) using DRAM Refresh default (5).

As expected, the bottom half contains garbage.  Unexpected is the the 8 corrupt characters on the right side of the screen (6 in reverse video, and 2 with an "overbar"), and the shifting of characters accross the screen!
 
After much research and experimentation, I've concluded the problem is due to the VDC not having enough time to read the text characters from RAM before trying to draw them on the screen.  The ZED program (as explained in Commodore Hacking article), increases register 0 (Horizontal Total) from the default of 126 to 128.  My theory is, this works because it increases the amount of time the VDC has to access RAM.
 
However, this compromises the NTSC standards.  With the default value, the horizontal (raster) rate is 15748 Hz (very close to the standard 15.75 kHz).  By changing register 0, ZED has changed the raster rate to 15.5 kHz.  Some video displays may except this, others may not.
 
I learned about ZED on the forums and eventually discovered the Commodore Hacking article on my own.  However, I wanted to produce a video display that conforms to NTSC standards (as close as possible).  In other words, I didn't want to change the Horizontal Total.  After all, the horizontal display should have nothing to do with vertical resolution (real interlace mode doubles the vertical resolution and does nothing to horizontal resolution).
 
There is a register in the VDC that controls the number of DRAM refreshes per scan line.  For those unfamiliar with DRAM, lets just say this is what keeps video memory from vanishing.  This is set by register 36 (DRAM refresh rate).  The default value is 5.  It has been reported that lower values -- as low as 0 -- will work without video memory "vanishing" (becoming corrupt).
 
So I thought, if the VDC spends less time refreshing DRAM each raster, it should have more time to fetch text characters from RAM, and thus solve the bizarre real interlace problem.  Using the "correct" NTSC value of 126 for register 0 (Horizontal Total), I tried using a smaller value for register 36 (DRAM refresh rate) of 4 (instead of 5).  The result was not perfect, but much better as I think you will agree from the screen shot:

A screen shot of VDC real interlace mode (in reverse video mode) using DRAM Refresh value 4.

Note in the screen shot that only the last two characters are corrupt.  More importantly, the characters are not shifted accross the screen!
 
So if DRAM refresh of 4 is better than default of 5, then what about using value of 3?  This results in a perfect display!  See for yourself (reverse video):

A screen shot of VDC real interlace mode (in reverse video mode) using DRAM Refresh value 3.

Of course the VDC is not usually in Reverse Video mode.  So here is another screen shot using DRAM refresh of 3, but in normal (not reverse) video mode:

A screen shot of VDC real interlace mode using DRAM Refresh value 3.


  Conclusion  
Besides fixing the issue of Horizontal Total (not changing it but instead changing DRAM refresh rate), there is also an issue with the number of vertical rasters.  ZED works by changing register 9 (Character Total Vertical) from default of 7 to a value of 8 (char height changes from 8 rasters to 9 rasters), and by changing register 4 (Vertical Total) to a value of 56.  This results in 57 rows of 9 rasters or a sub-total of 513 rasters.  ZED also changes register 5 (Vertical Total Adjust) from default of 0 to a value of 6.  This results in a grand total of 513 + 6 = 519 rasters.
 
But the NTSC specifications are for 525 rasters!  In all of the above screen shots, I tried to conform to NTSC specs.  I did this by not changing Horizontal Total (as described above).  I also did this by setting register 4 (Vertical Total) to a value of 64 (65 rows) and keeping register 9 (Character Total Vertical) at the default of 7 (char height 8 rasters).  This results in a 65 rows of 8 rasters or a sub-total of 520 rasters.  Since NTSC specifies 525 rasters, I set register 5 (Vertical Total Adjust) to a value of 5.  This results in a grand total of 525 rasters (at the proper frequency of 15.75kHz).  Perfect!
 
The magic code to enable VDC Real Interlace Mode (for NTSC video) is:
 
W=DEC("CDCC"):BANK15
SYSW,64,4: SYSW,5,5: SYS W,50,6: SYS W,56,7: SYS W,3,8: SYS W,3,36
 
Finally, but importantly, I wish to thank Robert Bernardo for taking the time to test my various VDC programming ideas on his NTSC Commodore 128.  Without his feedback, I might have thought my VDC was defective.  As it turns out, the documentation is inadequate.
 
Of course, PAL Real Interlace mode on the VDC needs to be tackled next.  Since I don't have any PAL equipment, I can only hope to get some feedback from users in other countries...

  ZED screen shots  
A (bad) screen shot of ZED text editor using default (wrong NTSC) settings

Because the official release of ZED does not conform to NTSC specifications, some video display devices may not function properly. In particular, my 35-inch JVC Television does not like its non-standard video output, as you can see from the screen first screen shot. Here ZED is using 9 * 57 + 6 = 519 rasters.

Naturally I wanted to see if my television would support VDC real interlace mode (using my RGBI-to-S-Video converter) when using the correct NTSC settings. So I modified ZED (download here) to produce the correct number of rasters. In the screen shot below, ZED is using 9 * 58 + 3 = 525 rasters. Note this is the correct number of rasters for NTSC, but ZED is still using an incorrect horizontal total of 128 chars (should be 126); fortunately my television works with the wrong horizontal settings.

A (good) screen shot of ZED text editor using fixed (correct NTSC) settings
© H2Obsession, 2009, 2015
Comments