Previous 199869 Revisions Next

r24854 Monday 12th August, 2013 at 04:35:26 UTC by R. Belmont
(MESS) MPU-401: Preliminary working MIDI out. [R. Belmont]
[src/mess/machine]mpu401.c mpu401.h

trunk/src/mess/machine/mpu401.c
r24853r24854
4040
4141#define M6801_TAG   "mpu6801"
4242#define ROM_TAG      "mpurom"
43#define MIDIIN_TAG   "mdin"
44#define MIDIOUT_TAG   "mdout"
4345
4446#define P2_SYNC_OUT   (0x01)
4547#define P2_SYNC_IN   (0x02)
r24853r24854
6466   AM_RANGE(M6801_PORT2, M6801_PORT2) AM_READWRITE(port2_r, port2_w)
6567ADDRESS_MAP_END
6668
69static SLOT_INTERFACE_START(midiin_slot)
70   SLOT_INTERFACE("midiin", MIDIIN_PORT)
71SLOT_INTERFACE_END
72
73static const serial_port_interface midiin_intf =
74{
75   DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, mpu401_device, midi_rx_w)
76};
77
78static SLOT_INTERFACE_START(midiout_slot)
79   SLOT_INTERFACE("midiout", MIDIOUT_PORT)
80SLOT_INTERFACE_END
81
82static const serial_port_interface midiout_intf =
83{
84   DEVCB_NULL  // midi out ports don't transmit inward
85};
86
6787MACHINE_CONFIG_FRAGMENT( mpu401 )
6888   MCFG_CPU_ADD(M6801_TAG, M6801, 4000000)   /* 4 MHz as per schematics */
6989   MCFG_CPU_PROGRAM_MAP(mpu401_map)
7090   MCFG_CPU_IO_MAP(mpu401_io_map)
91   MCFG_M6801_SER_TX(WRITELINE(mpu401_device, mpu401_midi_tx))
92
93   MCFG_SERIAL_PORT_ADD(MIDIIN_TAG, midiin_intf, midiin_slot, "midiin")
94   MCFG_SERIAL_PORT_ADD(MIDIOUT_TAG, midiout_intf, midiout_slot, "midiout")
7195MACHINE_CONFIG_END
7296
7397ROM_START( mpu401 )
r24853r24854
109133//-------------------------------------------------
110134
111135mpu401_device::mpu401_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
112   device_t(mconfig, MPU401, "Roland MPU-401", tag, owner, clock, "mpu401", __FILE__),
136   device_t(mconfig, MPU401, "Roland MPU-401 I/O box", tag, owner, clock, "mpu401", __FILE__),
113137   m_ourcpu(*this, M6801_TAG),
138   m_mdout(*this, MIDIOUT_TAG),
114139   write_irq(*this)
115140{
116141}
r24853r24854
122147void mpu401_device::device_start()
123148{
124149   write_irq.resolve_safe();
150   m_timer = timer_alloc(0, NULL);
125151}
126152
127153//-------------------------------------------------
r24853r24854
130156
131157void mpu401_device::device_reset()
132158{
133   m_port2 = 0xff & ~P2_SRCK_OUT;
159   m_port2 = 0xff & ~(P2_SRCK_OUT | P2_MIDI_IN);   // prevent spurious reception
134160   m_command = 0;
135161   m_mpudata = 0;
136162   m_gatearrstat = 0;
163
164   m_timer->adjust(attotime::zero, 0, attotime::from_hz(31250*8));
137165}
138166
167//-------------------------------------------------
168//  device_timer - called when our device timer expires
169//-------------------------------------------------
170
171void mpu401_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
172{
173   m_ourcpu->m6801_clock_serial();
174}
175
139176READ8_MEMBER(mpu401_device::regs_mode2_r)
140177{
141178   switch (offset)
r24853r24854
179216
180217WRITE8_MEMBER(mpu401_device::port1_w)
181218{
182   printf("port1_w: %02x met %x syncout %x DSRD %d DRRD %d\n", data, data & 3, (data>>3) & 3, (data>>6) & 1, (data>>7) & 1);
219//   printf("port1_w: %02x met %x syncout %x DSRD %d DRRD %d\n", data, data & 3, (data>>3) & 3, (data>>6) & 1, (data>>7) & 1);
183220}
184221
185222READ8_MEMBER(mpu401_device::port2_r)
186223{
187   printf("Read P2 (PC=%x)\n", space.device().safe_pc());
224//   printf("Read P2 (PC=%x)\n", space.device().safe_pc());
188225   return m_port2;
189226}
190227
191228WRITE8_MEMBER(mpu401_device::port2_w)
192229{
193   printf("port2_w: %02x SYCOUT %d SYCIN %d SRCK %d MIDI OUT %d\n", data, (data & 1), (data>>1) & 1, (data>>2) & 1, (data>>4) & 1);
230//   printf("port2_w: %02x SYCOUT %d SYCIN %d SRCK %d MIDI OUT %d\n", data, (data & 1), (data>>1) & 1, (data>>2) & 1, (data>>4) & 1);
194231}
195232
196233READ8_MEMBER(mpu401_device::mpu_r)
r24853r24854
219256   {
220257      m_gatearrstat |= STAT_CMD_PORT;
221258   }
259   else
260   {
261      m_gatearrstat &= ~STAT_CMD_PORT;
262   }
222263}
223264
224265READ8_MEMBER(mpu401_device::asic_r)
r24853r24854
248289   }
249290}
250291
292// MIDI receive
293WRITE_LINE_MEMBER( mpu401_device::midi_rx_w )
294{
295   if (state == ASSERT_LINE)
296   {
297      m_port2 |= P2_MIDI_IN;
298   }
299   else
300   {
301      m_port2 &= ~P2_MIDI_IN;
302   }
303}
304
305// MIDI send
306WRITE_LINE_MEMBER(mpu401_device::mpu401_midi_tx)
307{
308   m_mdout->tx(state);
309}
310
trunk/src/mess/machine/mpu401.h
r24853r24854
55
66#include "emu.h"
77#include "cpu/m6800/m6800.h"
8#include "machine/serial.h"
9#include "machine/midiinport.h"
10#include "machine/midioutport.h"
811
912#define MCFG_MPU401_ADD(_tag, _irqf ) \
1013   MCFG_DEVICE_ADD(_tag, MPU401, 0) \
r24853r24854
2730   virtual machine_config_constructor device_mconfig_additions() const;
2831
2932   required_device<m6801_cpu_device> m_ourcpu;
33   required_device<serial_port_device> m_mdout;
3034
3135   template<class _write> void set_irqf(_write wr)
3236   {
r24853r24854
4347   DECLARE_WRITE8_MEMBER(port1_w);
4448   DECLARE_READ8_MEMBER(port2_r);
4549   DECLARE_WRITE8_MEMBER(port2_w);
50   DECLARE_WRITE_LINE_MEMBER(midi_rx_w);
51   DECLARE_WRITE_LINE_MEMBER(mpu401_midi_tx);
4652
4753   // public API - call for reads/writes at I/O 330/331 on PC, C0n0/C0n1 on Apple II, etc.
4854   DECLARE_READ8_MEMBER(mpu_r);
r24853r24854
5359   virtual void device_start();
5460   virtual void device_reset();
5561   virtual const rom_entry *device_rom_region() const;
62   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
5663
5764private:
5865   UINT8 m_port2;
5966   UINT8 m_command;
6067   UINT8 m_mpudata;
6168   UINT8 m_gatearrstat;
69   emu_timer *m_timer;
6270};
6371
6472// device type definition

Previous 199869 Revisions Next


© 1997-2024 The MAME Team