com.monkeycoder.monkeynes.hardware
Class NesPalette

java.lang.Object
  |
  +--com.monkeycoder.monkeynes.hardware.NesPalette

public class NesPalette
extends Object

This class defines the built in 64 color palette of the NES. Only 52 of those colors are unique. It allows access to predefined colors as both Java specific Color objects and as raw RGB integer values. It also supports updating the palette dynamically which the NES does not.

Originally part of the MonkeyNES project.

Author:
David Stephens

Field Summary
static int PAL_BACKGROUND_ADDRESS
           
static int PAL_SPRITE_ADDRESS
           
 
Constructor Summary
NesPalette()
          Creates a new NesPalette and initializes it to the color values a real NES uses.
 
Method Summary
 Color getColor(int index)
          Returns the color at the requested index.
 int getColorRgb(int index)
          Returns the color at the requested index as an RGB integer value.
 void setColor(int index, Color value)
          Sets a new color value into the palette.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAL_BACKGROUND_ADDRESS

public static final int PAL_BACKGROUND_ADDRESS
See Also:
Constant Field Values

PAL_SPRITE_ADDRESS

public static final int PAL_SPRITE_ADDRESS
See Also:
Constant Field Values
Constructor Detail

NesPalette

public NesPalette()
Creates a new NesPalette and initializes it to the color values a real NES uses.

Method Detail

getColor

public Color getColor(int index)
Returns the color at the requested index.

Parameters:
index - The requested index.
Returns:
The color found at the requested index.

getColorRgb

public int getColorRgb(int index)
Returns the color at the requested index as an RGB integer value.

Parameters:
index - The requested index.
Returns:
The color found at the requested index.

setColor

public void setColor(int index,
                     Color value)
Sets a new color value into the palette. Technically this isn't allowed by the NES but perhaps user tweaks will be allowed.

Parameters:
index - The index that will get the new color.
value - The new color for the specified index.