SaveSlot.hh

Go to the documentation of this file.
00001 /*
00002  * Zelda II SRAM Editor
00003  * Copyright (C) 2004-2005,2007-2008 emuWorks
00004  * http://games.technoplaza.net/
00005  *
00006  * This file is part of z2se.
00007  *
00008  * z2se is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * z2se is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with z2se; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00021  */
00022 
00023 // $Id: SaveSlot.hh,v 1.9 2008/12/17 06:24:27 jdratlif Exp $
00024 
00025 #ifndef Z2SE_SAVESLOT_HH_
00026 #define Z2SE_SAVESLOT_HH_
00027 
00028 /// Game Size
00029 #define GAME_SIZE 0x32
00030 
00031 /// Starting SRAM offset of the experience levels
00032 #define LEVEL_OFFSET 0x00
00033 
00034 /// Starting SRAM offset for the spells
00035 #define SPELL_OFFSET 0x04
00036 
00037 /// Starting SRAM offset for the containers
00038 #define CONTAINER_OFFSET 0x0C
00039 
00040 /// Starting SRAM offset for the items
00041 #define ITEM_OFFSET 0x0E
00042 
00043 /// Starting SRAM offset for the palace seals
00044 #define PALACE_OFFSET 0x16
00045 
00046 /// SRAM offset for the seal count
00047 #define SEAL_OFFSET 0x1D
00048 
00049 /// SRAM offset for the keys
00050 #define KEYS_OFFSET 0x1C
00051 
00052 /// SRAM offset for the name
00053 #define NAME_OFFSET 0x2A
00054 
00055 /// SRAM offset for the sword techniques
00056 #define TECHNIQUE_OFFSET 0x1F
00057 
00058 /// SRAM offset for the play count
00059 #define PLAY_COUNT_OFFSET 0x28
00060 
00061 /// SRAM offset for the triforce
00062 #define TRIFORCE_OFFSET 0x29
00063 
00064 namespace emuWorks {
00065     /// the levels of experience
00066     enum Levels {
00067         SWORDLEVEL, MAGICLEVEL, LIFELEVEL
00068     };
00069     
00070     /// The spells that can be learned
00071     enum Spells {
00072         SHIELD, JUMP, LIFE, FAIRY, FIRE, REFLECT, SPELL, THUNDER
00073     };
00074     
00075     /// The containers
00076     enum Containers {
00077         MAGICCONTAINER, LIFECONTAINER
00078     };
00079     
00080     /// The game items
00081     enum Items {
00082         CANDLE, GLOVE, RAFT, BOOTS, CROSS, FLUTE, MAGICKEY, HAMMER
00083     };
00084     
00085     /// The sword techniques
00086     enum Techniques {
00087         DOWNWARDTHRUST = 0x10, UPWARDTHRUST = 0x04
00088     };
00089     
00090     /**
00091      * Class encapsulating a SaveSlot for a Zelda II game.
00092      */
00093     class SaveSlot {
00094         friend class SRAMFile;
00095         
00096     private:
00097         unsigned char *nvram;
00098         bool modified, valid;
00099         
00100         /**
00101          * Sets if this game has been modified or not.
00102          */
00103         void setModified(bool modified = true) { this->modified = modified; }
00104         
00105         /**
00106          * Translates a character from the Zelda II alphabet to ASCII.
00107          *
00108          * @param letter The letter to translate.
00109          *
00110          * @return The translated letter.
00111          */
00112         static char fromNES(unsigned char letter);
00113         
00114         /**
00115          * Translates a character from ASCII to the Zelda II alphabet.
00116          *
00117          * @param letter The letter to translate.
00118          *
00119          * @return The translated letter.
00120          */
00121         static unsigned char toNES(char letter);
00122 
00123     public:
00124         /**
00125          * Constructor for a SaveSlot.
00126          *
00127          * @param nvram The SRAM data for this SaveSlot.
00128          */
00129         SaveSlot(const char *nvram);
00130         
00131         /**
00132          * Destructor for a SaveSlot object.
00133          */
00134         ~SaveSlot();
00135         
00136         /**
00137          * Queries if this SaveSlot has been modified;
00138          *
00139          * @return true if modified; false otherwise.
00140          */
00141         bool isModified() const { return modified; }
00142         
00143         /**
00144          * Queries if this SaveSlot is valid.
00145          *
00146          * @return true if valid; false otherwise.
00147          */
00148         bool isValid() const { return valid; }
00149         
00150         /**
00151          * Fixes data for a new quest game.
00152          */
00153         void checkForNewGame();
00154 
00155         /**
00156          * Gets the name of the character.
00157          *
00158          * @return The name.
00159          */
00160         wxString getName() const;
00161         
00162         /**
00163          * Sets the name of the character.
00164          *
00165          * @param value The new name.
00166          */
00167         void setName(wxString &value);
00168         
00169         /**
00170          * Gets the play count.
00171          *
00172          * @return The play count.
00173          */
00174         int getPlayCount() const;
00175         
00176         /**
00177          * Sets the play count.
00178          *
00179          * @param value The new play count.
00180          */
00181         void setPlayCount(unsigned char value);
00182         
00183         /**
00184          * Queries if the player has saved the Triforce before.
00185          *
00186          * @return true if they have; false otherwise.
00187          */
00188         bool hasTriforce() const;
00189         
00190         /**
00191          * Sets whether this player has saved the Triforce before.
00192          *
00193          * @param value true if they have; false otherwise.
00194          */
00195         void setTriforce(bool value);
00196         
00197         /**
00198          * Gets one of the experience level elements.
00199          *
00200          * @param which Which level to retrieve. Valid values are one of the
00201          *              Levels enumeration.
00202          *
00203          * @return The experience level.
00204          */
00205         int getLevel(int which) const;
00206         
00207         /**
00208          * Sets one of the experience level elements.
00209          *
00210          * @param which Which level to set. Valid values are one of the
00211          *              Levels enumeration.
00212          * @param value The new experience level.
00213          */
00214         void setLevel(int which, unsigned char value);
00215         
00216         /**
00217          * Gets one of the container values.
00218          *
00219          * @param which Which container value to get. Valid values are one of
00220          *              Containers enumeration.
00221          *
00222          * @return The number of containers.
00223          */
00224         int getContainers(int which) const;
00225         
00226         /**
00227          * Sets one of the container values.
00228          *
00229          * @param which Which container value to set. Valid values are one of
00230          *              Containers enumeration.
00231          * @param value The new container value.
00232          */
00233         void setContainers(int which, unsigned char value);
00234         
00235         /**
00236          * Queries if the player has a sword technique.
00237          *
00238          * @param technique Which technique to check for. Valid values are in
00239          *                  the Techniques enumeration.
00240          *
00241          * @return true if they have the technique; false otherwise.
00242          */
00243         bool hasTechnique(int technique) const;
00244         
00245         /**
00246          * Sets if the player has a sword technique or not.
00247          * 
00248          * @param technique Which technique to set. Valid values are in
00249          *                  the Techniques enumeration.
00250          * @param value true to have the technique; false otherwise.
00251          */
00252         void setTechnique(int technique, bool value);
00253         
00254         /**
00255          * Queries if the player has a certain spell.
00256          *
00257          * @param spell Which spell. Valid values are in the Spells enumeration.
00258          *
00259          * @return true if they have it; false otherwise.
00260          */
00261         bool hasSpell(int spell) const;
00262         
00263         /**
00264          * Sets if the player has a certain spell.
00265          *
00266          * @param spell Which spell. Valid values are in the Spells enumeration.
00267          * @param value true to have the spell; false otherwise.
00268          */
00269         void setSpell(int spell, bool value);
00270         
00271         /**
00272          * Queries if the player has a certain item.
00273          *
00274          * @param item Which item. Valid values are in the Items enumeration.
00275          *
00276          * @return true if they have it; false otherwise.
00277          */
00278         bool hasItem(int item) const;
00279         
00280         /**
00281          * Sets if the player has a certain item.
00282          *
00283          * @param item Which item. Valid values are in the Items enumeration.
00284          * @param value true to have the item; false otherwise.
00285          */
00286         void setItem(int item, bool value);
00287         
00288         /**
00289          * Queries if the player has sealed a certain palace.
00290          *
00291          * @param palace Which palace. Valid values are 0-5.
00292          *
00293          * @return true if they have sealed it; false otherwise.
00294          */
00295         bool hasSeal(int palace) const;
00296         
00297         /**
00298          * Sets if the player has sealed a certain palace.
00299          *
00300          * @param palace Which palace. Valid values are 0-5.
00301          * @param value true to seal; false otherwise.
00302          */
00303         void setSeal(int palace, bool value);
00304         
00305         /**
00306          * Gets the number of keys the player has.
00307          *
00308          * @return The number of keys.
00309          */
00310         int getKeys() const;
00311         
00312         /**
00313          * Sets the number of keys the player has.
00314          *
00315          * @param value The new number of keys.
00316          */
00317         void setKeys(unsigned char value);
00318     };
00319 }
00320 
00321 #endif
00322 

Generated on Mon Dec 29 01:21:33 2008 for Zelda II SRAM Editor by  doxygen 1.5.4