com.monkeycoder.monkeynes.hardware
Class NesPpu

java.lang.Object
  |
  +--java.util.Observable
        |
        +--com.monkeycoder.monkeynes.hardware.NesPpu

public class NesPpu
extends Observable

This is the graphics processor of the NES. It manages everything related to drawing sprites and the background for a game.

Originally part of the MonkeyNES project.

Author:
David Stephens

Field Summary
static int CMD_BACKGROUND_COLOR
           
static int CMD_CLEAR_VIDEO_BUFFER
           
static int CMD_DRAW_BACKGROUND
           
static int CMD_DRAW_SPRITES
           
static int CMD_SEND_VIDEO_UPDATE
           
static int SPR_ATTRIBUTES
           
static int SPR_BG_PRIORITY
           
static int SPR_COLOR_HIGH
           
static int SPR_COLOR_LOW
           
static int SPR_H_FLIP
           
static int SPR_TILE_NUMBER
           
static int SPR_V_FLIP
           
static int SPR_X_COORD
           
static int SPR_Y_COORD
           
 
Constructor Summary
NesPpu(NesMainMemory inMainMem, NesVideoMemory inVidMem, NesSpriteMemory inSpriteMem, NesPalette inPalette)
          Creates a new NesPpu.
 
Method Summary
 void doCycle()
          Called to tell the PPU to do a cycle.
 int[] getVideoData()
          Returns the PPU internal raw video buffer.
 boolean isPowerOn()
          Returns whether or not the power is on in the PPU.
 void powerOff()
          Called to tell the PPU that power is now off.
 void powerOn()
          Called to tell the PPU that power is now on.
 void reset()
          Called to tell the PPU that a reset has occurred.
 void setHorzScroll(int inHorzScroll)
          Sets the horizontal scroll value.
 void setVertScroll(int inVertScroll)
          Sets the vertical scroll value.
 void testExecuteCommand(int inCommand, int inParam)
          For use by the OpCode Test Shell.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CMD_DRAW_SPRITES

public static final int CMD_DRAW_SPRITES
See Also:
Constant Field Values

CMD_DRAW_BACKGROUND

public static final int CMD_DRAW_BACKGROUND
See Also:
Constant Field Values

CMD_BACKGROUND_COLOR

public static final int CMD_BACKGROUND_COLOR
See Also:
Constant Field Values

CMD_CLEAR_VIDEO_BUFFER

public static final int CMD_CLEAR_VIDEO_BUFFER
See Also:
Constant Field Values

CMD_SEND_VIDEO_UPDATE

public static final int CMD_SEND_VIDEO_UPDATE
See Also:
Constant Field Values

SPR_Y_COORD

public static final int SPR_Y_COORD
See Also:
Constant Field Values

SPR_TILE_NUMBER

public static final int SPR_TILE_NUMBER
See Also:
Constant Field Values

SPR_ATTRIBUTES

public static final int SPR_ATTRIBUTES
See Also:
Constant Field Values

SPR_X_COORD

public static final int SPR_X_COORD
See Also:
Constant Field Values

SPR_V_FLIP

public static final int SPR_V_FLIP
See Also:
Constant Field Values

SPR_H_FLIP

public static final int SPR_H_FLIP
See Also:
Constant Field Values

SPR_BG_PRIORITY

public static final int SPR_BG_PRIORITY
See Also:
Constant Field Values

SPR_COLOR_HIGH

public static final int SPR_COLOR_HIGH
See Also:
Constant Field Values

SPR_COLOR_LOW

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

NesPpu

public NesPpu(NesMainMemory inMainMem,
              NesVideoMemory inVidMem,
              NesSpriteMemory inSpriteMem,
              NesPalette inPalette)
Creates a new NesPpu.

Parameters:
inMainMem - Main memory bank accessed by this PPU.
inVidMem - Video memory bank accessed by this PPU.
inSpriteMem - Sprite memory bank accessed by this PPU.
Method Detail

powerOn

public void powerOn()
Called to tell the PPU that power is now on.


powerOff

public void powerOff()
Called to tell the PPU that power is now off.


reset

public void reset()
Called to tell the PPU that a reset has occurred.


isPowerOn

public boolean isPowerOn()
Returns whether or not the power is on in the PPU.

Returns:
Whether or not the power is on.

doCycle

public void doCycle()
Called to tell the PPU to do a cycle. What this means depends entirely on what state the PPU is in at the time.


getVideoData

public int[] getVideoData()
Returns the PPU internal raw video buffer.

Returns:
The PPU internal raw video buffer.

setHorzScroll

public void setHorzScroll(int inHorzScroll)
Sets the horizontal scroll value.

Parameters:
inHorzScroll - The horizontal scroll value.

setVertScroll

public void setVertScroll(int inVertScroll)
Sets the vertical scroll value.

Parameters:
inVertScroll - The vertical scroll value.

testExecuteCommand

public void testExecuteCommand(int inCommand,
                               int inParam)
For use by the OpCode Test Shell. This function allows the test shell to request internal PPU activities to take place.

Parameters:
inCommand - The command to execute.
inParam - Additional parameter for the command or 0 if not used (0 is a valid value if it is used by the specified command).
See Also:
OpCodeTestShellGui