openMSX
RomSynthesizer.cc
Go to the documentation of this file.
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
23namespace openmsx {
24
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
35}
36
37void RomSynthesizer::reset(EmuTime::param time)
38{
39 dac.reset(time);
40}
41
42void RomSynthesizer::writeMem(word address, byte value, EmuTime::param time)
43{
44 if ((address & 0xC010) == 0x4000) {
45 dac.writeDAC(value, time);
46 }
47}
48
50{
51 if ((address & 0xC010 & CacheLine::HIGH) == 0x4000) {
52 return nullptr;
53 } else {
54 return unmappedWrite.data();
55 }
56}
57
58template<typename Archive>
59void RomSynthesizer::serialize(Archive& ar, unsigned /*version*/)
60{
61 ar.template serializeBase<Rom16kBBlocks>(*this);
62 ar.serialize("DAC", dac);
63}
66
67} // namespace openmsx
#define REGISTER_MSXDEVICE(CLASS, NAME)
Definition MSXDevice.hh:356
void reset(EmuTime::param time)
void writeDAC(uint8_t value, EmuTime::param time)
Definition DACSound8U.cc:17
static std::array< byte, 0x10000 > unmappedWrite
Definition MSXDevice.hh:307
EmuTime::param getCurrentTime() const
Definition MSXDevice.cc:125
void setUnmapped(unsigned region)
Select 'unmapped' memory for this region.
Definition RomBlocks.cc:92
void setRom(unsigned region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition RomBlocks.cc:104
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.
void reset(EmuTime::param time) override
This method is called on reset.
byte * getWriteCacheLine(word address) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
void serialize(Archive &ar, unsigned version)
RomSynthesizer(const DeviceConfig &config, Rom &&rom)
constexpr unsigned HIGH
Definition CacheLine.hh:10
This file implemented 3 utility functions:
Definition Autofire.cc:11
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29
STL namespace.
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)