nes_apu: converted to use inline config. nw.

This commit is contained in:
Fabio Priuli 2014-04-11 07:18:48 +00:00
parent ced2385be2
commit af800c1155
10 changed files with 25 additions and 92 deletions

View File

@ -108,7 +108,8 @@ nesapu_device::nesapu_device(const machine_config &mconfig, const char *tag, dev
m_samps_per_sync(0),
m_buffer_size(0),
m_real_rate(0),
m_stream(NULL)
m_stream(NULL),
m_cpu_tag("")
{
for (int i = 0; i < NOISE_LONG; i++)
{
@ -131,26 +132,6 @@ nesapu_device::nesapu_device(const machine_config &mconfig, const char *tag, dev
}
}
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void nesapu_device::device_config_complete()
{
// inherit a copy of the static data
const nesapu_interface *intf = reinterpret_cast<const nesapu_interface *>(static_config());
if (intf != NULL)
*static_cast<nesapu_interface *>(this) = *intf;
// or initialize to defaults if none provided
else
{
m_cpu_tag = "";
}
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
@ -158,7 +139,6 @@ void nesapu_device::device_config_complete()
void nesapu_device::device_start()
{
int rate = clock() / 4;
int i;
/* Initialize global variables */
m_samps_per_sync = rate / ATTOSECONDS_TO_HZ(machine().first_screen()->frame_period().attoseconds);
@ -180,7 +160,7 @@ void nesapu_device::device_start()
m_stream = machine().sound().stream_alloc(*this, 0, 1, rate, this);
/* register for save */
for (i = 0; i < 2; i++)
for (int i = 0; i < 2; i++)
{
save_item(NAME(m_APU.squ[i].regs), i);
save_item(NAME(m_APU.squ[i].vbl_length), i);

View File

@ -41,25 +41,20 @@
#define SYNCS_MAX1 0x20
#define SYNCS_MAX2 0x80
struct nesapu_interface
{
const char *m_cpu_tag; /* CPU tag */
};
class nesapu_device : public device_t,
public device_sound_interface,
public nesapu_interface
public device_sound_interface
{
public:
nesapu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
~nesapu_device() {}
static void set_cpu_tag(device_t &device, const char *tag) { downcast<nesapu_device &>(device).m_cpu_tag = tag; }
DECLARE_READ8_MEMBER( read );
DECLARE_WRITE8_MEMBER( write );
protected:
// device-level overrides
virtual void device_config_complete();
virtual void device_start();
// sound stream update overrides
@ -78,6 +73,8 @@ private:
uint32 m_sync_times2[SYNCS_MAX2]; /* Samples per sync table */
sound_stream *m_stream;
const char *m_cpu_tag;
void create_syncs(unsigned long sps);
int8 apu_square(square_t *chan);
int8 apu_triangle(triangle_t *chan);
@ -90,5 +87,8 @@ private:
extern const device_type NES_APU;
#define MCFG_NES_APU_CPU(_tag) \
nesapu_device::set_cpu_tag(*device, _tag);
#endif /* __NES_APU_H__ */

View File

@ -1334,9 +1334,6 @@ ADDRESS_MAP_END
*
*************************************/
static const nesapu_interface nes_interface_1 = { "n2a03a" };
static const nesapu_interface nes_interface_2 = { "n2a03b" };
const tms5110_interface tms_interface = {
NULL,
NULL,
@ -1469,11 +1466,11 @@ MACHINE_CONFIG_FRAGMENT( dkong3_audio )
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("nesapu1", NES_APU, N2A03_DEFAULTCLOCK)
MCFG_SOUND_CONFIG(nes_interface_1)
MCFG_NES_APU_CPU("n2a03a")
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MCFG_SOUND_ADD("nesapu2", NES_APU, N2A03_DEFAULTCLOCK)
MCFG_SOUND_CONFIG(nes_interface_2)
MCFG_NES_APU_CPU("n2a03b")
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MACHINE_CONFIG_END

View File

@ -272,11 +272,6 @@ static INPUT_PORTS_START( cham24 )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
INPUT_PORTS_END
static const nesapu_interface cham24_interface_1 =
{
"maincpu"
};
void cham24_state::machine_reset()
{
}
@ -361,7 +356,7 @@ static MACHINE_CONFIG_START( cham24, cham24_state )
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("nesapu", NES_APU, N2A03_DEFAULTCLOCK)
MCFG_SOUND_CONFIG(cham24_interface_1)
MCFG_NES_APU_CPU("maincpu")
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MCFG_DAC_ADD("dac")

View File

@ -511,11 +511,6 @@ INPUT_PORTS_END
*******************************************************/
static const nesapu_interface famibox_interface_1 =
{
"maincpu"
};
PALETTE_INIT_MEMBER(famibox_state, famibox)
{
m_ppu->init_palette(palette, 0);
@ -574,7 +569,6 @@ static MACHINE_CONFIG_START( famibox, famibox_state )
MCFG_CPU_ADD("maincpu", N2A03, N2A03_DEFAULTCLOCK)
MCFG_CPU_PROGRAM_MAP(famibox_map)
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_REFRESH_RATE(60)
@ -595,7 +589,7 @@ static MACHINE_CONFIG_START( famibox, famibox_state )
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("nesapu", NES_APU, N2A03_DEFAULTCLOCK)
MCFG_SOUND_CONFIG(famibox_interface_1)
MCFG_NES_APU_CPU("maincpu")
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MCFG_DAC_ADD("dac")

View File

@ -1140,11 +1140,6 @@ INPUT_PORTS_END
*******************************************************/
static const nesapu_interface multigam_interface_1 =
{
"maincpu"
};
PALETTE_INIT_MEMBER(multigam_state, multigam)
{
m_ppu->init_palette(palette, 0);
@ -1262,7 +1257,7 @@ static MACHINE_CONFIG_START( multigam, multigam_state )
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("nesapu", NES_APU, N2A03_DEFAULTCLOCK)
MCFG_SOUND_CONFIG(multigam_interface_1)
MCFG_NES_APU_CPU("maincpu")
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MCFG_DAC_ADD("dac")

View File

@ -660,11 +660,6 @@ INTERRUPT_GEN_MEMBER(playch10_state::playch10_interrupt){
device.execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
}
static const nesapu_interface nes_config =
{
"cart"
};
static MACHINE_CONFIG_START( playch10, playch10_state )
// basic machine hardware
MCFG_CPU_ADD("maincpu", Z80, 8000000/2) // 4 MHz
@ -705,7 +700,7 @@ static MACHINE_CONFIG_START( playch10, playch10_state )
// sound hardware
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("nesapu", NES_APU, N2A03_DEFAULTCLOCK)
MCFG_SOUND_CONFIG(nes_config)
MCFG_NES_APU_CPU("cart")
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MCFG_DAC_ADD("dac")

View File

@ -911,12 +911,6 @@ static GFXDECODE_START( armwrest )
GFXDECODE_END
static const nesapu_interface nes_config =
{
"audiocpu"
};
void punchout_state::machine_reset()
{
m_rp5c01_mode_sel = 0;
@ -971,7 +965,7 @@ static MACHINE_CONFIG_START( punchout, punchout_state )
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("nesapu", NES_APU, N2A03_DEFAULTCLOCK)
MCFG_SOUND_CONFIG(nes_config)
MCFG_NES_APU_CPU("audiocpu")
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MCFG_SOUND_ADD("vlm", VLM5030, 3580000)

View File

@ -1696,16 +1696,6 @@ static INPUT_PORTS_START( supxevs )
PORT_DIPSETTING( 0xc0, "RP2C04-0004" )
INPUT_PORTS_END
static const nesapu_interface nes_interface_1 =
{
"maincpu"
};
static const nesapu_interface nes_interface_2 =
{
"sub"
};
static MACHINE_CONFIG_START( vsnes, vsnes_state )
/* basic machine hardware */
@ -1737,7 +1727,7 @@ static MACHINE_CONFIG_START( vsnes, vsnes_state )
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("nesapu1", NES_APU, N2A03_DEFAULTCLOCK)
MCFG_SOUND_CONFIG(nes_interface_1)
MCFG_NES_APU_CPU("maincpu")
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MCFG_DAC_ADD("dac1")
@ -1829,11 +1819,11 @@ static MACHINE_CONFIG_START( vsdual, vsnes_state )
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("nesapu1", NES_APU, N2A03_DEFAULTCLOCK)
MCFG_SOUND_CONFIG(nes_interface_1)
MCFG_NES_APU_CPU("maincpu")
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MCFG_SOUND_ADD("nesapu2", NES_APU, N2A03_DEFAULTCLOCK)
MCFG_SOUND_CONFIG(nes_interface_2)
MCFG_NES_APU_CPU("sub")
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MCFG_DAC_ADD("dac1")
@ -1879,7 +1869,7 @@ static MACHINE_CONFIG_START( vsnes_bootleg, vsnes_state )
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("nesapu1", NES_APU, N2A03_DEFAULTCLOCK)
MCFG_SOUND_CONFIG(nes_interface_1)
MCFG_NES_APU_CPU("maincpu")
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MCFG_DAC_ADD("dac1")

View File

@ -640,12 +640,6 @@ static INPUT_PORTS_START( famicom )
INPUT_PORTS_END
static const nesapu_interface nes_apu_interface =
{
"maincpu"
};
void nes_state::ppu_nmi(int *ppu_regs)
{
m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
@ -693,7 +687,6 @@ static MACHINE_CONFIG_START( nes, nes_state )
MCFG_SCREEN_UPDATE_DRIVER(nes_state, screen_update_nes)
MCFG_SCREEN_PALETTE("palette")
MCFG_PALETTE_ADD("palette", 4*16*8)
MCFG_PALETTE_INIT_OWNER(nes_state, nes)
@ -704,7 +697,7 @@ static MACHINE_CONFIG_START( nes, nes_state )
/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("nessound", NES_APU, NTSC_CLOCK)
MCFG_SOUND_CONFIG(nes_apu_interface)
MCFG_NES_APU_CPU("maincpu")
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90)
MCFG_NES_CARTRIDGE_ADD("nes_slot", nes_cart, NULL)
@ -735,7 +728,7 @@ static MACHINE_CONFIG_DERIVED( nespal, nes )
/* sound hardware */
MCFG_SOUND_REPLACE("nessound", NES_APU, PAL_CLOCK)
MCFG_SOUND_CONFIG(nes_apu_interface)
MCFG_NES_APU_CPU("maincpu")
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90)
MACHINE_CONFIG_END
@ -757,7 +750,7 @@ static MACHINE_CONFIG_DERIVED( dendy, nes )
/* sound hardware */
MCFG_SOUND_REPLACE("nessound", NES_APU, 26601712/15) /* 26.601712MHz / 15 == 1.77344746666... MHz */
MCFG_SOUND_CONFIG(nes_apu_interface)
MCFG_NES_APU_CPU("maincpu")
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90)
MACHINE_CONFIG_END