44
44
45
45
#include < algorithm>
46
46
47
+ #define LOG_UNKNOWN (1 << 1 )
48
+ #define LOG_EEPROM (1 << 2 )
49
+ #define LOG_DMA (1 << 3 )
50
+
51
+ #define LOG_ALL (LOG_UNKNOWN | LOG_EEPROM | LOG_DMA)
52
+
53
+ #define VERBOSE (0 )
54
+
55
+ #include " logmacro.h"
56
+
57
+ #define LOGUNKNOWN (...) LOGMASKED(LOG_UNKNOWN, __VA_ARGS__)
58
+ #define LOGEEPROM (...) LOGMASKED(LOG_EEPROM, __VA_ARGS__)
59
+ #define LOGDMA (...) LOGMASKED(LOG_DMA, __VA_ARGS__)
47
60
48
61
namespace {
49
62
@@ -60,12 +73,15 @@ class wswan_state : public driver_device
60
73
m_cursx (*this , " CURSX" ),
61
74
m_cursy (*this , " CURSY" ),
62
75
m_buttons (*this , " BUTTONS" ),
76
+ m_sound_output (*this , " SOUND_OUTPUT" ),
63
77
m_icons (*this , " icon%u" , 0U )
64
78
{ }
65
79
66
80
void wswan (machine_config &config);
67
81
void pockchv2 (machine_config &config);
68
82
83
+ DECLARE_INPUT_CHANGED_MEMBER (sound_output_changed);
84
+
69
85
protected:
70
86
virtual void machine_start () override ATTR_COLD;
71
87
virtual void machine_reset () override ATTR_COLD;
@@ -109,6 +125,7 @@ class wswan_state : public driver_device
109
125
required_ioport m_cursx;
110
126
required_ioport m_cursy;
111
127
required_ioport m_buttons;
128
+ required_ioport m_sound_output;
112
129
output_finder<6 > m_icons;
113
130
114
131
u16 m_ws_portram[128 ] = { };
@@ -153,7 +170,8 @@ class wscolor_state : public wswan_state
153
170
public:
154
171
wscolor_state (const machine_config &mconfig, device_type type, const char *tag) :
155
172
wswan_state (mconfig, type, tag),
156
- m_dma_view (*this , " dma_view" )
173
+ m_dma_view (*this , " dma_view" ),
174
+ m_hypervoice_view (*this , " hypervoice_view" )
157
175
{ }
158
176
159
177
void wscolor (machine_config &config);
@@ -168,6 +186,7 @@ class wscolor_state : public wswan_state
168
186
static constexpr u8 SOUND_DMA_DIV[4 ] = { 6 , 4 , 2 , 1 };
169
187
170
188
memory_view m_dma_view;
189
+ memory_view m_hypervoice_view;
171
190
172
191
struct sound_dma_t
173
192
{
@@ -187,7 +206,7 @@ class wscolor_state : public wswan_state
187
206
188
207
u16 dma_r (offs_t offset, u16 mem_mask);
189
208
void dma_w (offs_t offset, u16 data, u16 mem_mask);
190
- void dma_view_w (int state);
209
+ void color_mode_view_w (int state);
191
210
192
211
TIMER_CALLBACK_MEMBER (sound_dma_cb);
193
212
@@ -222,6 +241,8 @@ void wscolor_state::io_map(address_map &map)
222
241
map (0x00 , 0xff ).rw (FUNC (wscolor_state::port_r), FUNC (wscolor_state::port_w)); // I/O ports
223
242
map (0x40 , 0x53 ).view (m_dma_view);
224
243
m_dma_view[0 ](0x40 , 0x53 ).rw (FUNC (wscolor_state::dma_r), FUNC (wscolor_state::dma_w));
244
+ map (0x64 , 0x6b ).view (m_hypervoice_view);
245
+ m_hypervoice_view[0 ](0x64 , 0x6b ).rw (m_sound, FUNC (wswan_sound_device::hypervoice_r), FUNC (wswan_sound_device::hypervoice_w));
225
246
}
226
247
227
248
@@ -248,6 +269,11 @@ static INPUT_PORTS_START(wswan)
248
269
PORT_BIT( 0x04 , IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME(" Y3 - Down" ) PORT_CODE(KEYCODE_S)
249
270
PORT_BIT( 0x02 , IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME(" Y2 - Right" ) PORT_CODE(KEYCODE_D)
250
271
PORT_BIT( 0x01 , IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME(" Y1 - Up" ) PORT_CODE(KEYCODE_W)
272
+
273
+ PORT_START(" SOUND_OUTPUT" )
274
+ PORT_CONFNAME( 0x01 , 0x01 , " Sound output select" ) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(wswan_state::sound_output_changed), 0)
275
+ PORT_CONFSETTING( 0x00 , " Internal speaker (Mono)" )
276
+ PORT_CONFSETTING( 0x01 , " External headphone (Stereo)" )
251
277
INPUT_PORTS_END
252
278
253
279
@@ -327,7 +353,7 @@ void wscolor_state::wscolor(machine_config &config)
327
353
m_vdp->set_screen (" screen" );
328
354
m_vdp->set_irq_callback (FUNC (wscolor_state::set_irq_line));
329
355
m_vdp->icons_cb ().set (FUNC (wscolor_state::set_icons));
330
- m_vdp->color_mode_cb ().set (FUNC (wscolor_state::dma_view_w ));
356
+ m_vdp->color_mode_cb ().set (FUNC (wscolor_state::color_mode_view_w ));
331
357
332
358
// software lists
333
359
config.device_remove (" wsc_list" );
@@ -337,6 +363,10 @@ void wscolor_state::wscolor(machine_config &config)
337
363
m_cart->set_must_be_loaded (true );
338
364
}
339
365
366
+ INPUT_CHANGED_MEMBER (wswan_state::sound_output_changed)
367
+ {
368
+ m_sound->set_headphone_connected (BIT (m_sound_output->read (), 0 ));
369
+ }
340
370
341
371
void wswan_state::handle_irqs ()
342
372
{
@@ -402,13 +432,19 @@ TIMER_CALLBACK_MEMBER(wscolor_state::sound_dma_cb)
402
432
if (BIT (m_sound_dma.control , 2 ))
403
433
{
404
434
// Sound DMA hold
405
- port_w (0x88 / 2 , 0 << 8 , 0xff00 );
435
+ if (BIT (m_sound_dma.control , 4 ))
436
+ m_sound->hypervoice_dma_w (0 );
437
+ else
438
+ port_w (0x88 / 2 , 0 << 8 , 0xff00 );
406
439
}
407
440
else
408
441
{
409
442
address_space &space = m_maincpu->space (AS_PROGRAM);
410
443
/* TODO: Output sound DMA byte */
411
- port_w (0x88 / 2 , space.read_byte (m_sound_dma.source ) << 8 , 0xff00 );
444
+ if (BIT (m_sound_dma.control , 4 ))
445
+ m_sound->hypervoice_dma_w (space.read_byte (m_sound_dma.source ));
446
+ else
447
+ port_w (0x88 / 2 , space.read_byte (m_sound_dma.source ) << 8 , 0xff00 );
412
448
m_sound_dma.size --;
413
449
m_sound_dma.source = (m_sound_dma.source + (BIT (m_sound_dma.control , 6 ) ? -1 : 1 )) & 0x0fffff ;
414
450
if (m_sound_dma.size == 0 )
@@ -511,6 +547,7 @@ void wscolor_state::machine_start()
511
547
512
548
void wswan_state::machine_reset ()
513
549
{
550
+ m_sound->set_headphone_connected (BIT (m_sound_output->read (), 0 ));
514
551
m_bios_disabled = false ;
515
552
516
553
m_rotate = 0 ;
@@ -536,6 +573,7 @@ void wscolor_state::machine_reset()
536
573
wswan_state::machine_reset ();
537
574
538
575
m_dma_view.disable ();
576
+ m_hypervoice_view.disable ();
539
577
540
578
/* Initialize sound DMA */
541
579
m_sound_dma.timer ->adjust (attotime::never);
@@ -545,12 +583,18 @@ void wscolor_state::machine_reset()
545
583
}
546
584
547
585
548
- void wscolor_state::dma_view_w (int state)
586
+ void wscolor_state::color_mode_view_w (int state)
549
587
{
550
588
if (state)
589
+ {
551
590
m_dma_view.select (0 );
591
+ m_hypervoice_view.select (0 );
592
+ }
552
593
else
594
+ {
553
595
m_dma_view.disable ();
596
+ m_hypervoice_view.disable ();
597
+ }
554
598
}
555
599
556
600
@@ -653,6 +697,10 @@ u16 wswan_state::port_r(offs_t offset, u16 mem_mask)
653
697
case 0xcc / 2 :
654
698
case 0xce / 2 :
655
699
return m_cart->read_io (offset, mem_mask);
700
+ default :
701
+ if (!machine ().side_effects_disabled ())
702
+ LOGUNKNOWN (" %s: Read from unsupported port: %02x & %04x" , machine ().describe_context (), offset << 1 , mem_mask);
703
+ break ;
656
704
}
657
705
658
706
return value;
@@ -844,7 +892,7 @@ void wswan_state::port_w(offs_t offset, u16 data, u16 mem_mask)
844
892
}
845
893
else
846
894
{
847
- logerror ( " Unsupported internal EEPROM command: %X \n " , data);
895
+ LOGEEPROM ( " %s: Unsupported internal EEPROM command: %02X \n " , machine (). describe_context (), data & 0xff );
848
896
}
849
897
}
850
898
break ;
@@ -859,7 +907,7 @@ void wswan_state::port_w(offs_t offset, u16 data, u16 mem_mask)
859
907
m_cart->write_io (offset, data, mem_mask);
860
908
break ;
861
909
default :
862
- logerror ( " Write to unsupported port: %x - %x \n " , offset, data);
910
+ LOGUNKNOWN ( " %s: Write to unsupported port: %02x - %04x & %04x \n " , machine (). describe_context (), offset << 1 , data, mem_mask );
863
911
break ;
864
912
}
865
913
@@ -900,6 +948,10 @@ u16 wscolor_state::dma_r(offs_t offset, u16 mem_mask)
900
948
case 0x52 / 2 :
901
949
// Sound DMA control
902
950
return m_sound_dma.control ;
951
+ default :
952
+ if (!machine ().side_effects_disabled ())
953
+ LOGDMA (" %s: Read from unknown DMA port: %02x & %04x" , machine ().describe_context (), offset << 1 , mem_mask);
954
+ break ;
903
955
}
904
956
return value;
905
957
}
@@ -1021,7 +1073,7 @@ void wscolor_state::dma_w(offs_t offset, u16 data, u16 mem_mask)
1021
1073
}
1022
1074
break ;
1023
1075
default :
1024
- logerror ( " Write to unsupported port: %x - %x\n " , offset, data);
1076
+ LOGDMA ( " %s: Write to unknown DMA port: %x - %x\n " , machine (). describe_context () , offset, data);
1025
1077
break ;
1026
1078
}
1027
1079
// Update the port value
0 commit comments