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: SRAMFile.hh,v 1.7 2008/12/17 06:24:27 jdratlif Exp $ 00024 00025 #ifndef Z2SE_SRAMFILE_HH_ 00026 #define Z2SE_SRAMFILE_HH_ 00027 00028 /// The size of the SRAM file 00029 #define SRAM_SIZE 0x2000 00030 00031 /// The starting offset of the games within the SRAM file 00032 #define GAME_OFFSET 0x1402 00033 00034 namespace emuWorks { 00035 class SaveSlot; 00036 00037 /** 00038 * Class to encapsulate an SRAM file. 00039 */ 00040 class SRAMFile { 00041 private: 00042 wxString *file; 00043 SaveSlot *games[3]; 00044 int current; 00045 char *data; 00046 00047 /** 00048 * Loads the SRAM data from a file. 00049 * 00050 * @param filename The file to load SRAM data from. 00051 */ 00052 void load(wxString &filename); 00053 00054 public: 00055 /** 00056 * Constructor for an SRAMFile object. 00057 * 00058 * @param filename The SRAM file to use. 00059 */ 00060 SRAMFile(wxString &filename); 00061 00062 /** 00063 * Destructor for an SRAMFile object. 00064 */ 00065 ~SRAMFile(); 00066 00067 /** 00068 * Checks if this SRAM file has been modified. 00069 * 00070 * @return true if modified; false otherwise. 00071 */ 00072 bool isModified(); 00073 00074 /** 00075 * Gets the current game. 00076 * 00077 * @return The current game data. 00078 */ 00079 SaveSlot *getCurrentGame(); 00080 00081 /** 00082 * Sets the current game. 00083 * 00084 * @param current The new game. 00085 * 00086 * @return true if the current game was changed; false otherwise. 00087 */ 00088 bool setCurrentGame(unsigned int current); 00089 00090 /** 00091 * Checks if a particular game is valid. 00092 * 00093 * @param game The game to check. 00094 * 00095 * @return true if the game is valid; false otherwise. 00096 */ 00097 bool isValidGame(int game); 00098 00099 /** 00100 * Saves the SRAM data to the file it was opened from. 00101 * 00102 * @return true if the data was saved; false otherwise. 00103 */ 00104 bool save(); 00105 00106 /** 00107 * Saves the SRAM data to a particular file. 00108 * 00109 * @param filename The file to save to. 00110 * 00111 * @return true if the data was saved; false otherwise. 00112 */ 00113 bool save(wxString &filename); 00114 }; 00115 } 00116 00117 #endif 00118