openMSX
JVCMSXMIDI.cc
Go to the documentation of this file.
1#include "JVCMSXMIDI.hh"
2#include "serialize.hh"
3
4namespace 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
29void JVCMSXMIDI::reset(EmuTime::param time)
30{
31 mc6850.reset(time);
32}
33
34byte 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
47byte 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
60void 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
73template<typename Archive>
74void JVCMSXMIDI::serialize(Archive& ar, unsigned /*version*/)
75{
76 ar.template serializeBase<MSXDevice>(*this);
77 ar.serialize("MC6850", mc6850);
78}
81
82} // namespace openmsx
#define REGISTER_MSXDEVICE(CLASS, NAME)
Definition MSXDevice.hh:356
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
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition JVCMSXMIDI.cc:47
JVCMSXMIDI(const DeviceConfig &config)
Definition JVCMSXMIDI.cc:22
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
void reset(EmuTime::param time) override
This method is called on reset.
Definition JVCMSXMIDI.cc:29
void serialize(Archive &ar, unsigned version)
Definition JVCMSXMIDI.cc:74
byte readDataReg()
Definition MC6850.cc:102
byte peekStatusReg() const
Definition MC6850.cc:95
void reset(EmuTime::param time)
Definition MC6850.cc:73
void writeControlReg(byte value, EmuTime::param time)
Definition MC6850.cc:119
byte readStatusReg() const
Definition MC6850.cc:90
void writeDataReg(byte value, EmuTime::param time)
Definition MC6850.cc:176
byte peekDataReg() const
Definition MC6850.cc:114
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition MSXDevice.hh:36
EmuTime::param getCurrentTime() const
Definition MSXDevice.cc:125
This file implemented 3 utility functions:
Definition Autofire.cc:11
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)