Chapter II - Playfield Hardware

From amiga historical society
Revision as of 17:38, 25 June 2024 by Bernard (talk | contribs) (Created page with "== II. PLAYFIELD HARDWARE == <br>'''1. INTRODUCTION'''<br> There are two basic parts to the display which you see on the screen: * Things which move, called "sprites", and...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

II. PLAYFIELD HARDWARE


1. INTRODUCTION


There are two basic parts to the display which you see on the screen:

  • Things which move, called "sprites", and
  • Things which don't move, called "playfields" or playfield objects.


A playfield is the backdrop against which the sprites may be displayed or with which the sprites can interact. A playfield object is simply a smaller subsection of the playfield which is considered by the software to be an object of some kind.

Even though playfield objects are classed as non-moving object, these objects can appear to move by using a technique called playfield animation. The chapter titled "THE BLITTER" shows that playfield objects can be rapidly redrawn on the screen, while saving and restoring the background onto which they are drawn, to give the illusion of motion. Much of the demonstration software which you may have already seen uses this animation technique.

This chapter concentrates on the playfield hardware itself. It shows you what defines a playfield, how its colors are specified, how it is controlled, and how other parts of the computer interact with the playfield hardware.


WHAT TOPICS ARE COVERED IN THIS CHAPTER


This chapter covers:

  • How to define playfield resolution
  • How to select the color of the playfield elements using one or more bit-planes
  • How Hold & Modify mode increases your choice of onscreen colors available
  • How to use the bit-planes as a single playfield, or how to split the static display into two independently controllable playfields.
  • How to control the size of the static display.
  • How to determine how much memory space is used by the display
  • What part of the display memory actually appears on the screen
  • How to smoothly scroll (move the playfield) in either a horizontal or vertical direction
  • How the playfield display interacts with other parts of the Amiga Personal Computer


2. PLAYFIELD RESOLUTION

There are two different operating modes for the playfield display:

  • Normal Resolution Mode
  • High Resolution Mode


  • 2.1. NORMAL RESOLUTION MODE

In normal resolution mode, there are 320 picture elements or "pixels" which form each horizontal line of the screen display. This is for the resolution which is generally used for the standard home television screen. It allows clear text at 40 columns per line as well as good resolution while displaying multi-colored images.

You can define a "color palette", essentially a set of paint pots, which contains 32 out of a possible 4096 available colors. Normal resolution mode allows you to select any one of these 32 colors which you have defined for any one of the pixel elements which make up the overall picture. This allows you to create detailed multi-colored pictures on the screen.

A special operating mode, called Hold & Modify, allows you to control the color even more closely. This mode, shown later in this chapter, lets you write up to 3616 colors on the screen at the same time on a standard television set, or up to 4096 different colors on an RGB monitor.


  • 2.2. HIGH RESOLUTION MODE

In high resolution mode, there are 640 pixels which form each horizontal line of the screen display. In this mode, each pixel can be any one of 16 colors which you have defined. High resolution pictures are normally only produced on a high resolution monochrome or RGB monitor. (A standard television set does not have a high enough resolution to respond correctly to the high resolution signal.)


  • 2.3. NON-INTERLACE MODE

In non-interlace mode, you have about 200 lines per screen in a vertical direction.


  • 2.4. INTERLACE MODE

In interlace mode, you have about 400 lines per screen in the vertical direction. Note that this does NOT mean you are using more screen area in the interlace mode than in non-interlace mode. It simply means that the video scanning circuitry, on one frame (roughly once each 1/60th of a second) displays 200 lines. Then on the next display frame, it interlaces (places a line in between two existing lines) the next picture frame along with the existing one onscreen. This provides additional vertical resolution.


  • 2.5. TEXT ON A GRAPHICS SCREEN

The normal operating mode of this system is GRAPHICS. Text is simply treated as a special form of graphics element.

On a 320 element horizontal line (normal resolution mode) you can generally expect to use 40 characters of text. In this mode, each character could be defined as a series of dots (pixels) in an 8 by 8 square matrix.

On a 640 element horizontal line (high resolution mode), you can use 80 characters of text per line. Again the same character set may be used.

Because text is simply a special case of graphics, you can easily mix multi-colored graphics and text on the same screen. You may use either the built-in character-set or your own special font. Likewise, the placement for text need not be limited to a hard-and-fast 40 or 80 positions on 25 fixed lines. A special purpose DMA channel called the blitter allows you to place any kind of graphics element anywhere on the screen.

This lets you use subscripts, superscripts, underlines, embedded special characters or graphics, proportional spacing and many other features for a what-you-see-is-what-you-get presentation to the computer user.


  • 2.6. CONTROL REGISTERS WHICH SELECT PLAYFIELD RESOLUTION

The register named BPLCON0 contains the bits which control both the horizontal bit resolution and the interlace/non-interlace mode.


Bit 15 - HIRES
High Resolution Mode Select
When a 1, selects 640 mode.
When the power is first applied, this bit is a 0.


Bit 2 - LACE
Interlace Mode Enable
When a 1, selects interlace mode.
(400 lines vertical resolution)
When the power is first applied, this bit is a 0.


A summary of the functions of all of the bits of this register is contained in the section titled "BIT-PLANE REGISTERS", later in this chapter.



3. HOW TO SELECT THE COLOR OF PLAYFIELD ELEMENTS

When you look at the screen, you see a complete picture. However that picture is, in turn, composed of the individual picture elements, called pixels. As specified above, the number of elements which define a standard display vary from


320 by 200 for normal resolution, non interlace mode, to
640 by 400 for high resolution, interlace mode.


Each pixel element is represented by one or more bits in the computer memory. In other words, for each individual pixel element, there is a corresponding bit (or bits) in the computer memory which have an effect on the color which is assigned to that pixel.


Because the pixels are organized in a two-dimensional array, you might refer to a playfield as a "color-plane". The corresponding section of memory which contains memory bits which have the effects on the color of the playfield pixels is called the "bit-plane".


  • 3.1. EXAMPLE ONE: COLOR SELECTION USING ONE BIT-PLANE

Imagine the television display area as a set of boxes (pixels) laid out as 320 boxes wide by 200 boxes high. Assume that the only choices of contents for each of those boxes is a number 0 or number 1.


This is illustrated in figure 3-1 below.


(Figure 3.1)


part of a screen display where each box represents a single pixel, and the value contained in the box represents the value of a single bit somewhere in the memory system which has an effect on the color of that pixel element.


Fig. 3-1: SINGLE BIT-PLANE COLOR INTERPRETATION

Also imagine that for every box in which there is a 1 stored, a particular color is put on the screen. And for every box in which there is a 0 stored, the background color shows through. For each box represented on the screen, there is a memory bit which is reserved to hold the number contents of that box. This set of memory locations which composes a complete display for this example is called a bit-plane.


The technique shown in fig 3-1 is exactly the way in which the Amiga Personal Computer selects its colors.

  • Determine the "value" of the element & use that value as an index into a color table.
  • The value stored in the color table is the actual color of the element.


This is also called "color indirection" because the value of the color to be used is not stored directly as part of a display, but it is rather stored in a color table, also called a color palette.


If there is only one bit-plane used to select the colors of the display, then

  • In each position where there is a 0, the background color (COLOR0) is shown.
  • In each position where there is a 1 in the bit-plane, the color specified as COLOR1 in the color table is shown.


The color table actually has 32 entries. This indicates that you might possibly be able to select from any one of up to 32 different colors for any one of the playfield elements. Here is a condensed view of the contents of the color table:


NAME Contents What It Means
COLOR0 12 bits User defined, Describes "COLOR" for the Background area of the display
COLOR1 12 bits User Defined COLOR number 1.
COLOR2 12 bits User Defined COLOR number 2.
--
--
--
COLOR31 12 bits User Defined COLOR number 31.


Twelve bits of color selection allows you to define each of the 32 registers, one of 4096 possible colors to display when that color register is selected. COLOR0 is always reserved for the background color for the display. The background color is the color which shows in any area on the display where there is no other object present, since all other objects have a higher priority than the background. The background color is also displayed outside the border of the video window defined on the screen.


COLOR1 through COLOR31 are selected by the combination of bits which you place on the screen through an overlap of the bit-planes. The combination of the bits to form a color selector is shown further in example two.


  • 3.2. HOW THE BITS OF THE COLOR REGISTERS ARE INTERPRETED

The 12 bits of COLOR information is contained in the low 12 bits of each of the 16-bit words which make up the color table. The INTERPRETATION of the color bits differs depending on the mode in which the system is operating.

  • 3.2.1. BITS WHICH CONTROL COLOR BIT INTERPRETATION

There are two bits in BPLCON0 which define the operating mode for color bit interpretation.

These are:

  • HIRES High Resolution (640) mode enable
  • RGB RGB color mode enable

When HIRES and RGB are both zero, the 12 bits are interpreted as:

11-8 7-4 3-0
Q I Y

where Q and I are vector lengths which describe color phasing for NTSC signals, and Y is the luminance level. This is the standard NTSC color mode.

When HIRES = 0 and RGB = 1, the 12 bits are interpreted as:

11-8 7-4 3-0
B G R

where R, G and B stand for the Red, Green and Blue electron gun intensity levels.


When HIRES = 1 and RGB = 1, the system interprets the 12 bits as follows:

11-9 8-6 5-4 3 2 1 0
B G R mr b g r

where: R is 2 bits of intensity value for Red
G is 3 bits of intensity value for Green
B is 3 bits of intensity value for Blue

r is Red-output-enable
g is Green-output-enable
b is Blue-output-enable

mr is MSB for the red value


There is one limitation in this mode. This limitation is related to the rate of change of the color. Specifically, the lower 4 bits of the color register may be changed dynamically, such that a change of color onscreen can occur at a high resolution rate (one change for each of the 640 pixel positions). However the upper 8 bits of the color definition will only change at a 320 horizontal rate.

An example will clarify this point:

Two pixels are next to each other on the screen. 640 mode (HIRES) is active, and RGB mode is also active.

Pixel 1 value points to color register 1

Pixel 2 value points to color register 2

Color register 1 contains "white" in the leftmost 8 bits and 1111 in the right 4.

Color register 2 contains "red" in the leftmost 8 bits and 0111 in the right 4 (half-intensity mode active).

If pixel 1 is on an even 320 mode pixel boundary, then pixel 1 will appear white, and pixel 2 will appear as grey. This is because the system will retain the previous value of the leftmost 8 bits during the second of the two pixels and will only change the color using the information available in the rightmost 4 bits.

In other words, if pixel 1 is not on an even 320 mode pixel boundary, then pixel 1 will be affected by the value of whichever pixel preceded it. Pixel 2, because it is, this time, on an even boundary, will appear as half-intensity red.

This demonstrates that the left 8 bits only change at a 320 rate where the rightmost 4 bits take effect immediately.


3.2.2. HOW THE COLOR BITS ARE INTERPRETED

The figure below shows a typical NTSC color vector chart, which shows the Q, I, Y color interpretations. When Y is 0, then the color is fully saturated. As Y increases, the color becomes "more white". The translation between QIY and RGB equations are also given below.


[Fig. 3-2: NTSC COLOR VECTORS AND QIY/RGB EQUATIONS]


  • 3.3. MULTI-BIT-PLANE COLOR SELECTION

If you wish to select from a color palette of more than two colors, there must be a way to tell the system that more color selections are desired. As you see from example one, if you use only one bit-plane to specify the color of a playfield, the value of each of the bits can only be 0 or 1. Therefore you can only select COLOR0 or COLOR1 for each element.

However, if you tell the system to combine bit-plane 1 and bit-plane 2, you have both the bits of plane 1 and plane 2 to use for specifying the color of individual pixel elements. Here is the way that works:

  • EACH individual bit-plane has a complete "bit-map" which defines the contents of the visible playfield area of the screen. (One bit per pixel position visible onscreen).
  • When the bit-planes are used together, the bits from bit-plane 2 are combined with those from bit-plane 1 to form binary number combinations. Those numbers, in turn, select which COLOR number is used as the color of the onscreen pixel element.
  • The highest numbered bit-plane contributes the most significant color selector bit.


  • 3.4. EXAMPLE TWO: TWO BIT-PLANES SELECTING A COLOR

Here is a representation of the 4 pixels at the upper lefthand corner of a video display. Again, for simplicity, they have been shown as a set of 4 boxes.

00 01 10 11 .. .. .. .. .. ..
Pixel 1 2 3 4 .. .. .. .. .. ..


Where the binary value of the pixel is:

00 selects COLOR0
01 selects COLOR1
10 selects COLOR2
11 selects COLOR3


Notice that each color of the boxes contains two bits instead of 1 bit as used in example one.

There are two bits used here because the two bit-planes are being used to select the color. ONE BIT FROM EACH of the bit-planes is used as part of the color selector. Here is an illustration showing exactly how the bit-plane data is combined to form the number combination for selecting the color of a playfield element.


[Fig. 3-3: HOW 2 BIT-PLANES DETERMINE COLOR NUMBER]


As shown in the chart, if there are two bit-planes combined into one playfield, it is possible to select from 4 possible colors for each one of the playfield elements.

The system has 6 bit-plane DMA channels. This would seem to indicate that you could tell the system to combine all 6 bit-planes into a single processor, however this is not the case. There is one special case, called hold-and-modify, which is used with all six bit-planes active and assigned to a single playfield. Hold-and-modify is discussed in section 12 of this chapter.

Normally, though, in any single playfield, only 5 bit-plane processors may be active. The combination of 5 binary bits allows you to select, for any single pixel element, a choice of 32 different colors. When five bit-planes are used, the significance of the binary bits is as follows:


  • 3.5. EXAMPLE THREE: HOW 5 BIT-PLANES SELECT A COLOR

[Fig. 3-4: HOW 5 BIT-PLANES SELECT A COLOR]


As you can see from the diagram above, the bits in each bit-plane corresponding to each individual picture element, combine to form a number for that element which selects the color which is to be displayed. One plane selects 2 colors. Two planes can select from 4 possible colors, three planes from 8 possible, four planes from 16 possible colors and five planes gives you 32 possible selections.

[FIG. 3-5 on the next page further illustrates how the contents of the bit-plane data selects the pixel color.]


Even though each bit plane is a separate section of memory, they are used by the display as though they were stacked, one on top of another.

The bits in identical positions are combined by the display hardware to form a binary number which is the color code for the pixel.

This bit-plane code selects one of 32 registers to use to display the color of the playfield pixel element.


[FIG 3-5 HOW BIT-PLANES SELECT A COLOR]



4. SELECTING COMBINATIONS OF BIT-PLANES

This section shows how you select how many bit-planes are used for the playfield display and how the system will combine them to select the color of the playfield display.


  • 4.1. SELECTING HOW MANY BIT-PLANES TO USE

You can tell the system how many bit-planes to use by writing that number into bits of BPLCON0 (Bit Plane Control Register 0) named BPU2, BPU1, BPU0 ("Bit Planes Used") which are bits 14, 13, and 12.

The value: Selects:
000 Zero Bit-Planes
Show only a background color, no playfield visible.
001 One bit-plane PLANE1
010 Two PLANES 1 & 2
011 Three PLANES 1 - 3
100 Four PLANES 1 - 4
101 Five PLANES 1 - 5
110 Six PLANES 1 - 6
111 Value not used


  • 4.2. SELECTING HOW BIT-PLANES ARE GROUPED

The figure above showed you how the system would interpret color for 5 bit-planes combined into a single playfield. There is another mode of operation, which provides more freedom of design. This is called Dual-Playfield mode.

You activate dual-playfield mode by writing a 1 into the dual-playfield bit "DOUPF" (bit 10) of BPLCON0.

This changes both the way in which the hardware groups the bit-planes for color interpretation and the way it can move the playfields on the screen.

In particular, when the dual-playfield bit is a 1, then all ODD-numbered bit-planes are grouped together and called "PLAYFIELD 1". All EVEN-numbered bit-planes are grouped together and called "PLAYFIELD 2".


  • 4.2.1. COLOR INTERPRETATION FOR PLAYFIELD 1

When dual-playfield mode is active, the hardware interprets color numbers for playfield 1 from the bit combinations of:

Highest Significance Bit-Plane 5
Bit-Plane 3
Lowest Significance Bit-Plane 1


The bit combinations, in turn, select the color registers from the first 8 colors in the color table, as:

Playfield 1 Bit Combo Selects
000 COLOR0 *
001 COLOR1
010 COLOR2
011 COLOR3
100 COLOR4
101 COLOR5
110 COLOR6
111 COLOR7


The (*) above specifies that the combination 000 is a special combination. It means "transparent mode".

Transparent mode means that wherever the bit combination in this playfield is a zero, it shows the color of whatever object (another playfield, a sprite, or the background color) may be "behind" this playfield.

In the section which shows interactions between the bit-planes and other parts of the computer, the priority descriptions show you that you can control the relative visual priority of the playfields and sprites. This enables you to show one object in front of or behind another.


  • 4.2.2. COLOR INTERPRETATION FOR PLAYFIELD 2

When dual-playfield mode is active, the hardware interprets color numbers for playfield 2 from the bit combinations of:

Highest Significance Bit-Plane 6
Bit-Plane 4
Lowest Significance Bit-Plane 2


The bit combinations, in turn, select the color registers from the second 8 colors in the color table as:

Playfield 2 Bit Combo Selects
000 Transparent Mode
001 COLOR9
010 COLOR10
011 COLOR11
100 COLOR12
101 COLOR13
110 COLOR14
111 COLOR15


The figure on the next page shows how bit-planes may be grouped when double playfield mode is active.


  • 4.3. HOLD & MODIFY MODE
  • 4.3.1. REGISTER BIT THAT SELECTS THIS MODE


5. HOW BIT-PLANE DATA IS STORED IN MEMORY

6. WHERE IS THE BIT-PLANE DATA STORED

  • 6.1. EXAMPLE ONE: PICTURE/DISPLAY SAME SIZE
  • 6.2. EXAMPLE TWO: PICTURE TWICE THE SIZE OF DISPLAY
  • 6.3. EXAMPLE THREE: INTERLACED PICTURE


7. HOW TO CONTROL THE SIZE OF THE DISPLAY

  • 7.1. CONTENTS OF DISPLAY WINDOW START REGISTER
  • 7.2. CONTENTS OF DISPLAY WINDOW STOP REGISTER


8. DETERMINING HOW MUCH DISPLAY MEMORY IS NEEDED

9. SCROLLING THE PLAYFIELDS

  • 9.1. VERTICAL SCROLLING
  • 9.2. HORIZONTAL SCROLLING
  • 9.2.1. REGISTERS WHICH AFFECT HORIZONTAL SCROLLING


10. INTERACTIONS WITH OTHER ELEMENTS

  • 10.1. VIDEO PRIORITIES


11. PLAYFIELD SELECTION COLOR CHARTS