Converted taito_en to a device. (nw)

This commit is contained in:
Ivan Vangelista 2013-08-22 19:15:23 +00:00
parent 22b8e0d09d
commit a642a95274
3 changed files with 157 additions and 105 deletions

View File

@ -13,24 +13,71 @@
#include "machine/mb87078.h"
#include "sound/es5506.h"
#include "taito_en.h"
#include "drivlgcy.h"
/*************************************
*
* Statics
*
*************************************/
const device_type TAITO_EN = &device_creator<taito_en_device>;
static UINT16 es5510_dsp_ram[0x200];
static UINT32 es5510_gpr[0xc0];
static UINT32 es5510_dram[1<<24];
static UINT32 es5510_dol_latch;
static UINT32 es5510_dil_latch;
static UINT32 es5510_dadr_latch;
static UINT32 es5510_gpr_latch;
static UINT8 es5510_ram_sel;
static UINT32 *snd_shared_ram;
taito_en_device::taito_en_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, TAITO_EN, "Taito Ensoniq Sound System", tag, owner, clock, "taito_en", __FILE__),
m_es5510_dol_latch(0),
m_es5510_dil_latch(0),
m_es5510_dadr_latch(0),
m_es5510_gpr_latch(0),
m_es5510_ram_sel(0),
m_snd_shared_ram(NULL)
{
}
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void taito_en_device::device_config_complete()
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void taito_en_device::device_start()
{
save_item(NAME(m_es5510_dsp_ram));
save_item(NAME(m_es5510_gpr));
save_item(NAME(m_es5510_dram));
save_item(NAME(m_es5510_dol_latch));
save_item(NAME(m_es5510_dil_latch));
save_item(NAME(m_es5510_dadr_latch));
save_item(NAME(m_es5510_gpr_latch));
save_item(NAME(m_es5510_ram_sel));
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void taito_en_device::device_reset()
{
/* Sound cpu program loads to 0xc00000 so we use a bank */
UINT16 *ROM = (UINT16 *)machine().root_device().memregion("audiocpu")->base();
UINT16 *sound_ram = (UINT16 *)machine().root_device().memshare("share1")->ptr();
machine().root_device().membank("bank1")->set_base(&ROM[0x80000]);
machine().root_device().membank("bank2")->set_base(&ROM[0x90000]);
machine().root_device().membank("bank3")->set_base(&ROM[0xa0000]);
sound_ram[0]=ROM[0x80000]; /* Stack and Reset vectors */
sound_ram[1]=ROM[0x80001];
sound_ram[2]=ROM[0x80002];
sound_ram[3]=ROM[0x80003];
/* reset CPU to catch any banking of startup vectors */
machine().device("audiocpu")->reset();
machine().device("audiocpu")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
m_snd_shared_ram = (UINT32 *)machine().root_device().memshare("snd_shared")->ptr();
}
/*************************************
@ -39,31 +86,31 @@ static UINT32 *snd_shared_ram;
*
*************************************/
static READ16_HANDLER( en_68000_share_r )
READ16_MEMBER( taito_en_device::en_68000_share_r )
{
switch (offset & 3)
{
case 0: return (snd_shared_ram[offset/4]&0xff000000)>>16;
case 1: return (snd_shared_ram[offset/4]&0x00ff0000)>>8;
case 2: return (snd_shared_ram[offset/4]&0x0000ff00)>>0;
case 3: return (snd_shared_ram[offset/4]&0x000000ff)<<8;
case 0: return (m_snd_shared_ram[offset/4]&0xff000000)>>16;
case 1: return (m_snd_shared_ram[offset/4]&0x00ff0000)>>8;
case 2: return (m_snd_shared_ram[offset/4]&0x0000ff00)>>0;
case 3: return (m_snd_shared_ram[offset/4]&0x000000ff)<<8;
}
return 0;
}
static WRITE16_HANDLER( en_68000_share_w )
WRITE16_MEMBER( taito_en_device::en_68000_share_w )
{
switch (offset & 3)
{
case 0: snd_shared_ram[offset/4] = (snd_shared_ram[offset/4]&0x00ffffff)|((data&0xff00)<<16);
case 1: snd_shared_ram[offset/4] = (snd_shared_ram[offset/4]&0xff00ffff)|((data&0xff00)<<8);
case 2: snd_shared_ram[offset/4] = (snd_shared_ram[offset/4]&0xffff00ff)|((data&0xff00)<<0);
case 3: snd_shared_ram[offset/4] = (snd_shared_ram[offset/4]&0xffffff00)|((data&0xff00)>>8);
case 0: m_snd_shared_ram[offset/4] = (m_snd_shared_ram[offset/4]&0x00ffffff)|((data&0xff00)<<16);
case 1: m_snd_shared_ram[offset/4] = (m_snd_shared_ram[offset/4]&0xff00ffff)|((data&0xff00)<<8);
case 2: m_snd_shared_ram[offset/4] = (m_snd_shared_ram[offset/4]&0xffff00ff)|((data&0xff00)<<0);
case 3: m_snd_shared_ram[offset/4] = (m_snd_shared_ram[offset/4]&0xffffff00)|((data&0xff00)>>8);
}
}
static WRITE16_HANDLER( en_es5505_bank_w )
WRITE16_MEMBER( taito_en_device::en_es5505_bank_w )
{
UINT32 max_banks_this_game = (space.machine().root_device().memregion("ensoniq.0")->bytes()/0x200000)-1;
@ -80,7 +127,7 @@ static WRITE16_HANDLER( en_es5505_bank_w )
es5505_voice_bank_w(space.machine().device("ensoniq"),offset,data<<20);
}
static WRITE16_HANDLER( en_volume_w )
WRITE16_MEMBER( taito_en_device::en_volume_w )
{
if (ACCESSING_BITS_8_15)
space.machine().device<mb87078_device>("mb87078")->data_w(data >> 8, offset ^ 1);
@ -93,27 +140,29 @@ static WRITE16_HANDLER( en_volume_w )
*
*************************************/
static READ16_HANDLER( es5510_dsp_r )
//todo: hook up cpu/es5510
READ16_MEMBER( taito_en_device::es5510_dsp_r )
{
// logerror("%06x: DSP read offset %04x (data is %04x)\n",space.device().safe_pc(),offset,es5510_dsp_ram[offset]);
// if (es_tmp) return es5510_dsp_ram[offset];
// logerror("%06x: DSP read offset %04x (data is %04x)\n",space.device().safe_pc(),offset,m_es5510_dsp_ram[offset]);
// if (es_tmp) return m_es5510_dsp_ram[offset];
/*
switch (offset) {
case 0x00: return (es5510_gpr_latch>>16)&0xff;
case 0x01: return (es5510_gpr_latch>> 8)&0xff;
case 0x02: return (es5510_gpr_latch>> 0)&0xff;
case 0x00: return (m_es5510_gpr_latch>>16)&0xff;
case 0x01: return (m_es5510_gpr_latch>> 8)&0xff;
case 0x02: return (m_es5510_gpr_latch>> 0)&0xff;
case 0x03: return 0;
}
*/
// offset<<=1;
//if (offset<7 && es5510_dsp_ram[0]!=0xff) return space.machine().rand()%0xffff;
//if (offset<7 && m_es5510_dsp_ram[0]!=0xff) return space.machine().rand()%0xffff;
switch(offset)
{
case 0x09: return (es5510_dil_latch >> 16) & 0xff;
case 0x0a: return (es5510_dil_latch >> 8) & 0xff;
case 0x0b: return (es5510_dil_latch >> 0) & 0xff; //TODO: docs says that this always returns 0
case 0x09: return (m_es5510_dil_latch >> 16) & 0xff;
case 0x0a: return (m_es5510_dil_latch >> 8) & 0xff;
case 0x0b: return (m_es5510_dil_latch >> 0) & 0xff; //TODO: docs says that this always returns 0
}
if (offset==0x12) return 0;
@ -121,44 +170,44 @@ static READ16_HANDLER( es5510_dsp_r )
// if (offset>4)
if (offset==0x16) return 0x27;
return es5510_dsp_ram[offset];
return m_es5510_dsp_ram[offset];
}
static WRITE16_HANDLER( es5510_dsp_w )
WRITE16_MEMBER( taito_en_device::es5510_dsp_w )
{
UINT8 *snd_mem = (UINT8 *)space.machine().root_device().memregion("ensoniq.0")->base();
// if (offset>4 && offset!=0x80 && offset!=0xa0 && offset!=0xc0 && offset!=0xe0)
// logerror("%06x: DSP write offset %04x %04x\n",space.device().safe_pc(),offset,data);
COMBINE_DATA(&es5510_dsp_ram[offset]);
COMBINE_DATA(&m_es5510_dsp_ram[offset]);
switch (offset) {
case 0x00: es5510_gpr_latch=(es5510_gpr_latch&0x00ffff)|((data&0xff)<<16); break;
case 0x01: es5510_gpr_latch=(es5510_gpr_latch&0xff00ff)|((data&0xff)<< 8); break;
case 0x02: es5510_gpr_latch=(es5510_gpr_latch&0xffff00)|((data&0xff)<< 0); break;
case 0x00: m_es5510_gpr_latch=(m_es5510_gpr_latch&0x00ffff)|((data&0xff)<<16); break;
case 0x01: m_es5510_gpr_latch=(m_es5510_gpr_latch&0xff00ff)|((data&0xff)<< 8); break;
case 0x02: m_es5510_gpr_latch=(m_es5510_gpr_latch&0xffff00)|((data&0xff)<< 0); break;
/* 0x03 to 0x08 INSTR Register */
/* 0x09 to 0x0b DIL Register (r/o) */
case 0x0c: es5510_dol_latch=(es5510_dol_latch&0x00ffff)|((data&0xff)<<16); break;
case 0x0d: es5510_dol_latch=(es5510_dol_latch&0xff00ff)|((data&0xff)<< 8); break;
case 0x0e: es5510_dol_latch=(es5510_dol_latch&0xffff00)|((data&0xff)<< 0); break; //TODO: docs says that this always returns 0xff
case 0x0c: m_es5510_dol_latch=(m_es5510_dol_latch&0x00ffff)|((data&0xff)<<16); break;
case 0x0d: m_es5510_dol_latch=(m_es5510_dol_latch&0xff00ff)|((data&0xff)<< 8); break;
case 0x0e: m_es5510_dol_latch=(m_es5510_dol_latch&0xffff00)|((data&0xff)<< 0); break; //TODO: docs says that this always returns 0xff
case 0x0f:
es5510_dadr_latch=(es5510_dadr_latch&0x00ffff)|((data&0xff)<<16);
if(es5510_ram_sel)
es5510_dil_latch = es5510_dram[es5510_dadr_latch];
m_es5510_dadr_latch=(m_es5510_dadr_latch&0x00ffff)|((data&0xff)<<16);
if(m_es5510_ram_sel)
m_es5510_dil_latch = m_es5510_dram[m_es5510_dadr_latch];
else
es5510_dram[es5510_dadr_latch] = es5510_dol_latch;
m_es5510_dram[m_es5510_dadr_latch] = m_es5510_dol_latch;
break;
case 0x10: es5510_dadr_latch=(es5510_dadr_latch&0xff00ff)|((data&0xff)<< 8); break;
case 0x11: es5510_dadr_latch=(es5510_dadr_latch&0xffff00)|((data&0xff)<< 0); break;
case 0x10: m_es5510_dadr_latch=(m_es5510_dadr_latch&0xff00ff)|((data&0xff)<< 8); break;
case 0x11: m_es5510_dadr_latch=(m_es5510_dadr_latch&0xffff00)|((data&0xff)<< 0); break;
/* 0x12 Host Control */
case 0x14: es5510_ram_sel = data & 0x80; /* bit 6 is i/o select, everything else is undefined */break;
case 0x14: m_es5510_ram_sel = data & 0x80; /* bit 6 is i/o select, everything else is undefined */break;
/* 0x16 Program Counter (test purpose, r/o?) */
/* 0x17 Internal Refresh counter (test purpose) */
@ -166,27 +215,27 @@ static WRITE16_HANDLER( es5510_dsp_w )
/* 0x1f Halt enable (w) / Frame Counter (r) */
case 0x80: /* Read select - GPR + INSTR */
// logerror("ES5510: Read GPR/INSTR %06x (%06x)\n",data,es5510_gpr[data]);
// logerror("ES5510: Read GPR/INSTR %06x (%06x)\n",data,m_es5510_gpr[data]);
/* Check if a GPR is selected */
if (data<0xc0) {
//es_tmp=0;
es5510_gpr_latch=es5510_gpr[data];
m_es5510_gpr_latch=m_es5510_gpr[data];
}// else es_tmp=1;
break;
case 0xa0: /* Write select - GPR */
// logerror("ES5510: Write GPR %06x %06x (0x%04x:=0x%06x\n",data,es5510_gpr_latch,data,snd_mem[es5510_gpr_latch>>8]);
// logerror("ES5510: Write GPR %06x %06x (0x%04x:=0x%06x\n",data,m_es5510_gpr_latch,data,snd_mem[m_es5510_gpr_latch>>8]);
if (data<0xc0)
es5510_gpr[data]=snd_mem[es5510_gpr_latch>>8];
m_es5510_gpr[data]=snd_mem[m_es5510_gpr_latch>>8];
break;
case 0xc0: /* Write select - INSTR */
// logerror("ES5510: Write INSTR %06x %06x\n",data,es5510_gpr_latch);
// logerror("ES5510: Write INSTR %06x %06x\n",data,m_es5510_gpr_latch);
break;
case 0xe0: /* Write select - GPR + INSTR */
// logerror("ES5510: Write GPR/INSTR %06x %06x\n",data,es5510_gpr_latch);
// logerror("ES5510: Write GPR/INSTR %06x %06x\n",data,m_es5510_gpr_latch);
break;
}
}
@ -200,47 +249,18 @@ static WRITE16_HANDLER( es5510_dsp_w )
static ADDRESS_MAP_START( en_sound_map, AS_PROGRAM, 16, driver_device )
AM_RANGE(0x000000, 0x00ffff) AM_RAM AM_MIRROR(0x30000) AM_SHARE("share1")
AM_RANGE(0x140000, 0x140fff) AM_READWRITE_LEGACY(en_68000_share_r, en_68000_share_w)
AM_RANGE(0x140000, 0x140fff) AM_DEVREADWRITE("taito_en", taito_en_device, en_68000_share_r, en_68000_share_w)
AM_RANGE(0x200000, 0x20001f) AM_DEVREADWRITE_LEGACY("ensoniq", es5505_r, es5505_w)
AM_RANGE(0x260000, 0x2601ff) AM_READWRITE_LEGACY(es5510_dsp_r, es5510_dsp_w)
AM_RANGE(0x260000, 0x2601ff) AM_DEVREADWRITE("taito_en", taito_en_device, es5510_dsp_r, es5510_dsp_w) //todo: hook up cpu/es5510
AM_RANGE(0x280000, 0x28001f) AM_DEVREADWRITE8_LEGACY("duart68681", duart68681_r, duart68681_w, 0x00ff)
AM_RANGE(0x300000, 0x30003f) AM_WRITE_LEGACY(en_es5505_bank_w)
AM_RANGE(0x340000, 0x340003) AM_WRITE_LEGACY(en_volume_w)
AM_RANGE(0x300000, 0x30003f) AM_DEVWRITE("taito_en", taito_en_device, en_es5505_bank_w)
AM_RANGE(0x340000, 0x340003) AM_DEVWRITE("taito_en", taito_en_device, en_volume_w)
AM_RANGE(0xc00000, 0xc1ffff) AM_ROMBANK("bank1")
AM_RANGE(0xc20000, 0xc3ffff) AM_ROMBANK("bank2")
AM_RANGE(0xc40000, 0xc7ffff) AM_ROMBANK("bank3")
AM_RANGE(0xff0000, 0xffffff) AM_RAM AM_SHARE("share1") // mirror
ADDRESS_MAP_END
/*************************************
*
* Reset
*
*************************************/
SOUND_RESET( taito_en_soundsystem_reset )
{
/* Sound cpu program loads to 0xc00000 so we use a bank */
UINT16 *ROM = (UINT16 *)machine.root_device().memregion("audiocpu")->base();
UINT16 *sound_ram = (UINT16 *)machine.root_device().memshare("share1")->ptr();
machine.root_device().membank("bank1")->set_base(&ROM[0x80000]);
machine.root_device().membank("bank2")->set_base(&ROM[0x90000]);
machine.root_device().membank("bank3")->set_base(&ROM[0xa0000]);
sound_ram[0]=ROM[0x80000]; /* Stack and Reset vectors */
sound_ram[1]=ROM[0x80001];
sound_ram[2]=ROM[0x80002];
sound_ram[3]=ROM[0x80003];
/* reset CPU to catch any banking of startup vectors */
machine.device("audiocpu")->reset();
//machine.device("audiocpu")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
snd_shared_ram = (UINT32 *)machine.root_device().memshare("snd_shared")->ptr();
}
/*************************************
*
* MB87078 callback
@ -264,6 +284,7 @@ static void mb87078_gain_changed( running_machine &machine, int channel, int per
*
*************************************/
static void taito_en_duart_irq_handler(device_t *device, int state, UINT8 vector)
{
if (state == ASSERT_LINE)
@ -328,14 +349,13 @@ static const es5505_interface es5505_taito_en_config =
*************************************/
MACHINE_CONFIG_FRAGMENT( taito_en_sound )
MCFG_TAITO_EN_ADD("taito_en")
MCFG_CPU_ADD("audiocpu", M68000, XTAL_30_4761MHz / 2)
MCFG_CPU_PROGRAM_MAP(en_sound_map)
MCFG_DUART68681_ADD("duart68681", XTAL_16MHz / 4, taito_en_duart68681_config)
MCFG_MB87078_ADD("mb87078", taito_en_mb87078_intf)
MCFG_SOUND_RESET(taito_en_soundsystem_reset)
MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
MCFG_SOUND_ADD("ensoniq", ES5505, XTAL_30_4761MHz / 2)
MCFG_SOUND_CONFIG(es5505_taito_en_config)

View File

@ -1,6 +1,48 @@
#include "cpu/m68000/m68000.h"
#include "sound/es5506.h"
SOUND_RESET( taito_en_soundsystem_reset );
class taito_en_device : public device_t
{
public:
taito_en_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
~taito_en_device() {}
DECLARE_READ16_MEMBER( en_68000_share_r );
DECLARE_WRITE16_MEMBER( en_68000_share_w );
DECLARE_WRITE16_MEMBER( en_es5505_bank_w );
DECLARE_WRITE16_MEMBER( en_volume_w );
//todo: hook up cpu/es5510
DECLARE_READ16_MEMBER( es5510_dsp_r );
DECLARE_WRITE16_MEMBER( es5510_dsp_w );
protected:
// device-level overrides
virtual void device_config_complete();
virtual void device_start();
virtual void device_reset();
private:
// internal state
//todo: hook up cpu/es5510
UINT16 m_es5510_dsp_ram[0x200];
UINT32 m_es5510_gpr[0xc0];
UINT32 m_es5510_dram[1<<24];
UINT32 m_es5510_dol_latch;
UINT32 m_es5510_dil_latch;
UINT32 m_es5510_dadr_latch;
UINT32 m_es5510_gpr_latch;
UINT8 m_es5510_ram_sel;
UINT32 *m_snd_shared_ram;
};
extern const device_type TAITO_EN;
MACHINE_CONFIG_EXTERN( taito_en_sound );
#define MCFG_TAITO_EN_ADD(_tag) \
MCFG_DEVICE_ADD(_tag, TAITO_EN, 0)

View File

@ -37,7 +37,6 @@
#include "sound/es5506.h"
#include "audio/taito_en.h"
#include "sound/okim6295.h"
#include "drivlgcy.h"
/******************************************************************************/
@ -409,14 +408,6 @@ INTERRUPT_GEN_MEMBER(taito_f3_state::f3_interrupt2)
timer_set(downcast<cpu_device *>(&device)->cycles_to_attotime(10000), TIMER_F3_INTERRUPT3);
}
static SOUND_RESET( f3 )
{
taito_f3_state *state = machine.driver_data<taito_f3_state>();
SOUND_RESET_CALL( taito_en_soundsystem_reset );
state->m_audiocpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
}
static const UINT16 recalh_eeprom[64] = {
0x8554,0x0000,0x3000,0x0000,0x0000,0x0000,0x0000,0xf335,
0x0001,0x86a0,0x0013,0x0413,0x0000,0xc350,0x0019,0x000a,
@ -460,7 +451,6 @@ static MACHINE_CONFIG_START( f3, taito_f3_state )
/* sound hardware */
MCFG_FRAGMENT_ADD(taito_en_sound)
MCFG_SOUND_RESET(f3)
MACHINE_CONFIG_END
/* These games reprogram the video output registers to display different scanlines,