Main Page | Namespace List | Class List | Directories | File List | Namespace Members | Class Members | File Members

mpg::Password Class Reference

#include <Password.hh>

List of all members.


Detailed Description

Class to encapsulate a Metroid Password.

Definition at line 58 of file Password.hh.

Public Member Functions

 Password ()
 Creates a new blank password.
 Password (const wxString &password, bool fixChecksum=false) throw (InvalidPasswordException)
 Creates a password from a Metroid password.
bool getBit (int bit) const throw (std::out_of_range)
 Gets a bit from the raw password data.
void setBit (int bit, bool value=true) throw (std::out_of_range)
 Sets a bit in the raw password data.
const wxString & getEncoded () const
 Gets the encoded Metroid password encapsulated by this Password.
wxUint32 getGameTime () const
 Gets the game time in ticks (1 tick = ~4 seconds).
void setGameTime (wxUint32 time)
 Sets the game time.
unsigned char getMissiles () const
 Gets the number of missiles held by Samus.
void setMissiles (unsigned char missiles)
 Sets the number of missiles held by Samus.
unsigned char getShift () const
 Gets the shift byte used by this Password.
void setShift (unsigned char shift)
 Sets the shift byte used by this Password.

Static Public Attributes

static const wxString ALPHABET

Private Member Functions

unsigned char calcChecksum () const
 Calculates the checksum value for this Password.
void decode (const wxString &password, bool fixChecksum) throw (InvalidPasswordException)
 Decodes a Metroid password into our raw format.
void encode ()
 Encodes the raw password data into a Metroid password.

Private Attributes

wxString encoded
unsigned char data [18]

Static Private Attributes

static const int MISSILE_COUNT_BYTE = 10
static const int GAME_TIME_BYTE = 11
static const int SHIFT_BYTE = 16
static const int CHECKSUM_BYTE = 17
static const unsigned char SPACE_VALUE = 0xFF


Constructor & Destructor Documentation

Password::Password  ) 
 

Creates a new blank password.

Definition at line 38 of file Password.cc.

Password::Password const wxString &  password,
bool  fixChecksum = false
throw (InvalidPasswordException)
 

Creates a password from a Metroid password.

Parameters:
password The Metroid password.
fixChecksum true if the checksum should be fixed to force a valid password; false to accept only valid Metroid passwords.
Exceptions:
InvalidPasswordException if an invalid password is supplied.

Definition at line 43 of file Password.cc.


Member Function Documentation

unsigned char Password::calcChecksum  )  const [private]
 

Calculates the checksum value for this Password.

Returns:
The checksum.

Definition at line 108 of file Password.cc.

void Password::decode const wxString &  password,
bool  fixChecksum
throw (InvalidPasswordException) [private]
 

Decodes a Metroid password into our raw format.

Parameters:
password The password to decode.
fixChecksum true if the checksum should be fixed to force a valid password; false to accept only valid Metroid passwords.
Exceptions:
InvalidPasswordException if the given password is invalid.

Definition at line 118 of file Password.cc.

void Password::encode  )  [private]
 

Encodes the raw password data into a Metroid password.

Definition at line 187 of file Password.cc.

bool Password::getBit int  bit  )  const throw (std::out_of_range)
 

Gets a bit from the raw password data.

Parameters:
bit The bit to get (1-128).
Returns:
true if the bit is set; false otherwise.
Exceptions:
std::out_of_range if the bit is outside the range [0,127].

Definition at line 56 of file Password.cc.

const wxString & mpg::Password::getEncoded  )  const [inline]
 

Gets the encoded Metroid password encapsulated by this Password.

Returns:
The Metroid password.

Definition at line 186 of file Password.hh.

wxUint32 Password::getGameTime  )  const
 

Gets the game time in ticks (1 tick = ~4 seconds).

Returns:
The game time in ticks.

Definition at line 82 of file Password.cc.

unsigned char mpg::Password::getMissiles  )  const [inline]
 

Gets the number of missiles held by Samus.

Returns:
The number of missiles.

Definition at line 187 of file Password.hh.

unsigned char mpg::Password::getShift  )  const [inline]
 

Gets the shift byte used by this Password.

Returns:
The shift byte.

Definition at line 189 of file Password.hh.

void Password::setBit int  bit,
bool  value = true
throw (std::out_of_range)
 

Sets a bit in the raw password data.

Parameters:
bit the bit to set (1-128).
value true to set the bit; false to clear it.
Exceptions:
std::out_of_range if the bit is outside the range [0,127].

Definition at line 66 of file Password.cc.

void Password::setGameTime wxUint32  time  ) 
 

Sets the game time.

Parameters:
time The game time in ticks (1 tick = ~4 seconds).

Definition at line 89 of file Password.cc.

void Password::setMissiles unsigned char  missiles  ) 
 

Sets the number of missiles held by Samus.

Parameters:
missiles The number of missiles.

Definition at line 96 of file Password.cc.

void Password::setShift unsigned char  shift  ) 
 

Sets the shift byte used by this Password.

Parameters:
shift The shift byte.

Definition at line 102 of file Password.cc.


Member Data Documentation

const wxString Password::ALPHABET [static]
 

const int mpg::Password::CHECKSUM_BYTE = 17 [static, private]
 

Definition at line 66 of file Password.hh.

unsigned char mpg::Password::data[18] [private]
 

Definition at line 61 of file Password.hh.

wxString mpg::Password::encoded [private]
 

Definition at line 60 of file Password.hh.

const int mpg::Password::GAME_TIME_BYTE = 11 [static, private]
 

Definition at line 64 of file Password.hh.

const int mpg::Password::MISSILE_COUNT_BYTE = 10 [static, private]
 

Definition at line 63 of file Password.hh.

const int mpg::Password::SHIFT_BYTE = 16 [static, private]
 

Definition at line 65 of file Password.hh.

const unsigned char mpg::Password::SPACE_VALUE = 0xFF [static, private]
 

Definition at line 67 of file Password.hh.


Generated on Sun Oct 2 01:02:58 2005 for Metroid Password Generator by  doxygen 1.4.2