mirror of
https://github.com/holub/mame
synced 2025-10-05 08:41:31 +03:00
vgmplay : Add K051649 support (#3131)
This commit is contained in:
parent
11e18ca812
commit
053fd7699f
@ -37,6 +37,7 @@ SOUNDS["YMF271"] = true
|
|||||||
SOUNDS["YMZ280B"] = true
|
SOUNDS["YMZ280B"] = true
|
||||||
SOUNDS["C6280"] = true
|
SOUNDS["C6280"] = true
|
||||||
SOUNDS["SN76496"] = true
|
SOUNDS["SN76496"] = true
|
||||||
|
SOUNDS["K051649"] = true
|
||||||
SOUNDS["K053260"] = true
|
SOUNDS["K053260"] = true
|
||||||
SOUNDS["K054539"] = true
|
SOUNDS["K054539"] = true
|
||||||
SOUNDS["SEGAPCM"] = true
|
SOUNDS["SEGAPCM"] = true
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
#include "k051649.h"
|
#include "k051649.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#define FREQ_BITS 16
|
#define FREQ_BITS 16
|
||||||
#define DEF_GAIN 8
|
#define DEF_GAIN 8
|
||||||
@ -51,7 +52,6 @@ k051649_device::k051649_device(const machine_config &mconfig, const char *tag, d
|
|||||||
m_rate(0),
|
m_rate(0),
|
||||||
m_mixer_table(nullptr),
|
m_mixer_table(nullptr),
|
||||||
m_mixer_lookup(nullptr),
|
m_mixer_lookup(nullptr),
|
||||||
m_mixer_buffer(nullptr),
|
|
||||||
m_test(0)
|
m_test(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ void k051649_device::device_start()
|
|||||||
m_mclock = clock();
|
m_mclock = clock();
|
||||||
|
|
||||||
// allocate a buffer to mix into - 1 second's worth should be more than enough
|
// allocate a buffer to mix into - 1 second's worth should be more than enough
|
||||||
m_mixer_buffer = std::make_unique<short[]>(2 * m_rate);
|
m_mixer_buffer.resize(2 * m_rate);
|
||||||
|
|
||||||
// build the mixer table
|
// build the mixer table
|
||||||
make_mixer_table(5);
|
make_mixer_table(5);
|
||||||
@ -96,6 +96,35 @@ void k051649_device::device_reset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// device_post_load - device-specific post-load
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
void k051649_device::device_post_load()
|
||||||
|
{
|
||||||
|
device_clock_changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// device_clock_changed - called if the clock
|
||||||
|
// changes
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
void k051649_device::device_clock_changed()
|
||||||
|
{
|
||||||
|
uint32_t old_rate = m_rate;
|
||||||
|
m_rate = clock()/16;
|
||||||
|
m_mclock = clock();
|
||||||
|
|
||||||
|
if (old_rate < m_rate)
|
||||||
|
{
|
||||||
|
m_mixer_buffer.resize(2 * m_rate, 0);
|
||||||
|
}
|
||||||
|
m_stream->set_sample_rate(m_rate);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// sound_stream_update - handle a stream update
|
// sound_stream_update - handle a stream update
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
@ -103,7 +132,7 @@ void k051649_device::device_reset()
|
|||||||
void k051649_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
|
void k051649_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
|
||||||
{
|
{
|
||||||
// zap the contents of the mixer buffer
|
// zap the contents of the mixer buffer
|
||||||
memset(m_mixer_buffer.get(), 0, samples * sizeof(short));
|
std::fill(m_mixer_buffer.begin(), m_mixer_buffer.end(), 0);
|
||||||
|
|
||||||
for (sound_channel &voice : m_channel_list)
|
for (sound_channel &voice : m_channel_list)
|
||||||
{
|
{
|
||||||
@ -115,8 +144,6 @@ void k051649_device::sound_stream_update(sound_stream &stream, stream_sample_t *
|
|||||||
int c=voice.counter;
|
int c=voice.counter;
|
||||||
int step = ((int64_t(m_mclock) << FREQ_BITS) / float((voice.frequency + 1) * 16 * (m_rate / 32))) + 0.5f;
|
int step = ((int64_t(m_mclock) << FREQ_BITS) / float((voice.frequency + 1) * 16 * (m_rate / 32))) + 0.5f;
|
||||||
|
|
||||||
short *mix = m_mixer_buffer.get();
|
|
||||||
|
|
||||||
// add our contribution
|
// add our contribution
|
||||||
for (int i = 0; i < samples; i++)
|
for (int i = 0; i < samples; i++)
|
||||||
{
|
{
|
||||||
@ -124,7 +151,7 @@ void k051649_device::sound_stream_update(sound_stream &stream, stream_sample_t *
|
|||||||
|
|
||||||
c += step;
|
c += step;
|
||||||
offs = (c >> FREQ_BITS) & 0x1f;
|
offs = (c >> FREQ_BITS) & 0x1f;
|
||||||
*mix++ += (w[offs] * v)>>3;
|
m_mixer_buffer[i] += (w[offs] * v)>>3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the counter for this voice
|
// update the counter for this voice
|
||||||
@ -134,9 +161,8 @@ void k051649_device::sound_stream_update(sound_stream &stream, stream_sample_t *
|
|||||||
|
|
||||||
// mix it down
|
// mix it down
|
||||||
stream_sample_t *buffer = outputs[0];
|
stream_sample_t *buffer = outputs[0];
|
||||||
short *mix = m_mixer_buffer.get();
|
|
||||||
for (int i = 0; i < samples; i++)
|
for (int i = 0; i < samples; i++)
|
||||||
*buffer++ = m_mixer_lookup[*mix++];
|
*buffer++ = m_mixer_lookup[m_mixer_buffer[i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,6 +44,8 @@ protected:
|
|||||||
// device-level overrides
|
// device-level overrides
|
||||||
virtual void device_start() override;
|
virtual void device_start() override;
|
||||||
virtual void device_reset() override;
|
virtual void device_reset() override;
|
||||||
|
virtual void device_post_load() override;
|
||||||
|
virtual void device_clock_changed() override;
|
||||||
|
|
||||||
// sound stream update overrides
|
// sound stream update overrides
|
||||||
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
|
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
|
||||||
@ -58,7 +60,7 @@ private:
|
|||||||
volume(0),
|
volume(0),
|
||||||
key(0)
|
key(0)
|
||||||
{
|
{
|
||||||
memset(waveram, 0, sizeof(signed char)*32);
|
std::fill(std::begin(waveram), std::end(waveram), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long counter;
|
unsigned long counter;
|
||||||
@ -80,7 +82,7 @@ private:
|
|||||||
/* mixer tables and internal buffers */
|
/* mixer tables and internal buffers */
|
||||||
std::unique_ptr<int16_t[]> m_mixer_table;
|
std::unique_ptr<int16_t[]> m_mixer_table;
|
||||||
int16_t *m_mixer_lookup;
|
int16_t *m_mixer_lookup;
|
||||||
std::unique_ptr<short[]> m_mixer_buffer;
|
std::vector<short> m_mixer_buffer;
|
||||||
|
|
||||||
/* chip registers */
|
/* chip registers */
|
||||||
uint8_t m_test;
|
uint8_t m_test;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "sound/c352.h"
|
#include "sound/c352.h"
|
||||||
#include "sound/c6280.h"
|
#include "sound/c6280.h"
|
||||||
#include "sound/gb.h"
|
#include "sound/gb.h"
|
||||||
|
#include "sound/k051649.h"
|
||||||
#include "sound/k053260.h"
|
#include "sound/k053260.h"
|
||||||
#include "sound/k054539.h"
|
#include "sound/k054539.h"
|
||||||
#include "sound/multipcm.h"
|
#include "sound/multipcm.h"
|
||||||
@ -83,7 +84,8 @@ public:
|
|||||||
A_YM2608 = 0x00013060,
|
A_YM2608 = 0x00013060,
|
||||||
A_K054539A = 0x00014000,
|
A_K054539A = 0x00014000,
|
||||||
A_K054539B = 0x00014400,
|
A_K054539B = 0x00014400,
|
||||||
A_QSOUND = 0x00013070
|
A_QSOUND = 0x00013070,
|
||||||
|
A_K051649 = 0x00013080
|
||||||
};
|
};
|
||||||
|
|
||||||
enum io16_t
|
enum io16_t
|
||||||
@ -180,6 +182,7 @@ public:
|
|||||||
|
|
||||||
template<int Chip> DECLARE_WRITE8_MEMBER(okim6295_clock_w);
|
template<int Chip> DECLARE_WRITE8_MEMBER(okim6295_clock_w);
|
||||||
template<int Chip> DECLARE_WRITE8_MEMBER(okim6295_pin7_w);
|
template<int Chip> DECLARE_WRITE8_MEMBER(okim6295_pin7_w);
|
||||||
|
DECLARE_WRITE8_MEMBER(scc_w);
|
||||||
|
|
||||||
void vgmplay(machine_config &config);
|
void vgmplay(machine_config &config);
|
||||||
private:
|
private:
|
||||||
@ -209,9 +212,11 @@ private:
|
|||||||
required_device<ymz280b_device> m_ymz280b;
|
required_device<ymz280b_device> m_ymz280b;
|
||||||
required_device<ym2608_device> m_ym2608;
|
required_device<ym2608_device> m_ym2608;
|
||||||
required_device<qsound_device> m_qsound;
|
required_device<qsound_device> m_qsound;
|
||||||
|
required_device<k051649_device> m_k051649;
|
||||||
|
|
||||||
uint32_t m_okim6295_clock[2];
|
uint32_t m_okim6295_clock[2];
|
||||||
uint32_t m_okim6295_pin7[2];
|
uint32_t m_okim6295_pin7[2];
|
||||||
|
uint8_t m_scc_reg;
|
||||||
|
|
||||||
uint32_t r32(int offset) const;
|
uint32_t r32(int offset) const;
|
||||||
uint8_t r8(int offset) const;
|
uint8_t r8(int offset) const;
|
||||||
@ -566,6 +571,15 @@ void vgmplay_device::execute_run()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 0xd2:
|
||||||
|
{
|
||||||
|
uint32_t offset = m_file->read_byte(m_pc+1) << 1;
|
||||||
|
m_io->write_byte(A_K051649 + (offset | 0), m_file->read_byte(m_pc+2));
|
||||||
|
m_io->write_byte(A_K051649 + (offset | 1), m_file->read_byte(m_pc+3));
|
||||||
|
m_pc += 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 0xd3:
|
case 0xd3:
|
||||||
{
|
{
|
||||||
uint16_t offset = m_file->read_byte(m_pc+1) << 16 | m_file->read_byte(m_pc+2);
|
uint16_t offset = m_file->read_byte(m_pc+1) << 16 | m_file->read_byte(m_pc+2);
|
||||||
@ -1064,6 +1078,7 @@ vgmplay_state::vgmplay_state(const machine_config &mconfig, device_type type, co
|
|||||||
, m_ymz280b(*this, "ymz280b")
|
, m_ymz280b(*this, "ymz280b")
|
||||||
, m_ym2608(*this, "ym2608")
|
, m_ym2608(*this, "ym2608")
|
||||||
, m_qsound(*this, "qsound")
|
, m_qsound(*this, "qsound")
|
||||||
|
, m_k051649(*this, "k051649")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1282,6 +1297,9 @@ void vgmplay_state::machine_start()
|
|||||||
m_okim6295[1]->set_unscaled_clock(m_okim6295_clock[1]);
|
m_okim6295[1]->set_unscaled_clock(m_okim6295_clock[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(version >= 0x161 && r32(0x9c)) {
|
||||||
|
m_k051649->set_unscaled_clock(r32(0x9c));
|
||||||
|
}
|
||||||
if(version >= 0x161 && r32(0xa0)) {
|
if(version >= 0x161 && r32(0xa0)) {
|
||||||
uint32_t clock = r32(0xa0);
|
uint32_t clock = r32(0xa0);
|
||||||
m_k054539[0]->set_unscaled_clock(clock & ~0x40000000);
|
m_k054539[0]->set_unscaled_clock(clock & ~0x40000000);
|
||||||
@ -1400,6 +1418,39 @@ WRITE8_MEMBER(vgmplay_device::okim6295_nmk112_bank_w)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WRITE8_MEMBER(vgmplay_state::scc_w)
|
||||||
|
{
|
||||||
|
switch(offset & 1)
|
||||||
|
{
|
||||||
|
case 0x00:
|
||||||
|
m_scc_reg = data;
|
||||||
|
break;
|
||||||
|
case 0x01:
|
||||||
|
switch(offset >> 1)
|
||||||
|
{
|
||||||
|
case 0x00:
|
||||||
|
m_k051649->k051649_waveform_w(space, m_scc_reg, data);
|
||||||
|
break;
|
||||||
|
case 0x01:
|
||||||
|
m_k051649->k051649_frequency_w(space, m_scc_reg, data);
|
||||||
|
break;
|
||||||
|
case 0x02:
|
||||||
|
m_k051649->k051649_volume_w(space, m_scc_reg, data);
|
||||||
|
break;
|
||||||
|
case 0x03:
|
||||||
|
m_k051649->k051649_keyonoff_w(space, m_scc_reg, data);
|
||||||
|
break;
|
||||||
|
case 0x04:
|
||||||
|
m_k051649->k052539_waveform_w(space, m_scc_reg, data);
|
||||||
|
break;
|
||||||
|
case 0x05:
|
||||||
|
m_k051649->k051649_test_w(space, m_scc_reg, data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static INPUT_PORTS_START( vgmplay )
|
static INPUT_PORTS_START( vgmplay )
|
||||||
INPUT_PORTS_END
|
INPUT_PORTS_END
|
||||||
|
|
||||||
@ -1459,6 +1510,7 @@ static ADDRESS_MAP_START( soundchips_map, AS_IO, 8, vgmplay_state )
|
|||||||
AM_RANGE(vgmplay_device::A_K054539A, vgmplay_device::A_K054539A+0x22f) AM_DEVWRITE ("k054539a", k054539_device, write)
|
AM_RANGE(vgmplay_device::A_K054539A, vgmplay_device::A_K054539A+0x22f) AM_DEVWRITE ("k054539a", k054539_device, write)
|
||||||
AM_RANGE(vgmplay_device::A_K054539B, vgmplay_device::A_K054539B+0x22f) AM_DEVWRITE ("k054539b", k054539_device, write)
|
AM_RANGE(vgmplay_device::A_K054539B, vgmplay_device::A_K054539B+0x22f) AM_DEVWRITE ("k054539b", k054539_device, write)
|
||||||
AM_RANGE(vgmplay_device::A_QSOUND, vgmplay_device::A_QSOUND+0x2) AM_DEVWRITE ("qsound", qsound_device, qsound_w)
|
AM_RANGE(vgmplay_device::A_QSOUND, vgmplay_device::A_QSOUND+0x2) AM_DEVWRITE ("qsound", qsound_device, qsound_w)
|
||||||
|
AM_RANGE(vgmplay_device::A_K051649, vgmplay_device::A_K051649+0xf) AM_WRITE (scc_w)
|
||||||
ADDRESS_MAP_END
|
ADDRESS_MAP_END
|
||||||
|
|
||||||
static ADDRESS_MAP_START( segapcm_map, 0, 8, vgmplay_state )
|
static ADDRESS_MAP_START( segapcm_map, 0, 8, vgmplay_state )
|
||||||
@ -1661,6 +1713,10 @@ MACHINE_CONFIG_START(vgmplay_state::vgmplay)
|
|||||||
MCFG_DEVICE_ADDRESS_MAP(0, qsound_map)
|
MCFG_DEVICE_ADDRESS_MAP(0, qsound_map)
|
||||||
MCFG_SOUND_ROUTE(0, "lspeaker", 1)
|
MCFG_SOUND_ROUTE(0, "lspeaker", 1)
|
||||||
MCFG_SOUND_ROUTE(1, "rspeaker", 1)
|
MCFG_SOUND_ROUTE(1, "rspeaker", 1)
|
||||||
|
|
||||||
|
MCFG_K051649_ADD("k051649", 3579545)
|
||||||
|
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.33)
|
||||||
|
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.33)
|
||||||
MACHINE_CONFIG_END
|
MACHINE_CONFIG_END
|
||||||
|
|
||||||
ROM_START( vgmplay )
|
ROM_START( vgmplay )
|
||||||
|
Loading…
Reference in New Issue
Block a user