====== Color ======
The Bally Arcade can generate 256 distinct colors (between values $00–$FF).† However, only eight colors may be displayed onscreen simultaneously: four on the left side of the [[#horizontal color boundary]], and four on the right side.††
Two bits are used to represent each pixel on the screen. These two bits, along with the left/right bit that is set by crossing the horizontal color boundary, map each pixel to one of eight different color registers.
Each color register is an 8-bit register for storage of output data from the computer. The binary bits in a selected color register define the color and intensity characteristics of the associated pixel to be displayed on the screen. The three least significant bits of the register define the pixel intensity—000 for darkest and 111 for lightest. The five most significant bits define the color. Color registers reside at [[hardware:i o ports|output ports]] $0–$7; register 0 at port 0, register 1 at port 1, etc.
----
†Frank Palazzolo's [[http://www.ballyalley.com/ml/ml_docs/astrocade_palette.html|Bally Astrocade Color Table]] lists and illustrates all 256 colors.
††Manipulating color registers during [[hardware:interrupts]] can circumvent the eight-color limitation.
===== Color Register Access =====
Color registers may be accessed in three different ways:
- Individually, via [[hardware:i o ports|output ports]] ($0–$7)
- All at once, via the [[system routines:screen handler#colset|COLSET]] system routine
- All at once, via an OTIR instruction
The OTIR instruction is to port $B (register C = BH) and register B should be set to 8. The eight bytes of data pointed to by HL will go to the following color registers, assuming X is the first byte:
^ Memory Location ^ Color Register ^
| X | 7 |
| X+1 | 6 |
| X+2 | 5 |
| X+3 | 4 |
| X+4 | 3 |
| X+5 | 2 |
| X+6 | 1 |
| X+7 | 0 |
==== Horizontal Color Boundary ====
A horizontal color boundary register (HORCB) defines the horizontal position of a vertical line that divides the screen into the left and right color palettes. The boundary line can be positioned between any two adjacent screen bytes. The line is immediately to the left of the byte whose number is sent to bits 0–5 of output port $9. For example, if the horizontal color boundary is set to 0, the line will be just to the left of byte 0; if it is set to 20, the line will be between bytes 19 and 20 in the center of the screen.
The left/right bit is an additional register identifying signal supplied by the video processor in response to the data stored in the horizontal color boundary register. If a pixel is to the left of the boundary, its left/right bit is set to 1. The left/right bit is set to 0 for pixels to the right of the boundary. Color registers 0–3 are used for pixels to the right of the boundary and registers 4–7 are used for pixels to the left of the boundary. If a byte read from display RAM has the values 00 11 10 00, and was to the right of the boundary line, for example, the four pixels will be defined by color registers 0, 3, 2, and 0, respectively. However, if the byte is located to the left of the horizontal color boundary line, the four pixels will be defined by color registers 4, 7, 6, and 4 respectively.
Setting the color boundary to either 0 or 44, respectively, causes the screen to display the right or left palette exclusively. Several commercial games do this to create a unified playfield palette, at the expense of fewer colors.
The color and intensity pattern of a picture stored in memory may be quickly modified in one step by selective placement of the horizontal color boundary. For example, if the entire screen is to the right of the horizontal color boundary, the colors and intensities of the pixels will be selected from color registers 0-3. One the other hand, placing the entire screen to the left results in the colors and intensities of color registers 4-7 being utilized. In this manner, the colors and intensities of the entire picture may be altered by merely changing the address of the horizontal color boundary.
----
=== Example: Palettes and HORCB ===
{{:rectangles01.png}}
In the test program output seen above, FILL blanks screen RAM to $0, creating a solid white background. RECTAN draws three stacked rectangles measuring 120x20 pixels. Each rectangle is assigned to a different color register value. The horizontal color boundary is positioned at the exact center of the screen, so it bisects the rectangles, dividing them into their left and right color values.
==== Frame Color ====
On most CRT televisions, the area defined by RAM is slightly smaller than the visible screen, leaving extra space on all four sides of the RAM area. The color and intensity of this "frame" area is defined by the frame color number (bits 6 and 7 of [[hardware:i o ports|output port]] $9). These two bits, along with the left/right bit, point to one of the color registers that determines the frame's color and intensity.
----
=== Example: Palettes, HORCB, & Frame Color ===
{{:rectangles02.png}}
The image above uses the same RECTAN drawing routine as Example 1. However, the horizontal color boundary is set to byte 10 (40 pixels) and the frame color is set to color 2 (red/yellow). The size of the frame is determined by the value in the [[interrupts#vertical blank|Vertical Blank Register]] (VERBL), which is set to line 90.
===== Color Register Map =====
The color register map shows which color registers are used to define colors in different areas of the screen. The map assumes the background color is set to 0. If it were set to 1 then color registers 1 and 5 would be used for background instead of 0 and 4. The color boundary is between bytes X and X-1.
{{:color_register_map.png}}
===== Commercial Cartridge Palettes =====
The following palettes were used in commercial Bally Arcade titles:
//Brickyard / Clowns// (1978)
{{:brickyard.png}}
{{:clowns.png}}
; Color Table (Clowns)
L2D53: DB $B5 ; COL3L - Green
DB $52 ; COL2L - Red
DB $F8 ; COL1L - Blue
DB $07 ; COL0L - White
; Color Table (Brickyard)
L2D57: DB $B5 ; COL3R - Green
DB $52 ; COL2R - Red
DB $F8 ; COL1R - Blue
DB $77 ; COL0R - Beige/Yellow
----
//Calculator// (1978)
{{:calculator.png}}
; Colors for Calculator
L2D53: DB $76 ; Yellow-orange
DB $5C ; Red-orange
DB $00 ; Black
DB $07 ; White
----
//Dog Patch// (1980)
{{:dogpatch.png}}
L274E: ; 8 Bytes COLTBL - Color Table for Color Register
; Left side of Horizontal Color Boundary
DB $22 ; COL3L - Border (purple)
DB $64 ; COL2L - Head (orange)
DB $74 ; COL1L - Body (gold)
DB $07 ; COL0L - Background (white)
; Right side of Horizontal Color Boundary
DB $22 ; COL3R - Border (purple)
DB $64 ; COL2R - Head (orange)
DB $C8 ; COL1R - Body (green)
DB $07 ; COL0R - Background (white)
----
//Football// (1979)
{{:football-play01.png}}
; Color Lists (Used when screen changed needed)
;
COLIST1: DB 248,119,247,163 ; Color List
COLIST2: DB 248,119,247,161 ; Color List
COLIST3: DB 248,119,247,163 ; Color List
COLIST4: DB 248,247,119,163 ; Color List
COLIST5: DB 248,247,119,161 ; Color List
COLIST6: DB 248,247,119,163 ; Color List
COLIST7: DB 248,119,247,163 ; Color List
//Football// has seven color lists, but they contain only five unique colors: $F7 (pale blue), $F8 (blue), $77 (yellow), $A3 (green), $A1 (darker green).
----
//Star Battle// (1978)
{{:starbattle.png}}
; Color Table
L266D: DB $0F ; COL3L - Pink
DB $0F ; COL2L - Pink
DB $02 ; COL1L - Dark Gray
DB $F8 ; COL0L - Dark Blue
DB $0F ; COL3R -
DB $0F ; COL2R -
DB $02 ; COL1R -
DB $F8 ; COL0R -
The table above defines //Star Battle//'s color palette at initialization, but the game does extensive horizontal color boundary and color register manipulation. Additional colors traceable in the source code are $FB (lighter blue), $64 (orange), $07 (white), and possibly $54 (darker orange). There are other color register writes that are more difficult to track since they are read from RAM.
----
[NM:88-91]