diff --git a/src/emu/cpu/avr8/avr8.c b/src/emu/cpu/avr8/avr8.c index 976b2ff8856..4f45b51e0ea 100644 --- a/src/emu/cpu/avr8/avr8.c +++ b/src/emu/cpu/avr8/avr8.c @@ -869,6 +869,7 @@ void avr8_device::device_reset() m_timer_prescale_count[t] = 0; } + m_ocr2_not_reached_yet = true; m_interrupt_pending = false; m_elapsed_cycles = 0; } @@ -1553,22 +1554,26 @@ void avr8_device::timer2_tick() switch(wgm2) { case WGM02_FAST_PWM: - if(count == ocr2[reg]) + if (reg==0) { - if (reg == 0) + if (count >= m_r[AVR8_REGIDX_OCR2A]) { - m_r[AVR8_REGIDX_TIFR2] |= AVR8_TIFR2_TOV2_MASK; - count = 0; - increment = 0; - } - - m_r[AVR8_REGIDX_TIFR2] |= ocf2[reg]; - } - else if(count == 0) - { - if (reg == 0) - { - m_r[AVR8_REGIDX_TIFR2] &= ~AVR8_TIFR2_TOV2_MASK; + if (count >= 0xFF) + { + //Turn on + m_io->write_byte(AVR8_IO_PORTD, m_io->read_byte(AVR8_IO_PORTD) | (1 << 7)); + m_r[AVR8_REGIDX_TCNT2] = 0; + m_ocr2_not_reached_yet = true; + } + else + { + if (m_ocr2_not_reached_yet) + { + //Turn off + m_io->write_byte(AVR8_IO_PORTD, m_io->read_byte(AVR8_IO_PORTD) & ~(1 << 7)); + m_ocr2_not_reached_yet = false; + } + } } } break; @@ -1585,7 +1590,7 @@ void avr8_device::timer2_tick() m_r[AVR8_REGIDX_TIFR2] |= ocf2[reg]; } - else if(count == 0) + else if (count == 0) { if (reg == 0) { @@ -1616,7 +1621,7 @@ void avr8_device::timer2_tick() */ } - m_r[AVR8_REGIDX_TCNT2] = count + increment; + m_r[AVR8_REGIDX_TCNT2] += increment; update_interrupt(AVR8_INTIDX_OCF2A); update_interrupt(AVR8_INTIDX_OCF2B); diff --git a/src/emu/cpu/avr8/avr8.h b/src/emu/cpu/avr8/avr8.h index 2384c585804..5708a571023 100644 --- a/src/emu/cpu/avr8/avr8.h +++ b/src/emu/cpu/avr8/avr8.h @@ -162,6 +162,7 @@ protected: UINT8 m_timer_increment[6]; UINT16 m_timer_prescale[6]; UINT16 m_timer_prescale_count[6]; + bool m_ocr2_not_reached_yet; // SPI bool m_spi_active; diff --git a/src/mess/drivers/uzebox.c b/src/mess/drivers/uzebox.c index a3b09b7621e..2193f129146 100644 --- a/src/mess/drivers/uzebox.c +++ b/src/mess/drivers/uzebox.c @@ -14,7 +14,7 @@ #include "emu.h" #include "cpu/avr8/avr8.h" -#include "sound/dac.h" +#include "sound/speaker.h" #include "bus/generic/slot.h" #include "bus/generic/carts.h" #include "bus/snes_ctrl/ctrl.h" @@ -32,13 +32,15 @@ public: m_maincpu(*this, "maincpu"), m_cart(*this, "cartslot"), m_ctrl1(*this, "ctrl1"), - m_ctrl2(*this, "ctrl2") + m_ctrl2(*this, "ctrl2"), + m_speaker(*this, "speaker") { } required_device m_maincpu; required_device m_cart; required_device m_ctrl1; required_device m_ctrl2; + required_device m_speaker; DECLARE_READ8_MEMBER(port_a_r); DECLARE_WRITE8_MEMBER(port_a_w); @@ -168,7 +170,10 @@ WRITE8_MEMBER(uzebox_state::port_d_w) // --x- x--- NC // ---- -x-- power // ---- --xx UART MIDI - + if ((m_port_d ^ data) & 0x80) + { + m_speaker->level_w(data & 0x80); + } m_port_d = data; } @@ -280,9 +285,9 @@ static MACHINE_CONFIG_START( uzebox, uzebox_state ) MCFG_SCREEN_UPDATE_DRIVER(uzebox_state, screen_update_uzebox) /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("avr8") - MCFG_SOUND_ADD("dac", DAC, 0) - MCFG_SOUND_ROUTE(0, "avr8", 1.00) + MCFG_SPEAKER_STANDARD_MONO("mono") + MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0) + MCFG_SOUND_ROUTE(0, "mono", 1.00) MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "uzebox") MCFG_GENERIC_EXTENSIONS("bin,uze") @@ -302,4 +307,4 @@ ROM_START( uzebox ) ROM_END /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME */ -CONS(2010, uzebox, 0, 0, uzebox, uzebox, driver_device, 0, "Belogic", "Uzebox", GAME_NO_SOUND | GAME_NOT_WORKING) +CONS(2010, uzebox, 0, 0, uzebox, uzebox, driver_device, 0, "Belogic", "Uzebox", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING)