The 4025 VGP is continuously compositing several layers several times per second. This composition allows complex visual effects without a lot of effort on the programmer's part. The composition system is designed to make it easy to create two-dimensional side-scrollers and the like, a typical staple for computers from the design time period.

Aside from the background and the border, there are four layers which can be configured to use any of the two available text modes or the hi-res graphics mode. There are also up to sixteen sprites available for use. While each layer is rendered in ascending order (so layer 0 is below layer 1), sprites can be assigned to be above an arbitrary layer (this is a sprite's z-index setting).

Due to the way the layers and sprites are rendered, a pixel that resolves to 0x00 in any layer is considered transparent and will show the layer underneath (or the background, if no layer is below). There is no support for partial transparency.

Layer Configuration

Layers are configured by first selecting the desired layer (0—3) and then modifying the associated configuration settings.

Selecting a layer is accomplished by writing the desired layer to port 0x12.

ld a, 0x01
out 0x12, a

At this point, any write to ports 0x13 to 0x1B will alter the configuration for the selected layer. Changes will take effect immediately, so you may need to take care to wait for the next frame if you are concerned about flicker or static.

Layer Visibility (0x13:7)

You can control the visibility of a layer by setting or clearing the high bit of port 0x13 (LAYER_SRC).

in a, 0x13
or al, 0b1000_0000       # set high bit so that this layer is visible
out 0x13, a              # ... make it so!

If the high bit is clear, the layer will not be rendered.

Layer Source Page (0x13:4-0)

Each layer's contents must be stored somewhere in memory. This setting controls which page contains the data that is used to render each layer. The layout of this page is determined by the layer's rendering mode. Because only the page can be specified, there are only 32 locations at which a layer's content can reside (these are 16k blocks throughout memory). By default, the first layer's page is set to 0x04, which maps to 0x10000 in memory.

in a, 0x13
or al, 0b000_00100     # set page to fourth page, mapped to 0x10000
out 0x13, a

For 32x24 text mode, the layout is as follows: