mirror of
https://github.com/holub/mame
synced 2025-04-28 19:14:55 +03:00
sound/namco: Eliminate auto_alloc
This commit is contained in:
parent
f5d8c8cbb7
commit
11c06a36ab
@ -87,8 +87,6 @@ namco_cus30_device::namco_cus30_device(const machine_config &mconfig, const char
|
|||||||
|
|
||||||
void namco_audio_device::device_start()
|
void namco_audio_device::device_start()
|
||||||
{
|
{
|
||||||
sound_channel *voice;
|
|
||||||
|
|
||||||
/* extract globals from the interface */
|
/* extract globals from the interface */
|
||||||
m_last_channel = m_channel_list + m_voices;
|
m_last_channel = m_channel_list + m_voices;
|
||||||
|
|
||||||
@ -114,13 +112,12 @@ void namco_audio_device::device_start()
|
|||||||
|
|
||||||
save_item(NAME(m_voices));
|
save_item(NAME(m_voices));
|
||||||
save_item(NAME(m_sound_enable));
|
save_item(NAME(m_sound_enable));
|
||||||
save_pointer(NAME(m_waveform[0]), MAX_VOLUME * 32 * 8 * (1+m_wave_size));
|
for (int v = 0; v < MAX_VOLUME; v++)
|
||||||
|
save_pointer(NAME(m_waveform[v]), 32 * 8 * (1+m_wave_size), v);
|
||||||
|
|
||||||
/* reset all the voices */
|
/* reset all the voices */
|
||||||
for (voice = m_channel_list; voice < m_last_channel; voice++)
|
for (sound_channel *voice = m_channel_list; voice < m_last_channel; voice++)
|
||||||
{
|
{
|
||||||
int voicenum = voice - m_channel_list;
|
|
||||||
|
|
||||||
voice->frequency = 0;
|
voice->frequency = 0;
|
||||||
voice->volume[0] = voice->volume[1] = 0;
|
voice->volume[0] = voice->volume[1] = 0;
|
||||||
voice->waveform_select = 0;
|
voice->waveform_select = 0;
|
||||||
@ -130,18 +127,18 @@ void namco_audio_device::device_start()
|
|||||||
voice->noise_seed = 1;
|
voice->noise_seed = 1;
|
||||||
voice->noise_counter = 0;
|
voice->noise_counter = 0;
|
||||||
voice->noise_hold = 0;
|
voice->noise_hold = 0;
|
||||||
|
|
||||||
/* register with the save state system */
|
|
||||||
save_item(NAME(voice->frequency), voicenum);
|
|
||||||
save_item(NAME(voice->counter), voicenum);
|
|
||||||
save_item(NAME(voice->volume), voicenum);
|
|
||||||
save_item(NAME(voice->noise_sw), voicenum);
|
|
||||||
save_item(NAME(voice->noise_state), voicenum);
|
|
||||||
save_item(NAME(voice->noise_seed), voicenum);
|
|
||||||
save_item(NAME(voice->noise_hold), voicenum);
|
|
||||||
save_item(NAME(voice->noise_counter), voicenum);
|
|
||||||
save_item(NAME(voice->waveform_select), voicenum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* register with the save state system */
|
||||||
|
save_pointer(STRUCT_MEMBER(m_channel_list, frequency), m_voices);
|
||||||
|
save_pointer(STRUCT_MEMBER(m_channel_list, counter), m_voices);
|
||||||
|
save_pointer(STRUCT_MEMBER(m_channel_list, volume), m_voices);
|
||||||
|
save_pointer(STRUCT_MEMBER(m_channel_list, noise_sw), m_voices);
|
||||||
|
save_pointer(STRUCT_MEMBER(m_channel_list, noise_state), m_voices);
|
||||||
|
save_pointer(STRUCT_MEMBER(m_channel_list, noise_seed), m_voices);
|
||||||
|
save_pointer(STRUCT_MEMBER(m_channel_list, noise_hold), m_voices);
|
||||||
|
save_pointer(STRUCT_MEMBER(m_channel_list, noise_counter), m_voices);
|
||||||
|
save_pointer(STRUCT_MEMBER(m_channel_list, waveform_select), m_voices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -196,14 +193,16 @@ void namco_audio_device::update_namco_waveform(int offset, uint8_t data)
|
|||||||
/* build the decoded waveform table */
|
/* build the decoded waveform table */
|
||||||
void namco_audio_device::build_decoded_waveform(uint8_t *rgnbase)
|
void namco_audio_device::build_decoded_waveform(uint8_t *rgnbase)
|
||||||
{
|
{
|
||||||
int16_t *p;
|
if (rgnbase != nullptr)
|
||||||
int size;
|
m_wavedata = rgnbase;
|
||||||
int offset;
|
else
|
||||||
int v;
|
{
|
||||||
|
m_waveram_alloc = make_unique_clear<uint8_t[]>(0x400);
|
||||||
m_wavedata = (rgnbase != nullptr) ? rgnbase : auto_alloc_array_clear(machine(), uint8_t, 0x400);
|
m_wavedata = m_waveram_alloc.get();
|
||||||
|
}
|
||||||
|
|
||||||
/* 20pacgal has waves in RAM but old sound system */
|
/* 20pacgal has waves in RAM but old sound system */
|
||||||
|
int size;
|
||||||
if (rgnbase == nullptr && m_voices != 3)
|
if (rgnbase == nullptr && m_voices != 3)
|
||||||
{
|
{
|
||||||
m_wave_size = 1;
|
m_wave_size = 1;
|
||||||
@ -215,20 +214,11 @@ void namco_audio_device::build_decoded_waveform(uint8_t *rgnbase)
|
|||||||
size = 32 * 8; /* 32 samples, 8 waveforms */
|
size = 32 * 8; /* 32 samples, 8 waveforms */
|
||||||
}
|
}
|
||||||
|
|
||||||
p = auto_alloc_array(machine(), int16_t, size * MAX_VOLUME);
|
for (int v = 0; v < MAX_VOLUME; v++)
|
||||||
|
m_waveform[v] = std::make_unique<int16_t[]>(size);
|
||||||
|
|
||||||
for (v = 0; v < MAX_VOLUME; v++)
|
for (int offset = 0; offset < 256; offset++)
|
||||||
{
|
update_namco_waveform(offset, m_wavedata[offset]);
|
||||||
m_waveform[v] = p;
|
|
||||||
p += size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We need waveform data. It fails if region is not specified. */
|
|
||||||
if (m_wavedata)
|
|
||||||
{
|
|
||||||
for (offset = 0; offset < 256; offset++)
|
|
||||||
update_namco_waveform(offset, m_wavedata[offset]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,8 +66,10 @@ protected:
|
|||||||
int m_voices; /* number of voices */
|
int m_voices; /* number of voices */
|
||||||
bool m_stereo; /* set to indicate stereo (e.g., System 1) */
|
bool m_stereo; /* set to indicate stereo (e.g., System 1) */
|
||||||
|
|
||||||
|
std::unique_ptr<uint8_t[]> m_waveram_alloc;
|
||||||
|
|
||||||
/* decoded waveform table */
|
/* decoded waveform table */
|
||||||
int16_t *m_waveform[MAX_VOLUME];
|
std::unique_ptr<int16_t[]> m_waveform[MAX_VOLUME];
|
||||||
|
|
||||||
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
|
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
|
||||||
};
|
};
|
||||||
@ -79,8 +81,6 @@ public:
|
|||||||
|
|
||||||
void pacman_sound_w(offs_t offset, uint8_t data);
|
void pacman_sound_w(offs_t offset, uint8_t data);
|
||||||
|
|
||||||
void polepos_sound_enable(int enable);
|
|
||||||
|
|
||||||
uint8_t polepos_sound_r(offs_t offset);
|
uint8_t polepos_sound_r(offs_t offset);
|
||||||
void polepos_sound_w(offs_t offset, uint8_t data);
|
void polepos_sound_w(offs_t offset, uint8_t data);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user