1818
1919#include " emu.h"
2020#include " cpu/z80/z80.h"
21+ #include " machine/pit8253.h"
2122#include " machine/i8255.h"
2223#include " machine/watchdog.h"
24+ #include " sound/spkrdev.h"
2325#include " screen.h"
26+ #include " speaker.h"
2427
2528
2629namespace {
@@ -32,6 +35,7 @@ class clayshoo_state : public driver_device
3235 driver_device (mconfig, type, tag),
3336 m_maincpu (*this , " maincpu" ),
3437 m_videoram (*this , " videoram" )
38+ , m_speaker(*this , " speaker" )
3539 { }
3640
3741 void clayshoo (machine_config &config);
@@ -43,6 +47,7 @@ class clayshoo_state : public driver_device
4347private:
4448 required_device<cpu_device> m_maincpu;
4549 required_shared_ptr<uint8_t > m_videoram;
50+ required_device<speaker_sound_device> m_speaker;
4651
4752 void analog_reset_w (uint8_t data);
4853 uint8_t analog_r ();
@@ -52,13 +57,14 @@ class clayshoo_state : public driver_device
5257 TIMER_CALLBACK_MEMBER (reset_analog_bit);
5358 uint8_t difficulty_input_port_r (int bit);
5459 void create_analog_timers ();
55-
60+ void sound_w ( int state);
5661 void main_io_map (address_map &map) ATTR_COLD;
5762 void main_map (address_map &map) ATTR_COLD;
5863
5964 emu_timer *m_analog_timer_1 = nullptr , *m_analog_timer_2 = nullptr ;
6065 uint8_t m_input_port_select = 0 ;
6166 uint8_t m_analog_port_val = 0 ;
67+ uint8_t m_sound_en = 0 ;
6268};
6369
6470
@@ -172,6 +178,11 @@ void clayshoo_state::machine_start()
172178 save_item (NAME (m_analog_port_val));
173179}
174180
181+ void clayshoo_state::sound_w (int state)
182+ {
183+ if (m_sound_en)
184+ m_speaker->level_w (state);
185+ }
175186
176187
177188/* ************************************
@@ -235,8 +246,8 @@ void clayshoo_state::main_io_map(address_map &map)
235246 map (0x00 , 0x00 ).w (" watchdog" , FUNC (watchdog_timer_device::reset_w));
236247 map (0x20 , 0x23 ).rw (" ppi8255_0" , FUNC (i8255_device::read), FUNC (i8255_device::write));
237248 map (0x30 , 0x33 ).rw (" ppi8255_1" , FUNC (i8255_device::read), FUNC (i8255_device::write));
238- // map(0x40, 0x43).noprw(); // 8253 for sound?
239- // map(0x50, 0x50).noprw(); // ?
249+ map (0x40 , 0x43 ).rw ( " pit " , FUNC (pit8253_device::read), FUNC (pit8253_device::write));
250+ map (0x50 , 0x50 ).lw8 ( NAME ([ this ] ( u8 data) {m_sound_en = data;}));
240251// map(0x60, 0x60).noprw(); // ?
241252}
242253
@@ -342,6 +353,13 @@ void clayshoo_state::clayshoo(machine_config &config)
342353 i8255_device &ppi1 (I8255A (config, " ppi8255_1" ));
343354 ppi1.out_pa_callback ().set (FUNC (clayshoo_state::input_port_select_w));
344355 ppi1.in_pb_callback ().set (FUNC (clayshoo_state::input_port_r));
356+
357+ pit8253_device &pit (PIT8253 (config, " pit" , 0 ));
358+ pit.set_clk <0 >(5068000 /4 ); // guess
359+ pit.out_handler <0 >().set (FUNC (clayshoo_state::sound_w));
360+
361+ SPEAKER (config, " mono" ).front_center ();
362+ SPEAKER_SOUND (config, m_speaker).add_route (ALL_OUTPUTS, " mono" , 0.50 );
345363}
346364
347365
0 commit comments