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