{{TOCright}} {{info|This section of the book is primarily reference material for the PVI. More detailed discussions can be found in the Tutorials.}} The Signetics 2636 Programmable Video Interface (PVI) is a 40-pin DIL chip that handles a number of functions within the console: * Video generation ** Screen colour ** Background grid ** Score digits ** Four objects (sprites) ** Object completion and collision detection * Square wave audio * A/D conversion for the analogue joysticks * Chip select signals for memory and input/output devices * 37 bytes of scratch memory These functions are all implemented by reading and writing to various registers within the PVI. {| |+ '''Graphical features of the PVI''' |- | [[File:PVI graphical elements.jpg|thumb|]] |   | {{legend|black|Screen colour}} {{legend|blue|Score digits}} {{legend|magenta|Objects}} {{legend|yellow|Background grid}} {{legend|cyan|Object duplicates}} |} ==PVI registers== Internally the PVI registers are located at addresses $F00 to $FFF. Within the console's memory map they are located at addresses $1F00 to $1FFF. Programmers only need to be concerned with these latter addresses, so those will be the ones we use throughout this book. For the same reason we will also ignore the areas where the memory map is duplicated. Note that some control registers are write-only. If a program needs to know the contents of any of them, a duplicate copy must be saved elsewhere. Tests on some of these registers on one console indicate that if a read operation is attempted the contents will be corrupted. {| |- style="vertical-align: top;" | rowspan=2| {| class="wikitable" |+ PVI registers |- | 1F00 || style="background: goldenrod;{{Text default color}};"|Object descriptor 1 |- | 1F0E || 2 bytes of scratch |- | 1F10 || style="background: goldenrod;{{Text default color}};"|Object descriptor 2 |- | 1F1E || 2 bytes of scratch |- | 1F20 || style="background: goldenrod;{{Text default color}};"|Object descriptor 3 |- | 1F2E || XXXXXXXXXXXXXXXXX |- | 1F40 || style="background: goldenrod;{{Text default color}};"|Object descriptor 4 |- | 1F4E || 32 bytes of scratch |- | 1F6E || XXXXXXXXXXXXXXXXX |- | 1F80 || Background vertical
bar definition |- | 1FA8 || Background horizontal
bar extensions |- | 1FAD || 1 byte of scratch |- | 1FAE || XXXXXXXXXXXXXXXXX |- | 1FC0 || style="background: salmon;{{Text default color}};"| Control registers |- | 1FD0 || ''Duplicate 1FC0'' |- | 1FE0 || ''Duplicate 1FC0'' |- | 1FF0 || ''Duplicate 1FC0'' |} | style="width:50px;" | | {| class="wikitable" |+ style="background: goldenrod;{{Text default color}};"| Object descriptor 1,2,3 or 4 |- | 0 | rowspan=10|Shape of object,
10 lines of 8 bits |- | 1 |- | 2 |- | 3 |- | 4 |- | 5 |- | 6 |- | 7 |- | 8 |- | 9 |- | A || Horizontal coordinate of object |- | B || Horizontal coordinate of duplicate |- | C || Vertical coordinate of object |- | D || Vertical offset of duplicate |} |- | | |} {| class="wikitable"| style="text-align: center;" cellpadding="0" |+ style="background: salmon;{{Text default color}};"| Control registers |- ! Byte !! width=6% | 7 !! width=6% | 6 !! width=6% | 5 !! width=6% | 4 !! width=6% |3 !! width=6% | 2 !! width=6% | 1 !! width=6% |0 !! Read/Write !! Function |- | 1FC0 | colspan=2 | Size object 4 | colspan=2 | Size object 3 | colspan=2 | Size object 2 | colspan=2 | Size object 1 | Write only | Sizes of objects |- | 1FC1 |colspan = 2 |   |{{overline|R}}1 || {{overline|G}}1 || {{overline|B}}1 ||{{overline|R}}2 || {{overline|G}}2 || {{overline|B}}2 || Write only |rowspan = 2| Colours of objects |- | 1FC2 |colspan = 2 |   |{{overline|R}}3 || {{overline|G}}3 || {{overline|B}}3 ||{{overline|R}}4 || {{overline|G}}4 || {{overline|B}}4 || Write only |- | 1FC3 |colspan = 6 |   | Format || Position || Write only || Score format and position |- | 1FC4 |colspan = 8 |   |rowspan = 2 |   |rowspan = 2 |   |- | 1FC5 |colspan = 8 |   |- | 1FC6 ||   |colspan = 3 | {| width="100%" border="0" cellpadding="0" |- | colspan = 3 | Grid colour |- | {{overline|R}} ||{{overline|G}} || {{overline|B}} |} | Grid enable |colspan = 3 | {| width="100%" border="0" cellpadding="0" |- | colspan = 3 | Screen colour |- | {{overline|R}} ||{{overline|G}} || {{overline|B}} |} | Write only || Grid enable and colours |- | 1FC7 |colspan = 8 | Sound | Write only || Tone period |- | 1FC8 | colspan=4 | Score digit 1 | colspan=4 | Score digit 2 |rowspan = 2 | Write only |rowspan = 2 | Values of the four score digits |- | 1FC9 | colspan=4 | Score digit 3 | colspan=4 | Score digit 4 |- | 1FCA | colspan=4 | {| width="100%" border="0" cellpadding="0" |- | colspan = 4 | Object/grid collision |- | 1 || 2 || 3 || 4 |} | colspan=4 | {| width="100%" border="0" cellpadding="0" |- | colspan = 4 | Object display complete |- | 1 || 2 || 3 || 4 |} |rowspan = 2 | Read only |rowspan = 2 | Collision status. Object display completion. VRLE set at leading edge of VRST. All bits reset when read or at trailing edge of VRST. |- | 1FCB ||   || VRLE | colspan=6 | {| width="100%" cellpadding="0" |- | colspan = 6 | Inter-object collision |- | 1/2 || 1/3 || 1/4 || 2/3 || 2/4 || 3/4 |} |- | 1FCC |colspan = 8 | A/D pot 1 |rowspan = 2 | Read only |rowspan = 2 | A/D value, valid during VRST only. |- | 1FCD |colspan = 8 | A/D pot 2 |- | 1FCE |colspan = 8 |   |rowspan = 2 |   |rowspan = 2 |   |- | 1FCF |colspan = 8 |   |} ==Objects== {{wikipedia|Sprite (computer graphics)}}The PVI has four, programmable, two-dimensional objects that can be positioned anywhere on screen in a single 3-bit colour in one of four different sizes. It is said that the PVI was the first device to have this capability. This style of graphic was later termed a sprite, but we will stick with 'object' in this book as it is the term used in the Signetics datasheet. ===Object shape=== The shape of the object is set in a ten-byte array. Bits set to zero are transparent, while bits set to a one are displayed as the selected colour. ===Object colours=== Object colours are set by registers $1FC1 and $1FC2. See [[../Programming colours/]] for details. ===Object size=== Objects can be displayed in four different sizes as set by two-bits in register $1FCO. {| class="wikitable" |- ! Magnification !! Size !! MSB !! LSB |- | x1 || 8 x 10 || 0 || 0 |- | x2 || 16 x 20 || 0 || 1 |- | x4 || 32 x 40 || 1 || 0 |- | x8 || 64 x 80 || 1 || 1 |} ===Object position=== Positioning of objects is determined by reference to the origin of the tv scan at the top-left of the screen. The ''horizontal coordinate'' (i.e. $1F0A) is set as the number of horizontal clocks to skip after the start of the raster line before the object is displayed. It maybe changed while the object is being displayed in which case the remainder of the object will be displaced. The ''vertical coordinate'' (i.e. $1F0C) of an object is set with an eight-bit unsigned value equal to the number of lines to skip before the object is displayed. This value must be set before the trailing edge of VRST. ===Object duplicates=== One or more duplicate objects can be displayed further down the screen. The ''horizontal coordinate of the duplicate'' (i.e. $1F0B) is set in the same way as the original object. The ''vertical coordinate of the duplicate'' is set as the "number of lines to skip - 1" after displaying the last line of its predecessor. The ''horizontal coordinate of the duplicate'' is read by the PVI on each line during HRST, so if it is changed during display of a duplicate, the rest of the duplicate will appear at a different position. The ''vertical coordinate of the duplicate'' must be programmed before the ''object completion'' status bit is set by the previous occurrence of that object. ===Object completion=== When the last line of an object has been displayed an ''object complete'' bit is set in register $1FCA and the PVI generates an interrupt signal for the microprocessor. ===Object collision=== If an object overlaps the background grid an ''object/grid collision'' bit is set in register $1FCA. If two objects overlap an inter-object collision bit is set in register $1FCB. ==Score== {{see also|{{BOOKNAME}}/Score|l1= Tutorial — Score}} The four score digits may be displayed as either two separate 2-digit numbers or as a single 4-digit number. They may be displayed at the top or bottom of the screen, or by reprogramming during the vertical scan between lines 40 and 199 they may appear at both top and bottom. The mode of display is determined by the format and position bits of register $1FC3. {| class="wikitable" |- ! $1FC3 !! 7 !! 6 !! 5 !! 4 !! 3 !! 2 !! 1
Format !! 0
Position |- | '''0'''|| || || || || || || two 2-digit ||top |- | '''1'''|| || || || || || || one 4-digit || bottom |} Each score digit is 12 clocks wide and 20 lines high. The top position corresponds to lines 0 to 19 of the background grid, or vertical coordinates 20 to 39. The bottom position corresponds to lines 180 to 199, or vertical coordinates 200 to 219. The colour of the score is the inverse of the colour programmed for the background grid. See: [[Signetics 2650 & 2636 programming/Programming colours|Programming colours]] {| class="wikitable" |+ Horizontal position of score digits |- !   !! 1 !! 2 !! 3 !! 4 !! Appearance |- | Format = 0 || 28 || 44 || 76 || 92 || 12  34 |- | Format = 1 || 28 || 44 || 60 || 76 || 1234 |} The four score digits in $1FC8 and $1FC9 may be set to any hexadecimal value 0 to F. Values 0-9 display as the number, A-F display a blank. ==Background grid== The PVI has a programmable background grid comprised of an array of elements, 16 wide and 20 deep. These elements are vertical bars, one pixel wide, arranged in pairs of horizontal rows; the first row of each pair is two raster lines deep and the second row is 18 raster lines deep. Each of these 320 vertical bars may be switched on or off by setting a bit in a 40-byte array located at memory addresses $1F80 - $1FA7. The vertical bars may be extended horizontally, controlled by five registers $1FA8 - $1FAC. Each of the five extension registers control four consecutive rows of vertical bars. {| |- | {| class="wikitable" |+ Extension registers |- ! Register !! 7 !! 6 !! 5 !! 4 !! 3 !! 2 !! 1 !! 0 |- style="text-align: center;" |   |colspan="2"|'''Extend group x1,2,4''' |colspan="6"|'''Extend row x8''' |- style="text-align: center;" | $1FA8 |colspan="2"| Rows 1-4 | 4B || 4A || 3 || 2B || 2A || 1 |- style="text-align: center;" | $1FA9 |colspan="2"| Rows 5-8 | 8B || 8A || 7 || 6B || 6A || 5 |- style="text-align: center;" | $1FAA |colspan="2"| Rows 9-12 | 12B || 12A || 11 || 10B || 10A || 9 |- style="text-align: center;" | $1FAB |colspan="2"| Rows 13-16 | 16B || 16A || 15 || 14B || 14A || 13 |- style="text-align: center;" | $1FAC |colspan="2"| Rows 17-20 | 20B || 20A || 19 || 18B || 18A || 17 |} |       | {| class="wikitable" style="text-align: center;" |+ Group extension |- !Extension !!    7     !!    6     |- | x1 || 0 || 0 |- | x2 || 0 || 1 |- | x1 || 1 || 0 |- | x4 || 1 || 1 |} |} Bits 5-0 of the extension register enable all of the vertical bars ''in a horizontal row'' to be extended to 8 pixels. The 18-line vertical bars are divided into two parts (A and B) each of 9 lines making it possible to extend the top and bottom part of the bars by 1, 2 or 4 pixels. Bits 7-6 of the extension register enable all of the vertical bars ''in a group of four rows'' to be extended by to either 1, 2 or 4 pixels. The colour of the background grid is set by bits 2-0 in register $1FC6. The background grid is enabled by setting bit 3 in register $1FC6. If the background grid is not enabled, registers $1F80-$1FAC maybe used as scratch memory, a whopping 45 bytes, in addition to the 37 bytes of scratch memory ==Sound== The PVI can generate a single audio square wave output. Its frequency is set by register $1FC7. If this value is 0, the square wave is inhibited, otherwise its period is 2(n+1)TH, where n is the value set in $1FC7 and TH is the horizontal reset period. For a PAL system this simplifies to 128(n+1)μs. If the sound register is changed while audio is being output, the change will not become effective until the next negative or positive transition of the audio signal. {{warning|The 2636 datasheet is misleading. It says that the horizontal reset period is normally 63.5μs. That is correct for an NTSC system, but for PAL it is 64μs.http://martin.hinner.info/vga/pal.html Both the horizontal reset period and a number of audio output frequencies have been verified on a Voltmace Database using a Hantek DSO5102P oscilloscope.}} See [[Signetics 2650 & 2636 programming/PVI audio frequency chart|PVI audio frequency chart]] for a table of frequencies attainable. ==Analogue to digital conversion== Two analogue to digital converters in the PVI are used to determine the position of the analogue joysticks. External circuitry driven from the processor's ''flag'' output is used to select input from either the horizontal or the vertical potentiometers. The conversion process occurs during the active part of the video scan. The resulting digital values must be read from $1FCC and $1FCD during the vertical reset period to get a valid result. ==References== {{Reflist}} {{Bookcat}} {{Status|50%}}