openMSX
CPURegs.cc
Go to the documentation of this file.
1 #include "CPURegs.hh"
2 #include "serialize.hh"
3 
4 namespace openmsx {
5 
6 // version 1: Initial version.
7 // version 2: Replaced 'afterEI' boolean with 'after' byte
8 // (holds both afterEI and afterLDAI information).
9 template<typename Archive>
10 void CPURegs::serialize(Archive& ar, unsigned version)
11 {
12  ar.serialize("af", AF_.w);
13  ar.serialize("bc", BC_.w);
14  ar.serialize("de", DE_.w);
15  ar.serialize("hl", HL_.w);
16  ar.serialize("af2", AF2_.w);
17  ar.serialize("bc2", BC2_.w);
18  ar.serialize("de2", DE2_.w);
19  ar.serialize("hl2", HL2_.w);
20  ar.serialize("ix", IX_.w);
21  ar.serialize("iy", IY_.w);
22  ar.serialize("pc", PC_.w);
23  ar.serialize("sp", SP_.w);
24  ar.serialize("i", I_);
25  byte r = getR();
26  ar.serialize("r", r); // combined R_ and R2_
27  if (ar.isLoader()) setR(r);
28  ar.serialize("im", IM_);
29  ar.serialize("iff1", IFF1_);
30  ar.serialize("iff2", IFF2_);
31 
32  if (ar.versionBelow(version, 2)) {
33  bool afterEI = false; // initialize to avoid warning
34  ar.serialize("afterEI", afterEI);
35  clearPrevious();
36  if (afterEI) setCurrentEI();
38  } else if (ar.versionBelow(version, 3)) {
39  byte after = 0;
40  ar.serialize("after", after);
41  clearPrevious();
42  prev_ = after; // flags still in same position
44  } else {
45  ar.serialize("previous", prev_);
46  }
47 
48  ar.serialize("halt", HALT_);
49 }
51 
52 } // namespace openmsx
void setR(byte x)
Definition: CPURegs.hh:108
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
void serialize(Archive &ar, unsigned version)
Definition: CPURegs.cc:10
void endInstruction()
Definition: CPURegs.hh:175
void clearPrevious()
Definition: CPURegs.hh:180
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void setCurrentEI()
Definition: CPURegs.hh:140
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:840
byte getR() const
Definition: CPURegs.hh:63