trunk/src/mame/audio/taito_en.c
| r32533 | r32534 | |
| 11 | 11 | ****************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | #include "emu.h" |
| 14 | | #include "machine/mb87078.h" |
| 15 | 14 | #include "taito_en.h" |
| 16 | 15 | |
| 17 | 16 | |
| r32533 | r32534 | |
| 19 | 18 | |
| 20 | 19 | taito_en_device::taito_en_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 21 | 20 | : device_t(mconfig, TAITO_EN, "Taito Ensoniq Sound System", tag, owner, clock, "taito_en", __FILE__), |
| 21 | m_audiocpu(*this, ":audiocpu"), |
| 22 | m_ensoniq(*this, ":ensoniq"), |
| 23 | m_duart68681(*this, ":duart68681"), |
| 24 | m_mb87078(*this, ":mb87078"), |
| 25 | m_snd_shared_ram(*this, ":snd_shared"), |
| 22 | 26 | m_es5510_dol_latch(0), |
| 23 | 27 | m_es5510_dil_latch(0), |
| 24 | 28 | m_es5510_dadr_latch(0), |
| 25 | 29 | m_es5510_gpr_latch(0), |
| 26 | | m_es5510_ram_sel(0), |
| 27 | | m_snd_shared_ram(NULL) |
| 30 | m_es5510_ram_sel(0) |
| 28 | 31 | { |
| 29 | 32 | } |
| 30 | 33 | |
| r32533 | r32534 | |
| 42 | 45 | save_item(NAME(m_es5510_dadr_latch)); |
| 43 | 46 | save_item(NAME(m_es5510_gpr_latch)); |
| 44 | 47 | save_item(NAME(m_es5510_ram_sel)); |
| 45 | | |
| 46 | | m_duart68681 = machine().device<mc68681_device>("duart68681"); |
| 47 | 48 | } |
| 48 | 49 | |
| 49 | 50 | //------------------------------------------------- |
| r32533 | r32534 | |
| 59 | 60 | machine().root_device().membank("bank2")->set_base(&ROM[0x90000]); |
| 60 | 61 | machine().root_device().membank("bank3")->set_base(&ROM[0xa0000]); |
| 61 | 62 | |
| 62 | | sound_ram[0]=ROM[0x80000]; /* Stack and Reset vectors */ |
| 63 | | sound_ram[1]=ROM[0x80001]; |
| 64 | | sound_ram[2]=ROM[0x80002]; |
| 65 | | sound_ram[3]=ROM[0x80003]; |
| 63 | sound_ram[0] = ROM[0x80000]; /* Stack and Reset vectors */ |
| 64 | sound_ram[1] = ROM[0x80001]; |
| 65 | sound_ram[2] = ROM[0x80002]; |
| 66 | sound_ram[3] = ROM[0x80003]; |
| 66 | 67 | |
| 67 | 68 | /* reset CPU to catch any banking of startup vectors */ |
| 68 | | machine().device("audiocpu")->reset(); |
| 69 | | machine().device("audiocpu")->execute().set_input_line(INPUT_LINE_RESET, ASSERT_LINE); |
| 70 | | |
| 71 | | m_snd_shared_ram = (UINT32 *)machine().root_device().memshare("snd_shared")->ptr(); |
| 69 | m_audiocpu->reset(); |
| 70 | m_audiocpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE); |
| 72 | 71 | } |
| 73 | 72 | |
| 74 | 73 | |
| r32533 | r32534 | |
| 78 | 77 | * |
| 79 | 78 | *************************************/ |
| 80 | 79 | |
| 81 | | READ16_MEMBER( taito_en_device::en_68000_share_r ) |
| 80 | READ8_MEMBER( taito_en_device::en_68000_share_r ) |
| 82 | 81 | { |
| 83 | 82 | switch (offset & 3) |
| 84 | 83 | { |
| 85 | | case 0: return (m_snd_shared_ram[offset/4]&0xff000000)>>16; |
| 86 | | case 1: return (m_snd_shared_ram[offset/4]&0x00ff0000)>>8; |
| 87 | | case 2: return (m_snd_shared_ram[offset/4]&0x0000ff00)>>0; |
| 88 | | case 3: return (m_snd_shared_ram[offset/4]&0x000000ff)<<8; |
| 84 | case 0: return (m_snd_shared_ram[offset/4]&0xff000000)>>24; |
| 85 | case 1: return (m_snd_shared_ram[offset/4]&0x00ff0000)>>16; |
| 86 | case 2: return (m_snd_shared_ram[offset/4]&0x0000ff00)>>8; |
| 87 | case 3: return (m_snd_shared_ram[offset/4]&0x000000ff)>>0; |
| 89 | 88 | } |
| 90 | 89 | |
| 91 | 90 | return 0; |
| 92 | 91 | } |
| 93 | 92 | |
| 94 | | WRITE16_MEMBER( taito_en_device::en_68000_share_w ) |
| 93 | WRITE8_MEMBER( taito_en_device::en_68000_share_w ) |
| 95 | 94 | { |
| 96 | 95 | switch (offset & 3) |
| 97 | 96 | { |
| 98 | | case 0: m_snd_shared_ram[offset/4] = (m_snd_shared_ram[offset/4]&0x00ffffff)|((data&0xff00)<<16); |
| 99 | | case 1: m_snd_shared_ram[offset/4] = (m_snd_shared_ram[offset/4]&0xff00ffff)|((data&0xff00)<<8); |
| 100 | | case 2: m_snd_shared_ram[offset/4] = (m_snd_shared_ram[offset/4]&0xffff00ff)|((data&0xff00)<<0); |
| 101 | | case 3: m_snd_shared_ram[offset/4] = (m_snd_shared_ram[offset/4]&0xffffff00)|((data&0xff00)>>8); |
| 97 | case 0: m_snd_shared_ram[offset/4] = (m_snd_shared_ram[offset/4]&0x00ffffff)|(data<<24); |
| 98 | case 1: m_snd_shared_ram[offset/4] = (m_snd_shared_ram[offset/4]&0xff00ffff)|(data<<16); |
| 99 | case 2: m_snd_shared_ram[offset/4] = (m_snd_shared_ram[offset/4]&0xffff00ff)|(data<<8); |
| 100 | case 3: m_snd_shared_ram[offset/4] = (m_snd_shared_ram[offset/4]&0xffffff00)|(data<<0); |
| 102 | 101 | } |
| 103 | 102 | } |
| 104 | 103 | |
| r32533 | r32534 | |
| 106 | 105 | { |
| 107 | 106 | UINT32 max_banks_this_game = (space.machine().root_device().memregion("ensoniq.0")->bytes()/0x200000)-1; |
| 108 | 107 | |
| 109 | | #if 0 |
| 110 | | { |
| 111 | | static char count[10]; |
| 112 | | count[data&7]++; |
| 113 | | popmessage("%x %x %x %x %x %x %x %x (%d)",count[0]&0xf,count[1]&0xf,count[2]&0xf,count[3]&0xf,count[4]&0xf,count[5]&0xf,count[6]&0xf,count[7]&0xf, max_banks_this_game); |
| 114 | | } |
| 115 | | #endif |
| 116 | | |
| 117 | 108 | /* mask out unused bits */ |
| 118 | 109 | data &= max_banks_this_game; |
| 119 | | space.machine().device<es5505_device>("ensoniq")->voice_bank_w(offset,data<<20); |
| 110 | m_ensoniq->voice_bank_w(offset,data<<20); |
| 120 | 111 | } |
| 121 | 112 | |
| 122 | | WRITE16_MEMBER( taito_en_device::en_volume_w ) |
| 113 | WRITE8_MEMBER( taito_en_device::en_volume_w ) |
| 123 | 114 | { |
| 124 | | if (ACCESSING_BITS_8_15) |
| 125 | | space.machine().device<mb87078_device>("mb87078")->data_w(data >> 8, offset ^ 1); |
| 115 | m_mb87078->data_w(data, offset ^ 1); |
| 126 | 116 | } |
| 127 | 117 | |
| 128 | 118 | |
| r32533 | r32534 | |
| 136 | 126 | |
| 137 | 127 | READ16_MEMBER( taito_en_device::es5510_dsp_r ) |
| 138 | 128 | { |
| 139 | | // logerror("%06x: DSP read offset %04x (data is %04x)\n",space.device().safe_pc(),offset,m_es5510_dsp_ram[offset]); |
| 140 | | // if (es_tmp) return m_es5510_dsp_ram[offset]; |
| 141 | | /* |
| 142 | | switch (offset) { |
| 143 | | case 0x00: return (m_es5510_gpr_latch>>16)&0xff; |
| 144 | | case 0x01: return (m_es5510_gpr_latch>> 8)&0xff; |
| 145 | | case 0x02: return (m_es5510_gpr_latch>> 0)&0xff; |
| 146 | | case 0x03: return 0; |
| 147 | | } |
| 148 | | */ |
| 149 | | // offset<<=1; |
| 150 | | |
| 151 | | //if (offset<7 && m_es5510_dsp_ram[0]!=0xff) return space.machine().rand()%0xffff; |
| 152 | | |
| 153 | | switch(offset) |
| 129 | switch (offset) |
| 154 | 130 | { |
| 155 | 131 | case 0x09: return (m_es5510_dil_latch >> 16) & 0xff; |
| 156 | 132 | case 0x0a: return (m_es5510_dil_latch >> 8) & 0xff; |
| 157 | | case 0x0b: return (m_es5510_dil_latch >> 0) & 0xff; //TODO: docs says that this always returns 0 |
| 133 | case 0x0b: return (m_es5510_dil_latch >> 0) & 0xff; // TODO: docs says that this always returns 0 |
| 134 | default: break; |
| 158 | 135 | } |
| 159 | 136 | |
| 160 | 137 | if (offset==0x12) return 0; |
| r32533 | r32534 | |
| 241 | 218 | |
| 242 | 219 | static ADDRESS_MAP_START( en_sound_map, AS_PROGRAM, 16, driver_device ) |
| 243 | 220 | AM_RANGE(0x000000, 0x00ffff) AM_RAM AM_MIRROR(0x30000) AM_SHARE("share1") |
| 244 | | AM_RANGE(0x140000, 0x140fff) AM_DEVREADWRITE("taito_en", taito_en_device, en_68000_share_r, en_68000_share_w) |
| 221 | AM_RANGE(0x140000, 0x140fff) AM_DEVREADWRITE8("taito_en", taito_en_device, en_68000_share_r, en_68000_share_w, 0xff00) |
| 245 | 222 | AM_RANGE(0x200000, 0x20001f) AM_DEVREADWRITE("ensoniq", es5505_device, read, write) |
| 246 | 223 | AM_RANGE(0x260000, 0x2601ff) AM_DEVREADWRITE("taito_en", taito_en_device, es5510_dsp_r, es5510_dsp_w) //todo: hook up cpu/es5510 |
| 247 | 224 | AM_RANGE(0x280000, 0x28001f) AM_DEVREADWRITE8("duart68681", mc68681_device, read, write, 0x00ff) |
| 248 | 225 | AM_RANGE(0x300000, 0x30003f) AM_DEVWRITE("taito_en", taito_en_device, en_es5505_bank_w) |
| 249 | | AM_RANGE(0x340000, 0x340003) AM_DEVWRITE("taito_en", taito_en_device, en_volume_w) |
| 226 | AM_RANGE(0x340000, 0x340003) AM_DEVWRITE8("taito_en", taito_en_device, en_volume_w, 0xff00) |
| 250 | 227 | AM_RANGE(0xc00000, 0xc1ffff) AM_ROMBANK("bank1") |
| 251 | 228 | AM_RANGE(0xc20000, 0xc3ffff) AM_ROMBANK("bank2") |
| 252 | 229 | AM_RANGE(0xc40000, 0xc7ffff) AM_ROMBANK("bank3") |
| 253 | 230 | AM_RANGE(0xff0000, 0xffffff) AM_RAM AM_SHARE("share1") // mirror |
| 254 | 231 | ADDRESS_MAP_END |
| 255 | 232 | |
| 233 | |
| 256 | 234 | /************************************* |
| 257 | 235 | * |
| 258 | 236 | * MB87078 callback |
| r32533 | r32534 | |
| 263 | 241 | { |
| 264 | 242 | if (offset > 1) |
| 265 | 243 | { |
| 266 | | machine().device<es5505_device>("ensoniq")->set_output_gain(offset & 1, data / 100.0); |
| 244 | m_ensoniq->set_output_gain(offset & 1, data / 100.0); |
| 267 | 245 | } |
| 268 | 246 | } |
| 269 | 247 | |
| r32533 | r32534 | |
| 274 | 252 | * |
| 275 | 253 | *************************************/ |
| 276 | 254 | |
| 277 | | |
| 278 | 255 | WRITE_LINE_MEMBER(taito_en_device::duart_irq_handler) |
| 279 | 256 | { |
| 280 | 257 | if (state == ASSERT_LINE) |
| 281 | 258 | { |
| 282 | | machine().device("audiocpu")->execute().set_input_line_vector(M68K_IRQ_6, m_duart68681->get_irq_vector()); |
| 283 | | machine().device("audiocpu")->execute().set_input_line(M68K_IRQ_6, ASSERT_LINE); |
| 259 | m_audiocpu->set_input_line_vector(M68K_IRQ_6, m_duart68681->get_irq_vector()); |
| 260 | m_audiocpu->set_input_line(M68K_IRQ_6, ASSERT_LINE); |
| 284 | 261 | } |
| 285 | 262 | else |
| 286 | 263 | { |
| 287 | | machine().device("audiocpu")->execute().set_input_line(M68K_IRQ_6, CLEAR_LINE); |
| 264 | m_audiocpu->set_input_line(M68K_IRQ_6, CLEAR_LINE); |
| 288 | 265 | } |
| 289 | 266 | } |
| 290 | 267 | |
| r32533 | r32534 | |
| 314 | 291 | *************************************/ |
| 315 | 292 | |
| 316 | 293 | MACHINE_CONFIG_FRAGMENT( taito_en_sound ) |
| 294 | |
| 295 | /* basic machine hardware */ |
| 317 | 296 | MCFG_TAITO_EN_ADD("taito_en") |
| 318 | 297 | MCFG_CPU_ADD("audiocpu", M68000, XTAL_30_4761MHz / 2) |
| 319 | 298 | MCFG_CPU_PROGRAM_MAP(en_sound_map) |
| r32533 | r32534 | |
| 325 | 304 | MCFG_DEVICE_ADD("mb87078", MB87078, 0) |
| 326 | 305 | MCFG_MB87078_GAIN_CHANGED_CB(DEVWRITE8("taito_en", taito_en_device, mb87078_gain_changed)) |
| 327 | 306 | |
| 307 | /* sound hardware */ |
| 328 | 308 | MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") |
| 329 | 309 | MCFG_SOUND_ADD("ensoniq", ES5505, XTAL_30_4761MHz / 2) |
| 330 | 310 | MCFG_ES5505_REGION0("ensoniq.0") |
| 331 | 311 | MCFG_ES5505_REGION1("ensoniq.0") |
| 332 | | MCFG_ES5506_CHANNELS(1) /* channels */ |
| 312 | MCFG_ES5506_CHANNELS(1) |
| 333 | 313 | MCFG_SOUND_ROUTE(0, "lspeaker", 0.08) |
| 334 | 314 | MCFG_SOUND_ROUTE(1, "rspeaker", 0.08) |
| 335 | 315 | MACHINE_CONFIG_END |
trunk/src/mame/audio/taito_en.h
| r32533 | r32534 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | Taito Ensoniq ES5505-based sound hardware |
| 4 | |
| 5 | ****************************************************************************/ |
| 6 | |
| 1 | 7 | #include "cpu/m68000/m68000.h" |
| 2 | 8 | #include "sound/es5506.h" |
| 3 | 9 | #include "machine/mc68681.h" |
| 10 | #include "machine/mb87078.h" |
| 4 | 11 | |
| 5 | 12 | class taito_en_device : public device_t |
| 6 | 13 | |
| r32533 | r32534 | |
| 9 | 16 | taito_en_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 10 | 17 | ~taito_en_device() {} |
| 11 | 18 | |
| 12 | | DECLARE_READ16_MEMBER( en_68000_share_r ); |
| 13 | | DECLARE_WRITE16_MEMBER( en_68000_share_w ); |
| 19 | DECLARE_READ8_MEMBER( en_68000_share_r ); |
| 20 | DECLARE_WRITE8_MEMBER( en_68000_share_w ); |
| 14 | 21 | DECLARE_WRITE16_MEMBER( en_es5505_bank_w ); |
| 15 | | DECLARE_WRITE16_MEMBER( en_volume_w ); |
| 22 | DECLARE_WRITE8_MEMBER( en_volume_w ); |
| 16 | 23 | |
| 17 | 24 | //todo: hook up cpu/es5510 |
| 18 | 25 | DECLARE_READ16_MEMBER( es5510_dsp_r ); |
| r32533 | r32534 | |
| 28 | 35 | virtual void device_reset(); |
| 29 | 36 | |
| 30 | 37 | private: |
| 31 | | // internal state |
| 38 | // inherited devices/pointers |
| 39 | required_device<cpu_device> m_audiocpu; |
| 40 | required_device<es5505_device> m_ensoniq; |
| 41 | required_device<mc68681_device> m_duart68681; |
| 42 | required_device<mb87078_device> m_mb87078; |
| 43 | required_shared_ptr<UINT32> m_snd_shared_ram; |
| 32 | 44 | |
| 33 | 45 | //todo: hook up cpu/es5510 |
| 34 | 46 | UINT16 m_es5510_dsp_ram[0x200]; |
| r32533 | r32534 | |
| 39 | 51 | UINT32 m_es5510_dadr_latch; |
| 40 | 52 | UINT32 m_es5510_gpr_latch; |
| 41 | 53 | UINT8 m_es5510_ram_sel; |
| 42 | | |
| 43 | | UINT32 *m_snd_shared_ram; |
| 44 | | |
| 45 | | mc68681_device *m_duart68681; |
| 46 | | |
| 47 | 54 | }; |
| 48 | 55 | |
| 49 | 56 | extern const device_type TAITO_EN; |