2011-01-07 11:11:56 +00:00
|
|
|
#ifdef SYSTEM_CPP
|
|
|
|
|
|
|
|
serializer System::serialize() {
|
|
|
|
serializer s(serialize_size);
|
|
|
|
|
2012-04-29 06:16:44 +00:00
|
|
|
unsigned signature = 0x31545342, version = Info::SerializerVersion;
|
|
|
|
char hash[64], description[512];
|
|
|
|
memcpy(&hash, (const char*)cartridge.sha256(), 64);
|
2011-01-07 11:11:56 +00:00
|
|
|
memset(&description, 0, sizeof description);
|
|
|
|
|
|
|
|
s.integer(signature);
|
|
|
|
s.integer(version);
|
2012-04-29 06:16:44 +00:00
|
|
|
s.array(hash);
|
2011-01-07 11:11:56 +00:00
|
|
|
s.array(description);
|
|
|
|
|
|
|
|
serialize_all(s);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
bool System::unserialize(serializer& s) {
|
2012-04-29 06:16:44 +00:00
|
|
|
unsigned signature, version;
|
|
|
|
char hash[64], description[512];
|
2011-01-07 11:11:56 +00:00
|
|
|
|
|
|
|
s.integer(signature);
|
|
|
|
s.integer(version);
|
2012-04-29 06:16:44 +00:00
|
|
|
s.array(hash);
|
2011-01-07 11:11:56 +00:00
|
|
|
s.array(description);
|
|
|
|
|
|
|
|
if(signature != 0x31545342) return false;
|
|
|
|
if(version != Info::SerializerVersion) return false;
|
|
|
|
|
2011-10-27 13:30:19 +00:00
|
|
|
power();
|
2011-01-07 11:11:56 +00:00
|
|
|
serialize_all(s);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
void System::serialize(serializer& s) {
|
2011-01-07 11:11:56 +00:00
|
|
|
s.integer(clocks_executed);
|
|
|
|
}
|
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
void System::serialize_all(serializer& s) {
|
2011-01-07 11:11:56 +00:00
|
|
|
cartridge.serialize(s);
|
|
|
|
system.serialize(s);
|
|
|
|
cpu.serialize(s);
|
2012-04-26 10:51:13 +00:00
|
|
|
ppu.serialize(s);
|
2011-01-22 08:15:49 +00:00
|
|
|
apu.serialize(s);
|
2011-01-07 11:11:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void System::serialize_init() {
|
|
|
|
serializer s;
|
|
|
|
|
|
|
|
unsigned signature = 0, version = 0, crc32 = 0;
|
2012-04-29 06:16:44 +00:00
|
|
|
char hash[64], description[512];
|
2011-01-07 11:11:56 +00:00
|
|
|
|
|
|
|
s.integer(signature);
|
|
|
|
s.integer(version);
|
2012-04-29 06:16:44 +00:00
|
|
|
s.array(hash);
|
2011-01-07 11:11:56 +00:00
|
|
|
s.array(description);
|
|
|
|
|
|
|
|
serialize_all(s);
|
|
|
|
serialize_size = s.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|