MOS Technology VIC
The Video Interface Chip (known as VIC or MOS Technology 6560/6561 for NTSC and PAL variants, respectively) is the video adapter IC for, and namesake of, the VIC-20. This chip handles the graphics and sound, interacts with light gun/pen, and converts analog paddle signals to a digital value.
It was originally designed for applications such as low cost CRT terminals, biomedical monitors, control system displays and arcade or home video game consoles.
Contents
History of development
The chip was designed by Al Charpentier in 1977 but Commodore could not find a market for the chip. In 1979 MOS Technology began work on a video chip named MOS Technology 6564 intended for the TOI computer and had also made some work on another chip, MOS 6562 intended for a color version of the Commodore PET. Both of these chips failed due to memory timing constraints (both required very fast and thus expensive SRAM, making them unsuitable for mass production). Before finally starting to use the VIC in the VIC-20, chip designer Robert Yannes fed features from the 6562 (a better sound generator) and 6564 (more colors) back to the 6560, so before beginning mass production for the VIC-20 it had been thoroughly revised.
Features
Its features include:
- 16 KB address space for screen, character and color memory (only 5 KB points to RAM on the VIC-20 without a hardware modification)
- 16 colors (the upper 8 can only be used in the global background and auxiliary colors)
- two selectable character sizes (8×8 or 8×16 bits; the pixel width is 1 bit for "hires" characters and 2 bits for "multicolor" characters)
- 4 channel sound system (3 square wave + "white" noise + global volume setting)
- two 8-bit A/D converters
- light pen support
- on-chip DMA and address generation
The maximum video resolution depends on the television system (176 × 184 is the standard for the VIC-20 firmware, although at least 224 × 256 is possible on the PAL machine)
The VIC was programmed by manipulating its 16 control registers, memory mapped to the range $9000–$900F in the VIC-20 address space. The on-chip A/D converters were used for dual paddle position readings by the VIC-20, which also used the VIC's lightpen facility. The VIC preceded the much more advanced VIC-II, used by the VIC-20's successors, the C64 and C128.
Pinout
┌────────┐ NC ─┤ ├─ VDD CHROMA ─┤ ├─ ϕ1 LUMA/SYNC ─┤ ├─ ϕ2 R/W ─┤ ├─ OPTION D11 ─┤ ├─ Pϕ2 D10 ─┤ ├─ Pϕ1 D9 ─┤ ├─ A13 D8 ─┤ ├─ A12 D7 ─┤ ├─ A11 D6 ─┤ ├─ A10 D5 ─┤ ├─ A9 D4 ─┤ ├─ A8 D3 ─┤ ├─ A7 D2 ─┤ ├─ A6 D1 ─┤ ├─ A5 D0 ─┤ ├─ A4 POTX ─┤ ├─ A3 POTY ─┤ ├─ A2 AUDIO ─┤ ├─ A1 VSS ─┤ ├─ A0 └────────┘ CHROMA/LUMA-SYNC: Analog video output R/W: Read (low) or write (high) access to registers D0-D7: System data bus D8-D11: Direct connection to Color RAM POTX/POTY: ADC input from Game controller port AUDIO: Analog audio out ϕ1/ϕ2: Two-phase clock input Pϕ1/Pϕ2: Two-phase clock output A0-A13: Address bus OPTION: Varied depending upon the model of VIC
Option pin
- 6560-001: ϕM — 2.0 MHz Clock for Clocked Memories
- 6560-101: LIGHT PEN — Negative edge triggered latch of raster position
- 6560-201: RESET — Reset Horizontal and Vertical counters to Vertical Sync
- 6560-301: BUS AVAILABLE — Pin is low when VIC is displaying data
The VIC-20 used chip model 101, with a light pen input.
Versions
- MOS Technology 6560 NTSC
- MOS Technology 6561E PAL Ceramic version, used in early VIC-20's
- MOS Technology 6561-101 PAL
Comparison of PAL and NTSC versions
Chip | 6560-101 | 6561-101 |
---|---|---|
System | NTSC-M | PAL-B |
Cycles per line | 65 | 71 |
Lines per frame | 261 | 312 |
Lines per frame interlaced | 525 | not available |
Crystal | 14318181 Hz | 4433618 Hz |
Bus clock | crystal/14 | crystal/4 |
Screen width | 210 | 233 |
Screen height | 233 | 284 |
Memory Map
The VIC has sixteen registers, located at memory addresses $9000-$900F (36864-36879). The default register values are stored in ROM at address $EDE4 to $EDF3.
Location | Bit function | Default value | Function | ||
---|---|---|---|---|---|
hex | dec | NTSC | PAL | ||
$9000 | 36864 | ABBBBBBB
|
$05 | $0C | Interlace mode / Screen origin (horizontal) |
$9001 | 36865 | CCCCCCCC
|
$19 | $26 | Screen origin (vertical) |
$9002 | 36866 | HDDDDDDD
|
$16 | Screen memory offset / Number of columns | |
$9003 | 36867 | GEEEEEEF
|
$2E | Raster value (lowest bit)/ Number of rows / Double character size | |
$9004 | 36868 | GGGGGGGG
|
variable | Raster value | |
$9005 | 36869 | HHHHIIII
|
$F0 | Screen memory location / Character memory location | |
$9006 | 36870 | JJJJJJJ1
|
$00 | Light pen position (horizontal) | |
$9007 | 36871 | KKKKKKKK
|
$00 | Light pen position (vertical) | |
$9008 | 36872 | LLLLLLLL
|
$FF | Paddle 1 | |
$9009 | 36873 | MMMMMMMM
|
$FF | Paddle 2 | |
$900A | 36874 | NRRRRRRR
|
$00 | Bass sound switch & frequency | |
$900B | 36875 | OSSSSSSS
|
$00 | Alto sound switch & frequency | |
$900C | 36876 | PTTTTTTT
|
$00 | Soprano sound switch & frequency | |
$900D | 36877 | QUUUUUUU
|
$00 | Noise switch & frequency | |
$900E | 36878 | WWWWVVVV
|
$00 | Auxiliary color / Composite sound volume | |
$900F | 36879 | XXXXYZZZ
|
$1B | Screen color / Reverse mode / Border color |
A: Interlace mode
In this mode, the VIC will draw 525 interlaced lines instead of the 261 non-interlaced lines in the normal mode. This bit has no effect on the PAL version.[1]
To turn off in BASIC:
POKE 36864, PEEK(36864) AND 127
To turn off in ML:
lda $9000 and #%01111111 sta $9000
To turn on in BASIC:
POKE 36864, PEEK(36864) OR 128
To turn on in ML:
lda $9000 ora #%10000000 sta $9000
B : Horizontal position
Moves the screen along the X axis half characters (4 hires pixels).
C : Vertical position
Moves the screen along the Y axis two dots per increment. The VIC can be tricked into single-line offsets by setting the horizontal position to 0 in the first raster line.
D: Number of columns
The number of character columns, normally set to 22. Values greater than 31 will be trimmed. 27 columns fill a NTSC screen, 30 columns fill a PAL screen. However, to keep all columns visible on any CRT you shouldn't use more than 24 columns on NTSC systems and no more than 26 columns on PAL systems. The total number of characters displayed may exceed 512 if enough internal RAM is available.
E: Number of rows
On NTSC systems the maximum number of rows is 28, on PAL it is 32. Greater values probably won't work on every CRT. The total number of characters displayed may exceed 512 if enough internal RAM is available.
F: Double character size
When set this will double the character size to 16 lines. This can be used to display bitmapped screens where every pixel can be modified.
G: Raster value
This holds the number of the line that is currently drawn to the screen. It's also used to synchronize the light pen. The single bit in register $9003/36867 is the lowest bit of the raster value.
H-I: Screen and character memory locations
- Bits 0-3: 4-bit address (see below) of character ROM. Default is 0; changes when inverse video and/or lowercase is selected
- Bits 4-7: 4-bit address of video memory. Default is 15 with $9002 set to offset (the highest 512 bytes of the internal 4k) for an unexpanded or 3k expanded VIC, or 12 with $9002 set to no-offset (the bottom 512 bytes of the internal 4k) for larger expansions.
- Bits 4-7 specify a 1k window in which the video memory resides. Bit 7 of $9002 is additionally part of this address as an "offset" bit: If this bit is cleared, the video memory will start at byte 0 of the specified 1k window. If this bit is set, the video memory instead starts at byte 512 of the 1k window. This was done to increase contiguous free memory, since the VIC-20's 22x23 character grid requires just under 512 bytes. This offset bit also affects the Color RAM address: The Color RAM is a 1k RAM chip starting at address $9400. If the offset bit is cleared, the Color RAM will start at byte 0 of this block. If the offset bit is set, the Color RAM will start at byte 512 of the block.
4-bit addresses
Byte $9005 (36869) is comprised of two 4-bit addresses for the character memory and video memory. These addresses refer to sixteen 1k blocks. Values in the range of 0-7 are addresses in the $8000-$9FFF range, and values in the range of 8-15 are in the $0000-$1FFF range:
- 0: $8000, 1k character ROM, capitals + glyphs
- 1: $8400, 1k character ROM, capitals + lowercase
- 2: $8800, 1k character ROM, inverse capitals + glyphs
- 3: $8C00, 1k character ROM, inverse capitals + lowercase
- 4: $9000, 1k VIC/VIA registers
- 5: $9400, 1k RAM used as Color RAM
- 6: $9800, 1k Expansion port
- 7: $9C00, 1k Expansion port
- 8: $0000, 1k RAM, zeropage, datasette buffer, and other various uses
- 9: $0400, 1k Expansion port
- 10: $0800, 1k Expansion port
- 11: $0C00, 1k Expansion port
- 12: $1000, 1k RAM
- 13: $1400, 1k RAM
- 14: $1800, 1k RAM
- 15: $1C00, 1k RAM
The character memory always starts at byte 0 of the selected block, while the video memory can be offset by 512 bytes by setting bit 7 of $9002. While these are the values that can be chosen via $9005, in practice, much isn't usable for a variety of reasons:
- Attempting to set the character and video locations to the same addresses, without offsetting the video memory, will result in the VIC reading the same memory to both determine which character is drawn, and what that character looks like. While the VIC succeeds in doing this, it would likely be impossible to create a readable display this way.
- Setting the video address to 0-3 will cause the VIC to read the character ROM as video memory, resulting in a random array of characters.
- Setting either value to 4 will cause the VIC to read its own registers, as well as the registers of both VIAs. Since these values don't in any way correspond to text characters, this will garble the display.
- Setting either value to 5 will cause the VIC to read the same bytes as Color RAM and whatever has been set to this address. If the character ROM is placed here, whichever half is being used for Color RAM will be read as character data, resulting in some garbled characters. However, since the characters are either 8 or 16 bytes apiece, this is still usable, it merely limits the character table to 128 or 64 usable characters. However, setting the video RAM to this location will never work, as the offset bit of $9002 always applies to both. If the character memory is at the default address, this will create the humorous effect of characters appearing as @ or the letters A-F depending upon the foreground color of that character, since @ followed by A-F are the first seven letters in the character ROM.
- Values of 6, 7, 9, 10, or 11 correspond to the expansion port. Having the VIC read from the expansion port could be a very valuable tool; aside from extra RAM, ROM chips holding character ROM could be placed on cartridges and read directly by the VIC, much like the video system of Nintendo video game consoles. Unfortunately, due to a design flaw, this isn't possible.[2] The VIC and CPU share the address and data buses, and access these on alternating clock cycles. Conflicts are avoided by using 74245 bus transceivers, which alternately disconnect the VIC or CPU from the buses. However, the physical topology of the motherboard is as follows:
6502 CPU <--> Expansion port <--> Transceiver <--> Onboard RAM/ROM <--> Transceiver <--> 6560/6561 VIC
- As a result, whenever the VIC has control of the buses, the expansion port remains connected to the CPU and isolated from the VIC. This means the data lines "float" unconnected for these address ranges whenever the VIC is active, resulting in random read values, resulting in garbled text.
- A value of 8 selects the lowest 1k of system memory, containing the zeropage and other items. It's not completely unusable– the highest 191 bytes of this range are the datasette port buffer, and seven bytes below that are unused. As a result, a very small screen or character set can be placed here. Only the highest 12 or 24 characters (depending upon regular or double-height) are thus usable if the character memory is placed here, and a screen would be limited to about 198 overall characters, a screen of 18x11 or similar. Also, since the screen memory must start no higher than byte 512, there will always be garbled text above the usable screen space, though this can be hidden by raising the top of the screen or setting the appropriate bytes in Color RAM to match the background or border colors.
Using values of 5 (color RAM) for character memory, and 8 (zeropage) for video memory, are a simple way to free up the entire system memory as a contiguous block while using modified characters. However, the limits this setup imposes requires tricky programming to overcome while writing quality software.
N-U: Sound switches and frequencies
When the sound switches are set to 1 the sound channel associated with it is turned on. The frequencies for the channels are calculated like this:
frequency = clock / (127 - value)
To get the register value for a particular frequency do:
value = 127 - (clock / frequency)
The 'clock' varies depending on the channel and on the version of the VIC you are using:
Channel | NTSC clock | PAL clock |
---|---|---|
bass | 3995 | 4329 |
alto | 7990 | 8659 |
soprano | 15980 | 17320 |
noise | 31960 | 34640 |
Internally, the square wave sound generators are realized as 8-bit linear feedback shift registers (LSFR). When they're active, one bit is shifted out, inverted, output and inserted at the other end, at the rate programmed with the low 7 bits of the frequency register. The noise generator seems to be a 13-bit LSFR.[3]
V: Master sound volume
This determines the loudness of all channels combined, ranging from 0 (off) to 15 (full volume). With high volume settings and more than one channel running clipping might occur. See DC offsets and clipping. For the smallest amount of clipping the volume should be set to a value of 8.[4]
W-Z: Color/inverse
- WWWW: Auxiliary color for Multicolor character mode
- XXXX: Background color
- Y: Inverse; swaps the specified background and individual color RAM (except for multicolor characters)
- ZZZ: Border color
Colors
Overview
The VIC produces a 16-color YPbPr composite video palette. The palette lacks any intermediate shade of gray, and it has only four levels of luminance above the zero (black).[5]
Color codes
These values may be used in the appropriate registers and also stored in color RAM. Colors 8-15 may only be used in the Auxiliary and Background registers, as foreground colors in the Color RAM and the background color use three-bit values.
Value | Color | Y | Pb (rel.) | Pr (rel.) |
---|---|---|---|---|
0 | black | 0 | 0 | 0 |
1 | white | 1 | 0 | 0 |
2 | red | 0.25 | -0.383 | 0.924 |
3 | cyan | 0.75 | 0.383 | -0.924 |
4 | purple | 0.5 | 0.707 | 0.707 |
5 | green | 0.5 | -0.707 | -0.707 |
6 | blue | 0.25 | 1 | 0 |
7 | yellow | 0.75 | -1 | 0 |
8 | orange | 0.5 | -0.707 | 0.707 |
9 | light orange | 0.75 | -0.707 | 0.707 |
10 | pink | 0.5 | -0.383 | 0.924 |
11 | light cyan* | 1 | 0.383 | -0.924 |
12 | light purple | 0.75 | 0.707 | 0.707 |
13 | light green | 0.75 | -0.707 | -0.707 |
14 | light blue | 0.5 | 1 | 0 |
15 | light yellow* | 1 | -1 | 0 |
The colors marked with an asterisk (*) are out of the RGB gamut.[6]
Advanced sound programming techniques
Digitized sound output
4-bit resolution digitized sounds can be played by writing samples to the volume register. See One hour of digitized music on the VIC.
The rather quiet output can be amplified with a HF carrier.
Manipulating waveforms
The waveforms of the three square wave oscillators can be modified by rapidly turning an oscillator on and off after letting it rest for a while. See 15 new waveforms for the VIC-20.
Advanced graphics mode programming techniques
With help of just-in-time graphics data manipulation (and great loss of CPU performance), resolutions far beyond the original VIC design can be established. See the New Frontiers in VIC-Hires-Graphics Series.
Die shot
The Visual 6502 project offers a 6561 die shot for reverse engineering purposes.
See Also
External links
- archive . 6502 . org / datasheets/mos_6560_6561_vic.pdf
- www . atarimagazines . com / compute/issue38/105_1_PART_III_VISITING_THE_VIC-20_VIDEO.php