4
4
Ensoniq panel/display device
5
5
*/
6
6
#include " emu.h"
7
+ #include " ioport.h"
7
8
#include " esqpanel.h"
8
9
#include " extpanel.h"
9
10
11
+ #include " vfx.lh"
12
+ #include " vfxsd.lh"
13
+ #include " sd1.lh"
14
+
10
15
#include " main.h"
11
16
12
17
// **************************************************************************
@@ -45,12 +50,13 @@ esqpanel_device::esqpanel_device(const machine_config &mconfig, device_type type
45
50
device_t(mconfig, type, tag, owner, clock),
46
51
device_serial_interface(mconfig, *this ),
47
52
m_external_panel(*this , " esq_external_panel" ),
48
- m_light_states(0x3f ), // maximum number of lights
53
+ m_light_states(),
49
54
m_write_tx(*this ),
50
55
m_write_analog(*this ),
51
56
m_read_analog(*this , 0 )
52
57
{
53
58
std::fill (std::begin (m_xmitring), std::end (m_xmitring), 0 );
59
+ m_light_states.reserve (0x80 );
54
60
}
55
61
56
62
@@ -247,9 +253,16 @@ uint16_t esqpanel_device::get_analog_value(offs_t offset)
247
253
return m_read_analog (offset, 0 );
248
254
}
249
255
250
-
251
256
void esqpanel_device::set_button (uint8_t button, bool pressed)
252
257
{
258
+ printf (" esqpanel.set_button(%d, %d)\r\n " , button, pressed);
259
+ bool current = m_pressed_buttons.find (button) != m_pressed_buttons.end ();
260
+ if (pressed == current)
261
+ {
262
+ printf (" - button %d already %d, skipping\r\n " , button, pressed);
263
+ return ;
264
+ }
265
+
253
266
uint8_t sendme = (pressed ? 0x80 : 0 ) | (button & 0xff );
254
267
// printf("button %d %s : sending char to mainboard: %02x\n", button, down ? "down" : "up", sendme);
255
268
xmit_char (sendme);
@@ -270,6 +283,7 @@ TIMER_CALLBACK_MEMBER(esqpanel_device::check_external_panel_server) {
270
283
{
271
284
switch (c.kind ) {
272
285
case esq_external_panel_device::Command::ButtonKind:
286
+ printf (" Panel Handling button event from external panel\r\n " );
273
287
set_button (c.button , c.pressed );
274
288
break ;
275
289
@@ -318,17 +332,31 @@ esqpanel2x40_device::esqpanel2x40_device(const machine_config &mconfig, const ch
318
332
319
333
/* panel with 2x40 VFD display used in the VFX, VFX-SD, SD-1 series */
320
334
335
+ esqpanel2x40_vfx_device::esqpanel2x40_vfx_device (const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
336
+ esqpanel_device(mconfig, ESQPANEL2X40_VFX, tag, owner, clock),
337
+ m_vfd(*this , " vfd" ),
338
+ m_lights(*this , " lights" ),
339
+ m_variant(*this , " variant" ), // an output on the panel
340
+ m_buttons_0(*this , " buttons_0" ),
341
+ m_buttons_32(*this , " buttons_32" ),
342
+ m_analog_data_entry(*this , " analog_data_entry" ),
343
+ m_analog_volume(*this , " analog_volume" )
344
+ {
345
+ m_eps_mode = false ;
346
+ }
347
+
321
348
void esqpanel2x40_vfx_device::device_add_mconfig (machine_config &config)
322
349
{
323
350
ESQ2X40_VFX (config, m_vfd, 60 );
324
351
ESQ_EXTERNAL_PANEL (config, m_external_panel, 0 );
325
- }
326
352
327
- esqpanel2x40_vfx_device::esqpanel2x40_vfx_device (const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
328
- esqpanel_device(mconfig, ESQPANEL2X40_VFX, tag, owner, clock),
329
- m_vfd(*this , " vfd" )
330
- {
331
- m_eps_mode = false ;
353
+ const std::string &name = owner ()->shortname ();
354
+ if (name == " vfx" )
355
+ config.set_default_layout (layout_vfx);
356
+ else if (name == " vfxsd" )
357
+ config.set_default_layout (layout_vfxsd);
358
+ else // "sd1" or "sd132"
359
+ config.set_default_layout (layout_sd1);
332
360
}
333
361
334
362
void esqpanel2x40_vfx_device::rcv_complete () // Rx completed receiving byte
@@ -376,7 +404,12 @@ void esqpanel2x40_vfx_device::rcv_complete() // Rx completed receiving byte
376
404
// 3 = Blinking
377
405
auto light_state = (data & 0xc0 ) >> 6 ;
378
406
m_light_states[light_number] = light_state;
407
+
408
+ // update the internal panel
409
+ update_lights ();
410
+ // and any external panel
379
411
m_external_panel->set_light (light_number, light_state);
412
+
380
413
m_expect_light_second_byte = false ;
381
414
}
382
415
else if (data == 0xfb ) // request calibration
@@ -463,18 +496,34 @@ void esqpanel2x40_vfx_device::rcv_complete() // Rx completed receiving byte
463
496
}
464
497
}
465
498
499
+ void esqpanel2x40_vfx_device::update_lights () {
500
+ // set the lights according to their status and bllink phase.
501
+ int32_t lights = 0 ;
502
+ int32_t bit = 1 ;
503
+ for (int i = 0 ; i < 16 ; i++)
504
+ {
505
+ if (m_light_states[i] == 2 || (m_light_states[i] == 3 && ((m_blink_phase & 1 ) == 0 )))
506
+ {
507
+ lights |= bit;
508
+ }
509
+ bit <<= 1 ;
510
+ }
511
+ m_lights = lights;
512
+ }
513
+
466
514
TIMER_CALLBACK_MEMBER (esqpanel2x40_vfx_device::update_blink) {
467
515
m_blink_phase = (m_blink_phase + 1 ) & 3 ;
468
516
m_vfd->set_blink_on (m_blink_phase & 2 );
469
517
m_external_panel->set_blink_phase (m_blink_phase);
518
+ update_lights ();
470
519
}
471
520
472
521
void esqpanel2x40_vfx_device::device_start ()
473
522
{
474
523
esqpanel_device::device_start ();
475
524
476
- m_external_panel-> set_keyboard ( owner ()-> shortname () );
477
- m_external_panel-> set_version ( " 1 " );
525
+ m_variant. resolve ( );
526
+ m_lights. resolve ( );
478
527
479
528
m_blink_timer = timer_alloc (FUNC (esqpanel2x40_vfx_device::update_blink), this );
480
529
m_blink_timer->enable (false );
@@ -484,13 +533,32 @@ void esqpanel2x40_vfx_device::device_reset()
484
533
{
485
534
esqpanel_device::device_reset ();
486
535
536
+ const std::string &shortname = owner ()->shortname ();
537
+ bool has_seq = shortname.find (" sd" ) != std::string::npos;
538
+ bool has_bank_set = shortname.find (" 1" ) != std::string::npos;
539
+ bool has_32_voices = shortname.find (" 32" ) != std::string::npos;
540
+
541
+ u32 bit_seq = 1 << 0 ;
542
+ u32 bit_bank_set = 1 << 1 ;
543
+ u32 bit_32_voices = 1 << 2 ;
544
+
545
+ m_variant =
546
+ (has_seq ? bit_seq : 0 )
547
+ | (has_bank_set ? bit_bank_set : 0 )
548
+ | (has_32_voices ? bit_32_voices : 0 );
549
+
550
+ m_external_panel->set_keyboard (shortname);
551
+ m_external_panel->set_version (" 1" );
552
+
487
553
if (m_blink_timer) {
488
554
attotime sample_time (0 , 250 * ATTOSECONDS_PER_MILLISECOND);
489
555
attotime initial_delay (0 , 250 * ATTOSECONDS_PER_MILLISECOND);
490
556
491
557
m_blink_timer->adjust (initial_delay, 0 , sample_time);
492
558
m_blink_timer->enable (true );
493
559
}
560
+
561
+
494
562
}
495
563
496
564
void esqpanel2x40_vfx_device::device_reset_after_children ()
@@ -545,6 +613,113 @@ void esqpanel2x40_vfx_device::send_light_states()
545
613
m_external_panel->set_light_states (light_states);
546
614
}
547
615
616
+ static INPUT_PORTS_START (esqpanel2x40_vfx_device)
617
+ PORT_START(" buttons_0" )
618
+ for (int i = 0 ; i < 32 ; i++)
619
+ {
620
+ PORT_BIT ((1 << i), IP_ACTIVE_HIGH, IPT_KEYBOARD);
621
+ PORT_CHANGED_MEMBER (DEVICE_SELF, FUNC (esqpanel2x40_vfx_device::button_change), i)
622
+ }
623
+
624
+ PORT_START (" buttons_32" )
625
+ for (int i = 0 ; i < 32 ; i++)
626
+ {
627
+ PORT_BIT ((1 << i), IP_ACTIVE_HIGH, IPT_KEYBOARD);
628
+ PORT_CHANGED_MEMBER (DEVICE_SELF, FUNC (esqpanel2x40_vfx_device::button_change), 32 + i)
629
+ }
630
+
631
+ PORT_START (" analog_data_entry" )
632
+ PORT_ADJUSTER(255 , " Data Entry" )
633
+ PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(esqpanel2x40_vfx_device::analog_value_change), 3)
634
+
635
+ PORT_START(" analog_volume" )
636
+ PORT_ADJUSTER(255 , " Volume" )
637
+ PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(esqpanel2x40_vfx_device::analog_value_change), 5)
638
+
639
+ INPUT_PORTS_END
640
+
641
+ ioport_constructor esqpanel2x40_vfx_device::device_input_ports() const
642
+ {
643
+ return INPUT_PORTS_NAME (esqpanel2x40_vfx_device);
644
+ }
645
+
646
+ // A button is pressed on the internal panel
647
+ INPUT_CHANGED_MEMBER (esqpanel2x40_vfx_device::button_change)
648
+ {
649
+ // Update the internal state
650
+ esqpanel_device::set_button (param, newval != 0 );
651
+
652
+ // Synchronize the change to the external panel
653
+ m_external_panel->set_button (param, newval != 0 );
654
+ }
655
+
656
+ // A button is pressed on the external panel
657
+ void esqpanel2x40_vfx_device::set_button (uint8_t button, bool pressed)
658
+ {
659
+ // Update the internal state
660
+ esqpanel_device::set_button (button, pressed);
661
+
662
+ // Synchronize the change to the internal panel
663
+ auto &port = button < 32 ? m_buttons_0 : m_buttons_32;
664
+ auto bit = 1 << (button % 32 );
665
+ port->field (bit)->set_value (pressed);
666
+ }
667
+
668
+ // An anlog value was changed on the internal panel
669
+ INPUT_CHANGED_MEMBER (esqpanel2x40_vfx_device::analog_value_change)
670
+ {
671
+ if (oldval == 255 )
672
+ {
673
+ // This is the initial write from the layout. Skip this.
674
+ printf (" skipping initial write from internal panel to channnel %d\r\n " , param);
675
+ return ;
676
+ }
677
+
678
+ int channel = param;
679
+ int clamped = std::max (0 , std::min (100 , (int )newval));
680
+ int value = (1023 << 6 ) * clamped / 100 ;
681
+ esqpanel_device::set_analog_value (channel, value);
682
+ printf (" sending analog channel %d value %d to external panel\r\n " , channel, value);
683
+ m_external_panel->set_analog_value (channel, value);
684
+ }
685
+
686
+ // An anlog value was changed on the external panel
687
+ void esqpanel2x40_vfx_device::set_analog_value (offs_t offset, uint16_t value)
688
+ {
689
+ // Update the internal state
690
+ esqpanel_device::set_analog_value (offset, value);
691
+
692
+ int intvalue = 100 * ((int )value) / (1023 << 6 );
693
+
694
+ // Synchronize the change to the internal panel by writing it to the corresponding io port
695
+ if (offset == 3 )
696
+ {
697
+ set_adjuster_value (m_analog_data_entry, intvalue);
698
+ printf (" Setting data entry io port to %d\r\n " , intvalue);
699
+ }
700
+ else if (offset == 5 )
701
+ {
702
+ set_adjuster_value (m_analog_volume, intvalue);
703
+ printf (" Setting volume io port to %d\r\n " , intvalue);
704
+ }
705
+ }
706
+
707
+ ioport_value esqpanel2x40_vfx_device::get_adjuster_value (required_ioport &ioport)
708
+ {
709
+ auto field = ioport->fields ().first ();
710
+ ioport_field::user_settings user_settings;
711
+ field->get_user_settings (user_settings);
712
+ return user_settings.value ;
713
+ }
714
+
715
+ void esqpanel2x40_vfx_device::set_adjuster_value (required_ioport &ioport, const ioport_value & value)
716
+ {
717
+ auto field = ioport->fields ().first ();
718
+ ioport_field::user_settings user_settings;
719
+ field->get_user_settings (user_settings);
720
+ user_settings.value = value;
721
+ field->set_user_settings (user_settings);
722
+ }
548
723
549
724
// --- SQ1 - Parduz --------------------------------------------------------------------------------------------------------------------------
550
725
void esqpanel2x16_sq1_device::device_add_mconfig (machine_config &config)
0 commit comments