com.monkeycoder.monkeynes.hardware
Class GameGenie

java.lang.Object
  |
  +--com.monkeycoder.monkeynes.hardware.GameGenie
All Implemented Interfaces:
MemoryFilter

public class GameGenie
extends Object
implements MemoryFilter

This class acts like the Game Genie (™ of Galoob) game enhancement device. Please note that MemoryFilters apply ONLY to single byte reads and writes or byte range reads and writes. No filtering is done for "word" reads or writes.

Originally part of the MonkeyNES project.

Author:
David Stephens

Constructor Summary
GameGenie()
          Creates a new GameGenie.
 
Method Summary
 void addCode(GameGenieCode inCode)
          Adds a code to the list of active codes.
 int getFilteredReadValue(int inAddress, int inValue)
          This function will mutate values read from memory according to the active GameGenieCode rules.
 int getFilteredWriteValue(int inAddress, int inValue)
          This function is not used by the GameGenie so it will always return the value passed in with no further processing.
 void removeCode(GameGenieCode inCode)
          Removes a code from the list of active codes.
 void removeCode(int inIndex)
          Removes a code from the list of active codes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GameGenie

public GameGenie()
Creates a new GameGenie.

Method Detail

addCode

public void addCode(GameGenieCode inCode)
Adds a code to the list of active codes.

Parameters:
inCode - The code to add to the list of active codes.

removeCode

public void removeCode(int inIndex)
Removes a code from the list of active codes.

Parameters:
inIndex - The index of the code to remove.

removeCode

public void removeCode(GameGenieCode inCode)
Removes a code from the list of active codes. The remove method that uses index directly is recommended.

Parameters:
inCode - The exact code object to remove.

getFilteredReadValue

public int getFilteredReadValue(int inAddress,
                                int inValue)
This function will mutate values read from memory according to the active GameGenieCode rules.

Specified by:
getFilteredReadValue in interface MemoryFilter
Parameters:
inAddress - The address from which the value was read.
inValue - A value already read from memory.
Returns:
The filtered value at that address.

getFilteredWriteValue

public int getFilteredWriteValue(int inAddress,
                                 int inValue)
This function is not used by the GameGenie so it will always return the value passed in with no further processing.

Specified by:
getFilteredWriteValue in interface MemoryFilter
Parameters:
inAddress - The address of the requested value.
inValue - The value that was going to be written.
Returns:
The filtered value to write at the indicated address.