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