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  "bc", BC_.w,
14  "de", DE_.w,
15  "hl", HL_.w,
16  "af2", AF2_.w,
17  "bc2", BC2_.w,
18  "de2", DE2_.w,
19  "hl2", HL2_.w,
20  "ix", IX_.w,
21  "iy", IY_.w,
22  "pc", PC_.w,
23  "sp", SP_.w,
24  "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  "iff1", IFF1_,
30  "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:981
byte getR() const
Definition: CPURegs.hh:63