OXYGENHUB
◆ main openmsx / src / cpu / CPURegs.cc
1.4 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#include "CPURegs.hh"
2
3
#include "serialize.hh"
4
5
namespace openmsx {
6
7
// version 1: Initial version.
8
// version 2: Replaced 'afterEI' boolean with 'after' byte
9
//            (holds both afterEI and afterLDAI information).
10
template<typename Archive>
11
void CPURegs::serialize(Archive& ar, unsigned version)
12
{
13
	ar.serialize("af",  AF_.w,
14
	             "bc",  BC_.w,
15
	             "de",  DE_.w,
16
	             "hl",  HL_.w,
17
	             "af2", AF2_.w,
18
	             "bc2", BC2_.w,
19
	             "de2", DE2_.w,
20
	             "hl2", HL2_.w,
21
	             "ix",  IX_.w,
22
	             "iy",  IY_.w,
23
	             "pc",  PC_.w,
24
	             "sp",  SP_.w,
25
	             "i",   I_);
26
	uint8_t r = getR();
27
	ar.serialize("r",   r);  // combined R_ and R2_
28
	if constexpr (Archive::IS_LOADER) setR(r);
29
	ar.serialize("im",   IM_,
30
	             "iff1", IFF1_,
31
	             "iff2", IFF2_);
32
33
	if (ar.versionBelow(version, 2)) {
34
		bool afterEI = false; // initialize to avoid warning
35
		ar.serialize("afterEI", afterEI);
36
		clearPrevious();
37
		if (afterEI) setCurrentEI();
38
		endInstruction();
39
	} else if (ar.versionBelow(version, 3)) {
40
		uint8_t after = 0;
41
		ar.serialize("after", after);
42
		clearPrevious();
43
		prev_ = after; // flags still in same position
44
		endInstruction();
45
	} else {
46
		ar.serialize("previous", prev_);
47
	}
48
49
	ar.serialize("halt", HALT_);
50
}
51
INSTANTIATE_SERIALIZE_METHODS(CPURegs);
52
53
} // namespace openmsx