OXYGENHUB
◆ main openmsx / src / memory / RomSynthesizer.cc
1.5 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
/* On Sat, 3 Apr 2004, Manuel Pazos wrote:
2
 *
3
 * As you know, the cartridge has an 8bit D/A, accessed through
4
 * memory-mapped at address #4000 by the program. openMSX also uses that
5
 * address to access it. But examining the cartridge board I found that the
6
 * address is decoded by a LS138 in this way:
7
 *
8
 *    /WR = L
9
 *    A15 = L
10
 *    A4 = L
11
 *    /MERQ = L
12
 *    /SLT = L
13
 *    A14 = H
14
 *
15
 * So any value equal to %01xxxxxxxxx0xxxx should work (i.e.: #4000, #4020,
16
 * #7C00, etc.)
17
*/
18
19
#include "RomSynthesizer.hh"
20
#include "CacheLine.hh"
21
#include "serialize.hh"
22
23
namespace openmsx {
24
25
RomSynthesizer::RomSynthesizer(const DeviceConfig& config, Rom&& rom_)
26
	: Rom16kBBlocks(config, std::move(rom_))
27
	, dac("Synthesizer-DAC", "Konami Synthesizer's DAC", config)
28
{
29
	setUnmapped(0);
30
	setRom(1, 0);
31
	setRom(2, 1);
32
	setUnmapped(3);
33
34
	reset(getCurrentTime());
35
}
36
37
void RomSynthesizer::reset(EmuTime time)
38
{
39
	dac.reset(time);
40
}
41
42
void RomSynthesizer::writeMem(uint16_t address, byte value, EmuTime time)
43
{
44
	if ((address & 0xC010) == 0x4000) {
45
		dac.writeDAC(value, time);
46
	}
47
}
48
49
byte* RomSynthesizer::getWriteCacheLine(uint16_t address)
50
{
51
	if ((address & 0xC010 & CacheLine::HIGH) == 0x4000) {
52
		return nullptr;
53
	} else {
54
		return unmappedWrite.data();
55
	}
56
}
57
58
template<typename Archive>
59
void RomSynthesizer::serialize(Archive& ar, unsigned /*version*/)
60
{
61
	ar.template serializeBase<Rom16kBBlocks>(*this);
62
	ar.serialize("DAC", dac);
63
}
64
INSTANTIATE_SERIALIZE_METHODS(RomSynthesizer);
65
REGISTER_MSXDEVICE(RomSynthesizer, "RomSynthesizer");
66
67
} // namespace openmsx