# Tutorial — Objects

    See also: PVI - Objects
The most powerful feature of the PVI are its four reprogrammable objects. Several sources cite this Signetics chip (c.1977) as being the first commercially available hardware implementation of a memory mapped object on a video chip.

## Tutorial code

The code for this tutorial can be found at Tutorial code - objects. It generates the static screen shown here. There are four objects, 1,2,3 and 4 in different colours and sizes. There are also duplicates of objects 1, 2 and 4.
This is the section of code that programs these objects. It is taken from the list file created by the WinArcadia assembler:
Lets look at each part in turn.

### Colour

| BLACK | 111 |
| BLUE | 110 |
| GREEN | 101 |
| CYAN | 100 |
| RED | 011 |
| MAGENTA | 010 |
| YELLOW | 001 |
| WHITE | 000 |
    See also: Tutorial — Programming colours
The pixels within one object are all the same colour. The colour of each object is set by three bits (giving a choice of eight colours) in the PVI registers at $1FC1 and $1FC2.
| | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| $1FC1 | X | X | R$_1$ | G$_1$ | B$_1$ | R$_2$ | G$_2$ | B$_2$ |
| $1FC2 | X | X | R$_3$ | G$_3$ | B$_3$ | R$_4$ | G$_4$ | B$_4$ |
The program sets: $1FC1 = 00000011 = 00 000 011 = white red $1FC2 = 00101001 = 00 101 001 = green yellow

### Size

| 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 |
The size of each object can be set independently to one of four different sizes. Each object can have a height of either 10, 20, 40 or 80 lines, and the widths are scaled similarly to 8, 16, 32 or 64 horizontal clocks. The individual pixels are not square; they are roughly twice as wide as they are tall, an important point to remember when designing shapes.
| | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 1FC0 | Size object 4 | Size object 4 | Size object 3 | Size object 3 | Size object 2 | Size object 2 | Size object 1 | Size object 1 |
The program sets: $1FC0 = 11100100 = 11 10 01 00 = x8 x4 x2 x1

### Object descriptors

Object descriptor 1,2,3 or 4 :
| 0 | Shape of object, 10 lines of 8 bits |
| 1 | Shape of object, 10 lines of 8 bits |
| 2 | Shape of object, 10 lines of 8 bits |
| 3 | Shape of object, 10 lines of 8 bits |
| 4 | Shape of object, 10 lines of 8 bits |
| 5 | Shape of object, 10 lines of 8 bits |
| 6 | Shape of object, 10 lines of 8 bits |
| 7 | Shape of object, 10 lines of 8 bits |
| 8 | Shape of object, 10 lines of 8 bits |
| 9 | Shape of object, 10 lines of 8 bits |
| A | Horizontal coordinate of object |
| B | Horizontal coordinate of duplicate |
| C | Vertical coordinate of object |
| D | Vertical offset of duplicate |
The shape and position of the four objects are each defined by 14 registers called an object descriptor, comprised, in order, as 10 bytes of shape data, a horizontal coordinate(HC), a horizontal coordinate for the duplicates(HCB), a vertical coordinate(VC) and a vertical offset for the duplicates(VCB).
The code that programs these objects copies blocks of data from tables one, two, three, four to the object descriptors $1F00, $1F10, $1F20 and $1F40. Register R3 is used as an index register to go through a loop 14 times, on each pass setting up one byte in each of the four object descriptors.

#### Shape

In the ten-bytes of the object descriptor that defines the shape, and bits set to zero are transparent, while bits set to a one are displayed as the programmed colour.

#### Position

The position of any primary object on the screen is set by its corresponding horizontal(HC) and vertical(VC) coordinates with the origin at the top left of the screen. The coordinates can be any eight bit value, but a horizontal coordinate greater than 227 pushes the object off the right hand side of the screen, and vertical coordinate greater than 252 will be off the bottom of the screen.

#### Duplicates

The power of these objects comes from the fact that they can be output again further down the screen. And again and again…. In fact it is possible to have up to 80 objects on the screen at one time. These are referred to as duplicates. A duplicated object will always be below its predecessor, and they cannot overlap. The horizontal coordinate of a duplicate is simply the distance from the left edge of the screen, in the same way that the original duplicate is specified. The vertical position of a duplicate is trickier; it is set as a vertical offset from its predecessor.
It is also possible to reprogram the shape, size and colour of an object between duplicates, but that requires some real-time programming which will be discussed in a later tutorial.
| | object 1 | object 2 | object 3 | object 4 |
| HC | 10 | 40 | 60 | 100 |
| HCB | 10 | 35 | 120 | 110 |
| VC | 20 | 60 | 90 | 0 |
| VCB | 20 | 10 | 250 | 255 |
Object 1 has a horizontal coordinate of 10, as do its duplicates. Its vertical coordinate is 20, and all of its duplicates are offset vertically by 20 from its predecessor.
Object 2’s duplicates are shifted 5 pixels left, and offset vertically by 10.
Object 3 is all on its own. Its duplicate has been pushed off the bottom of the screen by setting the vertical offset to 250.
Object 4’s duplicates are all touching. This is achieved by setting the offset to 255. This may seem a little odd, but if 255 is converted to 8 bit binary and then interpreted as a signed two’s complement number, we get -1. This is because VCB has to be set to “the number of lines -1” that you want to be skipped. If you want a gap of just one line, set VCB to 0 and so on.

### Exercises

* Change the size of an object.
* Change shape of an object.
* Change the position of an object.
* Change the position of an object's duplicates.