and an optimization

This commit is contained in:
Michaël Banaan Ananas 2013-06-28 01:59:26 +00:00
parent 80cf988718
commit bfbd892308
4 changed files with 16 additions and 13 deletions

View File

@ -633,14 +633,13 @@ void ymf271_device::sound_stream_update(sound_stream &stream, stream_sample_t **
int i, j; int i, j;
int op; int op;
INT32 *mixp; INT32 *mixp;
INT32 mix[48000*2];
memset(mix, 0, sizeof(mix[0])*samples*2); memset(m_mix_buffer, 0, sizeof(m_mix_buffer[0])*samples*2);
for (j = 0; j < 12; j++) for (j = 0; j < 12; j++)
{ {
YMF271Group *slot_group = &m_groups[j]; YMF271Group *slot_group = &m_groups[j];
mixp = &mix[0]; mixp = m_mix_buffer;
if (slot_group->pfm && slot_group->sync != 3) if (slot_group->pfm && slot_group->sync != 3)
{ {
@ -656,7 +655,7 @@ void ymf271_device::sound_stream_update(sound_stream &stream, stream_sample_t **
int slot2 = j + (1*12); int slot2 = j + (1*12);
int slot3 = j + (2*12); int slot3 = j + (2*12);
int slot4 = j + (3*12); int slot4 = j + (3*12);
mixp = &mix[0]; mixp = m_mix_buffer;
if (m_slots[slot1].active) if (m_slots[slot1].active)
{ {
@ -843,7 +842,7 @@ void ymf271_device::sound_stream_update(sound_stream &stream, stream_sample_t **
int slot1 = j + ((op + 0) * 12); int slot1 = j + ((op + 0) * 12);
int slot2 = j + ((op + 2) * 12); int slot2 = j + ((op + 2) * 12);
mixp = &mix[0]; mixp = m_mix_buffer;
if (m_slots[slot1].active) if (m_slots[slot1].active)
{ {
for (i = 0; i < samples; i++) for (i = 0; i < samples; i++)
@ -895,7 +894,7 @@ void ymf271_device::sound_stream_update(sound_stream &stream, stream_sample_t **
int slot1 = j + (0*12); int slot1 = j + (0*12);
int slot2 = j + (1*12); int slot2 = j + (1*12);
int slot3 = j + (2*12); int slot3 = j + (2*12);
mixp = &mix[0]; mixp = m_mix_buffer;
if (m_slots[slot1].active) if (m_slots[slot1].active)
{ {
@ -981,7 +980,7 @@ void ymf271_device::sound_stream_update(sound_stream &stream, stream_sample_t **
} }
} }
mixp = &mix[0]; mixp = m_mix_buffer;
update_pcm(j + (3*12), mixp, samples); update_pcm(j + (3*12), mixp, samples);
break; break;
} }
@ -997,7 +996,7 @@ void ymf271_device::sound_stream_update(sound_stream &stream, stream_sample_t **
} }
} }
mixp = &mix[0]; mixp = m_mix_buffer;
for (i = 0; i < samples; i++) for (i = 0; i < samples; i++)
{ {
outputs[0][i] = (*mixp++)>>2; outputs[0][i] = (*mixp++)>>2;
@ -1711,6 +1710,7 @@ void ymf271_device::device_start()
init_state(); init_state();
m_stream = machine().sound().stream_alloc(*this, 0, 2, clock()/384); m_stream = machine().sound().stream_alloc(*this, 0, 2, clock()/384);
m_mix_buffer = auto_alloc_array(machine(), INT32, 44100*2);
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {

View File

@ -65,7 +65,8 @@ private:
UINT32 loopaddr; UINT32 loopaddr;
UINT32 endaddr; UINT32 endaddr;
INT8 altloop; INT8 altloop;
INT8 fs, srcnote, srcb; INT8 fs;
INT8 srcnote, srcb;
INT64 step; INT64 step;
INT64 stepptr; INT64 stepptr;
@ -138,6 +139,7 @@ private:
emu_timer *m_timA, *m_timB; emu_timer *m_timA, *m_timB;
sound_stream *m_stream; sound_stream *m_stream;
INT32 *m_mix_buffer;
devcb2_write_line m_irq_handler; devcb2_write_line m_irq_handler;
devcb2_read8 m_ext_read_handler; devcb2_read8 m_ext_read_handler;

View File

@ -251,9 +251,8 @@ void ymf278b_device::sound_stream_update(sound_stream &stream, stream_sample_t *
INT16 sample = 0; INT16 sample = 0;
INT32 *mixp; INT32 *mixp;
INT32 vl, vr; INT32 vl, vr;
INT32 mix[44100*2];
memset(mix, 0, sizeof(mix[0])*samples*2); memset(m_mix_buffer, 0, sizeof(m_mix_buffer[0])*samples*2);
for (i = 0; i < 24; i++) for (i = 0; i < 24; i++)
{ {
@ -261,7 +260,7 @@ void ymf278b_device::sound_stream_update(sound_stream &stream, stream_sample_t *
if (slot->active) if (slot->active)
{ {
mixp = mix; mixp = m_mix_buffer;
for (j = 0; j < samples; j++) for (j = 0; j < samples; j++)
{ {
@ -320,7 +319,7 @@ void ymf278b_device::sound_stream_update(sound_stream &stream, stream_sample_t *
} }
} }
mixp = mix; mixp = m_mix_buffer;
vl = m_mix_level[m_pcm_l]; vl = m_mix_level[m_pcm_l];
vr = m_mix_level[m_pcm_r]; vr = m_mix_level[m_pcm_r];
for (i = 0; i < samples; i++) for (i = 0; i < samples; i++)
@ -972,6 +971,7 @@ void ymf278b_device::device_start()
} }
m_stream = machine().sound().stream_alloc(*this, 0, 2, clock()/768); m_stream = machine().sound().stream_alloc(*this, 0, 2, clock()/768);
m_mix_buffer = auto_alloc_array(machine(), INT32, 44100*2);
// rate tables // rate tables
precompute_rate_tables(); precompute_rate_tables();

View File

@ -125,6 +125,7 @@ private:
int m_clock; int m_clock;
sound_stream * m_stream; sound_stream * m_stream;
INT32 *m_mix_buffer;
devcb2_write_line m_irq_handler; devcb2_write_line m_irq_handler;
}; };