Chapter II - Playfield Hardware

From amiga historical society
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

This is a special mode which, as mentioned earlier in this chapter, allows you to produce more colors onscreen simultaneously than simply the 32 possible choices from the color palette.


  • 4.3.1. REGISTER BIT THAT SELECTS THIS MODE

The bit which selects HOLD & MODIFY mode is bit 11 of BPLCON0. Its name is HOMOD. When it is a 1, it changes the way in which the system interprets the combination of bits from the bit-planes.

NOTE: This mode is only active when: 1. HOMOD = 1, and 2. DOUPF = 0, (single playfield only) 3. HIRES = 0, (normal resolution only) and 3. BPU2 - BPU0 value = 101 or 110 (five or six bit-planes active)

Normally, as each bit-plane value is interpreted, the data contained in the selected color register is loaded into the color-output circuit for the pixel being written on the screen. Each pixel always is colored by the contents of the selected color register.

In hold & modify mode, the value in the color-output circuitry is held, and one of the three parts of THAT value is modified by the bits contained as the bit-plane bit combination.

This allows very fine gradients of color or shading to be produced onscreen. For 32 vases, each a different color (the color palette has been initialized to contain 32 different colors). Then, for each vase, you might use hold & modify to very finely shade or highlight (or add color) to each one of the vases. Here is the way the system interprets this mode.

BIT-PLANE INTERPRETATION IN HOLD & MODIFY MODE The bit combinations from planes 6-5, in that order, are used in this special mode, to modify the way in which the bits from planes 4-1 are treated. If the 6-5 combination is 00, the bit combinations from planes 4-1, in that significance, are used to choose one of 16 color registers. Note that if only 5 bit-planes are selected, the data from the 6th bit-plane is automatically treated as 0. If the 6-5 combination is 01, the color of the pixel immediately to the left of this pixel is duplicated. However, the bit combinations from planes 4-1 are used to REPLACE the 4 "Y" bits (NTSC) or "B" bits (RGB).

If the 6-5 combination is 10, again the color of the pixel immediately to the left is duplicated, but the bits from planes 4-1 REPLACE the 4 "Q" bits (NTSC) or "G" bits (RGB).

If the 6-5 combination is 11, again the color of the pixel immediately to the left is duplicated, but the bits from planes 4-1 REPLACE the 4 "I" bits (NTSC) or "R" bits (RGB).

As you can see, the reason for the name HOLD & MODIFY is that part of the color output register contents is held, from the previous contents, and part of it is modified by the data that comes from the bit-planes. In fact, using this mode, it is possible to get by with defining only ONE color register (that of the background) and treating the entire screen as a modification of that original color. In this manner, the bit-planes can easily be used to define the color contents of the whole screen.



5. HOW BIT-PLANE DATA IS STORED IN MEMORY

Each line of a playfield display which you see on a television or monitor screen is formed from the overlap of one or more bit-planes. Each bit -plane in turn, is formed from groups of 16-bit data words at consecutive memory locations. Each line of a bit-plane always consists of an end-to-end sequence of these data words, with the most significant bit of the word forming the leftmost bit of each word as it appears on the screen. The least significant bit is the rightmost bit. Each memory word across the line from left to right is at a sequentially increasing memory address. If the entire bit-plane is visible within the boundaries of the display, then the leftmost word of any line (except the top line) is defined by a memory word which is at an address one greater than the last word on the preceding line. See Figure 2-1 below.

Data For Line 1 Location: START START+1 START+2 ............ START+19 leftmost next next last display word word display word word

Data For Line 2 Location: START+20 START+21 START+22 ............ START+39 leftmost next next last display word word display word word and so on.

Fig. 5-1: HOW A BIT-PLANE'S DATA MAY BE STORED

Within each data word, each bit represents a single picture element (also called a pixel) in the final screen display. The 1 or 0 value of each bit in the bit-plane data has a part in the selection of the color of the final display element. In other words, the color of any single pixel element on the screen is determined by one or more bits of data, taken from one or more bit- planes.

The set of the display lines defined by this sequence of bits stored in memory forms a two- dimensional plane of bits having one bit for each X and Y position defined for the screen display. Therefore, this manual refers to this group of bits as a bit-plane.

Each bit-plane which is selected to appear on the screen as part of a playfield contributes one bit to the color selection to each pixel. Each bit- plane contains enough bits to provide one bit for each possible X-Y coordinate on the screen within the display window at the resolution which you have selected.




6. WHERE IS THE BIT-PLANE DATA STORED

During vertical blanking time, (usually through system-defined vertical blanking routines) you tell the system the starting address for the data for each of the bit-planes actually used.

The names of the registers which you use to point to the start of the bit-plane data are:

BPLxPTH and BPLxPTL

where x stands for any number 1 through 6 and stands for one of the six possible bit-planes. PTH and PTL stand for the high-word and low-word of each of the six pointers.

The bit-plane pointers are address pointers which point to the starting address within memory at which the data for a specific bit plane actually starts. The pointers are 19 bits wide, and are BYTE pointers. The hardware will truncate these byte addresses downward to a word boundary if necessary.

These pointers are dynamic. Once the display data fetch begins, the pointers themselves are continuously incremented to point to the next word to be fetched. As the beam reaches the end of the line, it will have fetched the last data word of the line (defined by a register called DDFSTOP). When this end-of-line condition is reached, each bit-plane pointer is adjusted by an amount known as a "modulo" so that it points to the memory word which is to appear as the leftmost word on the next line down on the screen.

The separate modulo for a each of the bit-planes is what allows you to convert the bit-plane data from a linear storage organization (each at sequentially increasing memory addresses) into a rectangular organization (one "line" of sequential data followed by another line, and so on.

Here are some examples which show how the use of a modulo affects which memory words will be used for the display. Example One shows the memory data fetch when the bit-plane modulo is 0. Example Two shows the data fetch when the modulo is 20.


  • 6.1. EXAMPLE ONE: PICTURE/DISPLAY SAME SIZE

Assume that the size of the bit-plane is exactly the same as the size of the display window, and the modulo is zero. In other words, the memory are is exactly the same number of words which appear on the screen. In this case, the data for each bit-plane is stored as shown in the figure below.

Data For Line 1 Location:

START    START+1    START+2    ............    START+19

leftmost next next last display word word display word word

Screen Data Fetch Stops (DDFSTOP) for each horizontal line after this last word on the line has been fetched. At this point, BPLxPTH and BPLxPTL contain the value START+20. The modulo is added to the current value of the pointer so that when it begins the data fetch for the next line, it fetches the data which you intend to appear on that line.

Data For Line 2 Location: START+20 START+21 START+22 ............ START+39 leftmost next next last display word word display word word and so on.

Fig. 6-1: DATA LAYOUT PER BIT-PLANE WHEN MODULO = 0

Example Two shows a bit-plane display which is defined as 40 words wide by 200 lines long, and a screen display window which is only 20 words wide by 200 lines long. You can control which portion of this memory display actually appears in the display window.

The section which follows, titled "What Appears In The Display Window", shows you how to smoothly scroll the display window along the defined memory display. However, for now, only the concept if bit-plane modulo will be covered.


  • 6.2. EXAMPLE TWO: PICTURE TWICE THE SIZE OF DISPLAY

Assume that the size of the bit-planes is exactly twice the size (width only) of the display window. In order to assure that the left-half data (one full window of data) appears on the real display, you use a modulo of 20. This is illustrated in the figure below. Assume that for a start, you wish to display only the left half of the memory picture. START START+39 +------------------------------------------------+

 Width of the Bit-Plane Defined In RAM
   Width of defined
   screen on which
   bit-plane data is
   to appear

+------------------------------------------------+ Data For Line 1 Location:

START    START+1    START+2    ............    START+19

leftmost next next last display word word display word word

Screen Data Fetch Stops (DDFSTOP) for each horizontal line after this last word on the line has been fetched.

At this point, BPLxPTH and BPLxPTL contain the value START+20. The modulo (in this case, the modulo must be 20) is added to the current value of the pointer so that when it begins the data fetch for the next line, it fetches the data which you intend to appear on that line.

Data For Line 2 Location:

START+40    START+41    START+42    ............    START+59
 leftmost    next           next                                  last
 display       word          word                                display
 word                                                                           word

and so on.

If you wish, now, to display the right half of the picture, you would simply command the vertical blanking routines to start the bit-planes at location START+20. The modulos remain the same and only the data representing the right half of the picture will be transmitted to the display area.

Fig. 6-2: DATA LAYOUT PER BIT-PLANE WHEN MODULO = 20


  • 6.3. EXAMPLE THREE: INTERLACED PICTURE

The modulo may be used in producing an interlace- scanned picture as well as a non-interlaced one. In this case, if all of the data of the "big picture" was located in continuous memory addresses, the modulo would then be equal to:

      PICTURE WIDTH (real picture in memory) minus
      DISPLAY WIDTH (what part can appear onscreen)
             plus
      PICTURE WIDTH
      --------------------
             MODULO

which allows the display of alternate lines of the complete picture during alternate frames of the display. The vertical blanking routines of the operating system can read bit 15 of control register VPOSR. This is the FRAME bit. If the system is currently producing an ODD frame, this bit will be a 0. If it is producing an EVEN frame, this bit will be a zero. Based on the value of this bit, the vertical blanking routines can start the bit-plane pointers either at line 1 (for odd) or line 2 (for even frames). [verify above info]

+--------------------------------------+ Big picture in memory is defined as 400 lines long. Screen shows 200 odd-numbered lines in one frame, then "interlaces" the other 200 lines the +--------------------------------------+ next frame to form the complete picture.

Data for line 1 of interlaced picture may begin at memory location START, Line 2 at START+20 Line 3 at START+40 Line 4 at START+60 Then for EVEN frames, point BPLxPTH and BPLxPTL to begin at START. Use a modulo of 20, so that odd numbered lines appear on subsequent scan lines as the beam proceeds down the screen. For ODD frames, point BPLxPTH, BPLxPTL to begin at START+20. Also uses the same modulo (20) whcih takes only the even numbered lines as the beam sweeps down the screen.

If you define an interlaced picture this way instead of defining it as two separate frames, it also has the advantage of forming a complete normal rectangular area, allowing you to use the blitter without any special consideration as to which of the two frames (odd or even) is being changed.



7. HOW TO CONTROL THE SIZE OF THE DISPLAY

You can control the size of the display which appears on the screen. This allows you some freedom in specifying where the borders are located. On some television sets, for example, there is a large amount of overscan which may make the borders invisible (if they are offscreen). This system allows you to specify where the screen borders begin and end, in both the horizontal and vertical direction. This adjustment affects the ENTIRE display area. This includes not only the playfield, but also the border and the sprites as well. The area in which the complete display is drawn is called the DISPLAY WINDOW. The registers which control its size are: DIWSTRT - Display Window Start DIWSTOP - Display Window Stop


  • 7.1. CONTENTS OF DISPLAY WINDOW START REGISTER

7.1 CONTENTS OF DISPLAY WINDOW START REGISTER DIWSTRT contains both the horizontal and vertical components of the display window starting position. BITS 15-8 V7-V0, VSTART - vertical starting position for the screen. BITS 7-0 H7-H0, HSTART - horizontal start position for the screen.

Horizontal Start: There are 362 possible positions across the screen at which the left hand edge of the display could potentially start. To provide single pixel resolution in the placement of the display window while only using 8 bits to specify the starting position, these 8 bits are assigned to the first 256 positions out of the possible 362 onscreen. FULL SCREEN AREA 0 255 361 +----------------------------------------------------------+ HSTART of DISPLAY WINDOW occurs in this region

+----------------------------------------------------------+

The normal-sized (320 pixel wide) normal resolution display occupies 320 of the 362 possible positions beginning at HSTART. A value of approx. 25 in HSTART centers the display on the average television screen. The selection of high-resolution mode (640 pixels horizontal) has NO EFFECT on the interpretation of HSTART.

Vertical Start: There are 262 (NTSC) or 312 (PAL) possible positions counting down from the top of the screen at which the display could potentially start. To provide single video line control over the stopping point, while still using only 8 bits to express it, this system assigns these 8 bits to the top 256 line positions. FULL SCREEN AREA +-------------------------------------------+ 0

VSTART of DISPLAY WINDOW occurs in this region 255 (NTSC)--------262 +--------------------------- (PAL)----------312 A value of approx. 43 decimal for these 8 bits centers a 200 line long (non- interlaced) display on most standard television screens. Selection of interlace mode has NO EFFECT on the interpretation of VSTART.


  • 7.2. CONTENTS OF DISPLAY WINDOW STOP REGISTER

7.2 CONTENTS OF DISPLAY WINDOW STOP REGISTER DIWSTOP contains both the horizontal and vertical components of the display window stopping position. BITS 15-8 V7-V0, VSTOP - vertical stopping position for the screen. BITS 7-0 H7-H0, HSTOP - horizontal stopping position for the screen.


Horizontal Stop: The horizontal stopping position can be controlled from position 256 through position 361 of the display area. The values of 0 through 63 select one of the possible stopping positions for the visual display.

FULL SCREEN AREA 0 255 361 +---------------------------------------------------------+ HSTOP of Display window occurs in this region +---------------------------------------------------------+


Vertical Stop: There are 262 (NTSC) or 312 (PAL) possible positions counting down from the top of the screen at which the display could potentially stop. To provide single line control over the stopping point of the display window, these 8 bits are assigned to positions 128 through 312, with the value 0 representing position 128.

FULL SCREEN AREA +---------------------------------------------------------+ 0

----------------------------------------- 128 VSTOP of DISPLAY

                               window occurs

in this region (NTSC) --- 262 +----------------------------------------------(PAL)-----+ 312

The figure below illustrates how the screen window definitions will affect an actual playfield display. Note again that ALL OBJECTS (sprites AND playfields) are limited to the area within the display window. No object appears onscreen outside of these boundaries.

(Figure 7-1) If the playfield display is larger than that defined by the difference between DIWSTOP and DIWSTRT, then not all of it will appear on the screen.



8. DETERMINING HOW MUCH DISPLAY MEMORY IS NEEDED


Modes 1 and 2 are generally used for home television applications (both graphics and text). In these modes, text will generally be limited to 40 letters per line. However, this system supports soft font generation to allow more characters per line if desired.

Modes 3 and 4 can be used for high density graphics and for 80 column colored text. This high density mode is more suited to separate color monitors due to the bandwidth limitations of a standard color television.




9. SCROLLING THE PLAYFIELDS

To scroll a playfield means to move it smoothly from one place to another. It is normally used to change the field of view of a playfield which is itself larger than the display window being used to view it. There are three different sets of register values which affect what part of a scene will appear in the display window: - BPLxPTH, BPLxPTL The pointers to the start of the bit-planes - DDFSTRT, DDFSTOP The position registers which say

             	where the data fetch should begin

and end on the screen. - BPLxMOD The bit-plane modulos, which must be changed if the data fetch width is different than the display window size. - BPLCON1 Bit-plane control register 1, contains bits which define a horizontal shift to the right of either playfield 1 or playfield 2.

  • 9.1. VERTICAL SCROLLING

If you design a scene in memory which is taller than can be shown within the display window, you can easily scroll the scene through the window area by changing the bit-plane start pointers. Again note that the change in the pointers will normally be done during a vertical blanking period so as not to upset the synchronization of the screen image. Here is a sample image:

Fig. 9-1: AN EXAMPLE OF A TALL IMAGE All that you must do to move the viewpoint is to progressively increase or decrease the starting point for the bit-plane pointers. This has the effect of moving the data within the window to show a higher or a lower part of the picture. Since there are 200 lines vertically, each step can be as little as 1/200th of the vertical size of the screen, or 1/400th if you are using interlace mode.

Fig 9-2: SCROLLING A TALL SCENE THROUGH THE WINDOW


  • 9.2. HORIZONTAL SCROLLING

If you produce a scene in memory which is wider than the display window, you may control the smooth horizontal scrolling by using the delay feature and the data-fetch control. Horizontal scrolling is performed by DELAYING the display of data which has already been fetched and is ready to be displayed. For each bit of delay which you specify, the onscreen data shifts one pixel position to the RIGHT. As the "current screen" shifts to the right, one bit at a time, there must be some data provided at the left border which, in turn, becomes visible one bit at a time as each bit at the rightmost edge disappears offscreen. Therefore, to allow horizontal scrolling (i.e. shifting of the data), the system must fetch ONE EXTRA WORD PER HORIZONTAL LINE.

Here are two illustrations which show: - The wider-than-window scene - How it scrolls through the window

Fig. 9-3: A SCENE WIDER THAN THE DISPLAY WINDOW

Fig. 9-4: SCROLLING A WIDE SCENE THROUGH THE WINDOW


  • 9.2.1. REGISTERS WHICH AFFECT HORIZONTAL SCROLLING

DDFSTRT - The contents of this register specify where, on a horizontal line, is the beginning position at which the data for that horizontal line should be fetched from the memory (affects ALL bit-planes). Its bits are: 15-8 No effect 7-2 Specifies pixel position number as horizontal position H8-H2. 1-0 No effect The value in this register has a 4-pixel resolution. This is as compared to Display window start, which has a 1-pixel position resolution. If there is NO horizontal scrolling needed, then the value of DDFSTRT need only be less than or equal to the horiztonal value of DIWSTRT (the display window start). This basically says that whatever data is fetched for display on a line, actually gets displayed. If horizontal scrolling IS required, and the maximum scroll delay is to be used (15 bits), then the data word (16 bits) which will be displayed (the early word) must be fetched at least 16 bits earlier than the starting time for the display window. As an example, if you specify that the display window starts at position 48 (decimal) on the horizontal line, then DDFSTRT must specify that data fetch starts at position 32. This guarantees that there will be at least 15 bits of displayable data if the display of fetched data is delayed by 15 pixel times.

DDFSTOP - The contents of this register specify where, on a horizontal line, is the ending position at which the data for that horizontal line should be fetched from the memory (affects ALL bit-planes). Its bits are: 15-8 No effect 7-2 Specifies pixel position number as horizontal position H8-H2. 1-0 No effect The value in this register has a 4-pixel resolution. It specifies at which horizontal pixel position the data fetch for the screen should stop. Normally, the value: (DDFSTRT - DDFSTOP) / 16 equals the number of data words which are needed to get enough bits for the display width. For a normal resolution display, 320 bits per line requires a 20 word fetch. If horizontal scrolling is enabled, it requires a 21 word fetch per horizontal line. High resolution requires 40 or 42 words per line, without or with scrolling. NOTE: Selection of high resolution mode does NOT affect the scrolling. Scrolling occurs as a normal resolution effect only, even if in high resolution mode.

BPLxMOD - Bit-plane modulos specify the number which must be added to the bit-plane pointers once the last word has been fetched on a horizontal line, in order to adjust the pointer to point to the first word of the next horizontal line. If there is no horizontal scrolling, the value of the modulo would reflect the normal width of the screen (likely 20 words). When horizontal scrolling is used, you will fetch 21 words per line, not 20, so that there will be some data there which will show up when the delay in presentation occurs. Therefore you must make the modulo ONE LESS than the case in which no scrolling takes place. The combination of one-more-word-per-line and one-less-word-per-modulo will allow you to point to the correct data position for the following display line.

BPLCON0, bits 15-12 - Playfield 1 Delay BPLCON1, bits 15-12 - Playfield 2 Delay This controls horizontal scrolling in single pixel increments, you will specify delay values for playfields 1 and 2. The figure on the next page, titled "Playfield Horizontal Scrolling", shows how these delay values are used to change the position of the playfield within the display window.

Horizontal scrolling is performed by DELAYING the display of the data which has been fetched for the display. This means that for each bit of delay which is specified, the onscreen data will appear to shift one bit position to the right. As this "current screen" shifts to the right, one bit at a time, there must be some data provided at the left border which, in turn, becomes visible one bit at a time as each bit at the rightmost edge disappears off the screen. Therefore to allow horizonal scrolling (i.e. shifting the data), the user must fetch one extra word per line. This word provides the bits which become visible as the onscreen data shifts.

Fig. 9-5: PLAYFIELD HORIZONTAL SCROLLING



10. INTERACTIONS WITH OTHER ELEMENTS

The playfields share the display with the sprites. The chapter titled "SYSTEM CONTROL REGISTERS" shows how - the playfields can be given different

  video display priorities relative to the
  sprites.

- the playfields can collide with the

  sprites or with each other.
  • 10.1. VIDEO PRIORITIES


11. PLAYFIELD SELECTION COLOR CHARTS

The charts on the following two pages summarize the way that the bit-plane values select the color of the playfield pixels.

If the bit-combinations from the playfields are the following, then the color will be taken from

Single Playfield Double Playfield Color Register Number Normal Mode Hold & Modify Lum/Sat/Hue Mode bit-planes 5-4321 bit-planes 4321 Playfield 1 00000 0000 000 0 * 00001 0001 001 1 00010 0010 010 2 00011 0011 011 3 00100 0100 100 4 00101 0101 101 5 00110 0110 110 6 00111 0111 111 7

Playfield 2 01000 1000 000 ** 8 01001 1001 001 9 01010 1010 010 10 01011 1011 011 11 01100 1100 100 12 01101 1101 101 13 01110 1110 110 14 01111 1111 111 15 10000 16 10001 17 10010 18 10011 19 10100 20 10101 21 10110 22 10111 23 11000 24 11001 25 11010 26 11011 27 11100 28 11101 29 11110 30 11111 31

Contents of Each Register: Bits 15 - 12 (Unused)


Bits 11 - 8 BLUE Bits 7-4 GREEN Bits 3-0 RED All Color Registers are WRITE ONLY

  • Color Register 0 always defines the background color.
    • Selects "transparent mode" instead of selecting register 8.

% Playfield 1 = bit-planes 5,3,1

    Playfield 2 = bit-planes 6,4,2

$ NOTE: BP6 BP5 Hold/Modify (6th/5th Plane Special Mode) (if bit 10 of BPLCON = 1) 0 0 Normal Operation (Use Color Reg itself) 0 1 Hold G & B -> R = BP4-1 contents 1 0 Hold G & R -> B = BP4-1 contents 1 1 Hold B & R -> G = BP4-1 contents (for whichever was the dominant color when this mode is activated) Table 11-1: COLOR SELECTION - SINGLE PLAYFIELD

If the bit-combinations from the playfields are the following, then the color will be taken from

Single Playfield Double Playfield Color Register Number bit-planes 4321 Playfield 1 0000 00 ** 0 * 0001 01 1 0010 10 2 0011 11 3 0100 4 0101 5 0110 6 0111 7

Playfield 2 1000 00 ** 8 1001 01 9 1010 10 10 1011 111 11 1100 12 1101 13 1110 14 1111 15

Contents of Each Register: Bits 15 - 12 (Unused)


Bits 11 - 9 BLUE Bits 8-6 GREEN Bits 5-4 RED + All Color Registers are WRITE ONLY

  • Color Register 0 always defines the background color.
    • Selects "transparent mode"

+ 3 2 1 0 bits

  mr  b  g  r

See section 3.2.1

NOTE: The HIRES mode was designed specifically for "black & white" operation, to provide an 80 column text capability. Due to the design of the hardware, it is also possible for the system to accept a new 4-bit value for each of the horizonal 640 bits. However, a new high 8-bit value can only be accepted for the odd-numbered bit positions on the screen. (High 8-Bit changes remain in Normal Res. mode). SInce the text characters generally take 8 horizontal bit positions, multicolored text in HIRES mode is easily produced. The Hold & Modify feature is inoperative in HIRES mode.

% Playfield 1 = Bit-planes 3 and 1

    Playfield 2 = Bit-planes 4 and 2

Table 11-2: COLOR SELECTION - DUAL PLAYFIELDS