uzebox: adding sound emulation (It works but with terrible performance. Uzebox's DrMario song is recognizable even though the sound is choppy, full of noise).

When running with -wavwrite the resulting file plays nicely on a music player. The sound is much better, but still contains a high frequency noisy sort of hiss.
This commit is contained in:
Felipe Corrêa da Silva Sanches 2015-06-13 10:42:53 -03:00
parent e3fdd3f033
commit 9a27b57c07
3 changed files with 30 additions and 19 deletions

View File

@ -869,6 +869,7 @@ void avr8_device::device_reset()
m_timer_prescale_count[t] = 0; m_timer_prescale_count[t] = 0;
} }
m_ocr2_not_reached_yet = true;
m_interrupt_pending = false; m_interrupt_pending = false;
m_elapsed_cycles = 0; m_elapsed_cycles = 0;
} }
@ -1553,22 +1554,26 @@ void avr8_device::timer2_tick()
switch(wgm2) switch(wgm2)
{ {
case WGM02_FAST_PWM: 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; if (count >= 0xFF)
count = 0; {
increment = 0; //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_r[AVR8_REGIDX_TIFR2] |= ocf2[reg]; m_ocr2_not_reached_yet = true;
} }
else if(count == 0) else
{ {
if (reg == 0) if (m_ocr2_not_reached_yet)
{ {
m_r[AVR8_REGIDX_TIFR2] &= ~AVR8_TIFR2_TOV2_MASK; //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; break;
@ -1585,7 +1590,7 @@ void avr8_device::timer2_tick()
m_r[AVR8_REGIDX_TIFR2] |= ocf2[reg]; m_r[AVR8_REGIDX_TIFR2] |= ocf2[reg];
} }
else if(count == 0) else if (count == 0)
{ {
if (reg == 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_OCF2A);
update_interrupt(AVR8_INTIDX_OCF2B); update_interrupt(AVR8_INTIDX_OCF2B);

View File

@ -162,6 +162,7 @@ protected:
UINT8 m_timer_increment[6]; UINT8 m_timer_increment[6];
UINT16 m_timer_prescale[6]; UINT16 m_timer_prescale[6];
UINT16 m_timer_prescale_count[6]; UINT16 m_timer_prescale_count[6];
bool m_ocr2_not_reached_yet;
// SPI // SPI
bool m_spi_active; bool m_spi_active;

View File

@ -32,13 +32,15 @@ public:
m_maincpu(*this, "maincpu"), m_maincpu(*this, "maincpu"),
m_cart(*this, "cartslot"), m_cart(*this, "cartslot"),
m_ctrl1(*this, "ctrl1"), m_ctrl1(*this, "ctrl1"),
m_ctrl2(*this, "ctrl2") m_ctrl2(*this, "ctrl2"),
m_dac(*this, "dac")
{ } { }
required_device<avr8_device> m_maincpu; required_device<avr8_device> m_maincpu;
required_device<generic_slot_device> m_cart; required_device<generic_slot_device> m_cart;
required_device<snes_control_port_device> m_ctrl1; required_device<snes_control_port_device> m_ctrl1;
required_device<snes_control_port_device> m_ctrl2; required_device<snes_control_port_device> m_ctrl2;
required_device<dac_device> m_dac;
DECLARE_READ8_MEMBER(port_a_r); DECLARE_READ8_MEMBER(port_a_r);
DECLARE_WRITE8_MEMBER(port_a_w); DECLARE_WRITE8_MEMBER(port_a_w);
@ -168,7 +170,10 @@ WRITE8_MEMBER(uzebox_state::port_d_w)
// --x- x--- NC // --x- x--- NC
// ---- -x-- power // ---- -x-- power
// ---- --xx UART MIDI // ---- --xx UART MIDI
if ((m_port_d ^ data) & 0x80)
{
m_dac->write_unsigned8((data & 0x80) ? 0x3F: 0);
}
m_port_d = data; m_port_d = data;
} }
@ -302,4 +307,4 @@ ROM_START( uzebox )
ROM_END ROM_END
/* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME */ /* 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)