openMSX
JVCMSXMIDI.cc
Go to the documentation of this file.
1 #include "JVCMSXMIDI.hh"
2 #include "serialize.hh"
3 
4 namespace openmsx {
5 
6 // MSX interface:
7 // port R/W
8 // 0 R DIN sync input. Bit0 stop/start, bit 1: clock pulse (NOT EMULATED)
9 // 2 W Control Register
10 // 3 W Transmit Data Register
11 // 2 R Status Register
12 // 3 R Receive Data Register
13 
14 // See information provided by gflorez here:
15 // https://www.msx.org/forum/msx-talk/hardware/jvc-msx-midi-interface?page=1#comment-377145
16 
17 // Some existing JVC MSX-MIDI detection routines:
18 // - Synthesix (copied from MusicModule): does INP(2), expects 0; OUT 2,3 : OUT
19 // 2,21: INP(2) and expects bit 1 to be 1 and bit 2, 3 and 7 to be 0. Then does
20 // OUT 3,0xFE : INP(2) and expects bit 1 to be 0.
21 
23  : MSXDevice(config)
24  , mc6850(MSXDevice::getName(), getMotherBoard(), 2000000) // 2 MHz
25 {
27 }
28 
29 void JVCMSXMIDI::reset(EmuTime::param time)
30 {
31  mc6850.reset(time);
32 }
33 
34 byte JVCMSXMIDI::readIO(word port, EmuTime::param /*time*/)
35 {
36  switch (port & 0x7) {
37  case 0:
38  return 0x00; // NOT IMPLEMENTED
39  case 2:
40  return mc6850.readStatusReg();
41  case 3:
42  return mc6850.readDataReg();
43  }
44  return 0xFF;
45 }
46 
47 byte JVCMSXMIDI::peekIO(word port, EmuTime::param /*time*/) const
48 {
49  switch (port & 0x7) {
50  case 0:
51  return 0x00; // NOT IMPLEMENTED
52  case 2:
53  return mc6850.peekStatusReg();
54  case 3:
55  return mc6850.peekDataReg();
56  }
57  return 0xFF;
58 }
59 
60 void JVCMSXMIDI::writeIO(word port, byte value, EmuTime::param time)
61 {
62  switch (port & 0x7) {
63  case 2:
64  mc6850.writeControlReg(value, time);
65  break;
66  case 3:
67  mc6850.writeDataReg(value, time);
68  break;
69  }
70 }
71 
72 // version 1: initial version
73 template<typename Archive>
74 void JVCMSXMIDI::serialize(Archive& ar, unsigned /*version*/)
75 {
76  ar.template serializeBase<MSXDevice>(*this);
77  ar.serialize("MC6850", mc6850);
78 }
81 
82 } // namespace openmsx
openmsx::MSXDevice
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:32
openmsx::MC6850::reset
void reset(EmuTime::param time)
Definition: MC6850.cc:75
serialize.hh
openmsx::DeviceConfig
Definition: DeviceConfig.hh:20
openmsx::MC6850::writeDataReg
void writeDataReg(byte value, EmuTime::param time)
Definition: MC6850.cc:178
openmsx::REGISTER_MSXDEVICE
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
JVCMSXMIDI.hh
openmsx::MC6850::peekStatusReg
byte peekStatusReg() const
Definition: MC6850.cc:97
openmsx::JVCMSXMIDI
Definition: JVCMSXMIDI.hh:10
openmsx::JVCMSXMIDI::JVCMSXMIDI
JVCMSXMIDI(const DeviceConfig &config)
Definition: JVCMSXMIDI.cc:22
openmsx::MC6850::readStatusReg
byte readStatusReg() const
Definition: MC6850.cc:92
openmsx::Keys::getName
string getName(KeyCode keyCode)
Translate key code to key name.
Definition: Keys.cc:742
openmsx::JVCMSXMIDI::reset
void reset(EmuTime::param time) override
This method is called on reset.
Definition: JVCMSXMIDI.cc:29
openmsx::MSXDevice::getCurrentTime
EmuTime::param getCurrentTime() const
Definition: MSXDevice.cc:131
openmsx::JVCMSXMIDI::serialize
void serialize(Archive &ar, unsigned version)
Definition: JVCMSXMIDI.cc:74
INSTANTIATE_SERIALIZE_METHODS
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:981
openmsx::MC6850::writeControlReg
void writeControlReg(byte value, EmuTime::param time)
Definition: MC6850.cc:121
openmsx::JVCMSXMIDI::peekIO
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: JVCMSXMIDI.cc:47
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
openmsx::JVCMSXMIDI::writeIO
void writeIO(word port, byte value, EmuTime::param time) override
Write a byte to a given IO port at a certain time to this device.
Definition: JVCMSXMIDI.cc:60
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::MC6850::peekDataReg
byte peekDataReg() const
Definition: MC6850.cc:116
openmsx::MC6850::readDataReg
byte readDataReg()
Definition: MC6850.cc:104
openmsx::JVCMSXMIDI::readIO
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Definition: JVCMSXMIDI.cc:34