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

source/model/SaveSlot.hh

Go to the documentation of this file.
00001 /*
00002  * z2se
00003  * Copyright (C) 2004-2005 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.5 2005/08/04 05:37:51 technoplaza Exp $
00024 
00025 #ifndef _SAVE_SLOT_HH
00026 #define _SAVE_SLOT_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     public:
00095         /**
00096          * Constructor for a SaveSlot.
00097          *
00098          * @param nvram The SRAM data for this SaveSlot.
00099          */
00100         SaveSlot(const char *nvram);
00101         
00102         /**
00103          * Destructor for a SaveSlot object.
00104          */
00105         ~SaveSlot();
00106         
00107         /**
00108          * Queries if this SaveSlot has been modified;
00109          *
00110          * @return true if modified; false otherwise.
00111          */
00112         bool isModified() const { return modified; }
00113         
00114         /**
00115          * Queries if this SaveSlot is valid.
00116          *
00117          * @return true if valid; false otherwise.
00118          */
00119         bool isValid() const { return valid; }
00120         
00121         /**
00122          * Fixes data for a new quest game.
00123          */
00124         void checkForNewGame();
00125 
00126         /**
00127          * Gets the name of the character.
00128          *
00129          * @return The name.
00130          */
00131         wxString getName() const;
00132         
00133         /**
00134          * Sets the name of the character.
00135          *
00136          * @param value The new name.
00137          */
00138         void setName(wxString &value);
00139         
00140         /**
00141          * Gets the play count.
00142          *
00143          * @return The play count.
00144          */
00145         int getPlayCount() const;
00146         
00147         /**
00148          * Sets the play count.
00149          *
00150          * @param value The new play count.
00151          */
00152         void setPlayCount(unsigned char value);
00153         
00154         /**
00155          * Queries if the player has saved the Triforce before.
00156          *
00157          * @return true if they have; false otherwise.
00158          */
00159         bool hasTriforce() const;
00160         
00161         /**
00162          * Sets whether this player has saved the Triforce before.
00163          *
00164          * @param value true if they have; false otherwise.
00165          */
00166         void setTriforce(bool value);
00167         
00168         /**
00169          * Gets one of the experience level elements.
00170          *
00171          * @param which Which level to retrieve. Valid values are one of the
00172          *              Levels enumeration.
00173          *
00174          * @return The experience level.
00175          */
00176         int getLevel(int which) const;
00177         
00178         /**
00179          * Sets one of the experience level elements.
00180          *
00181          * @param which Which level to set. Valid values are one of the
00182          *              Levels enumeration.
00183          * @param value The new experience level.
00184          */
00185         void setLevel(int which, unsigned char value);
00186         
00187         /**
00188          * Gets one of the container values.
00189          *
00190          * @param which Which container value to get. Valid values are one of
00191          *              Containers enumeration.
00192          *
00193          * @return The number of containers.
00194          */
00195         int getContainers(int which) const;
00196         
00197         /**
00198          * Sets one of the container values.
00199          *
00200          * @param which Which container value to set. Valid values are one of
00201          *              Containers enumeration.
00202          * @param value The new container value.
00203          */
00204         void setContainers(int which, unsigned char value);
00205         
00206         /**
00207          * Queries if the player has a sword technique.
00208          *
00209          * @param technique Which technique to check for. Valid values are in
00210          *                  the Techniques enumeration.
00211          *
00212          * @return true if they have the technique; false otherwise.
00213          */
00214         bool hasTechnique(int technique) const;
00215         
00216         /**
00217          * Sets if the player has a sword technique or not.
00218          * 
00219          * @param technique Which technique to set. Valid values are in
00220          *                  the Techniques enumeration.
00221          * @param value true to have the technique; false otherwise.
00222          */
00223         void setTechnique(int technique, bool value);
00224         
00225         /**
00226          * Queries if the player has a certain spell.
00227          *
00228          * @param spell Which spell. Valid values are in the Spells enumeration.
00229          *
00230          * @return true if they have it; false otherwise.
00231          */
00232         bool hasSpell(int spell) const;
00233         
00234         /**
00235          * Sets if the player has a certain spell.
00236          *
00237          * @param spell Which spell. Valid values are in the Spells enumeration.
00238          * @param value true to have the spell; false otherwise.
00239          */
00240         void setSpell(int spell, bool value);
00241         
00242         /**
00243          * Queries if the player has a certain item.
00244          *
00245          * @param item Which item. Valid values are in the Items enumeration.
00246          *
00247          * @return true if they have it; false otherwise.
00248          */
00249         bool hasItem(int item) const;
00250         
00251         /**
00252          * Sets if the player has a certain item.
00253          *
00254          * @param item Which item. Valid values are in the Items enumeration.
00255          * @param value true to have the item; false otherwise.
00256          */
00257         void setItem(int item, bool value);
00258         
00259         /**
00260          * Queries if the player has sealed a certain palace.
00261          *
00262          * @param palace Which palace. Valid values are 0-5.
00263          *
00264          * @return true if they have sealed it; false otherwise.
00265          */
00266         bool hasSeal(int palace) const;
00267         
00268         /**
00269          * Sets if the player has sealed a certain palace.
00270          *
00271          * @param palace Which palace. Valid values are 0-5.
00272          * @param value true to seal; false otherwise.
00273          */
00274         void setSeal(int palace, bool value);
00275         
00276         /**
00277          * Gets the number of keys the player has.
00278          *
00279          * @return The number of keys.
00280          */
00281         int getKeys() const;
00282         
00283         /**
00284          * Sets the number of keys the player has.
00285          *
00286          * @param value The new number of keys.
00287          */
00288         void setKeys(unsigned char value);
00289         
00290         friend class SRAMFile;
00291         
00292     private:
00293         /**
00294          * Sets if this game has been modified or not.
00295          */
00296         void setModified(bool modified = true) { this->modified = modified; }
00297         
00298         /**
00299          * Translates a character from the Zelda II alphabet to ASCII.
00300          *
00301          * @param letter The letter to translate.
00302          *
00303          * @return The translated letter.
00304          */
00305         static char fromNES(unsigned char letter);
00306         
00307         /**
00308          * Translates a character from ASCII to the Zelda II alphabet.
00309          *
00310          * @param letter The letter to translate.
00311          *
00312          * @return The translated letter.
00313          */
00314         static unsigned char toNES(char letter);
00315         
00316         unsigned char *nvram;
00317         bool modified, valid;
00318     };
00319 }
00320 
00321 #endif

Generated on Thu Aug 4 00:30:33 2005 for Zelda II SRAM Editor by  doxygen 1.4.4