OXYGENHUB
◆ main openmsx / src / memory / MSXRom.cc
1.7 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#include "MSXRom.hh"
2
3
#include "RomInfo.hh"
4
5
#include "TclObject.hh"
6
#include "XMLElement.hh"
7
8
namespace openmsx {
9
10
MSXRom::MSXRom(const DeviceConfig& config, Rom&& rom_)
11
	: MSXDevice(config, rom_.getName())
12
	, rom(std::move(rom_))
13
{
14
}
15
16
void MSXRom::writeMem(uint16_t /*address*/, byte /*value*/, EmuTime /*time*/)
17
{
18
	// nothing
19
}
20
21
byte* MSXRom::getWriteCacheLine(uint16_t /*address*/)
22
{
23
	return unmappedWrite.data();
24
}
25
26
std::string_view MSXRom::getMapperTypeString() const
27
{
28
	// This value is guaranteed to be stored in the device config (and
29
	// 'auto' is already changed to actual type).
30
	const auto* mapper = getDeviceConfig().findChild("mappertype");
31
	assert(mapper);
32
	return mapper->getData();
33
}
34
35
RomType MSXRom::getRomType() const
36
{
37
	auto result = RomInfo::nameToRomType(getMapperTypeString());
38
	assert(result != RomType::UNKNOWN);
39
	return result;
40
}
41
42
void MSXRom::getInfo(TclObject& result) const
43
{
44
	std::array<char, 40> buf1;
45
	std::array<char, 40> buf2;
46
	// Add detected rom type.
47
	result.addDictKeyValues("mappertype", getMapperTypeString(),
48
49
	// add sha1sum, to be able to get a unique key for this ROM device,
50
	// so that it can be used to look up things in databases
51
	                        "actualSHA1", rom.getSHA1().toString(buf1),
52
53
	// add original sha1sum
54
	                        "originalSHA1", rom.getOriginalSHA1().toString(buf2));
55
56
	// note that we're not using rom.getInfo(result); because we don't want
57
	// the filename included for this method...
58
}
59
60
void MSXRom::getExtraDeviceInfo(TclObject& result) const
61
{
62
	getInfo(result);
63
64
	// add original filename, e.g. to be able to see whether it comes
65
	// from a system_rom pool
66
	result.addDictKeyValue("filename", rom.getFilename());
67
}
68
69
} // namespace openmsx