Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libmeteor/source/sram.cpp
2 views
1
// Meteor - A Nintendo Gameboy Advance emulator
2
// Copyright (C) 2009-2011 Philippe Daouadi
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
#include "ameteor/sram.hpp"
18
#include <cstring>
19
#include <fstream>
20
#include "globals.hpp"
21
22
namespace AMeteor
23
{
24
Sram::Sram () :
25
CartMem()
26
{
27
m_size = SIZE;
28
29
*(uint32_t*)(m_data+MAX_SIZE) = m_size;
30
}
31
32
void Sram::Reset ()
33
{
34
std::memset(m_data, 0, SIZE);
35
}
36
37
bool Sram::Load (std::istream& f)
38
{
39
f.read((char*)m_data, SIZE);
40
return f.good();
41
}
42
43
bool Sram::Save (std::ostream& f)
44
{
45
f.write((char*)m_data, SIZE);
46
return f.good();
47
}
48
49
bool Sram::SaveState (std::ostream& stream)
50
{
51
SS_WRITE_DATA(m_data, SIZE);
52
53
return true;
54
}
55
56
bool Sram::LoadState (std::istream& stream)
57
{
58
SS_READ_DATA(m_data, SIZE);
59
60
return true;
61
}
62
}
63
64