Japanese
HARDWARE ManualVDP1 User's Manual
BackForward
VDP1 User's Manual/Chapter 6 Command Table

■Color calculation

Color calculation bit: color calculation bit, bits 2 to 0
Specifies color operations for Gouraud shading, shadow, semi-brightness, and translucency.
The respective function of each bit is as follows.

 bit
 function
2
 Gouraud shading enable bit
1
 Original picture 1/2 effective bit
0
 Base 1/2 effective bit

Performs color operations on the sprite or non-texture pixel data being drawn and the pixel data already drawn in the frame buffer.
Other than replacement and shadow color calculations, the color code of the original picture is valid only when it is an RGB code. Color operations can also be performed on color bank codes, but the results are not guaranteed.
For sprites, color operations can be performed when the color mode is mode 1 (lookup table mode) and the color code of the color lookup table is an RGB code, or when mode 5 (RGB mode) is selected. When non-textured, color calculations can be performed when the non-textured color is an RGB code.
In color calculations for parts with original pictures, the transparent code is valid when SPD=0, and the end code is valid when ECD=0, and color calculations are not performed for those pixels.
For color calculations on polygons, polylines, and lines, color calculations are valid only when the non-texture color is an RGB code.
Color calculations cannot be performed at 8bit/pixel (high resolution or rotation 8).

color calculation
Color operations include replace, shadow, semi-brightness, semi-transparent, Gouraud shading, and Gouraud shading semi-brightness and Gouraud shading semi-transparent, which are a combination of the two. Here's how to specify them:
 color calculation
bit
 Base
MSB
 Original picture
 Base
 Types of color operations
 Available modes
 2
 1
 0
 Original picture
 Base
0 0 0 1 0
 replace
 No limit
 No limit
0 0 1 0 0 1
 Not rewritten
 No limit
 No limit
1
 0*1
1/2
 shadow
 RGB
0 1 0
 1/2
0
 half luminance
 RGB
 No limit
0 1 1 0 1 0
 replace
 RGB
 No limit
1
 1/2
 1/2
 half translucent
 RGB
1 0 0
 gouraud
0
 gouraud shading
 RGB
 No limit
1 0 1
 Setting prohibited (please do not set)
1 1 0
 gouraud 1/2
0
 Gouraud shading + half brightness *2
 RGB
 No limit
1 1 1 0
 gouraud
0
 gouraud shading
 RGB
 No limit
1
 gouraud 1/2
 1/2
 Gouraud shading + translucent *3
 RGB
 [Note]−: Don't care
  Original picture: Pixel data to be drawn with sprite or non-texture
  Base: pixel data already drawn in the frame buffer
  *1: The original picture (transparent pixels and end code) will be referenced.
  *2: After Gouraud operation, the data that has been saturated is halved.
  *3: After the Gouraud operation, the base is added to the data that has undergone saturation processing, making it 1/2.

Replace (color calculation mode = 0)
Replace does not perform color calculations. The parts to be drawn are written directly to the frame buffer.
Pixel data already written to the framebuffer is not affected.
Color calculations are not possible when using 8bit/pixel, so please specify replacement.

Shadow (color calculation mode = 1)
Processing differs depending on the MSB of pixel data already drawn in the frame buffer. If the MSB of the frame buffer is 0, no color calculations are performed, including replacement, and the frame buffer remains as is.
Shadowing occurs when the MSB of the frame buffer is 1.
Shadows perform color operations on pixel data that has already been written to the frame buffer. For sprites, the target area on the frame buffer is determined from the character pattern and its drawing coordinates, and for non-textures, from the drawing coordinates. The brightness of the pixel data in the target area where the part is drawn and that has already been written to the frame buffer will be halved for each of R, G, and B.
Shadows do not change the underlying MSB. Areas that were transparent remain transparent.

Shadows reduce the brightness of pixels in the framebuffer by 1/2. If you want to reduce the brightness to 1/4, set the same command table twice on VRAM. If you want to set it to 1/8, set it 3 times.
Please note that with shadows, calculations are performed on pixel data read from the writing coordinates of the original picture's pixel data, so the drawing speed will slow down. It takes 6 times as long as without color calculation.

Half brightness (color calculation mode = 2)
Half-brightness reduces the brightness of each pixel data of the drawn part by half for R, G, and B.
Pixel data already written to the framebuffer is not affected.

Semi-transparent (color calculation mode = 3)
Processing differs depending on the MSB of the frame buffer. If the MSB of the frame buffer is 0, it will be replaced.
If the MSB of the frame buffer is 1, it will be semi-transparent.
For semi-transparent, 1/2 (average) of the sum of the original image and background data is written to the frame buffer.
In the case of translucent color calculations, color calculations are performed on the pixel data of the original picture and the pixel data read from the writing coordinates. Please note that this will slow down the drawing speed. It takes 6 times as long as without color calculation.

Gouraud shading (color calculation mode = 4)
Gouraud shading performs Gouraud shading processing using the RGB code set in the Gouraud shading table.
Pixel data already written to the framebuffer is not affected.
The Gouraud shading table address is specified by CMDGRDA (command table start address + 1CH).

Gouraud shading half brightness (color calculation mode = 6)
Gouraud shading half-brightness combines Gouraud shading and half-brightness processing. After applying Gouraud shading to the parts, perform half-brightness processing.

Gouraud shading translucent (color calculation mode = 7)
Processing differs depending on the MSB of the frame buffer. If the MSB of the frame buffer is 0, it will be Gouraud shading.
If the MSB of the frame buffer is 1, Gouraud shading becomes semi-transparent.

Gouraud shading translucency combines Gouraud shading and translucency. After applying Gouraud shading to the parts, apply semi-transparency.

Original picture
For parts (sprites) with original pictures, color calculations other than shadows are only valid in RGB mode (color mode 1, lookup table is RGB code, color mode 5). Results are not guaranteed when not in RGB mode (when using characters in color bank mode).
In color calculations for parts with original pictures, the transparent code is enabled when SPD=0, and the end code is enabled when ECD=0, so color calculations are not performed for that pixel.
If you perform color calculations other than shadows in RGB mode (color mode 5) and SPD=1, the results for pixels with the transparent color code (0000H) in the original picture are not guaranteed. Color calculations are performed assuming that it is black.
If you perform color calculations other than shadows in RGB mode (color mode 5) and ECD=1, the result of the pixel with the end code (7FFFH) of the original picture is not guaranteed. Color calculations are performed assuming that it is white.
Color operations other than shadows for polygons, polylines, and lines are valid only when the non-texture color is an RGB code.

Figure 6.15 Example of color operation
┏ ━ ━ ━ ━ ━ ━ ┓ ┏━━━━━━━━━┓
                ┃  MSB=0  ┃
┃ ┌─────────┐ ┃ ┃(Pallets,┃
  │         │   ┃   etc.) ┃
┃ │Original │ ┃ ┃         ┃
  │picture  │   ┠───base──┨
┃ │         │ ┃ ┃  MSB=1  ┃
  └─────────┘   ┃ (RGB,   ┃
┃             ┃ ┃  etc.)  ┃
                ┃         ┃
┗ ━ ━ ━ ━ ━ ━ ┛ ┗━━━━━━━━━┛


Color              Color              Color              Color 
calculation        calculation        calculation        calculation
mode = 0           mode = 1           mode = 2           mode = 3 
┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓
┃                ┃ ┃                ┃ ┃                ┃ ┃                ┃
┃ ┌────────────┐ ┃ ┃                ┃ ┃ ┌────────────┐ ┃ ┃ ┌────────────┐ ┃
┃ │            │ ┃ ┃                ┃ ┃ │            │ ┃ ┃ │Replace     │ ┃
┠─┤Replace     ├─┨ ┠─┬────────────┬─┨ ┠─┤Half        ├─┨ ┠─┼────────────┼─┨
┃ │            │ ┃ ┃ │Shadow      │ ┃ ┃ │brightness  │ ┃ ┃ │Translucent │ ┃
┃ └────────────┘ ┃ ┃ └────────────┘ ┃ ┃ └────────────┘ ┃ ┃ └────────────┘ ┃
┃                ┃ ┃                ┃ ┃                ┃ ┃                ┃
┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛


Color              Color              Color              Color 
calculation        calculation        calculation        calculation
mode = 4           mode = 5           mode = 6           mode = 7 
┏━━━━━━━━━━━━━━━━┓ ┏ ━ ━ ━ ━ ━ ━ ━ ━┓ ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓
┃                ┃ ┃                ┃ ┃                ┃ ┃                ┃
┃ ┌────────────┐ ┃ ┃                ┃ ┃ ┌────────────┐ ┃ ┃ ┌────────────┐ ┃
┃ │            │ ┃ ┃                ┃ ┃ │Gouraud     │ ┃ ┃ │Gouraud     │ ┃
┠─┤Gouraud     ├─┨ ┃Settings        ┃ ┠─┤            ├─┨ ┠─┼────────────┼─┨
┃ │            │ ┃ ┃prohibited      ┃ ┃ │+Half-      │ ┃ ┃ │Gouraud+    │ ┃
┃ │            │ ┃ ┃                ┃ ┃ │brightness  │ ┃ ┃ │Translucent │ ┃
┃ └────────────┘ ┃ ┃                ┃ ┃ └────────────┘ ┃ ┃ └────────────┘ ┃
┃                ┃ ┃                ┃ ┃                ┃ ┃                ┃
┗━━━━━━━━━━━━━━━━┛ ┗ ━ ━ ━ ━ ━ ━ ━ ━┛ ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛


BackForward
HARDWARE ManualVDP1 User's Manual
Copyright SEGA ENTERPRISES, LTD., 1997