// Meteor - A Nintendo Gameboy Advance emulator1// Copyright (C) 2009-2011 Philippe Daouadi2//3// This program is free software: you can redistribute it and/or modify4// it under the terms of the GNU General Public License as published by5// the Free Software Foundation, either version 3 of the License, or6// (at your option) any later version.7//8// This program is distributed in the hope that it will be useful,9// but WITHOUT ANY WARRANTY; without even the implied warranty of10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11// GNU General Public License for more details.12//13// You should have received a copy of the GNU General Public License14// along with this program. If not, see <http://www.gnu.org/licenses/>.1516#include "ameteor/sram.hpp"17#include <cstring>18#include <fstream>19#include "globals.hpp"2021namespace AMeteor22{23Sram::Sram () :24CartMem()25{26m_size = SIZE;2728*(uint32_t*)(m_data+MAX_SIZE) = m_size;29}3031void Sram::Reset ()32{33std::memset(m_data, 0, SIZE);34}3536bool Sram::Load (std::istream& f)37{38f.read((char*)m_data, SIZE);39return f.good();40}4142bool Sram::Save (std::ostream& f)43{44f.write((char*)m_data, SIZE);45return f.good();46}4748bool Sram::SaveState (std::ostream& stream)49{50SS_WRITE_DATA(m_data, SIZE);5152return true;53}5455bool Sram::LoadState (std::istream& stream)56{57SS_READ_DATA(m_data, SIZE);5859return true;60}61}626364