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

hack4u::SaveSlot Class Reference

#include <SaveSlot.hh>

List of all members.


Detailed Description

A class representing a single game save slot.

Definition at line 130 of file SaveSlot.hh.

Public Member Functions

 SaveSlot (const unsigned char *data)
 Constructor for a SaveSlot.
 ~SaveSlot ()
 Destructor for a SaveSlot.
unsigned char checksum () const
 Generates the checksum for the current data.
bool isValid () const
 Queries if this save slot is valid.
bool isModified () const
 Queries if this SaveSlot has been modified.
int getPhase (int moon) const
 Gets the current phase of one of the moons.
void setPhase (int trammel, int felucca)
 Sets the phases of the moons.
wxString getHerosName () const
 Gets the Hero's Name.
void setHerosName (wxString &name)
 Sets the Hero's Name.
int getVirtue (int virtue) const
 Gets the value for one of the eight virtues.
void setVirtue (int virtue, unsigned char value)
 Sets the value for one of the eight virtues.
int getMember (int position) const
 Gets the party member at a given position.
void setMember (int position, int character)
 Sets the party member at a given position.
bool hasStone (int stone) const
 Queries if the party has a particular stone in their inventory.
void setStone (int stone, bool give=true)
 Sets whether the party has a particular stone or not.
bool hasRune (int rune) const
 Queries whether the party has a particular rune or not.
void setRune (int rune, bool give=true)
 Sets whether the party has a particular rune of not.
bool hasMagic (int magic) const
 Queries whether the party has a particular magic or not.
void setMagic (int magic, bool give=true)
 Sets whether the party has a particular magic of not.
int getHerb (int herb) const
 Gets the current amount of a particular herb the party has.
void setHerb (int herb, unsigned char value)
 Sets the amount of a particular herb the party has.
wxInt16 getGold () const
 Gets the amount of gold held by the party.
void setGold (wxInt16 gold)
 Sets the amount of gold held by the party.
int getTool (int tool) const
 Gets the amount of a tool the party has.
void setTool (int tool, unsigned char value=1)
 Sets the amount of a tool the party has.
int getEquipment (int character, int slot) const
 Gets the item held by a particular player in a particular slot.
void setEquipment (int character, int slot, unsigned char value)
 Sets the item held by a particular player in a particular slot.
int getLevel (int character) const
 Gets the level of a character.
void setLevel (int character, unsigned char value)
 Sets the level of a character.
wxInt16 getCurrentHP (int character) const
 Gets the current HP of a character.
void setCurrentHP (int character, wxInt16 value)
 Sets the current HP of a character.
wxInt16 getMaxHP (int character) const
 Gets the max HP of a character.
void setMaxHP (int character, wxInt16 value)
 Sets the max HP of a character.
int getCurrentMP (int character) const
 Gets the current MP of a character.
void setCurrentMP (int character, unsigned char value)
 Sets the current MP of a character.
int getMaxMP (int character) const
 Gets the max MP of a character.
void setMaxMP (int character, unsigned char value)
 Sets the max MP of a charcter.
int getStrength (int character) const
 Gets the strength of a character.
void setStrength (int character, unsigned char value)
 Sets the strength of a charater.
int getIntelligence (int character) const
 Gets the intelligence of a character.
void setIntelligence (int character, unsigned char value)
 Sets the intelligence of a character.
int getDexterity (int character) const
 Gets the dexterity of a character.
void setDexterity (int character, unsigned char value)
 Sets the dexterity of a character.
wxInt16 getExperience (int character) const
 Gets the experience of a character.
void setExperience (int character, wxInt16 value)
 Sets the experience of a character.

Private Member Functions

void setModified (bool modified=true)
 Sets whether this slot is modified or not.

Static Private Member Functions

static unsigned char toNES (char letter)
 Translates an ASCII character to the Ultima alphabet.
static char fromNES (unsigned char letter)
 Translates an Ultima alphabet character to ASCII.

Private Attributes

unsigned char * nvram
bool valid
bool modified

Static Private Attributes

static const int CHECKSUM_XORS []
 Array of checksum xors used by the sanity algorithm.

Friends

class MainFrame


Constructor & Destructor Documentation

SaveSlot::SaveSlot const unsigned char *  data  ) 
 

Constructor for a SaveSlot.

Parameters:
data The SRAM data

Definition at line 45 of file SaveSlot.cc.

SaveSlot::~SaveSlot  ) 
 

Destructor for a SaveSlot.

Definition at line 58 of file SaveSlot.cc.


Member Function Documentation

unsigned char SaveSlot::checksum  )  const
 

Generates the checksum for the current data.

Returns:
The checksum.

Definition at line 62 of file SaveSlot.cc.

char SaveSlot::fromNES unsigned char  letter  )  [static, private]
 

Translates an Ultima alphabet character to ASCII.

Parameters:
letter The letter to translate.
Returns:
The translated character.

Definition at line 381 of file SaveSlot.cc.

wxInt16 SaveSlot::getCurrentHP int  character  )  const
 

Gets the current HP of a character.

Parameters:
character The character. Valid values are in the Character enumeration.
Returns:
The current HP.

Definition at line 274 of file SaveSlot.cc.

int SaveSlot::getCurrentMP int  character  )  const
 

Gets the current MP of a character.

Parameters:
character The character. Valid values are in the Character enumeration.
Returns:
The current MP.

Definition at line 300 of file SaveSlot.cc.

int SaveSlot::getDexterity int  character  )  const
 

Gets the dexterity of a character.

Parameters:
character The character. Valid values are in the Character enumeration.
Returns:
The dexterity.

Definition at line 336 of file SaveSlot.cc.

int SaveSlot::getEquipment int  character,
int  slot
const
 

Gets the item held by a particular player in a particular slot.

Parameters:
character The character whose equipment to get. Valid values are in the Character enumeration.
slot The inventory slot (0-5).
Returns:
The equipment item.

Definition at line 256 of file SaveSlot.cc.

wxInt16 SaveSlot::getExperience int  character  )  const
 

Gets the experience of a character.

Parameters:
character The character. Valid values are in the Character enumeration.
Returns:
The experience.

Definition at line 345 of file SaveSlot.cc.

wxInt16 SaveSlot::getGold  )  const
 

Gets the amount of gold held by the party.

Returns:
The amount of gold.

Definition at line 234 of file SaveSlot.cc.

int SaveSlot::getHerb int  herb  )  const
 

Gets the current amount of a particular herb the party has.

Parameters:
herb The herb whose value to get. Valid values are any of the members of the Herbs enumeration.
Returns:
The amount of the particular herb the party has.

Definition at line 225 of file SaveSlot.cc.

wxString SaveSlot::getHerosName  )  const
 

Gets the Hero's Name.

Returns:
wxString with the name of the Hero translated to a proper PC alphabet.

Definition at line 93 of file SaveSlot.cc.

int SaveSlot::getIntelligence int  character  )  const
 

Gets the intelligence of a character.

Parameters:
character The character. Valid values are in the Character enumeration.
Returns:
The intelligence.

Definition at line 327 of file SaveSlot.cc.

int SaveSlot::getLevel int  character  )  const
 

Gets the level of a character.

Parameters:
character The character. Valid values are in the Character enumeration.
Returns:
The character's level.

Definition at line 265 of file SaveSlot.cc.

wxInt16 SaveSlot::getMaxHP int  character  )  const
 

Gets the max HP of a character.

Parameters:
character The character. Valid values are in the Character enumeration.
Returns:
The Max HP.

Definition at line 287 of file SaveSlot.cc.

int SaveSlot::getMaxMP int  character  )  const
 

Gets the max MP of a character.

Parameters:
character The character. Valid values are in the Character enumeration.
Returns:
The max MP.

Definition at line 309 of file SaveSlot.cc.

int SaveSlot::getMember int  position  )  const
 

Gets the party member at a given position.

Parameters:
position The party position number (0-3).
Returns:
The character at that position. Return values range between 0 and 1 + one of the character values in the Characters enumeration. 1 = Mage, 8 = Shepherd, 0 = No one.

Definition at line 144 of file SaveSlot.cc.

int SaveSlot::getPhase int  moon  )  const
 

Gets the current phase of one of the moons.

Valid values are either TRAMMEL or FELUCCA.

Parameters:
moon The moon whose phase to return.
Returns:
The phase of the moon. Note that felucca's phase depends upon trammel's phase and can be only 0, 1, or 2 representing one of the three destination cities. Trammel's phase will always be one of the eight cities of virtue.

Definition at line 76 of file SaveSlot.cc.

int SaveSlot::getStrength int  character  )  const
 

Gets the strength of a character.

Parameters:
character The character. Valid values are in the Character enumeration.
Returns:
The strength.

Definition at line 318 of file SaveSlot.cc.

int SaveSlot::getTool int  tool  )  const
 

Gets the amount of a tool the party has.

Parameters:
tool The tool to get the amount of.
Returns:
The amount of the particular tool.

Definition at line 247 of file SaveSlot.cc.

int SaveSlot::getVirtue int  virtue  )  const
 

Gets the value for one of the eight virtues.

Parameters:
virtue The virtue whose value to retrieve. Must be one of the eight virtues in the Virtues enumeration.
Returns:
The value for the particular virtue.

Definition at line 123 of file SaveSlot.cc.

bool SaveSlot::hasMagic int  magic  )  const
 

Queries whether the party has a particular magic or not.

Definition at line 193 of file SaveSlot.cc.

bool SaveSlot::hasRune int  rune  )  const
 

Queries whether the party has a particular rune or not.

Parameters:
rune The rune. Valid values are one of the eight virtues in the Virtues enumeration.
Returns:
true if they have the rune; false otherwise.

Definition at line 173 of file SaveSlot.cc.

bool SaveSlot::hasStone int  stone  )  const
 

Queries if the party has a particular stone in their inventory.

Parameters:
stone The stone to check for. Valid values are one of the eight virtues in the Virtues enumeration.
Returns:
true if they have the stone; false otherwise.

Definition at line 153 of file SaveSlot.cc.

bool hack4u::SaveSlot::isModified  )  const [inline]
 

Queries if this SaveSlot has been modified.

Returns:
true if modified; false otherwise.

Definition at line 165 of file SaveSlot.hh.

bool hack4u::SaveSlot::isValid  )  const [inline]
 

Queries if this save slot is valid.

Initially determined by generating a checksum on the provided data and checking it against the contained checksum, just like the real game.

Returns:
true if valid; false otherwise.

Definition at line 158 of file SaveSlot.hh.

void SaveSlot::setCurrentHP int  character,
wxInt16  value
 

Sets the current HP of a character.

Parameters:
character The character. Valid values are in the Character enumeration.
value The new current HP.

Definition at line 280 of file SaveSlot.cc.

void SaveSlot::setCurrentMP int  character,
unsigned char  value
 

Sets the current MP of a character.

Parameters:
character The character. Valid values are in the Character enumeration.
value The new current MP.

Definition at line 304 of file SaveSlot.cc.

void SaveSlot::setDexterity int  character,
unsigned char  value
 

Sets the dexterity of a character.

Parameters:
character The character. Valid values are in the Character enumeration.
value The new dexterity.

Definition at line 340 of file SaveSlot.cc.

void SaveSlot::setEquipment int  character,
int  slot,
unsigned char  value
 

Sets the item held by a particular player in a particular slot.

Parameters:
character The character whose equipment to set. Valid values are in the Character enumeration.
slot The inventory slot (0-5).
value The new item value.

Definition at line 260 of file SaveSlot.cc.

void SaveSlot::setExperience int  character,
wxInt16  value
 

Sets the experience of a character.

Parameters:
character The character. Valid values are in the Character enumeration.
value The new experience.

Definition at line 351 of file SaveSlot.cc.

void SaveSlot::setGold wxInt16  gold  ) 
 

Sets the amount of gold held by the party.

Parameters:
gold The new amount of gold.

Definition at line 240 of file SaveSlot.cc.

void SaveSlot::setHerb int  herb,
unsigned char  value
 

Sets the amount of a particular herb the party has.

Parameters:
herb The herb whose value to set. Valid values are any of the members of the Herbs enumeration.
value The new value.

Definition at line 229 of file SaveSlot.cc.

void SaveSlot::setHerosName wxString &  name  ) 
 

Sets the Hero's Name.

Parameters:
name The new name of the hero. Valid values must not exceed 5 characters. Excess lengths will be ignored.

Definition at line 108 of file SaveSlot.cc.

void SaveSlot::setIntelligence int  character,
unsigned char  value
 

Sets the intelligence of a character.

Parameters:
character The character. Valid values are in the Character enumeration.
value The new intelligence.

Definition at line 331 of file SaveSlot.cc.

void SaveSlot::setLevel int  character,
unsigned char  value
 

Sets the level of a character.

Parameters:
character The character. Valid values are in the Character enumeration.
value The new level.

Definition at line 269 of file SaveSlot.cc.

void SaveSlot::setMagic int  magic,
bool  give = true
 

Sets whether the party has a particular magic of not.

Parameters:
magic The magic. Valid values are any of the members in the Magic enumeration other than INVALID.
give true to give the magic; false to take it away.

Definition at line 204 of file SaveSlot.cc.

void SaveSlot::setMaxHP int  character,
wxInt16  value
 

Sets the max HP of a character.

Parameters:
character The character. Valid values are in the Character enumeration.
value The new max HP.

Definition at line 293 of file SaveSlot.cc.

void SaveSlot::setMaxMP int  character,
unsigned char  value
 

Sets the max MP of a charcter.

Parameters:
character The character. Valid values are in the Character enumeration.
value The new max MP.

Definition at line 313 of file SaveSlot.cc.

void SaveSlot::setMember int  position,
int  character
 

Sets the party member at a given position.

Parameters:
position The party position number (0-3).
character What character class should be here, or 0 for no one. Use the Characters enumeration + 1 for proper character values (e.g. MAGE + 1).

Definition at line 148 of file SaveSlot.cc.

void SaveSlot::setModified bool  modified = true  )  [private]
 

Sets whether this slot is modified or not.

Parameters:
modified true if modified; false otherwise.

Definition at line 358 of file SaveSlot.cc.

void SaveSlot::setPhase int  trammel,
int  felucca
 

Sets the phases of the moons.

Parameters:
trammel The phase for trammel. Must be one of the eight cities of virtue.
felucca The phase for felucca. Must be 0, 1, or 2 representing one of the three destination cities from Trammel.

Definition at line 86 of file SaveSlot.cc.

void SaveSlot::setRune int  rune,
bool  give = true
 

Sets whether the party has a particular rune of not.

Parameters:
rune The rune. Valid values are one of the eight virtues in the Virtues enumeration.
give true to give the rune; false to take it away.

Definition at line 179 of file SaveSlot.cc.

void SaveSlot::setStone int  stone,
bool  give = true
 

Sets whether the party has a particular stone or not.

Parameters:
stone The stone. Valid values are one of the eight virtues in the Virtues enumeration.
give true to give the stone; false to take it away.

Definition at line 159 of file SaveSlot.cc.

void SaveSlot::setStrength int  character,
unsigned char  value
 

Sets the strength of a charater.

Parameters:
character The character. Valid values are in the Character enumeration.
value The new strength.

Definition at line 322 of file SaveSlot.cc.

void SaveSlot::setTool int  tool,
unsigned char  value = 1
 

Sets the amount of a tool the party has.

Parameters:
tool The tool to set the amount of.
value The new amount.

Definition at line 251 of file SaveSlot.cc.

void SaveSlot::setVirtue int  virtue,
unsigned char  value
 

Sets the value for one of the eight virtues.

Parameters:
virtue The virtue to set. Must be one of the eight virtues in the Virtues enumeration.
value The new value for the virtue.

Definition at line 127 of file SaveSlot.cc.

unsigned char SaveSlot::toNES char  letter  )  [static, private]
 

Translates an ASCII character to the Ultima alphabet.

Parameters:
letter The letter to translate.
Returns:
The translated character.

Definition at line 366 of file SaveSlot.cc.


Friends And Related Function Documentation

friend class MainFrame [friend]
 

Definition at line 540 of file SaveSlot.hh.


Member Data Documentation

const int SaveSlot::CHECKSUM_XORS [static, private]
 

Initial value:

 {
    0x55, 0xAA, 0x33, 0xCC,
    0xA5, 0x5A, 0xBB, 0x99
}
Array of checksum xors used by the sanity algorithm.

Definition at line 572 of file SaveSlot.hh.

bool hack4u::SaveSlot::modified [private]
 

Definition at line 569 of file SaveSlot.hh.

unsigned char* hack4u::SaveSlot::nvram [private]
 

Definition at line 567 of file SaveSlot.hh.

bool hack4u::SaveSlot::valid [private]
 

Definition at line 568 of file SaveSlot.hh.


Generated on Wed Aug 3 20:38:53 2005 for hack4u by  doxygen 1.4.4