Previous 199869 Revisions Next

r20505 Saturday 26th January, 2013 at 19:44:22 UTC by R. Belmont
(MESS) esq5505: Use esqpanel base class for massive cleanup. [R. Belmont]
(MESS) kt76: Convert to modern 68681 and add MIDI I/O. [R. Belmont]
[src/mess/drivers]esq5505.c esqkt.c

trunk/src/mess/drivers/esqkt.c
r20504r20505
2424#include "emu.h"
2525#include "cpu/m68000/m68000.h"
2626#include "sound/es5506.h"
27#include "machine/68681.h"
27#include "machine/n68681.h"
28#include "machine/esqpanel.h"
29#include "machine/serial.h"
30#include "machine/midiinport.h"
31#include "machine/midioutport.h"
2832
29#include "machine/esqvfd.h"
30
31#define KEYBOARD_HACK (1)   // turn on to play: Z and X are program up/down, A/S/D/F/G/H/J/K/L and Q/W/E/R/T/Y/U play notes
33#define KEYBOARD_HACK (0)   // turn on to play: Z and X are program up/down, A/S/D/F/G/H/J/K/L and Q/W/E/R/T/Y/U play notes
3234#define HACK_VIA_MIDI (1)
3335
3436#if KEYBOARD_HACK
r20504r20505
4648   : driver_device(mconfig, type, tag),
4749      m_maincpu(*this, "maincpu"),
4850      m_duart(*this, "duart"),
49      m_sq1vfd(*this, "sq1vfd")
51      m_sq1panel(*this, "sq1panel"),
52      m_mdout(*this, "mdout")
5053   { }
5154
5255   required_device<m68ec020_device> m_maincpu;
53   required_device<duart68681_device> m_duart;
54   required_device<esq2x40_sq1_t> m_sq1vfd;
56   required_device<duartn68681_device> m_duart;
57   required_device<esqpanel2x40_sq1_device> m_sq1panel;
58   required_device<serial_port_device> m_mdout;
5559
5660   virtual void machine_reset();
5761
5862   DECLARE_READ16_MEMBER(es5510_dsp_r);
5963   DECLARE_WRITE16_MEMBER(es5510_dsp_w);
60   DECLARE_READ16_MEMBER(mc68681_r);
61   DECLARE_WRITE16_MEMBER(mc68681_w);
6264   DECLARE_READ32_MEMBER(lower_r);
6365   DECLARE_WRITE32_MEMBER(lower_w);
6466
67   DECLARE_WRITE_LINE_MEMBER(duart_irq_handler);
68   DECLARE_WRITE_LINE_MEMBER(duart_tx_a);
69   DECLARE_WRITE_LINE_MEMBER(duart_tx_b);
70   DECLARE_READ8_MEMBER(duart_input);
71   DECLARE_WRITE8_MEMBER(duart_output);
72
6573   UINT8 m_duart_io;
6674   bool  m_bCalibSecondByte;
6775
r20504r20505
229237   AM_RANGE(0x200000, 0x20003f) AM_DEVREADWRITE8_LEGACY("ensoniq", es5506_r, es5506_w, 0xffffffff)
230238   AM_RANGE(0x240000, 0x24003f) AM_DEVREADWRITE8_LEGACY("ensoniq2", es5506_r, es5506_w, 0xffffffff)
231239   AM_RANGE(0x280000, 0x2801ff) AM_READWRITE16(es5510_dsp_r, es5510_dsp_w, 0xffffffff)
232   AM_RANGE(0x300000, 0x30000f) AM_DEVREADWRITE8_LEGACY("duart", duart68681_r, duart68681_w, 0xffffffff)
240   AM_RANGE(0x300000, 0x30001f) AM_DEVREADWRITE8("duart", duartn68681_device, read, write, 0xffffffff)
233241   AM_RANGE(0xff0000, 0xffffff) AM_RAM AM_SHARE("osram")
234242ADDRESS_MAP_END
235243
r20504r20505
267275   }
268276}
269277
270static void duart_irq_handler(device_t *device, int state, UINT8 vector)
278WRITE_LINE_MEMBER(esqkt_state::duart_irq_handler)
271279{
272   esqkt_state *esq5505 = device->machine().driver_data<esqkt_state>();
273
274   esq5505->m_maincpu->set_input_line(M68K_IRQ_3, state);
280   m_maincpu->set_input_line(M68K_IRQ_3, state);
275281};
276282
277static UINT8 duart_input(device_t *device)
283READ8_MEMBER(esqkt_state::duart_input)
278284{
279285   UINT8 result = 0;   // DUART input lines are separate from the output lines
280286
281287   return result;
282288}
283289
284static void duart_output(device_t *device, UINT8 data)
290WRITE8_MEMBER(esqkt_state::duart_output)
285291{
286   esqkt_state *state = device->machine().driver_data<esqkt_state>();
292   m_duart_io = data;
287293
288   state->m_duart_io = data;
294//    printf("DUART output: %02x (PC=%x)\n", data, m_maincpu->pc());
295}
289296
290//    printf("DUART output: %02x (PC=%x)\n", data, state->m_maincpu->pc());
297WRITE_LINE_MEMBER(esqkt_state::duart_tx_a)
298{
299   m_mdout->tx(state);
291300}
292301
293static void duart_tx(device_t *device, int channel, UINT8 data)
302WRITE_LINE_MEMBER(esqkt_state::duart_tx_b)
294303{
295   esqkt_state *state = device->machine().driver_data<esqkt_state>();
296
297   if (channel == 1)
298   {
299//        printf("ch %d: [%02x] (PC=%x)\n", channel, data, state->m_maincpu->pc());
300
301      state->m_sq1vfd->write_char(data);
302
303      if (state->m_bCalibSecondByte)
304      {
305         if (data == 0xfd)   // calibration request
306         {
307            duart68681_rx_data(state->m_duart, 1, (UINT8)(FPTR)0xff);   // this is the correct response for "calibration OK"
308         }
309         state->m_bCalibSecondByte = false;
310      }
311      else if (data == 0xfb)   // request calibration
312      {
313         state->m_bCalibSecondByte = true;
314      }
315   }
304   m_sq1panel->rx_w(state);
316305}
317306
318static const duart68681_config duart_config =
307static const duartn68681_config duart_config =
319308{
320   duart_irq_handler,
321   duart_tx,
322   duart_input,
323   duart_output,
309   DEVCB_DRIVER_LINE_MEMBER(esqkt_state, duart_irq_handler),
310   DEVCB_DRIVER_LINE_MEMBER(esqkt_state, duart_tx_a),
311   DEVCB_DRIVER_LINE_MEMBER(esqkt_state, duart_tx_b),
312   DEVCB_DRIVER_MEMBER(esqkt_state, duart_input),
313   DEVCB_DRIVER_MEMBER(esqkt_state, duart_output),
324314
325   1000000, 500000,    // IP3, IP4
326   500000, 1000000, // IP5, IP6
315   500000, 500000,    // IP3, IP4
316   1000000, 1000000, // IP5, IP6
327317};
328318
329319#if KEYBOARD_HACK
r20504r20505
434424   NULL
435425};
436426
427static const esqpanel_interface esqpanel_config =
428{
429   DEVCB_DEVICE_LINE_MEMBER("duart", duartn68681_device, rx_b_w)
430};
431
432static SLOT_INTERFACE_START(midiin_slot)
433   SLOT_INTERFACE("midiin", MIDIIN_PORT)
434SLOT_INTERFACE_END
435
436static const serial_port_interface midiin_intf =
437{
438   DEVCB_DEVICE_LINE_MEMBER("duart", duartn68681_device, rx_a_w)   // route MIDI Tx send directly to 68681 channel A Rx
439};
440
441static SLOT_INTERFACE_START(midiout_slot)
442   SLOT_INTERFACE("midiout", MIDIOUT_PORT)
443SLOT_INTERFACE_END
444
445static const serial_port_interface midiout_intf =
446{
447   DEVCB_NULL   // midi out ports don't transmit inward
448};
449
437450static MACHINE_CONFIG_START( kt, esqkt_state )
438451   MCFG_CPU_ADD("maincpu", M68EC020, XTAL_16MHz)
439452   MCFG_CPU_PROGRAM_MAP(kt_map)
440453
441   MCFG_ESQ2x40_SQ1_ADD("sq1vfd")
454   MCFG_ESQPANEL2x40_SQ1_ADD("sq1panel", esqpanel_config)
442455
443   MCFG_DUART68681_ADD("duart", 4000000, duart_config)
456   MCFG_DUARTN68681_ADD("duart", 4000000, duart_config)
457   MCFG_SERIAL_PORT_ADD("mdin", midiin_intf, midiin_slot, "midiin", NULL)
458   MCFG_SERIAL_PORT_ADD("mdout", midiout_intf, midiout_slot, "midiout", NULL)
444459
445460   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
446461   MCFG_SOUND_ADD("ensoniq", ES5506, XTAL_16MHz)
trunk/src/mess/drivers/esq5505.c
r20504r20505
135135      m_maincpu(*this, "maincpu"),
136136      m_duart(*this, "duart"),
137137      m_fdc(*this, "wd1772"),
138      m_epspanel(*this, "epspanel"),
139      m_sq1panel(*this, "sq1panel"),
140138      m_panel(*this, "panel"),
141139      m_dmac(*this, "mc68450"),
142140      m_mdout(*this, "mdout")
r20504r20505
145143   required_device<m68000_device> m_maincpu;
146144   required_device<duartn68681_device> m_duart;
147145   optional_device<wd1772_t> m_fdc;
148   optional_device<esqpanel1x22_device> m_epspanel;
149   optional_device<esqpanel2x40_sq1_device> m_sq1panel;
150   optional_device<esqpanel2x40_device> m_panel;
146   required_device<esqpanel_device> m_panel;
151147   optional_device<hd63450_device> m_dmac;
152148   required_device<serial_port_device> m_mdout;
153149
r20504r20505
155151
156152   DECLARE_READ16_MEMBER(es5510_dsp_r);
157153   DECLARE_WRITE16_MEMBER(es5510_dsp_w);
158   DECLARE_READ16_MEMBER(mc68681_r);
159   DECLARE_WRITE16_MEMBER(mc68681_w);
160154   DECLARE_READ16_MEMBER(lower_r);
161155   DECLARE_WRITE16_MEMBER(lower_w);
162156
r20504r20505
183177
184178   UINT16  *m_rom, *m_ram;
185179
186#if KEYBOARD_HACK
187   void send_through_panel(UINT8 data);
188#endif
189
190180public:
191181   DECLARE_DRIVER_INIT(eps);
192182   DECLARE_DRIVER_INIT(common);
r20504r20505
527517//    printf("DUART output: %02x (PC=%x)\n", data, m_maincpu->pc());
528518}
529519
530// MIDI send, we don't care yet
520// MIDI send
531521WRITE_LINE_MEMBER(esq5505_state::duart_tx_a)
532522{
533523   m_mdout->tx(state);
r20504r20505
535525
536526WRITE_LINE_MEMBER(esq5505_state::duart_tx_b)
537527{
538//  printf("Tx B: %d\n", state);
539   switch (m_system_type)
540   {
541      case GENERIC:
542         m_panel->rx_w(state);
543         break;
544
545      case EPS:
546         m_epspanel->rx_w(state);
547         break;
548
549      case SQ1:
550         m_sq1panel->rx_w(state);
551         break;
552   }
553
554#if 0
555   if (m_bCalibSecondByte)
556   {
557      if (data == 0xfd)   // calibration request
558      {
559         m_duart->duart68681_rx_data(1, (UINT8)(FPTR)0xff);   // this is the correct response for "calibration OK"
560      }
561      m_bCalibSecondByte = false;
562   }
563   else if (data == 0xfb)   // request calibration
564   {
565      m_bCalibSecondByte = true;
566   }
567   else
568   {
569      // EPS wants a throwaway reply byte for each byte sent to the KPC
570      // VFX-SD and SD-1 definitely don't :)
571      if (m_system_type == EPS)
572      {
573         if (data == 0xe7)
574         {
575            m_duart->duart68681_rx_data(1, (UINT8)(FPTR)0x00);   // actual value of response is never checked
576         }
577         else if (data == 0x71)
578         {
579            m_duart->duart68681_rx_data(1, (UINT8)(FPTR)0x00);   // actual value of response is never checked
580         }
581         else
582         {
583            m_duart->duart68681_rx_data(1, data);   // actual value of response is never checked
584         }
585      }
586   }
587#endif
528   m_panel->rx_w(state);
588529}
589530
590531static const duartn68681_config duart_config =
r20504r20505
632573}
633574
634575#if KEYBOARD_HACK
635void esq5505_state::send_through_panel(UINT8 data)
636{
637   switch (m_system_type)
638   {
639      case GENERIC:
640         m_panel->xmit_char(data);
641         break;
642
643      case EPS:
644         m_epspanel->xmit_char(data);
645         break;
646
647      case SQ1:
648         m_sq1panel->xmit_char(data);
649         break;
650   }
651}
652
653576INPUT_CHANGED_MEMBER(esq5505_state::key_stroke)
654577{
655578   #if HACK_VIA_MIDI
r20504r20505
723646      if (oldval == 0 && newval == 1)
724647      {
725648         printf("key pressed %d\n", val&0x7f);
726         send_through_panel(val);
727         send_through_panel(0x00);
649         m_panel->xmit_char(val);
650         m_panel->xmit_char(0x00);
728651      }
729652      else if (oldval == 1 && newval == 0)
730653      {
731654   //        printf("key off %x\n", (UINT8)(FPTR)param);
732         send_through_panel(val&0x7f);
733         send_through_panel(0x00);
655         m_panel->xmit_char(val&0x7f);
656         m_panel->xmit_char(0x00);
734657      }
735658   }
736659   #endif
r20504r20505
802725   MCFG_CPU_PROGRAM_MAP(eps_map)
803726
804727   MCFG_ESQPANEL_2x40_REMOVE("panel")
805   MCFG_ESQPANEL1x22_ADD("epspanel", esqpanel_config)
728   MCFG_ESQPANEL1x22_ADD("panel", esqpanel_config)
806729
807730   MCFG_WD1772x_ADD("wd1772", 8000000)
808731   MCFG_FLOPPY_DRIVE_ADD("wd1772:0", ensoniq_floppies, "35dd", 0, esq5505_state::floppy_formats)
r20504r20505
845768   MCFG_CPU_PROGRAM_MAP(sq1_map)
846769
847770   MCFG_ESQPANEL_2x40_REMOVE("panel")
848   MCFG_ESQPANEL2x40_SQ1_ADD("sq1panel", esqpanel_config)
771   MCFG_ESQPANEL2x40_SQ1_ADD("panel", esqpanel_config)
849772MACHINE_CONFIG_END
850773
851774static INPUT_PORTS_START( vfx )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team