clears variables to avoid random crashing (nw)

This commit is contained in:
smf- 2013-05-12 00:47:48 +00:00
parent 89008211f5
commit bd4fc60963
6 changed files with 61 additions and 28 deletions

View File

@ -136,7 +136,7 @@ void ym2203_device::device_start()
const ay8910_interface *ay8910_config = m_ay8910_config != NULL ? m_ay8910_config : &default_ay8910_config;
m_irq_handler.resolve();
m_psg = ay8910_start_ym(NULL, YM2203, this, clock(), ay8910_config);
m_psg = ay8910_start_ym(NULL, type(), this, clock(), ay8910_config);
assert_always(m_psg != NULL, "Error creating YM2203/AY8910 chip");
/* Timer Handler set */
@ -206,7 +206,8 @@ const device_type YM2203 = &device_creator<ym2203_device>;
ym2203_device::ym2203_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, YM2203, "YM2203", tag, owner, clock),
device_sound_interface(mconfig, *this),
m_irq_handler(*this)
m_irq_handler(*this),
m_ay8910_config(NULL)
{
}

View File

@ -205,7 +205,8 @@ const device_type YM2608 = &device_creator<ym2608_device>;
ym2608_device::ym2608_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, YM2608, "YM2608", tag, owner, clock),
device_sound_interface(mconfig, *this),
m_irq_handler(*this)
m_irq_handler(*this),
m_ay8910_config(NULL)
{
}

View File

@ -1711,9 +1711,7 @@ void ymf271_device::device_start()
void ymf271_device::device_reset()
{
int i;
for (i = 0; i < 48; i++)
for (int i = 0; i < 48; i++)
{
m_slots[i].active = 0;
m_slots[i].volume = 0;
@ -1725,10 +1723,27 @@ const device_type YMF271 = &device_creator<ymf271_device>;
ymf271_device::ymf271_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, YMF271, "YMF271", tag, owner, clock),
device_sound_interface(mconfig, *this),
m_timerA(0),
m_timerB(0),
m_timerAVal(0),
m_timerBVal(0),
m_irqstate(0),
m_status(0),
m_enable(0),
m_reg0(0),
m_reg1(0),
m_reg2(0),
m_reg3(0),
m_pcmreg(0),
m_timerreg(0),
m_ext_address(0),
m_ext_read(0),
m_irq_handler(*this),
m_ext_read_handler(*this),
m_ext_write_handler(*this)
{
memset(m_slots, 0, sizeof(&m_slots));
memset(m_groups, 0, sizeof(&m_groups));
}
//-------------------------------------------------

View File

@ -115,25 +115,32 @@ private:
YMF271Slot m_slots[48];
YMF271Group m_groups[12];
INT32 m_timerA, m_timerB;
INT32 m_timerAVal, m_timerBVal;
INT32 m_timerA;
INT32 m_timerB;
INT32 m_timerAVal;
INT32 m_timerBVal;
INT32 m_irqstate;
INT8 m_status;
INT8 m_enable;
emu_timer *m_timA, *m_timB;
INT8 m_reg0, m_reg1, m_reg2, m_reg3, m_pcmreg, m_timerreg;
INT8 m_reg0;
INT8 m_reg1;
INT8 m_reg2;
INT8 m_reg3;
INT8 m_pcmreg;
INT8 m_timerreg;
UINT32 m_ext_address;
UINT8 m_ext_read;
const UINT8 *m_rom;
UINT32 m_clock;
emu_timer *m_timA, *m_timB;
sound_stream *m_stream;
devcb2_write_line m_irq_handler;
devcb2_read8 m_ext_read_handler;
devcb2_write8 m_ext_write_handler;
UINT32 m_clock;
sound_stream * m_stream;
};
extern const device_type YMF271;

View File

@ -648,10 +648,8 @@ void ymz280b_device::device_start()
void ymz280b_device::device_reset()
{
int i;
/* initial clear registers */
for (i = 0xff; i >= 0; i--)
for (int i = 0xff; i >= 0; i--)
{
m_current_register = i;
write_to_register(0);
@ -662,7 +660,7 @@ void ymz280b_device::device_reset()
m_rom_readback_addr = 0;
/* clear other voice parameters */
for (i = 0; i < 8; i++)
for (int i = 0; i < 8; i++)
{
struct YMZ280BVoice *voice = &m_voice[i];
@ -935,10 +933,21 @@ const device_type YMZ280B = &device_creator<ymz280b_device>;
ymz280b_device::ymz280b_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, YMZ280B, "YMZ280B", tag, owner, clock),
device_sound_interface(mconfig, *this),
m_current_register(0),
m_status_register(0),
m_irq_state(0),
m_irq_mask(0),
m_irq_enable(0),
m_keyon_enable(0),
m_ext_mem_enable(0),
m_rom_addr_hi(0),
m_rom_addr_mid(0),
m_rom_readback_addr(0),
m_irq_handler(*this),
m_ext_read_handler(*this),
m_ext_write_handler(*this)
{
memset(m_voice, 0, sizeof(m_voice));
}
//-------------------------------------------------

View File

@ -97,9 +97,7 @@ private:
int compute_status();
// internal state
sound_stream * m_stream; /* which stream are we using */
UINT8 *m_region_base; /* pointer to the base of the region */
UINT32 m_region_size;
struct YMZ280BVoice m_voice[8]; /* the 8 voices */
UINT8 m_current_register; /* currently accessible register */
UINT8 m_status_register; /* current status register */
UINT8 m_irq_state; /* current IRQ state */
@ -107,20 +105,22 @@ private:
UINT8 m_irq_enable; /* current IRQ enable */
UINT8 m_keyon_enable; /* key on enable */
UINT8 m_ext_mem_enable; /* external memory enable */
double m_master_clock; /* master clock frequency */
devcb2_write_line m_irq_handler; /* IRQ callback */
struct YMZ280BVoice m_voice[8]; /* the 8 voices */
UINT32 m_rom_addr_hi;
UINT32 m_rom_addr_mid;
UINT32 m_rom_readback_addr; /* where the CPU can read the ROM */
devcb2_write_line m_irq_handler; /* IRQ callback */
devcb2_read8 m_ext_read_handler; /* external RAM read handler */
devcb2_write8 m_ext_write_handler;/* external RAM write handler */
#if MAKE_WAVS
void * m_wavresample; /* resampled waveform */
#endif
double m_master_clock; /* master clock frequency */
UINT8 *m_region_base; /* pointer to the base of the region */
UINT32 m_region_size;
sound_stream *m_stream; /* which stream are we using */
INT16 *m_scratch;
#if MAKE_WAVS
void *m_wavresample; /* resampled waveform */
#endif
};
extern const device_type YMZ280B;