Difference between revisions of "Palettes"

From NeoGeo Development Wiki
Jump to: navigation, search
m (Special colors)
m (Undo revision 6150 by Hpman (talk) I is stoopid)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[File:Palmap.png|thumb|Palette organisation]]
+
[[File:Palmap.png|500px|thumb|Palettes organization.]]
There are 2 banks (one usable at a time) of 256 palettes available. Each palette has 16 entries, the first is the transparent index ("color 0"), the 15 others are real colors, made of 16bit RGB definitions.
+
There are 2 banks (one usable at a time) of 256 palettes available. Each palette has 16 color entries, the first being the transparent index ("color 0"), the 15 others are real colors, made of 16-bit RGB definitions.
  
[[Sprites|Sprite]] tiles can use any of the 256 palettes, while the [[Fix layer|fix]] tiles can only use the 16 firsts.
+
[[Sprites|Sprite]] tiles can use '''any''' of the 256 palettes, while the [[Fix layer|fix]] tiles can '''only use the first 16'''.
  
The maximum number of colors on screen without [[timer interrupt]] tricks is: 256 palettes * 15 colors + 1 backdrop color = '''3841''' (out of 2^16 = 65536).
+
The maximum number of colors on screen without [[timer interrupt]] tricks is: 256 palettes * 15 colors = '''3840''' (out of 2^16 = 65536).
  
==Special colors==
+
=Color format=
  
There are two special colors used:
+
See [[colors]].
  
*The first color of the palette bank ($400000) is the [[reference color]] for the video output. It has to be $8000 (black) otherwise monitors won't be happy and other colors won't be displayed correctly.
+
=Access=
*The last color of the palette bank ($401FFE) is the [[backdrop color]] (the color of the backmost "layer" on the screen). Caused by line buffers in {{Chipname|NEO-B1}} being cleared to $FFF (Last color of last palette).
 
  
==Color format==
+
Palettes are located at $400000 in the [[68k memory map]]. They're physically stored in the [[palette RAM]].
  
[[File:Pal perfect.png|thumb|All 65536 (2^16) possible NeoGeo colors.]]
+
Byte writes are allowed, but the value will be written to both bytes of the word (/WE pins are tied together).
  
D
+
The palettes can be read and written at full speed at any time. During active display, since the CPU has priority over rendering, the color read or written will be displayed during at least one pixel, resulting in noticeable "snow" if multiple colors are updated. A workaround is to update the palettes only during blanking (horizontal or vertical), over multiple frames if necessary.
<span style="color:red;">R0</span>
 
<span style="color:green;">G0</span>
 
<span style="color:blue;">B0</span>
 
<span style="color:red;">R4 R3 R2 R1</span>
 
<span style="color:green;">G4 G3 G2 G1</span>
 
<span style="color:blue;">B4 B3 B2 B1</span>
 
  
{{Template:16BitRegister|[[Video DAC|Dark bit]]|1|R0|1|G0|1|B0|1|R4|1|R3|1|R2|1|R1|1|G4|1|G3|1|G2|1|G1|1|B4|1|B3|1|B2|1|B1|1|}}
+
The bank can be set by doing a byte write to registers {{Reg|REG_PALBANK1}} or {{Reg|REG_PALBANK0}}.
  
Each color component is coded with 6 bits, with 1 common LSB, effectively making full use of the 16 color definition bits.
+
=Special colors=
  
The top 4 bits of each component fits in 3 nibbles, making it easy to write or guess color values ($0F00 is red, $00F0, is green...).
+
There are two special colors used:
 
 
==Access==
 
 
 
Palettes are located at $400000 in the [[68k memory map]], and they're physically stored in the [[palette RAM]].
 
 
 
Byte access may be allowed, but it will trash the corresponding word's other byte (/WE are tied together). Maybe [[NEO-C1]] doesn't assert {{Sig|PAL|PAL}} during byte access ?
 
 
 
Palette can be read and written at any time. During active display, since the CPU has priority over rendering, the color read or written will be displayed for at least one pixel, resulting in noticeable "snow" if multiple palettes are updated. A workaround is to update the palette only during blanking (horizontal or vertical), over multiple frames if necessary.
 
 
 
The bank can be set by writing a byte to registers {{Reg|REG_PALBANK1}} or {{Reg|REG_PALBANK0}}.
 
 
 
=Converter=
 
  
<div id="color-converter"></div>
+
* The first color of the palette bank ($400000) is the [[reference color|'''R'''eference color]] for the video output. It always has to be pure black ($8000) otherwise monitors won't be happy and other colors won't be displayed correctly.
<div id="cconvresult"></div>
+
* The last color of the palette bank ($401FFE) is the [[backdrop color|'''B'''ackdrop color]], the color of the backmost [[layer]] on the screen. Caused by line buffers in {{Chipname|NEO-B1}} being cleared to $FFF (referencing the last color of the last palette).
  
 
[[Category:Video system]]
 
[[Category:Video system]]
[[Category:Interactive pages]]
 

Latest revision as of 21:01, 30 June 2018

Palettes organization.

There are 2 banks (one usable at a time) of 256 palettes available. Each palette has 16 color entries, the first being the transparent index ("color 0"), the 15 others are real colors, made of 16-bit RGB definitions.

Sprite tiles can use any of the 256 palettes, while the fix tiles can only use the first 16.

The maximum number of colors on screen without timer interrupt tricks is: 256 palettes * 15 colors = 3840 (out of 2^16 = 65536).

Color format

See colors.

Access

Palettes are located at $400000 in the 68k memory map. They're physically stored in the palette RAM.

Byte writes are allowed, but the value will be written to both bytes of the word (/WE pins are tied together).

The palettes can be read and written at full speed at any time. During active display, since the CPU has priority over rendering, the color read or written will be displayed during at least one pixel, resulting in noticeable "snow" if multiple colors are updated. A workaround is to update the palettes only during blanking (horizontal or vertical), over multiple frames if necessary.

The bank can be set by doing a byte write to registers REG_PALBANK1 or REG_PALBANK0.

Special colors

There are two special colors used:

  • The first color of the palette bank ($400000) is the Reference color for the video output. It always has to be pure black ($8000) otherwise monitors won't be happy and other colors won't be displayed correctly.
  • The last color of the palette bank ($401FFE) is the Backdrop color, the color of the backmost layer on the screen. Caused by line buffers in NEO-B1 being cleared to $FFF (referencing the last color of the last palette).