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 
23 namespace 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 
37 void RomSynthesizer::reset(EmuTime::param time)
38 {
39  dac.reset(time);
40 }
41 
42 void 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;
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 }
65 REGISTER_MSXDEVICE(RomSynthesizer, "RomSynthesizer");
66 
67 } // namespace openmsx
serialize.hh
openmsx::RomSynthesizer::serialize
void serialize(Archive &ar, unsigned version)
Definition: RomSynthesizer.cc:59
openmsx::DeviceConfig
Definition: DeviceConfig.hh:19
openmsx::MSXDevice::unmappedWrite
static byte unmappedWrite[0x10000]
Definition: MSXDevice.hh:293
openmsx::CacheLine::HIGH
constexpr unsigned HIGH
Definition: CacheLine.hh:10
openmsx::RomSynthesizer::reset
void reset(EmuTime::param time) override
This method is called on reset.
Definition: RomSynthesizer.cc:37
openmsx::REGISTER_MSXDEVICE
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
openmsx::RomBlocks::setRom
void setRom(byte region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition: RomBlocks.cc:104
openmsx::MSXDevice::getCurrentTime
EmuTime::param getCurrentTime() const
Definition: MSXDevice.cc:130
openmsx::RomSynthesizer
Definition: RomSynthesizer.hh:9
openmsx::RomBlocks::setUnmapped
void setUnmapped(byte region)
Select 'unmapped' memory for this region.
Definition: RomBlocks.cc:91
openmsx::RomBlocks
Definition: RomBlocks.hh:13
INSTANTIATE_SERIALIZE_METHODS
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:981
openmsx::RomSynthesizer::getWriteCacheLine
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition: RomSynthesizer.cc:49
CacheLine.hh
openmsx::RomSynthesizer::writeMem
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: RomSynthesizer.cc:42
openmsx::Rom
Definition: Rom.hh:20
RomSynthesizer.hh
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
openmsx::DACSound8U::writeDAC
void writeDAC(uint8_t value, EmuTime::param time)
Definition: DACSound8U.cc:16
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::RomSynthesizer::RomSynthesizer
RomSynthesizer(const DeviceConfig &config, Rom &&rom)
Definition: RomSynthesizer.cc:25
openmsx::DACSound16S::reset
void reset(EmuTime::param time)
Definition: DACSound16S.cc:29