com.monkeycoder.monkeynes.hardware
Class GameGenieCode

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

public class GameGenieCode
extends Object

This class holds a translated code, and provides static methods for translating codes.

Originally part of the MonkeyNES project.

Author:
David Stephens

Field Summary
static String[] letters
          A lookup array of letters used by the Original Game Genie.
 
Constructor Summary
GameGenieCode(int inAddress, int inValue)
          Creates a new GameGenieCode with the supplied address and value.
GameGenieCode(int inAddress, int inValue, int inTest)
          Creates a new GameGenieCode with the supplied address, value, and test value.
 
Method Summary
 int getAddress()
          Returns the 16-bit address that should be affected by this code.
 String getCode()
          Returns this GameGenieCode object as a code in the original form used by the Game Genie.
 int getTest()
          Returns the value that must be in memory at the specified address for the altered value to be returned.
 int getValue()
          Returns the value that should be returned instead of the value in memory.
 String toString()
          Creates a String with a reverse engineered code and the data values from this GameGenieCode.
static String translate(GameGenieCode inCode)
          Translates any GameGenieCode object into a code in the original form used by the Game Genie.
static GameGenieCode translate(String inCode)
          Expects a code in the original form used by the Game Genie and will translate the information into a GameGenieCode object.
 boolean usesTest()
          Returns whether or not this code uses the test value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

letters

public static final String[] letters
A lookup array of letters used by the Original Game Genie. The letters are indexed by their values.

Constructor Detail

GameGenieCode

public GameGenieCode(int inAddress,
                     int inValue)
Creates a new GameGenieCode with the supplied address and value. This is the equivelent of a 6 character code. A GameGenieCode created with this function will report false for usesTest() and will unconditionally return the inValue.

Parameters:
inAddress - The 16-bit address that may be changed by this code.
inValue - The value that will be provided instead of the memory value.
See Also:
usesTest()

GameGenieCode

public GameGenieCode(int inAddress,
                     int inValue,
                     int inTest)
Creates a new GameGenieCode with the supplied address, value, and test value. This is the equivelent of an 8 character code. A GameGenieCode created with this function will report true for usesTest().

Parameters:
inAddress - The 16-bit address that may be changed by this code.
inValue - The value that will be provided instead of the memory value.
inTest - The value that the original memory value is compared against. If the value matches inValue is the response, otherwise the value in memory is returned unaltered.
See Also:
usesTest()
Method Detail

getAddress

public int getAddress()
Returns the 16-bit address that should be affected by this code.

Returns:
The 16-bit address that should be affected by this code.

getValue

public int getValue()
Returns the value that should be returned instead of the value in memory.

Returns:
The value that should be returned instead of the value in memory.

getTest

public int getTest()
Returns the value that must be in memory at the specified address for the altered value to be returned.

Returns:
The test value.

usesTest

public boolean usesTest()
Returns whether or not this code uses the test value.

Returns:
Whether or not this code uses the test value.

getCode

public String getCode()
Returns this GameGenieCode object as a code in the original form used by the Game Genie.

Returns:
An original Game Genie code.

toString

public String toString()
Creates a String with a reverse engineered code and the data values from this GameGenieCode.

Overrides:
toString in class Object
Returns:
A String containing the resulting data.

translate

public static GameGenieCode translate(String inCode)
Expects a code in the original form used by the Game Genie and will translate the information into a GameGenieCode object.

Parameters:
inCode - An original Game Genie code.
Returns:
A GameGenieCode object with the translated information.

translate

public static String translate(GameGenieCode inCode)
Translates any GameGenieCode object into a code in the original form used by the Game Genie.

Parameters:
inCode - A GameGenieCode object.
Returns:
An original Game Genie code.