com.monkeycoder.monkeynes.hardware
Class DmaManager

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

public class DmaManager
extends Object

This class manages DMA activity within the system.

Originally part of the MonkeyNES project.

Author:
David Stephens

Field Summary
static int REG_JOYSTICK_PORT_1
           
static int REG_JOYSTICK_PORT_2
           
static int REG_PPU_CONTROL_1
           
static int REG_PPU_CONTROL_2
           
static int REG_PPU_HORZ_VERT_SCROLL
           
static int REG_PPU_STATUS
           
static int REG_SPRITE_DATA
           
static int REG_SPRITE_PAGE_WRITE
           
static int REG_SPRITE_START_ADDRESS
           
static int REG_VRAM_DATA
           
static int REG_VRAM_START_ADDRESS
           
 
Constructor Summary
DmaManager(NesHardware inNes)
          Creates a new DmaManager.
 
Method Summary
 void dmaJoyportRead(int inPortNum)
          Used to read button values from a joystick port.
 void dmaJoyportWrite(int inPortNum)
          Used to reset or clear a joystick port.
 void dmaPpuHorzVertScrollWrite()
          Transfers the horizontal and then vertical scroll values into internal PPU registers.
 void dmaPpuStatusRead()
           
 void dmaSetupSpriteWrite()
          Sets up a byte-wise transfer to sprite memory.
 void dmaSpritePageWrite()
          Transfers a full 256 byte page of main memory into sprite memory.
 void dmaSpriteWrite()
          Transfers one byte at a time to the current address in sprite memory.
 void dmaVramRead()
          Transfers one byte at a time from the current address in video memory.
 void dmaVramSetupAccess()
          Sets up byte-wise access to video memory for reading or writing.
 void dmaVramWrite()
          Transfers one byte at a time to the current address in video memory.
 void readManager(int inAddress)
          This function takes the address of a main memory read and translates it into a dmaXXX() function call as appropriate.
 void writeManager(int inAddress)
          This function takes the address of a main memory write and translates it into a dmaXXX() function call as appropriate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REG_PPU_CONTROL_1

public static final int REG_PPU_CONTROL_1
See Also:
Constant Field Values

REG_PPU_CONTROL_2

public static final int REG_PPU_CONTROL_2
See Also:
Constant Field Values

REG_PPU_STATUS

public static final int REG_PPU_STATUS
See Also:
Constant Field Values

REG_SPRITE_START_ADDRESS

public static final int REG_SPRITE_START_ADDRESS
See Also:
Constant Field Values

REG_SPRITE_DATA

public static final int REG_SPRITE_DATA
See Also:
Constant Field Values

REG_PPU_HORZ_VERT_SCROLL

public static final int REG_PPU_HORZ_VERT_SCROLL
See Also:
Constant Field Values

REG_VRAM_START_ADDRESS

public static final int REG_VRAM_START_ADDRESS
See Also:
Constant Field Values

REG_VRAM_DATA

public static final int REG_VRAM_DATA
See Also:
Constant Field Values

REG_SPRITE_PAGE_WRITE

public static final int REG_SPRITE_PAGE_WRITE
See Also:
Constant Field Values

REG_JOYSTICK_PORT_1

public static final int REG_JOYSTICK_PORT_1
See Also:
Constant Field Values

REG_JOYSTICK_PORT_2

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

DmaManager

public DmaManager(NesHardware inNes)
Creates a new DmaManager.

Parameters:
inNes - The NES hardware this DMA Manager will be managing.
Method Detail

writeManager

public void writeManager(int inAddress)
This function takes the address of a main memory write and translates it into a dmaXXX() function call as appropriate.

Parameters:
inAddress - The address of main memory that was written.

readManager

public void readManager(int inAddress)
This function takes the address of a main memory read and translates it into a dmaXXX() function call as appropriate.

Parameters:
inAddress - The address of main memory that was written.

dmaPpuStatusRead

public void dmaPpuStatusRead()

dmaSetupSpriteWrite

public void dmaSetupSpriteWrite()
Sets up a byte-wise transfer to sprite memory. This DMA is started by writing the sprite memory address to $2003.


dmaSpriteWrite

public void dmaSpriteWrite()
Transfers one byte at a time to the current address in sprite memory. Each call to this function writes to the target address and increments the target address. This DMA is started by writing the data byte to $2004.


dmaPpuHorzVertScrollWrite

public void dmaPpuHorzVertScrollWrite()
Transfers the horizontal and then vertical scroll values into internal PPU registers. This DMA is started by writing the data byte to $2005.


dmaSpritePageWrite

public void dmaSpritePageWrite()
Transfers a full 256 byte page of main memory into sprite memory. This DMA is started by writing the page byte to $4014.


dmaVramSetupAccess

public void dmaVramSetupAccess()
Sets up byte-wise access to video memory for reading or writing. This DMA is started by writing the high byte then the low byte to $2006.


dmaVramWrite

public void dmaVramWrite()
Transfers one byte at a time to the current address in video memory. Each call to this function writes to the target address and increments the target address. This DMA is started by writing the data byte to $2007.


dmaVramRead

public void dmaVramRead()
Transfers one byte at a time from the current address in video memory. Each call to this function reads from the target address and increments the target address. This DMA is started by reading data from to $2007. To accurately simulate the "throw away read" effect, this function does not alter the contents of $2007 on the 1st read.


dmaJoyportWrite

public void dmaJoyportWrite(int inPortNum)
Used to reset or clear a joystick port. This DMA is started by writing to $4016 for joystick port 1, and to $4017 for joystick port 2.

Parameters:
inPortNum - The joystick port for which the DMA was activated.

dmaJoyportRead

public void dmaJoyportRead(int inPortNum)
Used to read button values from a joystick port. This DMA is started by reading from $4016 for joystick port 1, and from $4017 for joystick port 2.

Parameters:
inPortNum - The joystick port for which the DMA was activated.