vgmplay.cpp : Add GA20 Support

iremga20.cpp : Minor cleanups, Remove MCFGs
This commit is contained in:
cam900 2018-07-12 03:39:01 +09:00 committed by Vas Crabb
parent 687c87abc0
commit 4e5169fd0b
6 changed files with 81 additions and 32 deletions

View File

@ -31,6 +31,8 @@ Revisions:
#include "emu.h"
#include "iremga20.h"
#include <algorithm>
#define MAX_VOL 256
@ -46,11 +48,11 @@ DEFINE_DEVICE_TYPE(IREMGA20, iremga20_device, "iremga20", "Irem GA20")
// iremga20_device - constructor
//-------------------------------------------------
iremga20_device::iremga20_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, IREMGA20, tag, owner, clock),
device_sound_interface(mconfig, *this),
m_rom(*this, DEVICE_SELF),
m_stream(nullptr)
iremga20_device::iremga20_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, IREMGA20, tag, owner, clock),
device_sound_interface(mconfig, *this),
device_rom_interface(mconfig, *this, 20),
m_stream(nullptr)
{
}
@ -65,8 +67,7 @@ void iremga20_device::device_start()
iremga20_reset();
for ( i = 0; i < 0x40; i++ )
m_regs[i] = 0;
std::fill(std::begin(m_regs), std::end(m_regs), 0);
m_stream = stream_alloc(0, 2, clock()/4);
@ -96,6 +97,24 @@ void iremga20_device::device_reset()
iremga20_reset();
}
//-------------------------------------------------
// device_clock_changed - called if the clock
// changes
//-------------------------------------------------
void iremga20_device::device_clock_changed()
{
m_stream->set_sample_rate(clock()/4);
}
//-------------------------------------------------
// rom_bank_updated - the rom bank has changed
//-------------------------------------------------
void iremga20_device::rom_bank_updated()
{
m_stream->update();
}
//-------------------------------------------------
// sound_stream_update - handle a stream update
@ -104,7 +123,6 @@ void iremga20_device::device_reset()
void iremga20_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
{
uint32_t rate[4], pos[4], frac[4], end[4], vol[4], play[4];
uint8_t *pSamples;
stream_sample_t *outL, *outR;
int i, sampleout;
@ -120,7 +138,6 @@ void iremga20_device::sound_stream_update(sound_stream &stream, stream_sample_t
}
i = samples;
pSamples = &m_rom[0];
outL = outputs[0];
outR = outputs[1];
@ -131,7 +148,7 @@ void iremga20_device::sound_stream_update(sound_stream &stream, stream_sample_t
// update the 4 channels inline
if (play[0])
{
sampleout += (pSamples[pos[0]] - 0x80) * vol[0];
sampleout += (read_byte(pos[0]) - 0x80) * vol[0];
frac[0] += rate[0];
pos[0] += frac[0] >> 24;
frac[0] &= 0xffffff;
@ -139,7 +156,7 @@ void iremga20_device::sound_stream_update(sound_stream &stream, stream_sample_t
}
if (play[1])
{
sampleout += (pSamples[pos[1]] - 0x80) * vol[1];
sampleout += (read_byte(pos[1]) - 0x80) * vol[1];
frac[1] += rate[1];
pos[1] += frac[1] >> 24;
frac[1] &= 0xffffff;
@ -147,7 +164,7 @@ void iremga20_device::sound_stream_update(sound_stream &stream, stream_sample_t
}
if (play[2])
{
sampleout += (pSamples[pos[2]] - 0x80) * vol[2];
sampleout += (read_byte(pos[2]) - 0x80) * vol[2];
frac[2] += rate[2];
pos[2] += frac[2] >> 24;
frac[2] &= 0xffffff;
@ -155,7 +172,7 @@ void iremga20_device::sound_stream_update(sound_stream &stream, stream_sample_t
}
if (play[3])
{
sampleout += (pSamples[pos[3]] - 0x80) * vol[3];
sampleout += (read_byte(pos[3]) - 0x80) * vol[3];
frac[3] += rate[3];
pos[3] += frac[3] >> 24;
frac[3] &= 0xffffff;

View File

@ -11,16 +11,6 @@
#pragma once
//**************************************************************************
// INTERFACE CONFIGURATION MACROS
//**************************************************************************
#define MCFG_IREMGA20_ADD(_tag, _clock) \
MCFG_DEVICE_ADD(_tag, IREMGA20, _clock)
#define MCFG_IREMGA20_REPLACE(_tag, _clock) \
MCFG_DEVICE_REPLACE(_tag, IREMGA20, _clock)
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
@ -29,7 +19,8 @@
// ======================> iremga20_device
class iremga20_device : public device_t,
public device_sound_interface
public device_sound_interface,
public device_rom_interface
{
public:
iremga20_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
@ -41,10 +32,14 @@ protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_clock_changed() override;
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
// device_rom_interface overrides
virtual void rom_bank_updated() override;
private:
struct channel_def
{
@ -62,9 +57,8 @@ private:
void iremga20_reset();
required_region_ptr<uint8_t> m_rom;
sound_stream *m_stream;
uint16_t m_regs[0x40];
uint8_t m_regs[0x40/2];
channel_def m_channel[4];
};

View File

@ -764,9 +764,9 @@ MACHINE_CONFIG_START(m107_state::firebarr)
MCFG_SOUND_ROUTE(0, "lspeaker", 0.40)
MCFG_SOUND_ROUTE(1, "rspeaker", 0.40)
MCFG_IREMGA20_ADD("irem", XTAL(14'318'181)/4)
MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
iremga20_device &ga20(IREMGA20(config, "irem", XTAL(14'318'181)/4));
ga20.add_route(0, "lspeaker", 1.0);
ga20.add_route(1, "rspeaker", 1.0);
MACHINE_CONFIG_END
MACHINE_CONFIG_START(m107_state::dsoccr94)

View File

@ -964,8 +964,8 @@ MACHINE_CONFIG_START(m92_state::m92)
MCFG_SOUND_ROUTE(0, "mono", 0.40)
MCFG_SOUND_ROUTE(1, "mono", 0.40)
MCFG_IREMGA20_ADD("irem", XTAL(14'318'181)/4)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
iremga20_device &ga20(IREMGA20(config, "irem", XTAL(14'318'181)/4));
ga20.add_route(ALL_OUTPUTS, "mono", 1.0);
MACHINE_CONFIG_END

View File

@ -20,6 +20,7 @@
#include "sound/c352.h"
#include "sound/c6280.h"
#include "sound/gb.h"
#include "sound/iremga20.h"
#include "sound/k051649.h"
#include "sound/k053260.h"
#include "sound/k054539.h"
@ -93,7 +94,8 @@ public:
A_K054539A = 0x00014000,
A_K054539B = 0x00014400,
A_QSOUND = 0x00013070,
A_K051649 = 0x00013080
A_K051649 = 0x00013080,
A_GA20 = 0x000130a0
};
enum io16_t
@ -126,6 +128,7 @@ public:
template<int Chip> DECLARE_READ8_MEMBER(k054539_rom_r);
DECLARE_READ8_MEMBER(c352_rom_r);
DECLARE_READ8_MEMBER(qsound_rom_r);
DECLARE_READ8_MEMBER(ga20_rom_r);
template<int Chip> DECLARE_WRITE8_MEMBER(multipcm_bank_hi_w);
template<int Chip> DECLARE_WRITE8_MEMBER(multipcm_bank_lo_w);
@ -182,6 +185,8 @@ private:
LED_K053260,
LED_K054539,
LED_GA20,
LED_COUNT
};
@ -268,6 +273,7 @@ public:
void vgmplay(machine_config &config);
void c352_map(address_map &map);
void file_map(address_map &map);
void ga20_map(address_map &map);
void h6280_io_map(address_map &map);
void h6280_map(address_map &map);
void k053260_map(address_map &map);
@ -316,6 +322,7 @@ private:
required_device<ym2608_device> m_ym2608;
required_device<qsound_device> m_qsound;
required_device<k051649_device> m_k051649;
required_device<iremga20_device> m_ga20;
uint32_t m_okim6295_clock[2];
uint32_t m_okim6295_pin7[2];
@ -726,6 +733,13 @@ void vgmplay_device::execute_run()
break;
}
case 0xbf: {
pulse_act_led(LED_GA20);
m_io->write_byte(A_GA20 + m_file->read_byte(m_pc+1), m_file->read_byte(m_pc+2));
m_pc += 3;
break;
}
case 0xc0:
pulse_act_led(LED_SEGAPCM);
m_io->write_byte(A_SEGAPCM + (m_file->read_word(m_pc+1) & 0x7ff), m_file->read_byte(m_pc+3));
@ -1253,6 +1267,11 @@ READ8_MEMBER(vgmplay_device::c352_rom_r)
return rom_r(0, 0x92, offset);
}
READ8_MEMBER(vgmplay_device::ga20_rom_r)
{
return rom_r(0, 0x93, offset);
}
vgmplay_state::vgmplay_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
, m_file(*this, "file")
@ -1284,6 +1303,7 @@ vgmplay_state::vgmplay_state(const machine_config &mconfig, device_type type, co
, m_ym2608(*this, "ym2608")
, m_qsound(*this, "qsound")
, m_k051649(*this, "k051649")
, m_ga20(*this, "ga20")
{
}
@ -1547,6 +1567,9 @@ void vgmplay_state::machine_start()
if(version >= 0x171 && r32(0xdc)) {
m_c352->set_unscaled_clock(r32(0xdc));
}
if(version >= 0x171 && r32(0xe0)) {
m_ga20->set_unscaled_clock(r32(0xe0));
}
}
}
}
@ -1758,6 +1781,7 @@ void vgmplay_state::soundchips_map(address_map &map)
map(vgmplay_device::A_K054539B, vgmplay_device::A_K054539B+0x22f).w("k054539b", FUNC(k054539_device::write));
map(vgmplay_device::A_QSOUND, vgmplay_device::A_QSOUND+0x2).w(m_qsound, FUNC(qsound_device::qsound_w));
map(vgmplay_device::A_K051649, vgmplay_device::A_K051649+0xf).w(FUNC(vgmplay_state::scc_w));
map(vgmplay_device::A_GA20, vgmplay_device::A_GA20+0x1f).w(m_ga20, FUNC(iremga20_device::irem_ga20_w));
}
void vgmplay_state::segapcm_map(address_map &map)
@ -1820,6 +1844,11 @@ void vgmplay_state::ymz280b_map(address_map &map)
map(0, 0xffffff).r("vgmplay", FUNC(vgmplay_device::ymz280b_rom_r));
}
void vgmplay_state::ga20_map(address_map &map)
{
map(0, 0xfffff).r("vgmplay", FUNC(vgmplay_device::ga20_rom_r));
}
void vgmplay_state::nescpu_map(address_map &map)
{
map(0, 0xffff).ram().share("nesapu_ram");
@ -1989,6 +2018,11 @@ MACHINE_CONFIG_START(vgmplay_state::vgmplay)
MCFG_K051649_ADD("k051649", 3579545)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.33)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.33)
IREMGA20(config, m_ga20, 3579545);
m_ga20->set_addrmap(0, &vgmplay_state::ga20_map);
m_ga20->add_route(0, "lspeaker", 1);
m_ga20->add_route(1, "rspeaker", 1);
MACHINE_CONFIG_END
ROM_START( vgmplay )

View File

@ -25,6 +25,7 @@
20: K051649
21: K053260
22: K054539
23: GA20
-->
<element name="backdrop"><rect><color red="0.0" green="0.0" blue="0.0" /></rect></element>
@ -57,6 +58,7 @@
<element name="act_label_k051649"><text string="K051649" align="1"><color red="1.0" green="1.0" blue="1.0" /></text></element>
<element name="act_label_k053260"><text string="K053260" align="1"><color red="1.0" green="1.0" blue="1.0" /></text></element>
<element name="act_label_k054539"><text string="K054539" align="1"><color red="1.0" green="1.0" blue="1.0" /></text></element>
<element name="act_label_ga20"><text string="GA20" align="1"><color red="1.0" green="1.0" blue="1.0" /></text></element>
<element name="static_black2"><rect><color red="0.2" green="0.21" blue="0.23" /></rect></element>
@ -113,6 +115,7 @@
<cpanel name="led_act_20" element="act_led"><bounds x="31" y="13" width="2" height="2" /></cpanel>
<cpanel name="led_act_21" element="act_led"><bounds x="31" y="16" width="2" height="2" /></cpanel>
<cpanel name="led_act_22" element="act_led"><bounds x="31" y="19" width="2" height="2" /></cpanel>
<cpanel name="led_act_23" element="act_led"><bounds x="31" y="22" width="2" height="2" /></cpanel>
<cpanel element="act_label_ay8910"><bounds x="4" y="1.2" width="10" height="1.6" /></cpanel>
<cpanel element="act_label_sn76496"><bounds x="4" y="4.2" width="10" height="1.6" /></cpanel>
@ -139,6 +142,7 @@
<cpanel element="act_label_k051649"><bounds x="34" y="13.2" width="10" height="1.6" /></cpanel>
<cpanel element="act_label_k053260"><bounds x="34" y="16.2" width="10" height="1.6" /></cpanel>
<cpanel element="act_label_k054539"><bounds x="34" y="19.2" width="10" height="1.6" /></cpanel>
<cpanel element="act_label_ga20"><bounds x="34" y="22.2" width="10" height="1.6" /></cpanel>
</group>
<view name="Internal Layout">