openMSX
MSXRom.cc
Go to the documentation of this file.
1#include "MSXRom.hh"
2#include "RomInfo.hh"
3#include "XMLElement.hh"
4#include "TclObject.hh"
5
6namespace openmsx {
7
8MSXRom::MSXRom(const DeviceConfig& config, Rom&& rom_)
9 : MSXDevice(config, rom_.getName())
10 , rom(std::move(rom_))
11{
12}
13
14void MSXRom::writeMem(word /*address*/, byte /*value*/, EmuTime::param /*time*/)
15{
16 // nothing
17}
18
19byte* MSXRom::getWriteCacheLine(word /*address*/) const
20{
21 return unmappedWrite.data();
22}
23
24std::string_view MSXRom::getMapperTypeString() const
25{
26 // This value is guaranteed to be stored in the device config (and
27 // 'auto' is already changed to actual type).
28 const auto* mapper = getDeviceConfig().findChild("mappertype");
29 assert(mapper);
30 return mapper->getData();
31}
32
34{
35 auto result = RomInfo::nameToRomType(getMapperTypeString());
36 assert(result != ROM_UNKNOWN);
37 return result;
38}
39
40void MSXRom::getInfo(TclObject& result) const
41{
42 // Add detected rom type.
43 result.addDictKeyValues("mappertype", getMapperTypeString(),
44
45 // add sha1sum, to be able to get a unique key for this ROM device,
46 // so that it can be used to look up things in databases
47 "actualSHA1", rom.getSHA1().toString(),
48
49 // add original sha1sum
50 "originalSHA1", rom.getOriginalSHA1().toString());
51
52 // note that we're not using rom.getInfo(result); because we don't want
53 // the filename included for this method...
54}
55
57{
58 getInfo(result);
59
60 // add original filename, e.g. to be able to see whether it comes
61 // from a system_rom pool
62 result.addDictKeyValue("filename", rom.getFilename());
63}
64
65} // namespace openmsx
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition MSXDevice.hh:36
static std::array< byte, 0x10000 > unmappedWrite
Definition MSXDevice.hh:305
const XMLElement & getDeviceConfig() const
Get the configuration section for this device.
Definition MSXDevice.hh:234
MSXRom(const DeviceConfig &config, Rom &&rom)
Definition MSXRom.cc:8
void writeMem(word address, byte value, EmuTime::param time) override
Write a given byte to a given location at a certain time to this device.
Definition MSXRom.cc:14
void getExtraDeviceInfo(TclObject &result) const override
Definition MSXRom.cc:56
RomType getRomType() const
Definition MSXRom.cc:33
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition MSXRom.cc:19
void getInfo(TclObject &result) const
Add dict values with info to result.
Definition MSXRom.cc:40
static RomType nameToRomType(std::string_view name)
Definition RomInfo.cc:178
const Sha1Sum & getSHA1() const
Definition Rom.cc:357
const Sha1Sum & getOriginalSHA1() const
Definition Rom.cc:349
std::string_view getFilename() const
Definition Rom.cc:344
std::string toString() const
void addDictKeyValue(const Key &key, const Value &value)
Definition TclObject.hh:145
void addDictKeyValues(Args &&... args)
Definition TclObject.hh:148
const XMLElement * findChild(std::string_view childName) const
Definition XMLElement.cc:21
This file implemented 3 utility functions:
Definition Autofire.cc:11
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29
@ ROM_UNKNOWN
Definition RomTypes.hh:94
STL namespace.