summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar Aaron Giles <aaron@aarongiles.com>2009-02-11 19:48:39 +0000
committerGravatarGravatar Aaron Giles <aaron@aarongiles.com>2009-02-11 19:48:39 +0000
commit5cb6bf00e90dd0e836bcabf7d5a8a2bdbf941767 (patch)
treef0fd5a55acb6b6592a5be0fd9c766aed1a695c88
parent1420ed893ae8344144582793cdcc1a0eafda4610 (diff)
downloadmame-5cb6bf00e90dd0e836bcabf7d5a8a2bdbf941767.tar.xz
mame-5cb6bf00e90dd0e836bcabf7d5a8a2bdbf941767.zip
Ok, this is The Big One.
Please note: regression testing is in progress, but the first round of glaring regressions have already been taken care of. That said, there is likely to be a host of regressions as a result of this change. Also note: There are still a few rough edges in the interfaces. I will try to clean them up systematically once the basic system is working. All sound chips are now proper devices. Merged the sound chip interface into the device interface, removing any differences (such as the whole ALIASing concept). Modified every sound chip in the following ways: * updated to match the device interface * reduced read/write handlers down to the minimal number * added the use of get_safe_token() for ensuring correctness * other minor cleanup Removed the custom sound device. The additional work to just make custom sound cases into full devices is minimal, so I just converted them all over to be actual devices. Vastly simplified the sound interfaces, removing the ghastly sndti_* business and moving everyone over to using tags for sound identity. sndintrf, like cpuintrf, is now just a header file with no implementation. Modified each and every driver that references a sound chip: * all memory maps explicitly reference the targeted device via AM_DEVREAD/AM_DEVWRITE/AM_DEVREADWRITE * 16-bit and 32-bit accesses to 8-bit chips no longer use trampoline functions but instead use the 8-bit AM_DEVREAD/WRITE macros * all references to sound chips are now done via tags * note that these changes are brute force, not optimal; in many cases drivers should grab pointers to devices in MACHINE_START and stash them away
-rw-r--r--.gitattributes7
-rw-r--r--src/emu/audit.c15
-rw-r--r--src/emu/clifront.c10
-rw-r--r--src/emu/cpu/h6280/h6280.c4
-rw-r--r--src/emu/cpu/h6280/h6280.h4
-rw-r--r--src/emu/cpuexec.c6
-rw-r--r--src/emu/devintrf.c40
-rw-r--r--src/emu/devintrf.h1
-rw-r--r--src/emu/emu.mak1
-rw-r--r--src/emu/info.c52
-rw-r--r--src/emu/inptport.h8
-rw-r--r--src/emu/machine/laserdsc.h13
-rw-r--r--src/emu/machine/latch8.c7
-rw-r--r--src/emu/machine/latch8.h4
-rw-r--r--src/emu/machine/ldcore.c66
-rw-r--r--src/emu/machine/pcshare.h2
-rw-r--r--src/emu/machine/scsicd.c66
-rw-r--r--src/emu/mame.c6
-rw-r--r--src/emu/mconfig.c135
-rw-r--r--src/emu/mconfig.h192
-rw-r--r--src/emu/sndintrf.c442
-rw-r--r--src/emu/sndintrf.h199
-rw-r--r--src/emu/sound.c506
-rw-r--r--src/emu/sound.h126
-rw-r--r--src/emu/sound/2151intf.c195
-rw-r--r--src/emu/sound/2151intf.h40
-rw-r--r--src/emu/sound/2203intf.c251
-rw-r--r--src/emu/sound/2203intf.h62
-rw-r--r--src/emu/sound/2413intf.c118
-rw-r--r--src/emu/sound/2413intf.h26
-rw-r--r--src/emu/sound/2608intf.c197
-rw-r--r--src/emu/sound/2608intf.h40
-rw-r--r--src/emu/sound/2610intf.c419
-rw-r--r--src/emu/sound/2610intf.h61
-rw-r--r--src/emu/sound/2612intf.c328
-rw-r--r--src/emu/sound/2612intf.h83
-rw-r--r--src/emu/sound/262intf.c130
-rw-r--r--src/emu/sound/262intf.h25
-rw-r--r--src/emu/sound/3526intf.c170
-rw-r--r--src/emu/sound/3526intf.h23
-rw-r--r--src/emu/sound/3812intf.c501
-rw-r--r--src/emu/sound/3812intf.h64
-rw-r--r--src/emu/sound/5110intf.c182
-rw-r--r--src/emu/sound/5110intf.h48
-rw-r--r--src/emu/sound/5220intf.c118
-rw-r--r--src/emu/sound/5220intf.h43
-rw-r--r--src/emu/sound/8950intf.c205
-rw-r--r--src/emu/sound/8950intf.h28
-rw-r--r--src/emu/sound/aica.c138
-rw-r--r--src/emu/sound/aica.h18
-rw-r--r--src/emu/sound/astrocde.c90
-rw-r--r--src/emu/sound/astrocde.h7
-rw-r--r--src/emu/sound/ay8910.c238
-rw-r--r--src/emu/sound/ay8910.h106
-rw-r--r--src/emu/sound/beep.c62
-rw-r--r--src/emu/sound/beep.h18
-rw-r--r--src/emu/sound/bsmt2000.c97
-rw-r--r--src/emu/sound/bsmt2000.h6
-rw-r--r--src/emu/sound/c140.c65
-rw-r--r--src/emu/sound/c140.h10
-rw-r--r--src/emu/sound/c352.c68
-rw-r--r--src/emu/sound/c352.h8
-rw-r--r--src/emu/sound/c6280.c67
-rw-r--r--src/emu/sound/c6280.h9
-rw-r--r--src/emu/sound/cdda.c112
-rw-r--r--src/emu/sound/cdda.h22
-rw-r--r--src/emu/sound/cdp1869.c77
-rw-r--r--src/emu/sound/cdp1869.h20
-rw-r--r--src/emu/sound/cem3394.c59
-rw-r--r--src/emu/sound/cem3394.h8
-rw-r--r--src/emu/sound/custom.c85
-rw-r--r--src/emu/sound/custom.h24
-rw-r--r--src/emu/sound/dac.c99
-rw-r--r--src/emu/sound/dac.h20
-rw-r--r--src/emu/sound/digitalk.c70
-rw-r--r--src/emu/sound/digitalk.h14
-rw-r--r--src/emu/sound/disc_inp.c57
-rw-r--r--src/emu/sound/discrete.c48
-rw-r--r--src/emu/sound/discrete.h17
-rw-r--r--src/emu/sound/dmadac.c66
-rw-r--r--src/emu/sound/dmadac.h12
-rw-r--r--src/emu/sound/es5503.c71
-rw-r--r--src/emu/sound/es5503.h14
-rw-r--r--src/emu/sound/es5506.c295
-rw-r--r--src/emu/sound/es5506.h41
-rw-r--r--src/emu/sound/es8712.c134
-rw-r--r--src/emu/sound/es8712.h20
-rw-r--r--src/emu/sound/flt_rc.c57
-rw-r--r--src/emu/sound/flt_rc.h6
-rw-r--r--src/emu/sound/flt_vol.c52
-rw-r--r--src/emu/sound/flt_vol.h6
-rw-r--r--src/emu/sound/fm.c6
-rw-r--r--src/emu/sound/gaelco.c111
-rw-r--r--src/emu/sound/gaelco.h12
-rw-r--r--src/emu/sound/hc55516.c135
-rw-r--r--src/emu/sound/hc55516.h41
-rw-r--r--src/emu/sound/ics2115.c76
-rw-r--r--src/emu/sound/ics2115.h10
-rw-r--r--src/emu/sound/iremga20.c70
-rw-r--r--src/emu/sound/iremga20.h8
-rw-r--r--src/emu/sound/k005289.c80
-rw-r--r--src/emu/sound/k005289.h16
-rw-r--r--src/emu/sound/k007232.c103
-rw-r--r--src/emu/sound/k007232.h18
-rw-r--r--src/emu/sound/k051649.c82
-rw-r--r--src/emu/sound/k051649.h17
-rw-r--r--src/emu/sound/k053260.c133
-rw-r--r--src/emu/sound/k053260.h16
-rw-r--r--src/emu/sound/k054539.c112
-rw-r--r--src/emu/sound/k054539.h18
-rw-r--r--src/emu/sound/msm5205.c93
-rw-r--r--src/emu/sound/msm5205.h14
-rw-r--r--src/emu/sound/msm5232.c108
-rw-r--r--src/emu/sound/msm5232.h11
-rw-r--r--src/emu/sound/multipcm.c88
-rw-r--r--src/emu/sound/multipcm.h12
-rw-r--r--src/emu/sound/n63701x.c56
-rw-r--r--src/emu/sound/n63701x.h6
-rw-r--r--src/emu/sound/namco.c160
-rw-r--r--src/emu/sound/namco.h30
-rw-r--r--src/emu/sound/namco52.c64
-rw-r--r--src/emu/sound/namco52.h6
-rw-r--r--src/emu/sound/nes_apu.c78
-rw-r--r--src/emu/sound/nes_apu.h10
-rw-r--r--src/emu/sound/nile.c65
-rw-r--r--src/emu/sound/nile.h12
-rw-r--r--src/emu/sound/okim6258.c186
-rw-r--r--src/emu/sound/okim6258.h36
-rw-r--r--src/emu/sound/okim6295.c199
-rw-r--r--src/emu/sound/okim6295.h30
-rw-r--r--src/emu/sound/okim6376.c189
-rw-r--r--src/emu/sound/okim6376.h24
-rw-r--r--src/emu/sound/pokey.c374
-rw-r--r--src/emu/sound/pokey.h45
-rw-r--r--src/emu/sound/psx.c70
-rw-r--r--src/emu/sound/psx.h14
-rw-r--r--src/emu/sound/qsound.c96
-rw-r--r--src/emu/sound/qsound.h10
-rw-r--r--src/emu/sound/rf5c400.c71
-rw-r--r--src/emu/sound/rf5c400.h8
-rw-r--r--src/emu/sound/rf5c68.c71
-rw-r--r--src/emu/sound/rf5c68.h10
-rw-r--r--src/emu/sound/s14001a.c61
-rw-r--r--src/emu/sound/s14001a.h14
-rw-r--r--src/emu/sound/saa1099.c118
-rw-r--r--src/emu/sound/saa1099.h15
-rw-r--r--src/emu/sound/samples.c125
-rw-r--r--src/emu/sound/samples.h32
-rw-r--r--src/emu/sound/scsp.c109
-rw-r--r--src/emu/sound/scsp.h18
-rw-r--r--src/emu/sound/segapcm.c58
-rw-r--r--src/emu/sound/segapcm.h8
-rw-r--r--src/emu/sound/sid6581.c59
-rw-r--r--src/emu/sound/sid6581.h8
-rw-r--r--src/emu/sound/sn76477.c276
-rw-r--r--src/emu/sound/sn76477.h62
-rw-r--r--src/emu/sound/sn76496.c137
-rw-r--r--src/emu/sound/sn76496.h30
-rw-r--r--src/emu/sound/snkwave.c56
-rw-r--r--src/emu/sound/snkwave.h6
-rw-r--r--src/emu/sound/sound.mak13
-rw-r--r--src/emu/sound/sp0250.c76
-rw-r--r--src/emu/sound/sp0250.h10
-rw-r--r--src/emu/sound/sp0256.c79
-rw-r--r--src/emu/sound/sp0256.h10
-rw-r--r--src/emu/sound/speaker.c52
-rw-r--r--src/emu/sound/speaker.h6
-rw-r--r--src/emu/sound/st0016.c80
-rw-r--r--src/emu/sound/st0016.h9
-rw-r--r--src/emu/sound/tiaintf.c60
-rw-r--r--src/emu/sound/tiaintf.h6
-rw-r--r--src/emu/sound/tms3615.c58
-rw-r--r--src/emu/sound/tms3615.h6
-rw-r--r--src/emu/sound/tms36xx.c70
-rw-r--r--src/emu/sound/tms36xx.h10
-rw-r--r--src/emu/sound/tms5110.c6
-rw-r--r--src/emu/sound/tms5110.h2
-rw-r--r--src/emu/sound/tms5220.c38
-rw-r--r--src/emu/sound/tms5220.h8
-rw-r--r--src/emu/sound/upd7759.c124
-rw-r--r--src/emu/sound/upd7759.h20
-rw-r--r--src/emu/sound/vlm5030.c90
-rw-r--r--src/emu/sound/vlm5030.h16
-rw-r--r--src/emu/sound/votrax.c58
-rw-r--r--src/emu/sound/votrax.h8
-rw-r--r--src/emu/sound/vrender0.c64
-rw-r--r--src/emu/sound/vrender0.h10
-rw-r--r--src/emu/sound/wave.c32
-rw-r--r--src/emu/sound/wave.h4
-rw-r--r--src/emu/sound/x1_010.c84
-rw-r--r--src/emu/sound/x1_010.h14
-rw-r--r--src/emu/sound/ym2151.c28
-rw-r--r--src/emu/sound/ym2151.h4
-rw-r--r--src/emu/sound/ymf271.c113
-rw-r--r--src/emu/sound/ymf271.h18
-rw-r--r--src/emu/sound/ymf278b.c221
-rw-r--r--src/emu/sound/ymf278b.h25
-rw-r--r--src/emu/sound/ymz280b.c257
-rw-r--r--src/emu/sound/ymz280b.h36
-rw-r--r--src/emu/streams.c104
-rw-r--r--src/emu/streams.h26
-rw-r--r--src/emu/ui.c33
-rw-r--r--src/emu/validity.c97
-rw-r--r--src/emu/video/cdp1869.c16
-rw-r--r--src/ldplayer/ldplayer.c3
-rw-r--r--src/mame/audio/8080bw.c246
-rw-r--r--src/mame/audio/amiga.c27
-rw-r--r--src/mame/audio/asteroid.c24
-rw-r--r--src/mame/audio/astrof.c28
-rw-r--r--src/mame/audio/atarijsa.c120
-rw-r--r--src/mame/audio/attckufo.c19
-rw-r--r--src/mame/audio/avalnche.c16
-rw-r--r--src/mame/audio/blockade.c7
-rw-r--r--src/mame/audio/bsktball.c14
-rw-r--r--src/mame/audio/bzone.c19
-rw-r--r--src/mame/audio/cage.c22
-rw-r--r--src/mame/audio/canyon.c16
-rw-r--r--src/mame/audio/carnival.c40
-rw-r--r--src/mame/audio/cchasm.c102
-rw-r--r--src/mame/audio/cclimber.c13
-rw-r--r--src/mame/audio/cinemat.c327
-rw-r--r--src/mame/audio/circus.c37
-rw-r--r--src/mame/audio/cps3.c21
-rw-r--r--src/mame/audio/crbaloon.c24
-rw-r--r--src/mame/audio/cyberbal.c6
-rw-r--r--src/mame/audio/dcs.c32
-rw-r--r--src/mame/audio/depthch.c15
-rw-r--r--src/mame/audio/dkong.c52
-rw-r--r--src/mame/audio/exidy.c128
-rw-r--r--src/mame/audio/exidy440.c42
-rw-r--r--src/mame/audio/fghtbskt.c5
-rw-r--r--src/mame/audio/firetrk.c34
-rw-r--r--src/mame/audio/flower.c23
-rw-r--r--src/mame/audio/galaxian.c52
-rw-r--r--src/mame/audio/geebee.c19
-rw-r--r--src/mame/audio/gomoku.c23
-rw-r--r--src/mame/audio/gorf.c15
-rw-r--r--src/mame/audio/gottlieb.c82
-rw-r--r--src/mame/audio/gotya.c5
-rw-r--r--src/mame/audio/gridlee.c32
-rw-r--r--src/mame/audio/harddriv.c4
-rw-r--r--src/mame/audio/invinco.c17
-rw-r--r--src/mame/audio/irem.c82
-rw-r--r--src/mame/audio/jaguar.c4
-rw-r--r--src/mame/audio/jedi.c15
-rw-r--r--src/mame/audio/laserbat.c23
-rw-r--r--src/mame/audio/leland.c72
-rw-r--r--src/mame/audio/llander.c14
-rw-r--r--src/mame/audio/m72.c12
-rw-r--r--src/mame/audio/m72.h4
-rw-r--r--src/mame/audio/mario.c28
-rw-r--r--src/mame/audio/mcr.c128
-rw-r--r--src/mame/audio/meadows.c27
-rw-r--r--src/mame/audio/mw8080bw.c253
-rw-r--r--src/mame/audio/n8080.c65
-rw-r--r--src/mame/audio/namco54.c14
-rw-r--r--src/mame/audio/namcoc7x.c4
-rw-r--r--src/mame/audio/orbit.c20
-rw-r--r--src/mame/audio/phoenix.c37
-rw-r--r--src/mame/audio/pleiads.c61
-rw-r--r--src/mame/audio/polepos.c22
-rw-r--r--src/mame/audio/polyplay.c22
-rw-r--r--src/mame/audio/poolshrk.c16
-rw-r--r--src/mame/audio/pulsar.c36
-rw-r--r--src/mame/audio/qix.c12
-rw-r--r--src/mame/audio/redalert.c48
-rw-r--r--src/mame/audio/redbaron.c23
-rw-r--r--src/mame/audio/rockola.c58
-rw-r--r--src/mame/audio/scramble.c68
-rw-r--r--src/mame/audio/segag80r.c139
-rw-r--r--src/mame/audio/segag80v.c105
-rw-r--r--src/mame/audio/segasnd.c38
-rw-r--r--src/mame/audio/seibu.c159
-rw-r--r--src/mame/audio/seibu.h23
-rw-r--r--src/mame/audio/senjyo.c11
-rw-r--r--src/mame/audio/snes.c16
-rw-r--r--src/mame/audio/spacefb.c10
-rw-r--r--src/mame/audio/spiders.c17
-rw-r--r--src/mame/audio/starwars.c8
-rw-r--r--src/mame/audio/subs.c20
-rw-r--r--src/mame/audio/suna8.c8
-rw-r--r--src/mame/audio/t5182.c9
-rw-r--r--src/mame/audio/taito_en.c6
-rw-r--r--src/mame/audio/targ.c39
-rw-r--r--src/mame/audio/tiamc1.c19
-rw-r--r--src/mame/audio/timeplt.c44
-rw-r--r--src/mame/audio/toaplan2.c40
-rw-r--r--src/mame/audio/trackfld.c22
-rw-r--r--src/mame/audio/turbo.c148
-rw-r--r--src/mame/audio/tx1.c76
-rw-r--r--src/mame/audio/vicdual.c63
-rw-r--r--src/mame/audio/warpwarp.c20
-rw-r--r--src/mame/audio/williams.c62
-rw-r--r--src/mame/audio/wiping.c24
-rw-r--r--src/mame/audio/wow.c15
-rw-r--r--src/mame/audio/zaxxon.c61
-rw-r--r--src/mame/drivers/1942.c6
-rw-r--r--src/mame/drivers/1943.c6
-rw-r--r--src/mame/drivers/1945kiii.c8
-rw-r--r--src/mame/drivers/20pacgal.c12
-rw-r--r--src/mame/drivers/2mindril.c9
-rw-r--r--src/mame/drivers/40love.c45
-rw-r--r--src/mame/drivers/4enraya.c11
-rw-r--r--src/mame/drivers/4roses.c8
-rw-r--r--src/mame/drivers/8080bw.c12
-rw-r--r--src/mame/drivers/86lions.c11
-rw-r--r--src/mame/drivers/88games.c19
-rw-r--r--src/mame/drivers/acommand.c12
-rw-r--r--src/mame/drivers/actfancr.c12
-rw-r--r--src/mame/drivers/adp.c10
-rw-r--r--src/mame/drivers/aeroboto.c18
-rw-r--r--src/mame/drivers/aerofgt.c41
-rw-r--r--src/mame/drivers/airbustr.c13
-rw-r--r--src/mame/drivers/ajax.c29
-rw-r--r--src/mame/drivers/aleck64.c1
-rw-r--r--src/mame/drivers/alg.c19
-rw-r--r--src/mame/drivers/aliens.c15
-rw-r--r--src/mame/drivers/alpha68k.c41
-rw-r--r--src/mame/drivers/ambush.c24
-rw-r--r--src/mame/drivers/ampoker2.c7
-rw-r--r--src/mame/drivers/amspdwy.c13
-rw-r--r--src/mame/drivers/angelkds.c12
-rw-r--r--src/mame/drivers/appoooh.c15
-rw-r--r--src/mame/drivers/aquarium.c19
-rw-r--r--src/mame/drivers/arabian.c16
-rw-r--r--src/mame/drivers/arcadecl.c24
-rw-r--r--src/mame/drivers/arcadia.c17
-rw-r--r--src/mame/drivers/argus.c17
-rw-r--r--src/mame/drivers/aristmk5.c2
-rw-r--r--src/mame/drivers/arkanoid.c16
-rw-r--r--src/mame/drivers/armedf.c7
-rw-r--r--src/mame/drivers/artmagic.c6
-rw-r--r--src/mame/drivers/ashnojoe.c27
-rw-r--r--src/mame/drivers/asterix.c12
-rw-r--r--src/mame/drivers/asteroid.c30
-rw-r--r--src/mame/drivers/astinvad.c44
-rw-r--r--src/mame/drivers/astrocde.c66
-rw-r--r--src/mame/drivers/astrocorp.c12
-rw-r--r--src/mame/drivers/asuka.c38
-rw-r--r--src/mame/drivers/atarisy1.c18
-rw-r--r--src/mame/drivers/atarisy2.c26
-rw-r--r--src/mame/drivers/ataxx.c17
-rw-r--r--src/mame/drivers/atetris.c18
-rw-r--r--src/mame/drivers/attckufo.c8
-rw-r--r--src/mame/drivers/avalnche.c6
-rw-r--r--src/mame/drivers/aztarac.c12
-rw-r--r--src/mame/drivers/backfire.c18
-rw-r--r--src/mame/drivers/badlands.c3
-rw-r--r--src/mame/drivers/bagman.c88
-rw-r--r--src/mame/drivers/bankp.c6
-rw-r--r--src/mame/drivers/baraduke.c4
-rw-r--r--src/mame/drivers/battlane.c9
-rw-r--r--src/mame/drivers/battlera.c22
-rw-r--r--src/mame/drivers/battlex.c3
-rw-r--r--src/mame/drivers/battlnts.c6
-rw-r--r--src/mame/drivers/bbusters.c16
-rw-r--r--src/mame/drivers/berzerk.c29
-rw-r--r--src/mame/drivers/bestleag.c8
-rw-r--r--src/mame/drivers/bfcobra.c18
-rw-r--r--src/mame/drivers/bfm_sc2.c72
-rw-r--r--src/mame/drivers/big10.c25
-rw-r--r--src/mame/drivers/bigevglf.c5
-rw-r--r--src/mame/drivers/bigfghtr.c7
-rw-r--r--src/mame/drivers/bigstrkb.c4
-rw-r--r--src/mame/drivers/bingoc.c13
-rw-r--r--src/mame/drivers/bionicc.c3
-rw-r--r--src/mame/drivers/bishi.c25
-rw-r--r--src/mame/drivers/bishjan.c11
-rw-r--r--src/mame/drivers/bking.c18
-rw-r--r--src/mame/drivers/bladestl.c29
-rw-r--r--src/mame/drivers/blktiger.c12
-rw-r--r--src/mame/drivers/blmbycar.c4
-rw-r--r--src/mame/drivers/blockade.c2
-rw-r--r--src/mame/drivers/blockhl.c3
-rw-r--r--src/mame/drivers/blockout.c9
-rw-r--r--src/mame/drivers/blueprnt.c28
-rw-r--r--src/mame/drivers/bmcbowl.c24
-rw-r--r--src/mame/drivers/bogeyman.c16
-rw-r--r--src/mame/drivers/bombjack.c9
-rw-r--r--src/mame/drivers/boogwing.c16
-rw-r--r--src/mame/drivers/bottom9.c20
-rw-r--r--src/mame/drivers/brasil.c10
-rw-r--r--src/mame/drivers/brkthru.c13
-rw-r--r--src/mame/drivers/bsktball.c6
-rw-r--r--src/mame/drivers/btime.c22
-rw-r--r--src/mame/drivers/btoads.c8
-rw-r--r--src/mame/drivers/bublbobl.c17
-rw-r--r--src/mame/drivers/buggychl.c32
-rw-r--r--src/mame/drivers/bwidow.c16
-rw-r--r--src/mame/drivers/bwing.c10
-rw-r--r--src/mame/drivers/bzone.c35
-rw-r--r--src/mame/drivers/cabal.c47
-rw-r--r--src/mame/drivers/cabaret.c3
-rw-r--r--src/mame/drivers/calomega.c30
-rw-r--r--src/mame/drivers/calorie.c8
-rw-r--r--src/mame/drivers/canyon.c8
-rw-r--r--src/mame/drivers/capbowl.c17
-rw-r--r--src/mame/drivers/cardline.c2
-rw-r--r--src/mame/drivers/carjmbre.c6
-rw-r--r--src/mame/drivers/carrera.c15
-rw-r--r--src/mame/drivers/caswin.c23
-rw-r--r--src/mame/drivers/cave.c116
-rw-r--r--src/mame/drivers/cbasebal.c5
-rw-r--r--src/mame/drivers/cbuster.c44
-rw-r--r--src/mame/drivers/ccastles.c8
-rw-r--r--src/mame/drivers/cchance.c22
-rw-r--r--src/mame/drivers/cchasm.c10
-rw-r--r--src/mame/drivers/cclimber.c17
-rw-r--r--src/mame/drivers/centiped.c63
-rw-r--r--src/mame/drivers/chaknpop.c34
-rw-r--r--src/mame/drivers/cham24.c18
-rw-r--r--src/mame/drivers/champbas.c36
-rw-r--r--src/mame/drivers/champbwl.c2
-rw-r--r--src/mame/drivers/chanbara.c21
-rw-r--r--src/mame/drivers/changela.c26
-rw-r--r--src/mame/drivers/chinagat.c47
-rw-r--r--src/mame/drivers/chinsan.c15
-rw-r--r--src/mame/drivers/chqflag.c39
-rw-r--r--src/mame/drivers/cidelsa.c24
-rw-r--r--src/mame/drivers/circusc.c17
-rw-r--r--src/mame/drivers/cischeat.c96
-rw-r--r--src/mame/drivers/citycon.c18
-rw-r--r--src/mame/drivers/cliffhgr.c19
-rw-r--r--src/mame/drivers/cloak.c12
-rw-r--r--src/mame/drivers/cloud9.c8
-rw-r--r--src/mame/drivers/clshroad.c19
-rw-r--r--src/mame/drivers/cninja.c49
-rw-r--r--src/mame/drivers/cntsteer.c8
-rw-r--r--src/mame/drivers/coinmstr.c24
-rw-r--r--src/mame/drivers/combatsc.c51
-rw-r--r--src/mame/drivers/commando.c6
-rw-r--r--src/mame/drivers/compgolf.c21
-rw-r--r--src/mame/drivers/contra.c5
-rw-r--r--src/mame/drivers/coolpool.c6
-rw-r--r--src/mame/drivers/coolridr.c4
-rw-r--r--src/mame/drivers/cop01.c14
-rw-r--r--src/mame/drivers/cosmic.c142
-rw-r--r--src/mame/drivers/cowrace.c9
-rw-r--r--src/mame/drivers/cps1.c25
-rw-r--r--src/mame/drivers/cps3.c11
-rw-r--r--src/mame/drivers/crbaloon.c24
-rw-r--r--src/mame/drivers/crgolf.c16
-rw-r--r--src/mame/drivers/crimfght.c19
-rw-r--r--src/mame/drivers/crospang.c9
-rw-r--r--src/mame/drivers/crshrace.c9
-rw-r--r--src/mame/drivers/crystal.c4
-rw-r--r--src/mame/drivers/cshooter.c13
-rw-r--r--src/mame/drivers/cubeqst.c17
-rw-r--r--src/mame/drivers/cubocd32.c13
-rw-r--r--src/mame/drivers/cultures.c2
-rw-r--r--src/mame/drivers/cvs.c54
-rw-r--r--src/mame/drivers/cyberbal.c3
-rw-r--r--src/mame/drivers/cybertnk.c9
-rw-r--r--src/mame/drivers/dacholer.c11
-rw-r--r--src/mame/drivers/darius.c144
-rw-r--r--src/mame/drivers/darkhors.c15
-rw-r--r--src/mame/drivers/darkseal.c44
-rw-r--r--src/mame/drivers/dassault.c24
-rw-r--r--src/mame/drivers/dblewing.c10
-rw-r--r--src/mame/drivers/dbz.c15
-rw-r--r--src/mame/drivers/dcheese.c8
-rw-r--r--src/mame/drivers/dday.c18
-rw-r--r--src/mame/drivers/ddayjlc.c16
-rw-r--r--src/mame/drivers/ddealer.c10
-rw-r--r--src/mame/drivers/ddenlovr.c318
-rw-r--r--src/mame/drivers/ddragon.c25
-rw-r--r--src/mame/drivers/ddragon3.c28
-rw-r--r--src/mame/drivers/ddrible.c48
-rw-r--r--src/mame/drivers/dec0.c56
-rw-r--r--src/mame/drivers/dec8.c41
-rw-r--r--src/mame/drivers/deco156.c51
-rw-r--r--src/mame/drivers/deco32.c61
-rw-r--r--src/mame/drivers/deco_mlc.c27
-rw-r--r--src/mame/drivers/decocass.c8
-rw-r--r--src/mame/drivers/deniam.c47
-rw-r--r--src/mame/drivers/dietgo.c24
-rw-r--r--src/mame/drivers/discoboy.c5
-rw-r--r--src/mame/drivers/diverboy.c10
-rw-r--r--src/mame/drivers/djboy.c7
-rw-r--r--src/mame/drivers/djmain.c34
-rw-r--r--src/mame/drivers/dlair.c24
-rw-r--r--src/mame/drivers/dmndrby.c5
-rw-r--r--src/mame/drivers/docastle.c40
-rw-r--r--src/mame/drivers/dogfgt.c17
-rw-r--r--src/mame/drivers/dominob.c12
-rw-r--r--src/mame/drivers/dooyong.c43
-rw-r--r--src/mame/drivers/dragrace.c32
-rw-r--r--src/mame/drivers/dreamwld.c38
-rw-r--r--src/mame/drivers/drgnmst.c12
-rw-r--r--src/mame/drivers/drmicro.c14
-rw-r--r--src/mame/drivers/drtomy.c8
-rw-r--r--src/mame/drivers/drw80pkr.c9
-rw-r--r--src/mame/drivers/dunhuang.c30
-rw-r--r--src/mame/drivers/dwarfd.c13
-rw-r--r--src/mame/drivers/dynadice.c8
-rw-r--r--src/mame/drivers/dynax.c170
-rw-r--r--src/mame/drivers/egghunt.c12
-rw-r--r--src/mame/drivers/enigma2.c19
-rw-r--r--src/mame/drivers/eolith16.c2
-rw-r--r--src/mame/drivers/epos.c4
-rw-r--r--src/mame/drivers/equites.c71
-rw-r--r--src/mame/drivers/esd16.c5
-rw-r--r--src/mame/drivers/esh.c3
-rw-r--r--src/mame/drivers/espial.c3
-rw-r--r--src/mame/drivers/esripsys.c16
-rw-r--r--src/mame/drivers/ettrivia.c34
-rw-r--r--src/mame/drivers/exedexes.c7
-rw-r--r--src/mame/drivers/exerion.c22
-rw-r--r--src/mame/drivers/expro02.c4
-rw-r--r--src/mame/drivers/exprraid.c12
-rw-r--r--src/mame/drivers/exterm.c15
-rw-r--r--src/mame/drivers/exzisus.c10
-rw-r--r--src/mame/drivers/f-32.c35
-rw-r--r--src/mame/drivers/f1gp.c11
-rw-r--r--src/mame/drivers/fantland.c47
-rw-r--r--src/mame/drivers/fastfred.c9
-rw-r--r--src/mame/drivers/fastlane.c38
-rw-r--r--src/mame/drivers/fcombat.c15
-rw-r--r--src/mame/drivers/fcrash.c14
-rw-r--r--src/mame/drivers/feversoc.c4
-rw-r--r--src/mame/drivers/finalizr.c4
-rw-r--r--src/mame/drivers/findout.c2
-rw-r--r--src/mame/drivers/firebeat.c44
-rw-r--r--src/mame/drivers/firefox.c24
-rw-r--r--src/mame/drivers/firetrap.c9
-rw-r--r--src/mame/drivers/firetrk.c55
-rw-r--r--src/mame/drivers/flkatck.c17
-rw-r--r--src/mame/drivers/flower.c8
-rw-r--r--src/mame/drivers/flstory.c45
-rw-r--r--src/mame/drivers/foodf.c37
-rw-r--r--src/mame/drivers/forte2.c19
-rw-r--r--src/mame/drivers/fortecar.c16
-rw-r--r--src/mame/drivers/freekick.c24
-rw-r--r--src/mame/drivers/fromanc2.c9
-rw-r--r--src/mame/drivers/fromance.c21
-rw-r--r--src/mame/drivers/funkybee.c13
-rw-r--r--src/mame/drivers/funkyjet.c12
-rw-r--r--src/mame/drivers/funworld.c32
-rw-r--r--src/mame/drivers/funybubl.c10
-rw-r--r--src/mame/drivers/fuukifg2.c20
-rw-r--r--src/mame/drivers/fuukifg3.c33
-rw-r--r--src/mame/drivers/gaelco.c19
-rw-r--r--src/mame/drivers/gaelco2.c24
-rw-r--r--src/mame/drivers/gaelco3d.c20
-rw-r--r--src/mame/drivers/gaiden.c21
-rw-r--r--src/mame/drivers/galaga.c20
-rw-r--r--src/mame/drivers/galaxi.c2
-rw-r--r--src/mame/drivers/galaxian.c170
-rw-r--r--src/mame/drivers/galaxold.c36
-rw-r--r--src/mame/drivers/galdrvr.c23
-rw-r--r--src/mame/drivers/galivan.c9
-rw-r--r--src/mame/drivers/galpani2.c12
-rw-r--r--src/mame/drivers/galpani3.c3
-rw-r--r--src/mame/drivers/galpanic.c32
-rw-r--r--src/mame/drivers/galspnbl.c9
-rw-r--r--src/mame/drivers/gameplan.c16
-rw-r--r--src/mame/drivers/gaplus.c10
-rw-r--r--src/mame/drivers/gatron.c4
-rw-r--r--src/mame/drivers/gauntlet.c14
-rw-r--r--src/mame/drivers/gberet.c6
-rw-r--r--src/mame/drivers/gbusters.c21
-rw-r--r--src/mame/drivers/gcpinbal.c4
-rw-r--r--src/mame/drivers/genesis.c69
-rw-r--r--src/mame/drivers/getrivia.c4
-rw-r--r--src/mame/drivers/gijoe.c8
-rw-r--r--src/mame/drivers/ginganin.c8
-rw-r--r--src/mame/drivers/gladiatr.c51
-rw-r--r--src/mame/drivers/glass.c4
-rw-r--r--src/mame/drivers/gng.c6
-rw-r--r--src/mame/drivers/goal92.c24
-rw-r--r--src/mame/drivers/goindol.c3
-rw-r--r--src/mame/drivers/goldnpkr.c6
-rw-r--r--src/mame/drivers/goldstar.c78
-rw-r--r--src/mame/drivers/gomoku.c9
-rw-r--r--src/mame/drivers/good.c2
-rw-r--r--src/mame/drivers/gotcha.c17
-rw-r--r--src/mame/drivers/gottlieb.c4
-rw-r--r--src/mame/drivers/gpworld.c3
-rw-r--r--src/mame/drivers/gradius3.c17
-rw-r--r--src/mame/drivers/grchamp.c55
-rw-r--r--src/mame/drivers/gridlee.c10
-rw-r--r--src/mame/drivers/gstream.c13
-rw-r--r--src/mame/drivers/gstriker.c11
-rw-r--r--src/mame/drivers/gsword.c48
-rw-r--r--src/mame/drivers/gticlub.c2
-rw-r--r--src/mame/drivers/guab.c2
-rw-r--r--src/mame/drivers/gumbo.c12
-rw-r--r--src/mame/drivers/gundealr.c3
-rw-r--r--src/mame/drivers/gunsmoke.c6
-rw-r--r--src/mame/drivers/gyruss.c124
-rw-r--r--src/mame/drivers/halleys.c25
-rw-r--r--src/mame/drivers/hanaawas.c14
-rw-r--r--src/mame/drivers/hanaroku.c13
-rw-r--r--src/mame/drivers/harddriv.c2
-rw-r--r--src/mame/drivers/hcastle.c33
-rw-r--r--src/mame/drivers/hexa.c13
-rw-r--r--src/mame/drivers/hexion.c10
-rw-r--r--src/mame/drivers/higemaru.c6
-rw-r--r--src/mame/drivers/highvdeo.c24
-rw-r--r--src/mame/drivers/himesiki.c3
-rw-r--r--src/mame/drivers/hitme.c24
-rw-r--r--src/mame/drivers/hnayayoi.c68
-rw-r--r--src/mame/drivers/holeland.c24
-rw-r--r--src/mame/drivers/homedata.c30
-rw-r--r--src/mame/drivers/homerun.c13
-rw-r--r--src/mame/drivers/hornet.c2
-rw-r--r--src/mame/drivers/hotblock.c12
-rw-r--r--src/mame/drivers/hyhoo.c19
-rw-r--r--src/mame/drivers/hyperspt.c12
-rw-r--r--src/mame/drivers/hyprduel.c22
-rw-r--r--src/mame/drivers/igs009.c5
-rw-r--r--src/mame/drivers/igs017.c7
-rw-r--r--src/mame/drivers/igs_blit.c62
-rw-r--r--src/mame/drivers/igspoker.c5
-rw-r--r--src/mame/drivers/ikki.c4
-rw-r--r--src/mame/drivers/imolagp.c4
-rw-r--r--src/mame/drivers/inufuku.c9
-rw-r--r--src/mame/drivers/iqblock.c3
-rw-r--r--src/mame/drivers/irobot.c4
-rw-r--r--src/mame/drivers/ironhors.c25
-rw-r--r--src/mame/drivers/istellar.c3
-rw-r--r--src/mame/drivers/itech32.c5
-rw-r--r--src/mame/drivers/itech8.c44
-rw-r--r--src/mame/drivers/jack.c12
-rw-r--r--src/mame/drivers/jackal.c3
-rw-r--r--src/mame/drivers/jackie.c3
-rw-r--r--src/mame/drivers/jackpool.c2
-rw-r--r--src/mame/drivers/jailbrek.c18
-rw-r--r--src/mame/drivers/jalmah.c4
-rw-r--r--src/mame/drivers/jangou.c42
-rw-r--r--src/mame/drivers/jantotsu.c16
-rw-r--r--src/mame/drivers/jchan.c3
-rw-r--r--src/mame/drivers/jollyjgr.c4
-rw-r--r--src/mame/drivers/jongkyo.c53
-rw-r--r--src/mame/drivers/jpmimpct.c24
-rw-r--r--src/mame/drivers/jpmsys5.c23
-rw-r--r--src/mame/drivers/jrpacman.c4
-rw-r--r--src/mame/drivers/junofrst.c25
-rw-r--r--src/mame/drivers/kaneko16.c165
-rw-r--r--src/mame/drivers/kangaroo.c10
-rw-r--r--src/mame/drivers/karnov.c12
-rw-r--r--src/mame/drivers/kchamp.c25
-rw-r--r--src/mame/drivers/kickgoal.c128
-rw-r--r--src/mame/drivers/kingobox.c14
-rw-r--r--src/mame/drivers/klax.c24
-rw-r--r--src/mame/drivers/kncljoe.c40
-rw-r--r--src/mame/drivers/koftball.c2
-rw-r--r--src/mame/drivers/koikoi.c16
-rw-r--r--src/mame/drivers/konamigq.c8
-rw-r--r--src/mame/drivers/konamigv.c13
-rw-r--r--src/mame/drivers/konamigx.c15
-rw-r--r--src/mame/drivers/ksayakyu.c26
-rw-r--r--src/mame/drivers/ksys573.c13
-rw-r--r--src/mame/drivers/kyugo.c24
-rw-r--r--src/mame/drivers/labyrunr.c28
-rw-r--r--src/mame/drivers/ladybug.c14
-rw-r--r--src/mame/drivers/ladyfrog.c15
-rw-r--r--src/mame/drivers/laserbat.c23
-rw-r--r--src/mame/drivers/lasso.c16
-rw-r--r--src/mame/drivers/lastduel.c28
-rw-r--r--src/mame/drivers/lazercmd.c12
-rw-r--r--src/mame/drivers/legionna.c4
-rw-r--r--src/mame/drivers/leland.c36
-rw-r--r--src/mame/drivers/lemmings.c13
-rw-r--r--src/mame/drivers/lethal.c6
-rw-r--r--src/mame/drivers/lethalj.c6
-rw-r--r--src/mame/drivers/lgp.c3
-rw-r--r--src/mame/drivers/liberate.c16
-rw-r--r--src/mame/drivers/liberatr.c16
-rw-r--r--src/mame/drivers/limenko.c4
-rw-r--r--src/mame/drivers/lkage.c16
-rw-r--r--src/mame/drivers/lockon.c29
-rw-r--r--src/mame/drivers/looping.c40
-rw-r--r--src/mame/drivers/lordgun.c24
-rw-r--r--src/mame/drivers/lsasquad.c29
-rw-r--r--src/mame/drivers/ltcasino.c5
-rw-r--r--src/mame/drivers/lucky74.c30
-rw-r--r--src/mame/drivers/lvcards.c16
-rw-r--r--src/mame/drivers/lwings.c20
-rw-r--r--src/mame/drivers/m10.c45
-rw-r--r--src/mame/drivers/m107.c11
-rw-r--r--src/mame/drivers/m63.c17
-rw-r--r--src/mame/drivers/m72.c49
-rw-r--r--src/mame/drivers/m90.c10
-rw-r--r--src/mame/drivers/m92.c11
-rw-r--r--src/mame/drivers/macrossp.c20
-rw-r--r--src/mame/drivers/macs.c2
-rw-r--r--src/mame/drivers/madalien.c19
-rw-r--r--src/mame/drivers/madmotor.c44
-rw-r--r--src/mame/drivers/magic10.c10
-rw-r--r--src/mame/drivers/magicard.c3
-rw-r--r--src/mame/drivers/magicfly.c2
-rw-r--r--src/mame/drivers/magmax.c42
-rw-r--r--src/mame/drivers/mainevt.c43
-rw-r--r--src/mame/drivers/mainsnk.c6
-rw-r--r--src/mame/drivers/mappy.c31
-rw-r--r--src/mame/drivers/marineb.c15
-rw-r--r--src/mame/drivers/mario.c4
-rw-r--r--src/mame/drivers/markham.c4
-rw-r--r--src/mame/drivers/mastboy.c22
-rw-r--r--src/mame/drivers/matmania.c25
-rw-r--r--src/mame/drivers/maxaflex.c8
-rw-r--r--src/mame/drivers/mayumi.c11
-rw-r--r--src/mame/drivers/mazerbla.c28
-rw-r--r--src/mame/drivers/mcatadv.c20
-rw-r--r--src/mame/drivers/mcr.c8
-rw-r--r--src/mame/drivers/meadows.c2
-rw-r--r--src/mame/drivers/mediagx.c16
-rw-r--r--src/mame/drivers/megadriv.c84
-rw-r--r--src/mame/drivers/megaplay.c2
-rw-r--r--src/mame/drivers/megasys1.c74
-rw-r--r--src/mame/drivers/megatech.c2
-rw-r--r--src/mame/drivers/megazone.c25
-rw-r--r--src/mame/drivers/meijinsn.c6
-rw-r--r--src/mame/drivers/merit.c18
-rw-r--r--src/mame/drivers/meritm.c23
-rw-r--r--src/mame/drivers/mermaid.c8
-rw-r--r--src/mame/drivers/metlclsh.c14
-rw-r--r--src/mame/drivers/metro.c162
-rw-r--r--src/mame/drivers/mexico86.c21
-rw-r--r--src/mame/drivers/mhavoc.c31
-rw-r--r--src/mame/drivers/micro3d.c20
-rw-r--r--src/mame/drivers/midas.c5
-rw-r--r--src/mame/drivers/midyunit.c8
-rw-r--r--src/mame/drivers/mikie.c4
-rw-r--r--src/mame/drivers/mil4000.c2
-rw-r--r--src/mame/drivers/mirage.c4
-rw-r--r--src/mame/drivers/mirax.c22
-rw-r--r--src/mame/drivers/missb2.c11
-rw-r--r--src/mame/drivers/missile.c8
-rw-r--r--src/mame/drivers/mitchell.c24
-rw-r--r--src/mame/drivers/mjkjidai.c36
-rw-r--r--src/mame/drivers/mjsister.c16
-rw-r--r--src/mame/drivers/mlanding.c27
-rw-r--r--src/mame/drivers/model1.c66
-rw-r--r--src/mame/drivers/model2.c76
-rw-r--r--src/mame/drivers/model3.c12
-rw-r--r--src/mame/drivers/mogura.c8
-rw-r--r--src/mame/drivers/mole.c3
-rw-r--r--src/mame/drivers/momoko.c20
-rw-r--r--src/mame/drivers/moo.c19
-rw-r--r--src/mame/drivers/mosaic.c14
-rw-r--r--src/mame/drivers/mouser.c6
-rw-r--r--src/mame/drivers/mpu4.c12
-rw-r--r--src/mame/drivers/mpu4drvr.c8
-rw-r--r--src/mame/drivers/mquake.c41
-rw-r--r--src/mame/drivers/mrdo.c4
-rw-r--r--src/mame/drivers/mrflea.c83
-rw-r--r--src/mame/drivers/mrjong.c4
-rw-r--r--src/mame/drivers/ms32.c4
-rw-r--r--src/mame/drivers/msisaac.c28
-rw-r--r--src/mame/drivers/mugsmash.c13
-rw-r--r--src/mame/drivers/multigam.c24
-rw-r--r--src/mame/drivers/munchmo.c8
-rw-r--r--src/mame/drivers/mw8080bw.c60
-rw-r--r--src/mame/drivers/mwarr.c10
-rw-r--r--src/mame/drivers/mystston.c10
-rw-r--r--src/mame/drivers/mystwarr.c40
-rw-r--r--src/mame/drivers/namcona1.c18
-rw-r--r--src/mame/drivers/namconb1.c2
-rw-r--r--src/mame/drivers/namcond1.c2
-rw-r--r--src/mame/drivers/namcos1.c21
-rw-r--r--src/mame/drivers/namcos12.c2
-rw-r--r--src/mame/drivers/namcos2.c13
-rw-r--r--src/mame/drivers/namcos21.c9
-rw-r--r--src/mame/drivers/namcos22.c4
-rw-r--r--src/mame/drivers/namcos23.c2
-rw-r--r--src/mame/drivers/namcos86.c10
-rw-r--r--src/mame/drivers/naomi.c12
-rw-r--r--src/mame/drivers/naughtyb.c17
-rw-r--r--src/mame/drivers/nbmj8688.c85
-rw-r--r--src/mame/drivers/nbmj8891.c81
-rw-r--r--src/mame/drivers/nbmj8991.c39
-rw-r--r--src/mame/drivers/nbmj9195.c17
-rw-r--r--src/mame/drivers/nemesis.c148
-rw-r--r--src/mame/drivers/neogeo.c9
-rw-r--r--src/mame/drivers/news.c4
-rw-r--r--src/mame/drivers/nightgal.c56
-rw-r--r--src/mame/drivers/ninjakd2.c17
-rw-r--r--src/mame/drivers/ninjaw.c46
-rw-r--r--src/mame/drivers/niyanpai.c13
-rw-r--r--src/mame/drivers/nmg5.c15
-rw-r--r--src/mame/drivers/nmk16.c82
-rw-r--r--src/mame/drivers/norautp.c5
-rw-r--r--src/mame/drivers/nova2001.c80
-rw-r--r--src/mame/drivers/nss.c6
-rw-r--r--src/mame/drivers/nwk-tr.c2
-rw-r--r--src/mame/drivers/nycaptor.c18
-rw-r--r--src/mame/drivers/nyny.c36
-rw-r--r--src/mame/drivers/ohmygod.c4
-rw-r--r--src/mame/drivers/ojankohs.c72
-rw-r--r--src/mame/drivers/olibochu.c5
-rw-r--r--src/mame/drivers/omegrace.c7
-rw-r--r--src/mame/drivers/oneshot.c19
-rw-r--r--src/mame/drivers/onetwo.c10
-rw-r--r--src/mame/drivers/opwolf.c35
-rw-r--r--src/mame/drivers/orbit.c12
-rw-r--r--src/mame/drivers/othldrby.c10
-rw-r--r--src/mame/drivers/othunder.c21
-rw-r--r--src/mame/drivers/overdriv.c30
-rw-r--r--src/mame/drivers/pacland.c4
-rw-r--r--src/mame/drivers/pacman.c62
-rw-r--r--src/mame/drivers/pandoras.c22
-rw-r--r--src/mame/drivers/paradise.c30
-rw-r--r--src/mame/drivers/paranoia.c4
-rw-r--r--src/mame/drivers/parodius.c17
-rw-r--r--src/mame/drivers/pasha2.c40
-rw-r--r--src/mame/drivers/pass.c5
-rw-r--r--src/mame/drivers/pastelg.c26
-rw-r--r--src/mame/drivers/pbaction.c9
-rw-r--r--src/mame/drivers/pcktgal.c14
-rw-r--r--src/mame/drivers/pcxt.c10
-rw-r--r--src/mame/drivers/pengo.c8
-rw-r--r--src/mame/drivers/peplus.c7
-rw-r--r--src/mame/drivers/pgm.c8
-rw-r--r--src/mame/drivers/phoenix.c33
-rw-r--r--src/mame/drivers/pingpong.c4
-rw-r--r--src/mame/drivers/pipedrm.c18
-rw-r--r--src/mame/drivers/pipeline.c2
-rw-r--r--src/mame/drivers/pirates.c6
-rw-r--r--src/mame/drivers/pitnrun.c15
-rw-r--r--src/mame/drivers/pkscram.c23
-rw-r--r--src/mame/drivers/pktgaldx.c14
-rw-r--r--src/mame/drivers/playch10.c20
-rw-r--r--src/mame/drivers/playmark.c16
-rw-r--r--src/mame/drivers/plygonet.c4
-rw-r--r--src/mame/drivers/pokechmp.c10
-rw-r--r--src/mame/drivers/polepos.c35
-rw-r--r--src/mame/drivers/policetr.c19
-rw-r--r--src/mame/drivers/polyplay.c12
-rw-r--r--src/mame/drivers/poolshrk.c8
-rw-r--r--src/mame/drivers/popeye.c25
-rw-r--r--src/mame/drivers/popper.c6
-rw-r--r--src/mame/drivers/powerbal.c14
-rw-r--r--src/mame/drivers/powerins.c21
-rw-r--r--src/mame/drivers/ppmast93.c6
-rw-r--r--src/mame/drivers/prehisle.c25
-rw-r--r--src/mame/drivers/progolf.c8
-rw-r--r--src/mame/drivers/psikyo.c27
-rw-r--r--src/mame/drivers/psikyo4.c59
-rw-r--r--src/mame/drivers/psikyosh.c63
-rw-r--r--src/mame/drivers/psychic5.c18
-rw-r--r--src/mame/drivers/pturn.c6
-rw-r--r--src/mame/drivers/puckpkmn.c28
-rw-r--r--src/mame/drivers/punchout.c26
-rw-r--r--src/mame/drivers/pushman.c12
-rw-r--r--src/mame/drivers/qdrmfgp.c32
-rw-r--r--src/mame/drivers/quantum.c57
-rw-r--r--src/mame/drivers/quasar.c7
-rw-r--r--src/mame/drivers/quizdna.c23
-rw-r--r--src/mame/drivers/quizo.c3
-rw-r--r--src/mame/drivers/quizpani.c4
-rw-r--r--src/mame/drivers/quizpun2.c3
-rw-r--r--src/mame/drivers/r2dtank.c50
-rw-r--r--src/mame/drivers/raiden2.c13
-rw-r--r--src/mame/drivers/rainbow.c23
-rw-r--r--src/mame/drivers/rallyx.c7
-rw-r--r--src/mame/drivers/rampart.c47
-rw-r--r--src/mame/drivers/rastan.c27
-rw-r--r--src/mame/drivers/rcasino.c13
-rw-r--r--src/mame/drivers/re900.c57
-rw-r--r--src/mame/drivers/realbrk.c15
-rw-r--r--src/mame/drivers/relief.c47
-rw-r--r--src/mame/drivers/renegade.c41
-rw-r--r--src/mame/drivers/retofinv.c4
-rw-r--r--src/mame/drivers/rmhaihai.c24
-rw-r--r--src/mame/drivers/rockola.c7
-rw-r--r--src/mame/drivers/rockrage.c21
-rw-r--r--src/mame/drivers/rohga.c22
-rw-r--r--src/mame/drivers/rollerg.c17
-rw-r--r--src/mame/drivers/rollrace.c9
-rw-r--r--src/mame/drivers/route16.c34
-rw-r--r--src/mame/drivers/royalmah.c104
-rw-r--r--src/mame/drivers/rpunch.c27
-rw-r--r--src/mame/drivers/runaway.c27
-rw-r--r--src/mame/drivers/rungun.c10
-rw-r--r--src/mame/drivers/sandscrp.c17
-rw-r--r--src/mame/drivers/sangho.c6
-rw-r--r--src/mame/drivers/sauro.c12
-rw-r--r--src/mame/drivers/sbasketb.c12
-rw-r--r--src/mame/drivers/sbowling.c4
-rw-r--r--src/mame/drivers/sbrkout.c2
-rw-r--r--src/mame/drivers/sbugger.c4
-rw-r--r--src/mame/drivers/scobra.c32
-rw-r--r--src/mame/drivers/scotrsht.c3
-rw-r--r--src/mame/drivers/scramble.c40
-rw-r--r--src/mame/drivers/scregg.c12
-rw-r--r--src/mame/drivers/sderby.c6
-rw-r--r--src/mame/drivers/segac2.c63
-rw-r--r--src/mame/drivers/segae.c4
-rw-r--r--src/mame/drivers/segag80r.c14
-rw-r--r--src/mame/drivers/segag80v.c70
-rw-r--r--src/mame/drivers/segahang.c22
-rw-r--r--src/mame/drivers/segald.c3
-rw-r--r--src/mame/drivers/segaorun.c5
-rw-r--r--src/mame/drivers/segas16a.c17
-rw-r--r--src/mame/drivers/segas16b.c36
-rw-r--r--src/mame/drivers/segas18.c14
-rw-r--r--src/mame/drivers/segas24.c41
-rw-r--r--src/mame/drivers/segas32.c40
-rw-r--r--src/mame/drivers/segaxbd.c11
-rw-r--r--src/mame/drivers/segaybd.c11
-rw-r--r--src/mame/drivers/seibuspi.c46
-rw-r--r--src/mame/drivers/seicross.c32
-rw-r--r--src/mame/drivers/senjyo.c12
-rw-r--r--src/mame/drivers/seta.c170
-rw-r--r--src/mame/drivers/seta2.c30
-rw-r--r--src/mame/drivers/sf.c22
-rw-r--r--src/mame/drivers/sfkick.c9
-rw-r--r--src/mame/drivers/sg1000a.c2
-rw-r--r--src/mame/drivers/shadfrce.c15
-rw-r--r--src/mame/drivers/shangha3.c33
-rw-r--r--src/mame/drivers/shanghai.c18
-rw-r--r--src/mame/drivers/shangkid.c97
-rw-r--r--src/mame/drivers/shaolins.c4
-rw-r--r--src/mame/drivers/shisen.c5
-rw-r--r--src/mame/drivers/shootout.c28
-rw-r--r--src/mame/drivers/shougi.c4
-rw-r--r--src/mame/drivers/shuuz.c22
-rw-r--r--src/mame/drivers/sidearms.c19
-rw-r--r--src/mame/drivers/sidepckt.c12
-rw-r--r--src/mame/drivers/silkroad.c62
-rw-r--r--src/mame/drivers/simpl156.c42
-rw-r--r--src/mame/drivers/simpsons.c7
-rw-r--r--src/mame/drivers/skyarmy.c5
-rw-r--r--src/mame/drivers/skydiver.c22
-rw-r--r--src/mame/drivers/skyfox.c10
-rw-r--r--src/mame/drivers/skykid.c4
-rw-r--r--src/mame/drivers/skylncr.c12
-rw-r--r--src/mame/drivers/slapfght.c40
-rw-r--r--src/mame/drivers/slapshot.c13
-rw-r--r--src/mame/drivers/sliver.c2
-rw-r--r--src/mame/drivers/slotcarn.c16
-rw-r--r--src/mame/drivers/sms.c3
-rw-r--r--src/mame/drivers/snesb.c6
-rw-r--r--src/mame/drivers/snk.c68
-rw-r--r--src/mame/drivers/snk68.c25
-rw-r--r--src/mame/drivers/snookr10.c4
-rw-r--r--src/mame/drivers/snowbros.c81
-rw-r--r--src/mame/drivers/solomon.c9
-rw-r--r--src/mame/drivers/sonson.c6
-rw-r--r--src/mame/drivers/sothello.c29
-rw-r--r--src/mame/drivers/spacefb.c2
-rw-r--r--src/mame/drivers/spbactn.c11
-rw-r--r--src/mame/drivers/spcforce.c6
-rw-r--r--src/mame/drivers/spdodgeb.c18
-rw-r--r--src/mame/drivers/speedatk.c4
-rw-r--r--src/mame/drivers/speedbal.c3
-rw-r--r--src/mame/drivers/speedspn.c10
-rw-r--r--src/mame/drivers/speglsht.c2
-rw-r--r--src/mame/drivers/splash.c14
-rw-r--r--src/mame/drivers/spoker.c5
-rw-r--r--src/mame/drivers/spool99.c4
-rw-r--r--src/mame/drivers/sprcros2.c6
-rw-r--r--src/mame/drivers/sprint2.c40
-rw-r--r--src/mame/drivers/sprint4.c36
-rw-r--r--src/mame/drivers/spy.c33
-rw-r--r--src/mame/drivers/srmp2.c49
-rw-r--r--src/mame/drivers/srmp5.c2
-rw-r--r--src/mame/drivers/srmp6.c4
-rw-r--r--src/mame/drivers/srumbler.c6
-rw-r--r--src/mame/drivers/sshangha.c11
-rw-r--r--src/mame/drivers/ssingles.c8
-rw-r--r--src/mame/drivers/sslam.c64
-rw-r--r--src/mame/drivers/ssozumo.c8
-rw-r--r--src/mame/drivers/ssrj.c13
-rw-r--r--src/mame/drivers/ssv.c7
-rw-r--r--src/mame/drivers/st0016.c2
-rw-r--r--src/mame/drivers/stadhero.c34
-rw-r--r--src/mame/drivers/starshp1.c28
-rw-r--r--src/mame/drivers/statriv2.c28
-rw-r--r--src/mame/drivers/stfight.c12
-rw-r--r--src/mame/drivers/stlforce.c8
-rw-r--r--src/mame/drivers/strnskil.c4
-rw-r--r--src/mame/drivers/stv.c27
-rw-r--r--src/mame/drivers/subs.c10
-rw-r--r--src/mame/drivers/subsino.c5
-rw-r--r--src/mame/drivers/suna16.c37
-rw-r--r--src/mame/drivers/suna8.c43
-rw-r--r--src/mame/drivers/supbtime.c24
-rw-r--r--src/mame/drivers/supdrapo.c3
-rw-r--r--src/mame/drivers/superdq.c6
-rw-r--r--src/mame/drivers/superqix.c101
-rw-r--r--src/mame/drivers/supertnk.c5
-rw-r--r--src/mame/drivers/suprgolf.c19
-rw-r--r--src/mame/drivers/suprloco.c4
-rw-r--r--src/mame/drivers/suprnova.c10
-rw-r--r--src/mame/drivers/suprridr.c18
-rw-r--r--src/mame/drivers/suprslam.c9
-rw-r--r--src/mame/drivers/surpratk.c9
-rw-r--r--src/mame/drivers/system1.c4
-rw-r--r--src/mame/drivers/system16.c29
-rw-r--r--src/mame/drivers/system18.c41
-rw-r--r--src/mame/drivers/tagteam.c8
-rw-r--r--src/mame/drivers/tail2nos.c24
-rw-r--r--src/mame/drivers/taito_b.c43
-rw-r--r--src/mame/drivers/taito_f2.c46
-rw-r--r--src/mame/drivers/taito_f3.c17
-rw-r--r--src/mame/drivers/taito_h.c13
-rw-r--r--src/mame/drivers/taito_l.c200
-rw-r--r--src/mame/drivers/taito_x.c28
-rw-r--r--src/mame/drivers/taito_z.c63
-rw-r--r--src/mame/drivers/taitoair.c9
-rw-r--r--src/mame/drivers/taitosj.c68
-rw-r--r--src/mame/drivers/tank8.c50
-rw-r--r--src/mame/drivers/tankbatt.c19
-rw-r--r--src/mame/drivers/tankbust.c22
-rw-r--r--src/mame/drivers/taotaido.c9
-rw-r--r--src/mame/drivers/targeth.c2
-rw-r--r--src/mame/drivers/tatsumi.c19
-rw-r--r--src/mame/drivers/taxidrvr.c30
-rw-r--r--src/mame/drivers/tbowl.c26
-rw-r--r--src/mame/drivers/tceptor.c13
-rw-r--r--src/mame/drivers/tecmo.c36
-rw-r--r--src/mame/drivers/tecmo16.c13
-rw-r--r--src/mame/drivers/tecmosys.c14
-rw-r--r--src/mame/drivers/tehkanwc.c42
-rw-r--r--src/mame/drivers/tempest.c36
-rw-r--r--src/mame/drivers/terracre.c16
-rw-r--r--src/mame/drivers/tetrisp2.c36
-rw-r--r--src/mame/drivers/thayers.c3
-rw-r--r--src/mame/drivers/thedeep.c9
-rw-r--r--src/mame/drivers/thepit.c14
-rw-r--r--src/mame/drivers/thief.c46
-rw-r--r--src/mame/drivers/thoop2.c4
-rw-r--r--src/mame/drivers/thunderx.c26
-rw-r--r--src/mame/drivers/tiamc1.c8
-rw-r--r--src/mame/drivers/tickee.c42
-rw-r--r--src/mame/drivers/tigeroad.c24
-rw-r--r--src/mame/drivers/timelimt.c16
-rw-r--r--src/mame/drivers/tmaster.c10
-rw-r--r--src/mame/drivers/tmnt.c164
-rw-r--r--src/mame/drivers/tnzs.c74
-rw-r--r--src/mame/drivers/toaplan1.c22
-rw-r--r--src/mame/drivers/toaplan2.c81
-rw-r--r--src/mame/drivers/toki.c17
-rw-r--r--src/mame/drivers/topspeed.c29
-rw-r--r--src/mame/drivers/toratora.c36
-rw-r--r--src/mame/drivers/toypop.c10
-rw-r--r--src/mame/drivers/tp84.c14
-rw-r--r--src/mame/drivers/trackfld.c18
-rw-r--r--src/mame/drivers/triplhnt.c21
-rw-r--r--src/mame/drivers/truco.c2
-rw-r--r--src/mame/drivers/trucocl.c10
-rw-r--r--src/mame/drivers/trvmadns.c3
-rw-r--r--src/mame/drivers/trvquest.c6
-rw-r--r--src/mame/drivers/tryout.c3
-rw-r--r--src/mame/drivers/tsamurai.c29
-rw-r--r--src/mame/drivers/tubep.c72
-rw-r--r--src/mame/drivers/tugboat.c3
-rw-r--r--src/mame/drivers/tumbleb.c108
-rw-r--r--src/mame/drivers/tumblep.c24
-rw-r--r--src/mame/drivers/tunhunt.c44
-rw-r--r--src/mame/drivers/twin16.c29
-rw-r--r--src/mame/drivers/twincobr.c7
-rw-r--r--src/mame/drivers/twins.c12
-rw-r--r--src/mame/drivers/tx1.c75
-rw-r--r--src/mame/drivers/uapce.c4
-rw-r--r--src/mame/drivers/ultraman.c5
-rw-r--r--src/mame/drivers/ultratnk.c24
-rw-r--r--src/mame/drivers/ultrsprt.c27
-rw-r--r--src/mame/drivers/unico.c52
-rw-r--r--src/mame/drivers/upscope.c16
-rw-r--r--src/mame/drivers/usgames.c6
-rw-r--r--src/mame/drivers/vamphalf.c106
-rw-r--r--src/mame/drivers/vaportra.c36
-rw-r--r--src/mame/drivers/vastar.c13
-rw-r--r--src/mame/drivers/vball.c13
-rw-r--r--src/mame/drivers/vcombat.c6
-rw-r--r--src/mame/drivers/vendetta.c21
-rw-r--r--src/mame/drivers/videopin.c36
-rw-r--r--src/mame/drivers/videopkr.c32
-rw-r--r--src/mame/drivers/vigilant.c15
-rw-r--r--src/mame/drivers/vmetal.c26
-rw-r--r--src/mame/drivers/volfied.c15
-rw-r--r--src/mame/drivers/vroulet.c12
-rw-r--r--src/mame/drivers/vsnes.c47
-rw-r--r--src/mame/drivers/vulgus.c6
-rw-r--r--src/mame/drivers/wallc.c4
-rw-r--r--src/mame/drivers/wardner.c7
-rw-r--r--src/mame/drivers/warpwarp.c18
-rw-r--r--src/mame/drivers/warriorb.c33
-rw-r--r--src/mame/drivers/wc90.c11
-rw-r--r--src/mame/drivers/wc90b.c21
-rw-r--r--src/mame/drivers/wecleman.c56
-rw-r--r--src/mame/drivers/welltris.c9
-rw-r--r--src/mame/drivers/wgp.c9
-rw-r--r--src/mame/drivers/williams.c2
-rw-r--r--src/mame/drivers/wink.c14
-rw-r--r--src/mame/drivers/wiping.c16
-rw-r--r--src/mame/drivers/witch.c39
-rw-r--r--src/mame/drivers/wiz.c31
-rw-r--r--src/mame/drivers/wldarrow.c24
-rw-r--r--src/mame/drivers/wolfpack.c17
-rw-r--r--src/mame/drivers/wrally.c2
-rw-r--r--src/mame/drivers/wwfsstar.c9
-rw-r--r--src/mame/drivers/wwfwfest.c17
-rw-r--r--src/mame/drivers/xain.c12
-rw-r--r--src/mame/drivers/xexex.c17
-rw-r--r--src/mame/drivers/xmen.c5
-rw-r--r--src/mame/drivers/xorworld.c4
-rw-r--r--src/mame/drivers/xtheball.c16
-rw-r--r--src/mame/drivers/xxmissio.c32
-rw-r--r--src/mame/drivers/xyonix.c4
-rw-r--r--src/mame/drivers/yiear.c20
-rw-r--r--src/mame/drivers/yumefuda.c22
-rw-r--r--src/mame/drivers/yunsun16.c11
-rw-r--r--src/mame/drivers/yunsung8.c17
-rw-r--r--src/mame/drivers/zaccaria.c45
-rw-r--r--src/mame/drivers/zaxxon.c4
-rw-r--r--src/mame/drivers/zerozone.c2
-rw-r--r--src/mame/drivers/zn.c48
-rw-r--r--src/mame/drivers/zodiack.c3
-rw-r--r--src/mame/drivers/zr107.c8
-rw-r--r--src/mame/includes/8080bw.h9
-rw-r--r--src/mame/includes/amiga.h6
-rw-r--r--src/mame/includes/asteroid.h14
-rw-r--r--src/mame/includes/astrocde.h2
-rw-r--r--src/mame/includes/atari.h2
-rw-r--r--src/mame/includes/attckufo.h6
-rw-r--r--src/mame/includes/avalnche.h6
-rw-r--r--src/mame/includes/blockade.h2
-rw-r--r--src/mame/includes/bsktball.h6
-rw-r--r--src/mame/includes/bzone.h10
-rw-r--r--src/mame/includes/canyon.h8
-rw-r--r--src/mame/includes/cchasm.h6
-rw-r--r--src/mame/includes/cps3.h5
-rw-r--r--src/mame/includes/crbaloon.h12
-rw-r--r--src/mame/includes/dc.h8
-rw-r--r--src/mame/includes/exidy.h7
-rw-r--r--src/mame/includes/exidy440.h3
-rw-r--r--src/mame/includes/firetrk.h16
-rw-r--r--src/mame/includes/flower.h6
-rw-r--r--src/mame/includes/galaxold.h6
-rw-r--r--src/mame/includes/genesis.h2
-rw-r--r--src/mame/includes/gomoku.h6
-rw-r--r--src/mame/includes/gridlee.h6
-rw-r--r--src/mame/includes/harddriv.h2
-rw-r--r--src/mame/includes/leland.h19
-rw-r--r--src/mame/includes/mario.h4
-rw-r--r--src/mame/includes/meadows.h2
-rw-r--r--src/mame/includes/mw8080bw.h42
-rw-r--r--src/mame/includes/orbit.h8
-rw-r--r--src/mame/includes/phoenix.h21
-rw-r--r--src/mame/includes/polepos.h6
-rw-r--r--src/mame/includes/polyplay.h4
-rw-r--r--src/mame/includes/poolshrk.h8
-rw-r--r--src/mame/includes/rockola.h5
-rw-r--r--src/mame/includes/segag80v.h2
-rw-r--r--src/mame/includes/simpsons.h2
-rw-r--r--src/mame/includes/snes.h5
-rw-r--r--src/mame/includes/stfight.h2
-rw-r--r--src/mame/includes/subs.h10
-rw-r--r--src/mame/includes/suna8.h4
-rw-r--r--src/mame/includes/tatsumi.h4
-rw-r--r--src/mame/includes/tiamc1.h6
-rw-r--r--src/mame/includes/toaplan2.h8
-rw-r--r--src/mame/includes/tx1.h19
-rw-r--r--src/mame/includes/warpwarp.h8
-rw-r--r--src/mame/machine/archimds.c2
-rw-r--r--src/mame/machine/atari.c35
-rw-r--r--src/mame/machine/atarifb.c48
-rw-r--r--src/mame/machine/atarigen.c20
-rw-r--r--src/mame/machine/atarigen.h2
-rw-r--r--src/mame/machine/balsente.c22
-rw-r--r--src/mame/machine/cubocd32.c64
-rw-r--r--src/mame/machine/dc.c24
-rw-r--r--src/mame/machine/gaplus.c3
-rw-r--r--src/mame/machine/leland.c20
-rw-r--r--src/mame/machine/mhavoc.c2
-rw-r--r--src/mame/machine/n64.c19
-rw-r--r--src/mame/machine/namcoio.c2
-rw-r--r--src/mame/machine/namcos1.c4
-rw-r--r--src/mame/machine/nitedrvr.c19
-rw-r--r--src/mame/machine/nmk004.c181
-rw-r--r--src/mame/machine/nmk004.h2
-rw-r--r--src/mame/machine/qix.c4
-rw-r--r--src/mame/machine/simpsons.c4
-rw-r--r--src/mame/machine/stfight.c10
-rw-r--r--src/mame/machine/tatsumi.c10
-rw-r--r--src/mame/machine/toaplan1.c3
-rw-r--r--src/mame/machine/williams.c8
-rw-r--r--src/mame/machine/xevious.c5
-rw-r--r--src/mame/video/astrocde.c2
-rw-r--r--src/mame/video/attckufo.c1
-rw-r--r--src/mame/video/cheekyms.c2
-rw-r--r--src/mame/video/dday.c2
-rw-r--r--src/mame/video/genesis.c6
-rw-r--r--src/mame/video/hanaawas.c6
-rw-r--r--src/mame/video/homerun.c8
-rw-r--r--src/mame/video/leland.c4
-rw-r--r--src/mame/video/mitchell.c5
-rw-r--r--src/mame/video/phoenix.c2
-rw-r--r--src/mame/video/seta.c5
-rw-r--r--src/mame/video/skydiver.c7
-rw-r--r--src/mame/video/sprint4.c10
-rw-r--r--src/mame/video/starcrus.c28
-rw-r--r--src/mame/video/subs.c6
-rw-r--r--src/mame/video/tia.c2
-rw-r--r--src/mame/video/toaplan2.c3
-rw-r--r--src/mame/video/triplhnt.c6
-rw-r--r--src/mame/video/ultratnk.c6
-rw-r--r--src/mame/video/xxmissio.c4
1203 files changed, 16152 insertions, 21734 deletions
diff --git a/.gitattributes b/.gitattributes
index 988c801e0b6..91c51713558 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -720,7 +720,6 @@ src/emu/restrack.c svneol=native#text/plain
src/emu/restrack.h svneol=native#text/plain
src/emu/romload.c svneol=native#text/plain
src/emu/romload.h svneol=native#text/plain
-src/emu/sndintrf.c svneol=native#text/plain
src/emu/sndintrf.h svneol=native#text/plain
src/emu/sound.c svneol=native#text/plain
src/emu/sound.h svneol=native#text/plain
@@ -738,12 +737,16 @@ src/emu/sound/2612intf.c svneol=native#text/plain
src/emu/sound/2612intf.h svneol=native#text/plain
src/emu/sound/262intf.c svneol=native#text/plain
src/emu/sound/262intf.h svneol=native#text/plain
+src/emu/sound/3526intf.c svneol=native#text/plain
+src/emu/sound/3526intf.h svneol=native#text/plain
src/emu/sound/3812intf.c svneol=native#text/plain
src/emu/sound/3812intf.h svneol=native#text/plain
src/emu/sound/5110intf.c svneol=native#text/plain
src/emu/sound/5110intf.h svneol=native#text/plain
src/emu/sound/5220intf.c svneol=native#text/plain
src/emu/sound/5220intf.h svneol=native#text/plain
+src/emu/sound/8950intf.c svneol=native#text/plain
+src/emu/sound/8950intf.h svneol=native#text/plain
src/emu/sound/aica.c svneol=native#text/plain
src/emu/sound/aica.h svneol=native#text/plain
src/emu/sound/aicadsp.c svneol=native#text/plain
@@ -769,8 +772,6 @@ src/emu/sound/cdp1869.c svneol=native#text/plain
src/emu/sound/cdp1869.h svneol=native#text/plain
src/emu/sound/cem3394.c svneol=native#text/plain
src/emu/sound/cem3394.h svneol=native#text/plain
-src/emu/sound/custom.c svneol=native#text/plain
-src/emu/sound/custom.h svneol=native#text/plain
src/emu/sound/dac.c svneol=native#text/plain
src/emu/sound/dac.h svneol=native#text/plain
src/emu/sound/digitalk.c svneol=native#text/plain
diff --git a/src/emu/audit.c b/src/emu/audit.c
index 3fd8a79448d..6b7e8c4d7a1 100644
--- a/src/emu/audit.c
+++ b/src/emu/audit.c
@@ -139,14 +139,15 @@ int audit_samples(core_options *options, const game_driver *gamedrv, audit_recor
int records = 0;
#if HAS_SAMPLES
machine_config *config = machine_config_alloc(gamedrv->machine_config);
+ const device_config *device;
audit_record *record;
- int sndnum, sampnum;
+ int sampnum;
/* count the number of sample records attached to this driver */
- for (sndnum = 0; sndnum < ARRAY_LENGTH(config->sound); sndnum++)
- if (config->sound[sndnum].type == SOUND_SAMPLES)
+ for (device = sound_first(config); device != NULL; device = sound_next(device))
+ if (sound_get_type(device) == SOUND_SAMPLES)
{
- const samples_interface *intf = (const samples_interface *)config->sound[sndnum].config;
+ const samples_interface *intf = (const samples_interface *)device->static_config;
if (intf->samplenames != NULL)
{
@@ -167,10 +168,10 @@ int audit_samples(core_options *options, const game_driver *gamedrv, audit_recor
record = *audit;
/* now iterate over sample entries */
- for (sndnum = 0; sndnum < ARRAY_LENGTH(config->sound); sndnum++)
- if (config->sound[sndnum].type == SOUND_SAMPLES)
+ for (device = sound_first(config); device != NULL; device = sound_next(device))
+ if (sound_get_type(device) == SOUND_SAMPLES)
{
- const samples_interface *intf = (const samples_interface *)config->sound[sndnum].config;
+ const samples_interface *intf = (const samples_interface *)device->static_config;
const char *sharedname = NULL;
if (intf->samplenames != NULL)
diff --git a/src/emu/clifront.c b/src/emu/clifront.c
index 27722ae5638..2e60ea20918 100644
--- a/src/emu/clifront.c
+++ b/src/emu/clifront.c
@@ -339,7 +339,6 @@ int cli_info_listxml(core_options *options, const char *gamename)
{
/* since print_mame_xml expands the machine driver, we need to set things up */
init_resource_tracking();
- sndintrf_init(NULL);
print_mame_xml(stdout, drivers, gamename);
@@ -604,20 +603,19 @@ int cli_info_listsamples(core_options *options, const char *gamename)
/* since we expand the machine driver, we need to set things up */
init_resource_tracking();
- sndintrf_init(NULL);
/* iterate over drivers */
for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
machine_config *config = machine_config_alloc(drivers[drvindex]->machine_config);
- int sndnum;
+ const device_config *device;
/* find samples interfaces */
- for (sndnum = 0; sndnum < MAX_SOUND && config->sound[sndnum].type != SOUND_DUMMY; sndnum++)
- if (config->sound[sndnum].type == SOUND_SAMPLES)
+ for (device = sound_first(config); device != NULL; device = sound_next(device))
+ if (sound_get_type(device) == SOUND_SAMPLES)
{
- const char *const *samplenames = ((const samples_interface *)config->sound[sndnum].config)->samplenames;
+ const char *const *samplenames = ((const samples_interface *)device->static_config)->samplenames;
int sampnum;
/* if the list is legit, walk it and print the sample info */
diff --git a/src/emu/cpu/h6280/h6280.c b/src/emu/cpu/h6280/h6280.c
index 57a7ca0a867..28fd0ca5cb4 100644
--- a/src/emu/cpu/h6280/h6280.c
+++ b/src/emu/cpu/h6280/h6280.c
@@ -356,12 +356,12 @@ static CPU_TRANSLATE( h6280 )
return TRUE;
}
-UINT8 h6280io_get_buffer(device_config *device)
+UINT8 h6280io_get_buffer(const device_config *device)
{
h6280_Regs* cpustate = device->token;
return cpustate->io_buffer;
}
-void h6280io_set_buffer(device_config *device, UINT8 data)
+void h6280io_set_buffer(const device_config *device, UINT8 data)
{
h6280_Regs* cpustate = device->token;
cpustate->io_buffer=data;
diff --git a/src/emu/cpu/h6280/h6280.h b/src/emu/cpu/h6280/h6280.h
index 3a714074741..3f40ddcf03e 100644
--- a/src/emu/cpu/h6280/h6280.h
+++ b/src/emu/cpu/h6280/h6280.h
@@ -84,8 +84,8 @@ READ8_HANDLER( h6280_timer_r );
WRITE8_HANDLER( h6280_timer_w );
/* functions for use by the PSG and joypad port only! */
-UINT8 h6280io_get_buffer(device_config*);
-void h6280io_set_buffer(device_config*, UINT8);
+UINT8 h6280io_get_buffer(const device_config*);
+void h6280io_set_buffer(const device_config*, UINT8);
CPU_DISASSEMBLE( h6280 );
diff --git a/src/emu/cpuexec.c b/src/emu/cpuexec.c
index d7145ad1a4b..fa709823692 100644
--- a/src/emu/cpuexec.c
+++ b/src/emu/cpuexec.c
@@ -433,7 +433,7 @@ const char *cpuexec_describe_context(running_machine *machine)
/***************************************************************************
- VIDEO SCREEN DEVICE INTERFACE
+ CPU DEVICE INTERFACE
***************************************************************************/
/*-------------------------------------------------
@@ -536,9 +536,9 @@ static DEVICE_START( cpu )
/* if no state registered for saving, we can't save */
if (num_regs == 0)
{
- logerror("CPU '%s' did not register any state to save!\n", cpu_get_name(device));
+ logerror("CPU '%s' did not register any state to save!\n", device->tag);
if (device->machine->gamedrv->flags & GAME_SUPPORTS_SAVE)
- fatalerror("CPU '%s' did not register any state to save!", cpu_get_name(device));
+ fatalerror("CPU '%s' did not register any state to save!", device->tag);
}
/* register some internal states as well */
diff --git a/src/emu/devintrf.c b/src/emu/devintrf.c
index 1011fae1056..616aac761a2 100644
--- a/src/emu/devintrf.c
+++ b/src/emu/devintrf.c
@@ -49,6 +49,7 @@ static int temp_string_pool_index;
static void device_list_stop(running_machine *machine);
static void device_list_reset(running_machine *machine);
+static void set_default_string(UINT32 state, char *buffer);
@@ -608,18 +609,20 @@ void device_list_start(running_machine *machine)
for (device = (device_config *)machine->config->devicelist; device != NULL; device = device->next)
{
device_start_func start = (device_start_func)device_get_info_fct(device, DEVINFO_FCT_START);
-
assert(start != NULL);
+
if (!device->started)
{
device->started = DEVICE_STARTING;
(*start)(device);
+
+ /* if the start was delayed, move back to the stopped state, otherwise count it */
if (device->started == DEVICE_DELAYED)
device->started = DEVICE_STOPPED;
else
{
device->started = DEVICE_STARTED;
- numstarted ++;
+ numstarted++;
}
}
}
@@ -632,9 +635,10 @@ void device_list_start(running_machine *machine)
/*-------------------------------------------------
- device_delay_init - delay the startup of a given
- device for dependency reasons
+ device_delay_init - delay the startup of a
+ given device for dependency reasons
-------------------------------------------------*/
+
void device_delay_init(const device_config *device)
{
if (device->started != DEVICE_STARTING && device->started != DEVICE_DELAYED)
@@ -642,6 +646,7 @@ void device_delay_init(const device_config *device)
((device_config *)device)->started = DEVICE_DELAYED;
}
+
/*-------------------------------------------------
device_list_stop - stop the configured list
of devices for a machine
@@ -811,6 +816,8 @@ const char *device_get_info_string(const device_config *device, UINT32 state)
/* retrieve the value */
info.s = get_temp_string_buffer();
(*device->type)(device, state, &info);
+ if (info.s[0] == 0)
+ set_default_string(state, info.s);
return info.s;
}
@@ -876,6 +883,8 @@ const char *devtype_get_info_string(device_type type, UINT32 state)
/* retrieve the value */
info.s = get_temp_string_buffer();
(*type)(NULL, state, &info);
+ if (info.s[0] == 0)
+ set_default_string(state, info.s);
return info.s;
}
@@ -943,3 +952,26 @@ void device_set_info_fct(const device_config *device, UINT32 state, genf *data)
info.f = data;
(*device->set_info)(device, state, &info);
}
+
+
+
+/***************************************************************************
+ DEVICE INFORMATION SETTERS
+***************************************************************************/
+
+/*-------------------------------------------------
+ set_default_string - compute a default string
+ if none is provided
+-------------------------------------------------*/
+
+static void set_default_string(UINT32 state, char *buffer)
+{
+ switch (state)
+ {
+ case DEVINFO_STR_NAME: strcpy(buffer, "Custom"); break;
+ case DEVINFO_STR_FAMILY: strcpy(buffer, "Custom"); break;
+ case DEVINFO_STR_VERSION: strcpy(buffer, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(buffer, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(buffer, "Copyright Nicola Salmoria and the MAME Team"); break;
+ }
+}
diff --git a/src/emu/devintrf.h b/src/emu/devintrf.h
index b3a25b9116c..203e432c30c 100644
--- a/src/emu/devintrf.h
+++ b/src/emu/devintrf.h
@@ -336,6 +336,7 @@ void device_set_clock(const device_config *device, UINT32 clock);
void device_delay_init(const device_config *device);
+
/* ----- device information getters ----- */
/* return an integer state value from an allocated device */
diff --git a/src/emu/emu.mak b/src/emu/emu.mak
index 8a7604bf60c..96233ccb270 100644
--- a/src/emu/emu.mak
+++ b/src/emu/emu.mak
@@ -68,7 +68,6 @@ EMUOBJS = \
$(EMUOBJ)/restrack.o \
$(EMUOBJ)/romload.o \
$(EMUOBJ)/sound.o \
- $(EMUOBJ)/sndintrf.o \
$(EMUOBJ)/state.o \
$(EMUOBJ)/streams.o \
$(EMUOBJ)/tilemap.o \
diff --git a/src/emu/info.c b/src/emu/info.c
index b50a05c0d12..3cfeafd09f7 100644
--- a/src/emu/info.c
+++ b/src/emu/info.c
@@ -485,12 +485,12 @@ static void print_game_rom(FILE *out, const game_driver *game, const machine_con
static void print_game_sampleof(FILE *out, const game_driver *game, const machine_config *config)
{
#if (HAS_SAMPLES)
- int sndnum;
+ const device_config *device;
- for (sndnum = 0; sndnum < ARRAY_LENGTH(config->sound) && config->sound[sndnum].type != SOUND_DUMMY; sndnum++)
- if (config->sound[sndnum].type == SOUND_SAMPLES)
+ for (device = sound_first(config); device != NULL; device = sound_next(device))
+ if (sound_get_type(device) == SOUND_SAMPLES)
{
- const char *const *samplenames = ((const samples_interface *)config->sound[sndnum].config)->samplenames;
+ const char *const *samplenames = ((const samples_interface *)device->static_config)->samplenames;
if (samplenames != NULL)
{
int sampnum;
@@ -518,13 +518,13 @@ static void print_game_sampleof(FILE *out, const game_driver *game, const machin
static void print_game_sample(FILE *out, const game_driver *game, const machine_config *config)
{
#if (HAS_SAMPLES)
- int sndnum;
+ const device_config *device;
/* iterate over sound chips looking for samples */
- for (sndnum = 0; sndnum < ARRAY_LENGTH(config->sound) && config->sound[sndnum].type != SOUND_DUMMY; sndnum++)
- if (config->sound[sndnum].type == SOUND_SAMPLES)
+ for (device = sound_first(config); device != NULL; device = sound_next(device))
+ if (sound_get_type(device) == SOUND_SAMPLES)
{
- const char *const *samplenames = ((const samples_interface *)config->sound[sndnum].config)->samplenames;
+ const char *const *samplenames = ((const samples_interface *)device->static_config)->samplenames;
if (samplenames != NULL)
{
int sampnum;
@@ -563,7 +563,6 @@ static void print_game_sample(FILE *out, const game_driver *game, const machine_
static void print_game_chips(FILE *out, const game_driver *game, const machine_config *config)
{
const device_config *device;
- int chipnum;
/* iterate over CPUs */
for (device = cpu_first(config); device != NULL; device = cpu_next(device))
@@ -577,17 +576,16 @@ static void print_game_chips(FILE *out, const game_driver *game, const machine_c
}
/* iterate over sound chips */
- for (chipnum = 0; chipnum < ARRAY_LENGTH(config->sound); chipnum++)
- if (config->sound[chipnum].type != SOUND_DUMMY)
- {
- fprintf(out, "\t\t<chip");
- fprintf(out, " type=\"audio\"");
- fprintf(out, " tag=\"%s\"", xml_normalize_string(config->sound[chipnum].tag));
- fprintf(out, " name=\"%s\"", xml_normalize_string(sndtype_get_name(config->sound[chipnum].type)));
- if (config->sound[chipnum].clock != 0)
- fprintf(out, " clock=\"%d\"", config->sound[chipnum].clock);
- fprintf(out, "/>\n");
- }
+ for (device = sound_first(config); device != NULL; device = sound_next(device))
+ {
+ fprintf(out, "\t\t<chip");
+ fprintf(out, " type=\"audio\"");
+ fprintf(out, " tag=\"%s\"", xml_normalize_string(device->tag));
+ fprintf(out, " name=\"%s\"", xml_normalize_string(device_get_name(device)));
+ if (device->clock != 0)
+ fprintf(out, " clock=\"%d\"", device->clock);
+ fprintf(out, "/>\n");
+ }
}
@@ -684,19 +682,9 @@ static void print_game_display(FILE *out, const game_driver *game, const machine
static void print_game_sound(FILE *out, const game_driver *game, const machine_config *config)
{
int speakers = speaker_output_count(config);
- int has_sound = FALSE;
- int sndnum;
-
- /* see if we have any sound chips to report */
- for (sndnum = 0; sndnum < ARRAY_LENGTH(config->sound); sndnum++)
- if (config->sound[sndnum].type != SOUND_DUMMY)
- {
- has_sound = TRUE;
- break;
- }
- /* if we have sound, count the number of speakers */
- if (!has_sound)
+ /* if we have no sound, zero out the speaker count */
+ if (sound_first(config) == NULL)
speakers = 0;
fprintf(out, "\t\t<sound channels=\"%d\"/>\n", speakers);
diff --git a/src/emu/inptport.h b/src/emu/inptport.h
index 86ccb51756b..796f22495c1 100644
--- a/src/emu/inptport.h
+++ b/src/emu/inptport.h
@@ -677,14 +677,6 @@ struct _inp_header
/* macro for wrapping a default string */
#define DEF_STR(str_num) ((const char *)INPUT_STRING_##str_num)
-/* macros for referencing input ports in place of read handlers */
-#define HANDLER_PORT(name, type) ((type)("\0\0\0\0" name))
-#define DEVICE8_PORT(name) HANDLER_PORT(name, read8_device_func)
-#define MACHINE8_PORT(name) HANDLER_PORT(name, read8_space_func)
-#define IS_HANDLER_PORT(ptr) (((const char *)(ptr))[0] == 0 && ((const char *)(ptr))[1] == 0 && ((const char *)(ptr))[2] == 0 && ((const char *)(ptr))[3] == 0)
-#define CALL_DEVICE8_READ(ptr,d,offs) (IS_HANDLER_PORT(ptr) ? input_port_read((d)->machine, ((const char *)(ptr)) + 4) : (*ptr)(d, offs))
-#define CALL_MACHINE8_READ(ptr,m,offs) (IS_HANDLER_PORT(ptr) ? input_port_read((m), ((const char *)(ptr)) + 4) : (*ptr)(m, offs))
-
/***************************************************************************
diff --git a/src/emu/machine/laserdsc.h b/src/emu/machine/laserdsc.h
index 06c497184e0..5f6117c3ea3 100644
--- a/src/emu/machine/laserdsc.h
+++ b/src/emu/machine/laserdsc.h
@@ -15,7 +15,6 @@
#define __LASERDSC_H__
#include "chd.h"
-#include "sound/custom.h"
@@ -153,14 +152,6 @@ struct _laserdisc_config
/***************************************************************************
- GLOBAL VARIABLES
-***************************************************************************/
-
-extern const custom_sound_interface laserdisc_custom_interface;
-
-
-
-/***************************************************************************
FUNCTION PROTOTYPES
***************************************************************************/
@@ -233,5 +224,9 @@ void laserdisc_set_config(const device_config *device, const laserdisc_config *c
#define LASERDISC DEVICE_GET_INFO_NAME(laserdisc)
DEVICE_GET_INFO( laserdisc );
+/* audio get info callback */
+#define SOUND_LASERDISC DEVICE_GET_INFO_NAME(laserdisc_sound)
+DEVICE_GET_INFO( laserdisc_sound );
+
#endif /* __LASERDSC_H__ */
diff --git a/src/emu/machine/latch8.c b/src/emu/machine/latch8.c
index 5cfbc32695b..74ec2b64f61 100644
--- a/src/emu/machine/latch8.c
+++ b/src/emu/machine/latch8.c
@@ -34,7 +34,6 @@ INLINE latch8_t *get_safe_token(const device_config *device) {
static void update(const device_config *device, UINT8 new_val, UINT8 mask)
{
/* temporary hack until the discrete system is a device */
- const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
latch8_t *latch8 = get_safe_token(device);
UINT8 old_val = latch8->value;
@@ -46,7 +45,7 @@ static void update(const device_config *device, UINT8 new_val, UINT8 mask)
UINT8 changed = old_val ^ latch8->value;
for (i=0; i<8; i++)
if (((changed & (1<<i)) != 0) && latch8->intf->node_map[i] != 0)
- discrete_sound_w(space, latch8->intf->node_map[i] , (latch8->value >> i) & 1);
+ discrete_sound_w(devtag_get_device(device->machine, SOUND, latch8->intf->node_device[i]), latch8->intf->node_map[i] , (latch8->value >> i) & 1);
}
}
@@ -196,7 +195,11 @@ static DEVICE_START( latch8 )
/* setup nodemap */
for (i=0; i<8; i++)
if (latch8->intf->node_map[i] )
+ {
+ if (!latch8->intf->node_device[i])
+ fatalerror("Device %s: Bit %d has invalid discrete device\n", device->tag, i);
latch8->has_node_map = 1;
+ }
/* setup device read handlers */
for (i=0; i<8; i++)
diff --git a/src/emu/machine/latch8.h b/src/emu/machine/latch8.h
index 3455a259de9..2c9732d6971 100644
--- a/src/emu/machine/latch8.h
+++ b/src/emu/machine/latch8.h
@@ -40,6 +40,7 @@ struct _latch8_config
UINT32 xor; /* after mask */
UINT32 nosync;
UINT32 node_map[8];
+ const char * node_device[8];
latch8_devread devread[8];
};
@@ -64,7 +65,8 @@ struct _latch8_config
MDRV_DEVICE_CONFIG_DATA32(latch8_config, nosync, _nosync)
/* Write bit to discrete node */
-#define MDRV_LATCH8_DISCRETE_NODE(_bit, _node) \
+#define MDRV_LATCH8_DISCRETE_NODE(_device, _bit, _node) \
+ MDRV_DEVICE_CONFIG_DATA32_ARRAY(latch8_config, node_device, _bit, _device) \
MDRV_DEVICE_CONFIG_DATA32_ARRAY(latch8_config, node_map, _bit, _node)
/* Upon read, replace bits by reading from another device handler */
diff --git a/src/emu/machine/ldcore.c b/src/emu/machine/ldcore.c
index 179389d0067..349b078cd33 100644
--- a/src/emu/machine/ldcore.c
+++ b/src/emu/machine/ldcore.c
@@ -15,7 +15,6 @@
#include "streams.h"
#include "vbiparse.h"
#include "config.h"
-#include "sound/custom.h"
@@ -105,7 +104,7 @@ struct _ldcore_data
UINT32 audiobufout; /* output index */
UINT32 audiocursamples; /* current samples this track */
UINT32 audiomaxsamples; /* maximum samples per track */
- int audiocustom; /* custom sound index */
+ const device_config *audiocustom; /* custom sound device */
/* metadata */
vbi_metadata metadata[2]; /* metadata parsed from the stream, for each field */
@@ -145,7 +144,7 @@ struct _sound_token
static TIMER_CALLBACK( perform_player_update );
static void read_track_data(laserdisc_state *ld);
static void process_track_data(const device_config *device);
-static CUSTOM_START( custom_start );
+static DEVICE_START( laserdisc_sound );
static STREAM_UPDATE( custom_stream_callback );
static void configuration_load(running_machine *machine, int config_type, xml_data_node *parentnode);
static void configuration_save(running_machine *machine, int config_type, xml_data_node *parentnode);
@@ -167,11 +166,6 @@ static const ldplayer_interface *const player_interfaces[] =
&vp931_interface
};
-const custom_sound_interface laserdisc_custom_interface =
-{
- custom_start
-};
-
/***************************************************************************
@@ -198,11 +192,12 @@ INLINE laserdisc_state *get_safe_token(const device_config *device)
current time
-------------------------------------------------*/
-INLINE void update_audio(ldcore_data *ldcore)
+INLINE void update_audio(laserdisc_state *ld)
{
- if (ldcore->audiocustom != -1)
+ ldcore_data *ldcore = ld->core;
+ if (ldcore->audiocustom != NULL)
{
- sound_token *token = custom_get_token(ldcore->audiocustom);
+ sound_token *token = ldcore->audiocustom->token;
stream_update(token->stream);
}
}
@@ -338,7 +333,7 @@ static TIMER_CALLBACK( perform_player_update )
add_and_clamp_track(ldcore, (*ldcore->intf.update)(ld, &ldcore->metadata[ldcore->fieldnum], ldcore->fieldnum, curtime));
/* flush any audio before we read more */
- update_audio(ldcore);
+ update_audio(ld);
/* start reading the track data for the next round */
ldcore->fieldnum ^= 1;
@@ -530,7 +525,7 @@ laserdisc_state *ldcore_get_safe_token(const device_config *device)
void ldcore_set_audio_squelch(laserdisc_state *ld, UINT8 squelchleft, UINT8 squelchright)
{
- update_audio(ld->core);
+ update_audio(ld);
ld->core->audiosquelch = (squelchleft ? 1 : 0) | (squelchright ? 2 : 0);
}
@@ -939,16 +934,37 @@ static void process_track_data(const device_config *device)
/*-------------------------------------------------
- custom_start - custom audio start
+ laserdisc_sound_start - custom audio start
for laserdiscs
-------------------------------------------------*/
-static CUSTOM_START( custom_start )
+static DEVICE_START( laserdisc_sound )
{
- sound_token *token = auto_malloc(sizeof(*token));
+ sound_token *token = device->token;
token->stream = stream_create(device, 0, 2, 48000, token, custom_stream_callback);
token->ld = NULL;
- return token;
+}
+
+
+/*-------------------------------------------------
+ laserdisc_sound_get_info - information
+ callback for laserdisc audio
+-------------------------------------------------*/
+
+DEVICE_GET_INFO( laserdisc_sound )
+{
+ switch (state)
+ {
+ /* --- the following bits of info are returned as 64-bit signed integers --- */
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(sound_token); break;
+
+ /* --- the following bits of info are returned as pointers to data or functions --- */
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(laserdisc_sound);break;
+
+ /* --- the following bits of info are returned as NULL-terminated strings --- */
+ case DEVINFO_STR_NAME: strcpy(info->s, "Laserdisc Analog"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ }
}
@@ -1412,19 +1428,9 @@ static void init_audio(const device_config *device)
{
laserdisc_state *ld = get_safe_token(device);
ldcore_data *ldcore = ld->core;
- int sndnum;
/* find the custom audio */
- ldcore->audiocustom = 0;
- for (sndnum = 0; sndnum < MAX_SOUND; sndnum++)
- {
- if (device->machine->config->sound[sndnum].tag != NULL && strcmp(device->machine->config->sound[sndnum].tag, ldcore->config.sound) == 0)
- break;
- if (device->machine->config->sound[sndnum].type == SOUND_CUSTOM)
- ldcore->audiocustom++;
- }
- if (sndnum == MAX_SOUND)
- ldcore->audiocustom = -1;
+ ldcore->audiocustom = devtag_get_device(device->machine, SOUND, ldcore->config.sound);
/* allocate audio buffers */
ldcore->audiomaxsamples = ((UINT64)ldcore->samplerate * 1000000 + ldcore->fps_times_1million - 1) / ldcore->fps_times_1million;
@@ -1541,9 +1547,9 @@ static DEVICE_RESET( laserdisc )
ldcore->intf = *player_interfaces[pltype];
/* attempt to wire up the audio */
- if (ldcore->audiocustom != -1)
+ if (ldcore->audiocustom != NULL)
{
- sound_token *token = custom_get_token(ldcore->audiocustom);
+ sound_token *token = ldcore->audiocustom->token;
token->ld = ld;
stream_set_sample_rate(token->stream, ldcore->samplerate);
}
diff --git a/src/emu/machine/pcshare.h b/src/emu/machine/pcshare.h
index cb877e2777e..6696e3215b4 100644
--- a/src/emu/machine/pcshare.h
+++ b/src/emu/machine/pcshare.h
@@ -1,5 +1,3 @@
-#include "sound/custom.h"
-
/* flags for init_pc_common */
#define PCCOMMON_KEYBOARD_PC 0
#define PCCOMMON_KEYBOARD_AT 1
diff --git a/src/emu/machine/scsicd.c b/src/emu/machine/scsicd.c
index 74ad9f105ed..add7d134dd0 100644
--- a/src/emu/machine/scsicd.c
+++ b/src/emu/machine/scsicd.c
@@ -45,7 +45,7 @@ static int scsicd_exec_command( SCSIInstance *scsiInstance, UINT8 *statusCode )
SCSICd *our_this = SCSIThis( &SCSIClassCDROM, scsiInstance );
cdrom_file *cdrom = our_this->cdrom;
- int cddanum;
+ const device_config *cdda;
int trk;
SCSIGetCommand( scsiInstance, &command, &commandLength );
@@ -71,10 +71,10 @@ static int scsicd_exec_command( SCSIInstance *scsiInstance, UINT8 *statusCode )
return SCSILengthFromUINT8( &command[ 4 ] );
case 0x1b: // START STOP UNIT
- cddanum = cdda_num_from_cdrom(cdrom);
- if (cddanum != -1)
+ cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
+ if (cdda != NULL)
{
- cdda_stop_audio(cddanum);
+ cdda_stop_audio(cdda);
}
SCSISetPhase( scsiInstance, SCSI_PHASE_STATUS );
return 0;
@@ -104,10 +104,10 @@ static int scsicd_exec_command( SCSIInstance *scsiInstance, UINT8 *statusCode )
our_this->cur_subblock = 0;
}
- cddanum = cdda_num_from_cdrom(cdrom);
- if (cddanum != -1)
+ cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
+ if (cdda != NULL)
{
- cdda_stop_audio(cddanum);
+ cdda_stop_audio(cdda);
}
SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
@@ -144,10 +144,10 @@ static int scsicd_exec_command( SCSIInstance *scsiInstance, UINT8 *statusCode )
length = 4;
}
- cddanum = cdda_num_from_cdrom(cdrom);
- if (cddanum != -1)
+ cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
+ if (cdda != NULL)
{
- cdda_stop_audio(cddanum);
+ cdda_stop_audio(cdda);
}
SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
@@ -174,9 +174,9 @@ static int scsicd_exec_command( SCSIInstance *scsiInstance, UINT8 *statusCode )
if (cdrom_get_track_type(cdrom, trk) == CD_TRACK_AUDIO)
{
our_this->play_err_flag = 0;
- cddanum = cdda_num_from_cdrom(cdrom);
- if (cddanum != -1)
- cdda_start_audio(cddanum, our_this->lba, our_this->blocks);
+ cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
+ if (cdda != NULL)
+ cdda_start_audio(cdda, our_this->lba, our_this->blocks);
}
else
{
@@ -204,9 +204,9 @@ static int scsicd_exec_command( SCSIInstance *scsiInstance, UINT8 *statusCode )
if (our_this->blocks && cdrom)
{
- cddanum = cdda_num_from_cdrom(cdrom);
- if (cddanum != -1)
- cdda_start_audio(cddanum, our_this->lba, our_this->blocks);
+ cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
+ if (cdda != NULL)
+ cdda_start_audio(cdda, our_this->lba, our_this->blocks);
}
logerror("SCSICD: PLAY AUDIO T/I: strk %d idx %d etrk %d idx %d frames %d\n", command[4], command[5], command[7], command[8], our_this->blocks);
@@ -216,9 +216,9 @@ static int scsicd_exec_command( SCSIInstance *scsiInstance, UINT8 *statusCode )
case 0x4b: // PAUSE/RESUME
if (cdrom)
{
- cddanum = cdda_num_from_cdrom(cdrom);
- if (cddanum != -1)
- cdda_pause_audio(cddanum, (command[8] & 0x01) ^ 0x01);
+ cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
+ if (cdda != NULL)
+ cdda_pause_audio(cdda, (command[8] & 0x01) ^ 0x01);
}
logerror("SCSICD: PAUSE/RESUME: %s\n", command[8]&1 ? "RESUME" : "PAUSE");
@@ -255,9 +255,9 @@ static int scsicd_exec_command( SCSIInstance *scsiInstance, UINT8 *statusCode )
if (cdrom_get_track_type(cdrom, trk) == CD_TRACK_AUDIO)
{
our_this->play_err_flag = 0;
- cddanum = cdda_num_from_cdrom(cdrom);
- if (cddanum != -1)
- cdda_start_audio(cddanum, our_this->lba, our_this->blocks);
+ cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
+ if (cdda != NULL)
+ cdda_start_audio(cdda, our_this->lba, our_this->blocks);
}
else
{
@@ -283,10 +283,10 @@ static int scsicd_exec_command( SCSIInstance *scsiInstance, UINT8 *statusCode )
our_this->cur_subblock = 0;
}
- cddanum = cdda_num_from_cdrom(cdrom);
- if (cddanum != -1)
+ cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
+ if (cdda != NULL)
{
- cdda_stop_audio(cddanum);
+ cdda_stop_audio(cdda);
}
SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
@@ -317,7 +317,7 @@ static void scsicd_read_data( SCSIInstance *scsiInstance, UINT8 *data, int dataL
cdrom_file *cdrom = our_this->cdrom;
UINT32 temp;
UINT8 tmp_buffer[2048];
- int cddanum;
+ const device_config *cdda;
SCSIGetCommand( scsiInstance, &command, &commandLength );
@@ -330,8 +330,8 @@ static void scsicd_read_data( SCSIInstance *scsiInstance, UINT8 *data, int dataL
data[0] = 0x71; // deferred error
- cddanum = cdda_num_from_cdrom(cdrom);
- if (cddanum != -1 && cdda_audio_active(cddanum))
+ cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
+ if (cdda != NULL && cdda_audio_active(cdda))
{
data[12] = 0x00;
data[13] = 0x11; // AUDIO PLAY OPERATION IN PROGRESS
@@ -423,11 +423,11 @@ static void scsicd_read_data( SCSIInstance *scsiInstance, UINT8 *data, int dataL
msf = command[1] & 0x2;
- cddanum = cdda_num_from_cdrom(cdrom);
- audio_active = cddanum != -1 && cdda_audio_active(cddanum);
+ cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
+ audio_active = cdda != NULL && cdda_audio_active(cdda);
if (audio_active)
{
- if (cdda_audio_paused(cddanum))
+ if (cdda_audio_paused(cdda))
{
data[1] = 0x12; // audio is paused
}
@@ -438,7 +438,7 @@ static void scsicd_read_data( SCSIInstance *scsiInstance, UINT8 *data, int dataL
}
else
{
- if (cddanum != -1 && cdda_audio_ended(cddanum))
+ if (cdda != NULL && cdda_audio_ended(cdda))
{
data[1] = 0x13; // ended successfully
}
@@ -452,7 +452,7 @@ static void scsicd_read_data( SCSIInstance *scsiInstance, UINT8 *data, int dataL
// if audio is playing, get the latest LBA from the CDROM layer
if (audio_active)
{
- our_this->last_lba = cdda_get_audio_lba(cddanum);
+ our_this->last_lba = cdda_get_audio_lba(cdda);
}
else
{
diff --git a/src/emu/mame.c b/src/emu/mame.c
index 18a15de9157..938bff007da 100644
--- a/src/emu/mame.c
+++ b/src/emu/mame.c
@@ -25,7 +25,6 @@
- calls init_machine() [mame.c]
init_machine() [mame.c]
- - calls sndintrf_init() [sndintrf.c] to determine which sound chips are available
- calls fileio_init() [fileio.c] to initialize file I/O info
- calls config_init() [config.c] to initialize configuration system
- calls input_init() [input.c] to initialize the input system
@@ -86,6 +85,7 @@
#include "ui.h"
#include "uimenu.h"
#include "uiinput.h"
+#include "streams.h"
#include "deprecat.h"
#include "debug/debugcon.h"
@@ -1470,7 +1470,6 @@ static void init_machine(running_machine *machine)
time_t newbase;
/* initialize basic can't-fail systems here */
- sndintrf_init(machine);
fileio_init(machine);
config_init(machine);
input_init(machine);
@@ -1508,6 +1507,9 @@ static void init_machine(running_machine *machine)
/* intialize UI input */
ui_input_init(machine);
+
+ /* initialize the streams engine before the sound devices start */
+ streams_init(machine);
/* first load ROMs, then populate memory, and finally initialize CPUs */
/* these operations must proceed in this order */
diff --git a/src/emu/mconfig.c b/src/emu/mconfig.c
index b3c3e5ff332..a93e17a92a2 100644
--- a/src/emu/mconfig.c
+++ b/src/emu/mconfig.c
@@ -58,94 +58,16 @@ machine_config *machine_config_alloc(const machine_config_token *tokens)
void machine_config_free(machine_config *config)
{
- int soundnum;
-
/* release the device list */
while (config->devicelist != NULL)
device_list_remove(&config->devicelist, config->devicelist->type, config->devicelist->tag);
- /* release the strings */
- for (soundnum = 0; soundnum < ARRAY_LENGTH(config->soundtag); soundnum++)
- if (config->soundtag[soundnum] != NULL)
- astring_free(config->soundtag[soundnum]);
-
/* release the configuration itself */
free(config);
}
/*-------------------------------------------------
- sound_add - add a sound system during
- machine driver expansion
--------------------------------------------------*/
-
-static sound_config *sound_add(machine_config *machine, const char *tag, sound_type type, int clock)
-{
- int soundnum;
-
- for (soundnum = 0; soundnum < MAX_SOUND; soundnum++)
- if (machine->sound[soundnum].type == SOUND_DUMMY)
- {
- if (machine->soundtag[soundnum] == NULL)
- machine->soundtag[soundnum] = astring_alloc();
- astring_cpyc(machine->soundtag[soundnum], tag);
- machine->sound[soundnum].tag = astring_c(machine->soundtag[soundnum]);
- machine->sound[soundnum].type = type;
- machine->sound[soundnum].clock = clock;
- machine->sound[soundnum].config = NULL;
- machine->sound[soundnum].routes = 0;
- return &machine->sound[soundnum];
- }
-
- fatalerror("Out of sounds!\n");
- return NULL;
-}
-
-
-/*-------------------------------------------------
- sound_find - find a tagged sound system during
- machine driver expansion
--------------------------------------------------*/
-
-static sound_config *sound_find(machine_config *machine, const char *tag)
-{
- int soundnum;
-
- for (soundnum = 0; soundnum < MAX_SOUND; soundnum++)
- if (machine->sound[soundnum].tag && strcmp(machine->sound[soundnum].tag, tag) == 0)
- return &machine->sound[soundnum];
-
- fatalerror("Can't find sound '%s'!\n", tag);
- return NULL;
-}
-
-
-/*-------------------------------------------------
- sound_remove - remove a tagged sound system
- during machine driver expansion
--------------------------------------------------*/
-
-static void sound_remove(machine_config *machine, const char *tag)
-{
- int soundnum;
-
- for (soundnum = 0; soundnum < MAX_SOUND; soundnum++)
- if (machine->sound[soundnum].tag && strcmp(machine->sound[soundnum].tag, tag) == 0)
- {
- if (machine->soundtag[soundnum] != NULL)
- astring_free(machine->soundtag[soundnum]);
- memmove(&machine->sound[soundnum], &machine->sound[soundnum + 1], sizeof(machine->sound[0]) * (MAX_SOUND - soundnum - 1));
- memmove(&machine->soundtag[soundnum], &machine->soundtag[soundnum + 1], sizeof(machine->soundtag[0]) * (MAX_SOUND - soundnum - 1));
- memset(&machine->sound[MAX_SOUND - 1], 0, sizeof(machine->sound[0]));
- memset(&machine->soundtag[MAX_SOUND - 1], 0, sizeof(machine->soundtag[0]));
- return;
- }
-
- fatalerror("Can't find sound '%s'!\n", tag);
-}
-
-
-/*-------------------------------------------------
machine_config_detokenize - detokenize a
machine config
-------------------------------------------------*/
@@ -155,15 +77,13 @@ static void machine_config_detokenize(machine_config *config, const machine_conf
UINT32 entrytype = MCONFIG_TOKEN_INVALID;
astring *tempstring = astring_alloc();
device_config *device = NULL;
- sound_config *sound = NULL;
/* loop over tokens until we hit the end */
while (entrytype != MCONFIG_TOKEN_END)
{
- int size, offset, bits, in, out;
- UINT32 data32, clock, gain;
+ int size, offset, bits;
+ UINT32 data32, clock;
device_type devtype;
- sound_type type;
const char *tag;
UINT64 data64;
@@ -358,57 +278,6 @@ static void machine_config_detokenize(machine_config *config, const machine_conf
config->sound_reset = TOKEN_GET_PTR(tokens, sound_reset);
break;
- /* add/remove/replace sounds */
- case MCONFIG_TOKEN_SOUND_ADD:
- TOKEN_UNGET_UINT32(tokens);
- TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, clock, 32);
- type = TOKEN_GET_PTR(tokens, sndtype);
- tag = TOKEN_GET_STRING(tokens);
- sound = sound_add(config, device_build_tag(tempstring, owner, tag), type, clock);
- break;
-
- case MCONFIG_TOKEN_SOUND_REMOVE:
- sound_remove(config, TOKEN_GET_STRING(tokens));
- break;
-
- case MCONFIG_TOKEN_SOUND_MODIFY:
- tag = TOKEN_GET_STRING(tokens);
- sound = sound_find(config, device_build_tag(tempstring, owner, tag));
- if (sound == NULL)
- fatalerror("Unable to find sound: tag=%s\n", astring_c(tempstring));
- sound->routes = 0;
- break;
-
- case MCONFIG_TOKEN_SOUND_CONFIG:
- assert(sound != NULL);
- sound->config = TOKEN_GET_PTR(tokens, voidptr);
- break;
-
- case MCONFIG_TOKEN_SOUND_REPLACE:
- TOKEN_UNGET_UINT32(tokens);
- TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, clock, 32);
- type = TOKEN_GET_PTR(tokens, sndtype);
- tag = TOKEN_GET_STRING(tokens);
- sound = sound_find(config, device_build_tag(tempstring, owner, tag));
- if (sound == NULL)
- fatalerror("Unable to find sound: tag=%s\n", astring_c(tempstring));
- sound->type = type;
- sound->clock = clock;
- sound->config = NULL;
- sound->routes = 0;
- break;
-
- case MCONFIG_TOKEN_SOUND_ROUTE:
- assert(sound != NULL);
- TOKEN_UNGET_UINT32(tokens);
- TOKEN_GET_UINT64_UNPACK4(tokens, entrytype, 8, out, -12, in, -12, gain, 32);
- sound->route[sound->routes].input = in;
- sound->route[sound->routes].output = out;
- sound->route[sound->routes].gain = (float)gain / 16777216.0f;
- sound->route[sound->routes].target = TOKEN_GET_STRING(tokens);
- sound->routes++;
- break;
-
default:
fatalerror("Invalid token %d in machine config\n", entrytype);
break;
diff --git a/src/emu/mconfig.h b/src/emu/mconfig.h
index c5228374dde..e0ca465edf5 100644
--- a/src/emu/mconfig.h
+++ b/src/emu/mconfig.h
@@ -137,9 +137,6 @@ struct _machine_config
video_eof_func video_eof; /* end-of-frame video callback */
video_update_func video_update; /* video update callback */
- sound_config sound[MAX_SOUND]; /* array of sound chips in the system */
- astring * soundtag[MAX_SOUND]; /* allocated strings for each sound tag */
-
sound_start_func sound_start; /* one-time sound start callback */
sound_reset_func sound_reset; /* sound reset callback */
@@ -173,7 +170,6 @@ union _machine_config_token
palette_init_func palette_init;
video_eof_func video_eof;
video_update_func video_update;
- sound_type sndtype;
};
@@ -199,78 +195,6 @@ union _machine_config_token
TOKEN_PTR(tokenptr, machine_config_##_name),
-/* add/remove/config devices */
-#define MDRV_DEVICE_ADD(_tag, _type, _clock) \
- TOKEN_UINT64_PACK2(MCONFIG_TOKEN_DEVICE_ADD, 8, _clock, 32), \
- TOKEN_PTR(devtype, _type), \
- TOKEN_STRING(_tag),
-
-#define MDRV_DEVICE_REMOVE(_tag, _type) \
- TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_REMOVE, 8), \
- TOKEN_PTR(devtype, _type), \
- TOKEN_STRING(_tag),
-
-#define MDRV_DEVICE_MODIFY(_tag, _type) \
- TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_MODIFY, 8), \
- TOKEN_PTR(devtype, _type), \
- TOKEN_STRING(_tag),
-
-#define MDRV_DEVICE_CONFIG(_config) \
- TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_CONFIG, 8), \
- TOKEN_PTR(voidptr, &(_config)),
-
-#define MDRV_DEVICE_CLOCK(_clock) \
- TOKEN_UINT64_PACK2(MCONFIG_TOKEN_DEVICE_CLOCK, 8, _clock, 32),
-
-#define structsizeof(_struct, _field) sizeof(((_struct *)NULL)->_field)
-
-#define MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(_size, _offset, _val) \
- TOKEN_UINT32_PACK3(MCONFIG_TOKEN_DEVICE_CONFIG_DATA32, 8, (_size), 6, (_offset), 12), \
- TOKEN_UINT32((UINT32)(_val)),
-
-#define MDRV_DEVICE_CONFIG_DATA32(_struct, _field, _val) \
- MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(structsizeof(_struct, _field), offsetof(_struct, _field), _val)
-
-#define MDRV_DEVICE_CONFIG_DATA32_ARRAY(_struct, _field, _index, _val) \
- MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(structsizeof(_struct, _field[0]), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]), _val)
-
-#define MDRV_DEVICE_CONFIG_DATA32_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) \
- MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(structsizeof(_memstruct, _member), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]) + offsetof(_memstruct, _member), _val)
-
-#define MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(_size, _offset, _val) \
- TOKEN_UINT32_PACK3(MCONFIG_TOKEN_DEVICE_CONFIG_DATA64, 8, (_size), 6, (_offset), 12), \
- TOKEN_UINT64((UINT64)(_val)),
-
-#define MDRV_DEVICE_CONFIG_DATA64(_struct, _field, _val) \
- MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(structsizeof(_struct, _field), offsetof(_struct, _field), _val)
-
-#define MDRV_DEVICE_CONFIG_DATA64_ARRAY(_struct, _field, _index, _val) \
- MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(structsizeof(_struct, _field[0]), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]), _val)
-
-#define MDRV_DEVICE_CONFIG_DATA64_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) \
- MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(structsizeof(_memstruct, _member), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]) + offsetof(_memstruct, _member), _val)
-
-#define MDRV_DEVICE_CONFIG_DATAFP32(_struct, _field, _val, _fixbits) \
- TOKEN_UINT32_PACK4(MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP32, 8, structsizeof(_struct, _field), 6, _fixbits, 6, offsetof(_struct, _field), 12), \
- TOKEN_UINT32((INT32)((float)(_val) * (float)(1 << (_fixbits)))),
-
-#define MDRV_DEVICE_CONFIG_DATAFP64(_struct, _field, _val, _fixbits) \
- TOKEN_UINT32_PACK4(MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP64, 8, structsizeof(_struct, _field), 6, _fixbits, 6, offsetof(_struct, _field), 12), \
- TOKEN_UINT64((INT64)((float)(_val) * (float)((UINT64)1 << (_fixbits)))),
-
-#ifdef PTR64
-#define MDRV_DEVICE_CONFIG_DATAPTR_EXPLICIT(_struct, _size, _offset) MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(_struct, _size, _offset)
-#define MDRV_DEVICE_CONFIG_DATAPTR(_struct, _field, _val) MDRV_DEVICE_CONFIG_DATA64(_struct, _field, _val)
-#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(_struct, _field, _index, _val) MDRV_DEVICE_CONFIG_DATA64_ARRAY(_struct, _field, _index, _val)
-#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) MDRV_DEVICE_CONFIG_DATA64_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val)
-#else
-#define MDRV_DEVICE_CONFIG_DATAPTR_EXPLICIT(_struct, _size, _offset) MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(_struct, _size, _offset)
-#define MDRV_DEVICE_CONFIG_DATAPTR(_struct, _field, _val) MDRV_DEVICE_CONFIG_DATA32(_struct, _field, _val)
-#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(_struct, _field, _index, _val) MDRV_DEVICE_CONFIG_DATA32_ARRAY(_struct, _field, _index, _val)
-#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) MDRV_DEVICE_CONFIG_DATA32_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val)
-#endif
-
-
/* core parameters */
#define MDRV_DRIVER_DATA(_struct) \
TOKEN_UINT32_PACK2(MCONFIG_TOKEN_DRIVER_DATA, 8, sizeof(_struct), 24),
@@ -347,24 +271,6 @@ union _machine_config_token
TOKEN_PTR(video_update, video_update_##_func),
-/* add/remove speakers */
-#define MDRV_SPEAKER_ADD(_tag, _x, _y, _z) \
- MDRV_DEVICE_ADD(_tag, SPEAKER_OUTPUT, 0) \
- MDRV_DEVICE_CONFIG_DATAFP32(speaker_config, x, _x, 24) \
- MDRV_DEVICE_CONFIG_DATAFP32(speaker_config, y, _y, 24) \
- MDRV_DEVICE_CONFIG_DATAFP32(speaker_config, z, _z, 24)
-
-#define MDRV_SPEAKER_REMOVE(_tag) \
- MDRV_DEVICE_REMOVE(_tag, SPEAKER_OUTPUT)
-
-#define MDRV_SPEAKER_STANDARD_MONO(_tag) \
- MDRV_SPEAKER_ADD(_tag, 0.0, 0.0, 1.0)
-
-#define MDRV_SPEAKER_STANDARD_STEREO(_tagl, _tagr) \
- MDRV_SPEAKER_ADD(_tagl, -0.2, 0.0, 1.0) \
- MDRV_SPEAKER_ADD(_tagr, 0.2, 0.0, 1.0)
-
-
/* core sound functions */
#define MDRV_SOUND_START(_func) \
TOKEN_UINT32_PACK1(MCONFIG_TOKEN_SOUND_START, 8), \
@@ -375,35 +281,95 @@ union _machine_config_token
TOKEN_PTR(sound_start, sound_reset_##_func),
-/* add/remove/replace sounds */
-#define MDRV_SOUND_ADD(_tag, _type, _clock) \
- TOKEN_UINT64_PACK2(MCONFIG_TOKEN_SOUND_ADD, 8, _clock, 32), \
- TOKEN_PTR(sndtype, SOUND_##_type), \
+/* add/remove devices */
+#define MDRV_DEVICE_ADD(_tag, _type, _clock) \
+ TOKEN_UINT64_PACK2(MCONFIG_TOKEN_DEVICE_ADD, 8, _clock, 32), \
+ TOKEN_PTR(devtype, _type), \
TOKEN_STRING(_tag),
-#define MDRV_SOUND_REMOVE(_tag) \
- TOKEN_UINT32_PACK1(MCONFIG_TOKEN_SOUND_REMOVE, 8), \
+#define MDRV_DEVICE_REMOVE(_tag, _type) \
+ TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_REMOVE, 8), \
+ TOKEN_PTR(devtype, _type), \
TOKEN_STRING(_tag),
-#define MDRV_SOUND_MODIFY(_tag) \
- TOKEN_UINT32_PACK1(MCONFIG_TOKEN_SOUND_MODIFY, 8), \
+#define MDRV_DEVICE_MODIFY(_tag, _type) \
+ TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_MODIFY, 8), \
+ TOKEN_PTR(devtype, _type), \
TOKEN_STRING(_tag),
-#define MDRV_SOUND_CONFIG(_config) \
- TOKEN_UINT32_PACK1(MCONFIG_TOKEN_SOUND_CONFIG, 8), \
+
+/* configure devices */
+#define MDRV_DEVICE_CONFIG(_config) \
+ TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_CONFIG, 8), \
TOKEN_PTR(voidptr, &(_config)),
-#define MDRV_SOUND_REPLACE(_tag, _type, _clock) \
- TOKEN_UINT64_PACK2(MCONFIG_TOKEN_SOUND_REPLACE, 8, _clock, 32), \
- TOKEN_PTR(sndtype, SOUND_##_type), \
- TOKEN_STRING(_tag),
+#define MDRV_DEVICE_CONFIG_CLEAR() \
+ TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_CONFIG, 8), \
+ TOKEN_PTR(voidptr, NULL),
-#define MDRV_SOUND_ROUTE_EX(_output, _target, _gain, _input) \
- TOKEN_UINT64_PACK4(MCONFIG_TOKEN_SOUND_ROUTE, 8, _output, 12, _input, 12, (UINT32)((float)(_gain) * 16777216.0f), 32), \
- TOKEN_STRING(_target),
+#define MDRV_DEVICE_CLOCK(_clock) \
+ TOKEN_UINT64_PACK2(MCONFIG_TOKEN_DEVICE_CLOCK, 8, _clock, 32),
+
+#define structsizeof(_struct, _field) sizeof(((_struct *)NULL)->_field)
+
+
+/* inline device configurations that require 32 bits of storage in the token */
+#define MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(_size, _offset, _val) \
+ TOKEN_UINT32_PACK3(MCONFIG_TOKEN_DEVICE_CONFIG_DATA32, 8, _size, 6, _offset, 12), \
+ TOKEN_UINT32((UINT32)(_val)),
-#define MDRV_SOUND_ROUTE(_output, _target, _gain) \
- MDRV_SOUND_ROUTE_EX(_output, _target, _gain, -1)
+#define MDRV_DEVICE_CONFIG_DATA32(_struct, _field, _val) \
+ MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(structsizeof(_struct, _field), offsetof(_struct, _field), _val)
+
+#define MDRV_DEVICE_CONFIG_DATA32_ARRAY(_struct, _field, _index, _val) \
+ MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(structsizeof(_struct, _field[0]), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]), _val)
+
+#define MDRV_DEVICE_CONFIG_DATA32_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) \
+ MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(structsizeof(_memstruct, _member), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]) + offsetof(_memstruct, _member), _val)
+
+
+/* inline device configurations that require 32 bits of fixed-point storage in the token */
+#define MDRV_DEVICE_CONFIG_DATAFP32_EXPLICIT(_size, _offset, _val, _fixbits) \
+ TOKEN_UINT32_PACK4(MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP32, 8, _size, 6, _fixbits, 6, _offset, 12), \
+ TOKEN_UINT32((INT32)((float)(_val) * (float)(1 << (_fixbits)))),
+
+#define MDRV_DEVICE_CONFIG_DATAFP32(_struct, _field, _val, _fixbits) \
+ MDRV_DEVICE_CONFIG_DATAFP32_EXPLICIT(structsizeof(_struct, _field), offsetof(_struct, _field), _val, _fixbits)
+
+#define MDRV_DEVICE_CONFIG_DATAFP32_ARRAY(_struct, _field, _index, _val, _fixbits) \
+ MDRV_DEVICE_CONFIG_DATAFP32_EXPLICIT(structsizeof(_struct, _field[0]), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]), _val, _fixbits)
+
+#define MDRV_DEVICE_CONFIG_DATAFP32_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val, _fixbits) \
+ MDRV_DEVICE_CONFIG_DATAFP32_EXPLICIT(structsizeof(_memstruct, _member), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]) + offsetof(_memstruct, _member), _val, _fixbits)
+
+
+/* inline device configurations that require 64 bits of storage in the token */
+#define MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(_size, _offset, _val) \
+ TOKEN_UINT32_PACK3(MCONFIG_TOKEN_DEVICE_CONFIG_DATA64, 8, _size, 6, _offset, 12), \
+ TOKEN_UINT64((UINT64)(_val)),
+
+#define MDRV_DEVICE_CONFIG_DATA64(_struct, _field, _val) \
+ MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(structsizeof(_struct, _field), offsetof(_struct, _field), _val)
+
+#define MDRV_DEVICE_CONFIG_DATA64_ARRAY(_struct, _field, _index, _val) \
+ MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(structsizeof(_struct, _field[0]), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]), _val)
+
+#define MDRV_DEVICE_CONFIG_DATA64_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) \
+ MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(structsizeof(_memstruct, _member), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]) + offsetof(_memstruct, _member), _val)
+
+
+/* inline device configurations that require a pointer-sized amount of storage in the token */
+#ifdef PTR64
+#define MDRV_DEVICE_CONFIG_DATAPTR_EXPLICIT(_struct, _size, _offset) MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(_struct, _size, _offset)
+#define MDRV_DEVICE_CONFIG_DATAPTR(_struct, _field, _val) MDRV_DEVICE_CONFIG_DATA64(_struct, _field, _val)
+#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(_struct, _field, _index, _val) MDRV_DEVICE_CONFIG_DATA64_ARRAY(_struct, _field, _index, _val)
+#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) MDRV_DEVICE_CONFIG_DATA64_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val)
+#else
+#define MDRV_DEVICE_CONFIG_DATAPTR_EXPLICIT(_struct, _size, _offset) MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(_struct, _size, _offset)
+#define MDRV_DEVICE_CONFIG_DATAPTR(_struct, _field, _val) MDRV_DEVICE_CONFIG_DATA32(_struct, _field, _val)
+#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(_struct, _field, _index, _val) MDRV_DEVICE_CONFIG_DATA32_ARRAY(_struct, _field, _index, _val)
+#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) MDRV_DEVICE_CONFIG_DATA32_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val)
+#endif
diff --git a/src/emu/sndintrf.c b/src/emu/sndintrf.c
deleted file mode 100644
index 038d588cdf0..00000000000
--- a/src/emu/sndintrf.c
+++ /dev/null
@@ -1,442 +0,0 @@
-/***************************************************************************
-
- sndintrf.c
-
- Core sound interface functions and definitions.
-
- Copyright Nicola Salmoria and the MAME Team.
- Visit http://mamedev.org for licensing and usage restrictions.
-
-****************************************************************************
-
- Still to do:
- * fix drivers that used to use ADPCM
- * many cores do their own resampling; they should stop
- * many cores mix to a separate buffer; no longer necessary
-
-***************************************************************************/
-
-#include "driver.h"
-
-
-
-/***************************************************************************
- DEBUGGING
-***************************************************************************/
-
-#define VERBOSE (0)
-
-#define VPRINTF(x) do { if (VERBOSE) mame_printf_debug x; } while (0)
-
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-typedef struct _sndintrf_data sndintrf_data;
-struct _sndintrf_data
-{
- sound_type sndtype; /* type index of this sound chip */
- sound_type aliastype; /* aliased type index of this sound chip */
- device_config * device; /* dummy device for now */
- int index; /* index of this sound chip */
-};
-
-
-
-/***************************************************************************
- VALIDATION MACROS
-***************************************************************************/
-
-#define VERIFY_SNDNUM(name) \
- assert_always(sndnum >= 0 && sndnum < totalsnd, #name "() called with invalid sound num!")
-
-#define VERIFY_SNDTI(name) \
- int sndnum = sndti_to_sndnum(sndtype, sndindex); \
- assert_always(sndindex >= 0 && sndindex < totalsnd && sndnum != -1, #name "() called with invalid (type,index) pair!")
-
-#define VERIFY_SNDTYPE(name) \
-
-
-
-/***************************************************************************
- GLOBAL VARIABLES
-***************************************************************************/
-
-static sndintrf_data sound[MAX_SOUND];
-static int totalsnd;
-
-
-
-/***************************************************************************
- INITIALIZATION
-***************************************************************************/
-
-/*-------------------------------------------------
- sndintrf_init - discover all linked sound
- systems and build a matrix for sound
- (type,index) pairs for the current machine
--------------------------------------------------*/
-
-void sndintrf_init(running_machine *machine)
-{
- /* zap the sound data structures */
- memset(sound, 0, sizeof(sound));
- totalsnd = 0;
-}
-
-
-/*-------------------------------------------------
- sndintrf_init_sound - initialize data for a
- particular sndnum
--------------------------------------------------*/
-
-static DEVICE_GET_INFO( sndclass )
-{
- sndintrf_data *snddata = device->inline_config;
- (*snddata->sndtype)(device, state, (sndinfo *)info);
-}
-
-int sndintrf_init_sound(running_machine *machine, int sndnum, const char *tag, sound_type sndtype, int clock, const void *config)
-{
- snd_start_func start;
- sndintrf_data *info = &sound[sndnum];
- int tokenbytes;
- int index;
- int sndidx;
-
- info->device = auto_malloc(sizeof(*info->device) + strlen(tag));
- memset(info->device, 0, sizeof(*info->device) + strlen(tag));
- info->device->type = DEVICE_GET_INFO_NAME(sndclass);
- info->device->machine = machine;
- strcpy(info->device->tag, tag);
- info->device->static_config = config;
- info->device->region = memory_region(info->device->machine, info->device->tag);
- info->device->regionbytes = memory_region_length(info->device->machine, info->device->tag);
-
- /* hack: stash the info pointer in the inline_config */
- info->device->inline_config = info;
-
- /* fill in the type and interface */
- info->sndtype = sndtype;
- info->aliastype = (sound_type)sndtype_get_info_fct(sndtype, SNDINFO_FCT_ALIAS);
- if (info->aliastype == 0)
- info->aliastype = sndtype;
- info->device->clock = clock;
-
- /* compute the index */
- for (index = 0, sndidx = 0; sndidx < totalsnd; sndidx++)
- if (sound[sndidx].aliastype == info->aliastype)
- index++;
- info->index = index;
- totalsnd++;
-
- /* allocate the token */
- tokenbytes = sndtype_get_info_int(sndtype, DEVINFO_INT_TOKEN_BYTES);
- assert(tokenbytes != 0);
- info->device->token = auto_malloc(tokenbytes);
- memset(info->device->token, 0, tokenbytes);
-
- /* start the chip, tagging all its streams */
- start = (snd_start_func)sndtype_get_info_fct(sndtype, SNDINFO_PTR_START);
- (*start)(info->device, clock);
- VPRINTF((" token = %p\n", info->device->token));
-
- return 0;
-}
-
-
-/*-------------------------------------------------
- sndintrf_exit_sound - tear down data for a
- particular sndnum
--------------------------------------------------*/
-
-void sndintrf_exit_sound(int sndnum)
-{
- sndinfo info;
-
- info.stop = NULL;
- (*sound[sndnum].sndtype)(NULL, SNDINFO_PTR_STOP, &info);
-
- /* stop the chip */
- if (info.stop)
- (*info.stop)(sound[sndnum].device);
-}
-
-
-
-/***************************************************************************
- HELPERS
-***************************************************************************/
-
-/*-------------------------------------------------
- sndti_exists - return TRUE if a (type,index)
- pair describes an existing chip
--------------------------------------------------*/
-
-int sndti_exists(sound_type type, int index)
-{
- return (sndti_to_sndnum(type, index) != -1);
-}
-
-
-/*-------------------------------------------------
- sndti_to_sndnum - map a (type,index) pair to
- a sound number
--------------------------------------------------*/
-
-int sndti_to_sndnum(sound_type type, int index)
-{
- int sndnum;
- for (sndnum = 0; sndnum < totalsnd; sndnum++)
- if (sound[sndnum].aliastype == type)
- if (index-- == 0)
- return sndnum;
- return -1;
-}
-
-
-/*-------------------------------------------------
- sndnum_to_sndti - map a sound number to a
- (type,index) pair
--------------------------------------------------*/
-
-sound_type sndnum_to_sndti(int sndnum, int *index)
-{
- if (index != NULL)
- *index = sound[sndnum].index;
- return sound[sndnum].aliastype;
-}
-
-
-/*-------------------------------------------------
- sndtype_count - count the number of a
- given type
--------------------------------------------------*/
-
-int sndtype_count(sound_type sndtype)
-{
- int index;
- int count = 0;
-
- for (index = 0; index < totalsnd; index++)
- if (sound[index].sndtype == sndtype)
- count++;
-
- return count;
-}
-
-
-
-/***************************************************************************
- CHIP INTERFACES BY INDEX
-***************************************************************************/
-
-/*-------------------------------------------------
- Get info accessors
--------------------------------------------------*/
-
-INT64 sndnum_get_info_int(int sndnum, UINT32 state)
-{
- sndinfo info;
-
- VERIFY_SNDNUM(sndnum_get_info_int);
- info.i = 0;
- (*sound[sndnum].sndtype)(sound[sndnum].device, state, &info);
- return info.i;
-}
-
-void *sndnum_get_info_ptr(int sndnum, UINT32 state)
-{
- sndinfo info;
-
- VERIFY_SNDNUM(sndnum_get_info_ptr);
- info.p = NULL;
- (*sound[sndnum].sndtype)(sound[sndnum].device, state, &info);
- return info.p;
-}
-
-genf *sndnum_get_info_fct(int sndnum, UINT32 state)
-{
- sndinfo info;
-
- VERIFY_SNDNUM(sndnum_get_info_fct);
- info.f = NULL;
- (*sound[sndnum].sndtype)(sound[sndnum].device, state, &info);
- return info.f;
-}
-
-const char *sndnum_get_info_string(int sndnum, UINT32 state)
-{
- extern char *get_temp_string_buffer(void);
- sndinfo info;
-
- VERIFY_SNDNUM(sndnum_get_info_string);
- info.s = get_temp_string_buffer();
- (*sound[sndnum].sndtype)(sound[sndnum].device, state, &info);
- return info.s;
-}
-
-
-/*-------------------------------------------------
- Misc accessors
--------------------------------------------------*/
-
-void sndnum_reset(int sndnum)
-{
- sndinfo info;
-
- VERIFY_SNDNUM(sndnum_reset);
- info.reset = NULL;
- (*sound[sndnum].sndtype)(NULL, SNDINFO_PTR_RESET, &info);
- if (info.reset)
- (info.reset)(sound[sndnum].device);
-}
-
-int sndnum_clock(int sndnum)
-{
- VERIFY_SNDNUM(sndnum_clock);
- return sound[sndnum].device->clock;
-}
-
-void *sndnum_token(int sndnum)
-{
- VERIFY_SNDNUM(sndnum_token);
- return sound[sndnum].device->token;
-}
-
-
-
-/***************************************************************************
- CHIP INTERFACES BY (TYPE,INDEX) PAIR
-***************************************************************************/
-
-/*-------------------------------------------------
- Get info accessors
--------------------------------------------------*/
-
-INT64 sndti_get_info_int(sound_type sndtype, int sndindex, UINT32 state)
-{
- sndinfo info;
-
- VERIFY_SNDTI(sndti_get_info_int);
- info.i = 0;
- (*sound[sndnum].sndtype)(sound[sndnum].device, state, &info);
- return info.i;
-}
-
-void *sndti_get_info_ptr(sound_type sndtype, int sndindex, UINT32 state)
-{
- sndinfo info;
-
- VERIFY_SNDTI(sndti_get_info_ptr);
- info.p = NULL;
- (*sound[sndnum].sndtype)(sound[sndnum].device, state, &info);
- return info.p;
-}
-
-genf *sndti_get_info_fct(sound_type sndtype, int sndindex, UINT32 state)
-{
- sndinfo info;
-
- VERIFY_SNDTI(sndti_get_info_fct);
- info.f = NULL;
- (*sound[sndnum].sndtype)(sound[sndnum].device, state, &info);
- return info.f;
-}
-
-const char *sndti_get_info_string(sound_type sndtype, int sndindex, UINT32 state)
-{
- extern char *get_temp_string_buffer(void);
- sndinfo info;
-
- VERIFY_SNDTI(sndti_get_info_string);
- info.s = get_temp_string_buffer();
- (*sound[sndnum].sndtype)(sound[sndnum].device, state, &info);
- return info.s;
-}
-
-
-/*-------------------------------------------------
- Misc accessors
--------------------------------------------------*/
-
-void sndti_reset(sound_type sndtype, int sndindex)
-{
- sndinfo info;
-
- VERIFY_SNDTI(sndti_reset);
- info.reset = NULL;
- (*sound[sndnum].sndtype)(NULL, SNDINFO_PTR_RESET, &info);
-
- if (info.reset)
- (*info.reset)(sound[sndnum].device);
-}
-
-int sndti_clock(sound_type sndtype, int sndindex)
-{
- VERIFY_SNDTI(sndti_clock);
- return sound[sndnum].device->clock;
-}
-
-void *sndti_token(sound_type sndtype, int sndindex)
-{
- VERIFY_SNDTI(sndti_token);
- return sound[sndnum].device->token;
-}
-
-
-
-/***************************************************************************
- CHIP INTERFACES BY TYPE
-***************************************************************************/
-
-/*-------------------------------------------------
- Get info accessors
--------------------------------------------------*/
-
-INT64 sndtype_get_info_int(sound_type sndtype, UINT32 state)
-{
- snd_get_info_func get_info = sndtype;
- sndinfo info;
-
- VERIFY_SNDTYPE(sndtype_get_info_int);
- info.i = 0;
- (*get_info)(NULL, state, &info);
- return info.i;
-}
-
-void *sndtype_get_info_ptr(sound_type sndtype, UINT32 state)
-{
- snd_get_info_func get_info = sndtype;
- sndinfo info;
-
- VERIFY_SNDTYPE(sndtype_get_info_ptr);
- info.p = NULL;
- (*get_info)(NULL, state, &info);
- return info.p;
-}
-
-genf *sndtype_get_info_fct(sound_type sndtype, UINT32 state)
-{
- snd_get_info_func get_info = sndtype;
- sndinfo info;
-
- VERIFY_SNDTYPE(sndtype_get_info_fct);
- info.f = NULL;
- (*get_info)(NULL, state, &info);
- return info.f;
-}
-
-const char *sndtype_get_info_string(sound_type sndtype, UINT32 state)
-{
- extern char *get_temp_string_buffer(void);
- snd_get_info_func get_info = sndtype;
- sndinfo info;
-
- VERIFY_SNDTYPE(sndtype_get_info_string);
- info.s = get_temp_string_buffer();
- (*get_info)(NULL, state, &info);
- return info.s;
-}
diff --git a/src/emu/sndintrf.h b/src/emu/sndintrf.h
index 15a38447fba..647d12b9dd0 100644
--- a/src/emu/sndintrf.h
+++ b/src/emu/sndintrf.h
@@ -17,204 +17,7 @@
#include "memory.h"
#include "mame.h"
#include "state.h"
-
-
-/***************************************************************************
- CONSTANTS
-***************************************************************************/
-
-#define MAX_SOUND 32
-
-
-/* Sound information constants */
-enum
-{
- /* --- the following bits of info are returned as 64-bit signed integers --- */
- SNDINFO_INT_FIRST = DEVINFO_INT_FIRST,
-
- SNDINFO_INT_TOKEN_BYTES = DEVINFO_INT_TOKEN_BYTES, /* R/O: bytes to allocate for the token */
-
- SNDINFO_INT_CORE_SPECIFIC = DEVINFO_INT_DEVICE_SPECIFIC, /* R/W: core-specific values start here */
-
- /* --- the following bits of info are returned as pointers to data or functions --- */
- SNDINFO_PTR_FIRST = DEVINFO_PTR_FIRST,
-
- SNDINFO_PTR_CORE_SPECIFIC = DEVINFO_PTR_DEVICE_SPECIFIC, /* R/W: core-specific values start here */
-
- /* --- the following bits of info are returned as pointers to functions --- */
- SNDINFO_FCT_FIRST = DEVINFO_FCT_FIRST,
-
- SNDINFO_PTR_START = DEVINFO_FCT_START, /* R/O: void *(*start)(const device_config *device, int clock) */
- SNDINFO_PTR_STOP = DEVINFO_FCT_STOP, /* R/O: void (*stop)(const device_config *device) */
- SNDINFO_PTR_RESET = DEVINFO_FCT_RESET, /* R/O: void (*reset)(const device_config *device) */
-
- SNDINFO_PTR_SET_INFO = DEVINFO_FCT_CLASS_SPECIFIC, /* R/O: void (*set_info)(const device_config *device, UINT32 state, sndinfo *info) */
- SNDINFO_FCT_ALIAS, /* R/O: alias to sound type for (type,index) identification */
-
- SNDINFO_FCT_CORE_SPECIFIC = DEVINFO_FCT_DEVICE_SPECIFIC, /* R/W: core-specific values start here */
-
- /* --- the following bits of info are returned as NULL-terminated strings --- */
- SNDINFO_STR_FIRST = DEVINFO_STR_FIRST,
-
- SNDINFO_STR_NAME = DEVINFO_STR_NAME, /* R/O: name of the sound chip */
- SNDINFO_STR_CORE_FAMILY = DEVINFO_STR_FAMILY, /* R/O: family of the sound chip */
- SNDINFO_STR_CORE_VERSION = DEVINFO_STR_VERSION, /* R/O: version of the sound core */
- SNDINFO_STR_CORE_FILE = DEVINFO_STR_SOURCE_FILE, /* R/O: file containing the sound core */
- SNDINFO_STR_CORE_CREDITS = DEVINFO_STR_CREDITS, /* R/O: credits for the sound core */
-
- SNDINFO_STR_CORE_SPECIFIC = DEVINFO_STR_DEVICE_SPECIFIC /* R/W: core-specific values start here */
-};
-
-
-
-/***************************************************************************
- MACROS
-***************************************************************************/
-
-#define SND_GET_INFO_NAME(name) snd_get_info_##name
-#define SND_GET_INFO(name) void SND_GET_INFO_NAME(name)(const device_config *device, UINT32 state, sndinfo *info)
-#define SND_GET_INFO_CALL(name) SND_GET_INFO_NAME(name)(device, state, info)
-
-#define SND_SET_INFO_NAME(name) snd_set_info_##name
-#define SND_SET_INFO(name) void SND_SET_INFO_NAME(name)(const device_config *device, UINT32 state, sndinfo *info)
-#define SND_SET_INFO_CALL(name) SND_SET_INFO_NAME(name)(device, state, info)
-
-#define SND_START_NAME(name) snd_start_##name
-#define SND_START(name) void SND_START_NAME(name)(const device_config *device, int clock)
-#define SND_START_CALL(name) SND_START_NAME(name)(device, clock)
-
-#define SND_STOP_NAME(name) snd_stop_##name
-#define SND_STOP(name) void SND_STOP_NAME(name)(const device_config *device)
-#define SND_STOP_CALL(name) SND_STOP_NAME(name)(device)
-
-#define SND_RESET_NAME(name) snd_reset_##name
-#define SND_RESET(name) void SND_RESET_NAME(name)(const device_config *device)
-#define SND_RESET_CALL(name) SND_RESET_NAME(name)(device)
-
-
-
-/***************************************************************************
- TYPE DEFINITIONS
-***************************************************************************/
-
-/* forward declaration of this union */
-typedef union _sndinfo sndinfo;
-
-/* define the various callback functions */
-typedef void (*snd_get_info_func)(const device_config *device, UINT32 state, sndinfo *info);
-typedef void (*snd_set_info_func)(const device_config *device, UINT32 state, sndinfo *info);
-typedef void (*snd_start_func)(const device_config *device, int clock);
-typedef void (*snd_stop_func)(const device_config *device);
-typedef void (*snd_reset_func)(const device_config *device);
-
-typedef snd_get_info_func sound_type;
-
-
-/* sndinfo union used to pass data to/from the get_info/set_info functions */
-union _sndinfo
-{
- INT64 i; /* generic integers */
- void * p; /* generic pointers */
- genf * f; /* generic function pointers */
- char * s; /* generic strings */
- sound_type type; /* generic type */
-
- snd_set_info_func set_info; /* SNDINFO_PTR_SET_INFO */
- snd_start_func start; /* SNDINFO_PTR_START */
- snd_stop_func stop; /* SNDINFO_PTR_STOP */
- snd_reset_func reset; /* SNDINFO_PTR_RESET */
-};
-
-
-
-/***************************************************************************
- CHIP INTERFACES BY INDEX
-***************************************************************************/
-
-/* get info accessors */
-INT64 sndnum_get_info_int(int sndnum, UINT32 state);
-void *sndnum_get_info_ptr(int sndnum, UINT32 state);
-genf *sndnum_get_info_fct(int sndnum, UINT32 state);
-const char *sndnum_get_info_string(int sndnum, UINT32 state);
-
-/* set info accessors */
-void sndnum_set_info_int(int sndnum, UINT32 state, INT64 data);
-void sndnum_set_info_ptr(int sndnum, UINT32 state, void *data);
-void sndnum_set_info_fct(int sndnum, UINT32 state, genf *data);
-
-#define sndnum_get_name(sndnum) sndnum_get_info_string(sndnum, SNDINFO_STR_NAME)
-#define sndnum_get_core_family(sndnum) sndnum_get_info_string(sndnum, SNDINFO_STR_CORE_FAMILY)
-#define sndnum_get_core_version(sndnum) sndnum_get_info_string(sndnum, SNDINFO_STR_CORE_VERSION)
-#define sndnum_get_core_file(sndnum) sndnum_get_info_string(sndnum, SNDINFO_STR_CORE_FILE)
-#define sndnum_get_core_credits(sndnum) sndnum_get_info_string(sndnum, SNDINFO_STR_CORE_CREDITS)
-
-/* misc accessors */
-void sndnum_reset(int sndnum);
-int sndnum_clock(int sndnum);
-void *sndnum_token(int sndnum);
-
-
-
-/***************************************************************************
- CHIP INTERFACES BY (TYPE,INDEX) PAIR
-***************************************************************************/
-
-/* get info accessors */
-INT64 sndti_get_info_int(sound_type sndtype, int sndindex, UINT32 state);
-void *sndti_get_info_ptr(sound_type sndtype, int sndindex, UINT32 state);
-genf *sndti_get_info_fct(sound_type sndtype, int sndindex, UINT32 state);
-const char *sndti_get_info_string(sound_type sndtype, int sndindex, UINT32 state);
-
-#define sndti_get_name(sndtype, sndindex) sndti_get_info_string(sndtype, sndindex, SNDINFO_STR_NAME)
-#define sndti_get_core_family(sndtype, sndindex) sndti_get_info_string(sndtype, sndindex, SNDINFO_STR_CORE_FAMILY)
-#define sndti_get_core_version(sndtype, sndindex) sndti_get_info_string(sndtype, sndindex, SNDINFO_STR_CORE_VERSION)
-#define sndti_get_core_file(sndtype, sndindex) sndti_get_info_string(sndtype, sndindex, SNDINFO_STR_CORE_FILE)
-#define sndti_get_core_credits(sndtype, sndindex) sndti_get_info_string(sndtype, sndindex, SNDINFO_STR_CORE_CREDITS)
-
-/* misc accessors */
-void sndti_reset(sound_type sndtype, int sndindex);
-int sndti_clock(sound_type sndtype, int sndindex);
-void *sndti_token(sound_type sndtype, int sndindex);
-
-/* driver gain controls on chip outputs */
-void sndti_set_output_gain(sound_type sndtype, int sndindex, int output, float gain);
-
-
-
-/***************************************************************************
- CHIP INTERFACES BY TYPE
-***************************************************************************/
-
-/* get info accessors */
-INT64 sndtype_get_info_int(sound_type sndtype, UINT32 state);
-void *sndtype_get_info_ptr(sound_type sndtype, UINT32 state);
-genf *sndtype_get_info_fct(sound_type sndtype, UINT32 state);
-const char *sndtype_get_info_string(sound_type sndtype, UINT32 state);
-
-#define sndtype_get_name(sndtype) sndtype_get_info_string(sndtype, SNDINFO_STR_NAME)
-#define sndtype_get_core_family(sndtype) sndtype_get_info_string(sndtype, SNDINFO_STR_CORE_FAMILY)
-#define sndtype_get_core_version(sndtype) sndtype_get_info_string(sndtype, SNDINFO_STR_CORE_VERSION)
-#define sndtype_get_core_file(sndtype) sndtype_get_info_string(sndtype, SNDINFO_STR_CORE_FILE)
-#define sndtype_get_core_credits(sndtype) sndtype_get_info_string(sndtype, SNDINFO_STR_CORE_CREDITS)
-
-
-
-/***************************************************************************
- FUNCTION PROTOTYPES
-***************************************************************************/
-
-/* Initialization/Tear down */
-void sndintrf_init(running_machine *machine);
-int sndintrf_init_sound(running_machine *machine, int sndnum, const char *tag, sound_type sndtype, int clock, const void *config);
-void sndintrf_exit_sound(int sndnum);
-
-/* Misc helpers */
-int sndti_exists(sound_type sndtype, int sndindex);
-int sndti_to_sndnum(sound_type type, int index);
-sound_type sndnum_to_sndti(int sndnum, int *index);
-int sndtype_count(sound_type sndtype);
-
-#define SOUND_DUMMY NULL
+#include "sound.h"
#endif /* __SNDINTRF_H__ */
diff --git a/src/emu/sound.c b/src/emu/sound.c
index a6df8328b38..3b22fc2b9f5 100644
--- a/src/emu/sound.c
+++ b/src/emu/sound.c
@@ -24,7 +24,7 @@
#define VERBOSE (0)
-#define VPRINTF(x) do { if (VERBOSE) mame_printf_debug x; } while (0)
+#define VPRINTF(x) do { if (VERBOSE) mame_printf_debug x; } while (0)
@@ -33,7 +33,6 @@
***************************************************************************/
#define MAX_MIXER_CHANNELS 100
-#define SOUND_UPDATE_FREQUENCY ATTOTIME_IN_HZ(50)
@@ -49,12 +48,11 @@ struct _sound_output
};
-typedef struct _sound_info sound_info;
-struct _sound_info
+typedef struct _sound_class_data sound_class_data;
+struct _sound_class_data
{
- const sound_config *sound; /* pointer to the sound info */
int outputs; /* number of outputs from this instance */
- sound_output * output; /* array of output information */
+ sound_output output[MAX_OUTPUTS]; /* array of output information */
};
@@ -91,7 +89,6 @@ struct _speaker_info
static emu_timer *sound_update_timer;
static int totalsnd;
-static sound_info sound[MAX_SOUND];
static INT16 *finalmix;
static UINT32 finalmix_leftover;
@@ -116,7 +113,6 @@ static void sound_pause(running_machine *machine, int pause);
static void sound_load(running_machine *machine, int config_type, xml_data_node *parentnode);
static void sound_save(running_machine *machine, int config_type, xml_data_node *parentnode);
static TIMER_CALLBACK( sound_update );
-static void start_sound_chips(running_machine *machine);
static void route_sound(running_machine *machine);
static STREAM_UPDATE( mixer_update );
static STATE_POSTLOAD( mixer_postload );
@@ -128,43 +124,58 @@ static STATE_POSTLOAD( mixer_postload );
***************************************************************************/
/*-------------------------------------------------
- get_safe_token - makes sure that the passed
- in device is, in fact, a timer
+ get_class_data - return a pointer to the
+ class data
-------------------------------------------------*/
-INLINE speaker_info *get_safe_token(const device_config *device)
+INLINE sound_class_data *get_class_data(const device_config *device)
{
assert(device != NULL);
+ assert(device->type == SOUND);
+ assert(device->class == DEVICE_CLASS_SOUND_CHIP);
assert(device->token != NULL);
- assert(device->type == SPEAKER_OUTPUT);
-
- return (speaker_info *)device->token;
+ return (sound_class_data *)((UINT8 *)device->token + device->tokenbytes) - 1;
}
/*-------------------------------------------------
- find_speaker_by_tag - find a tagged speaker
+ get_safe_token - makes sure that the passed
+ in device is, in fact, a timer
-------------------------------------------------*/
-INLINE speaker_info *find_speaker_by_tag(running_machine *machine, const char *tag)
+INLINE speaker_info *get_safe_token(const device_config *device)
{
- const device_config *speaker = device_list_find_by_tag(machine->config->devicelist, SPEAKER_OUTPUT, tag);
- return (speaker == NULL) ? NULL : speaker->token;
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SPEAKER_OUTPUT);
+
+ return (speaker_info *)device->token;
}
/*-------------------------------------------------
- find_sound_by_tag - find a tagged sound chip
+ index_to_input - map an absolute index to
+ a particular input
-------------------------------------------------*/
-INLINE sound_info *find_sound_by_tag(const char *tag)
+INLINE speaker_info *index_to_input(running_machine *machine, int index, int *input)
{
- int sndnum;
+ const device_config *curspeak;
+ int count = 0;
+
+ /* scan through the speakers until we find the indexed input */
+ for (curspeak = speaker_output_first(machine->config); curspeak != NULL; curspeak = speaker_output_next(curspeak))
+ {
+ speaker_info *info = curspeak->token;
+ if (index < count + info->inputs)
+ {
+ *input = index - count;
+ return info;
+ }
+ count += info->inputs;
+ }
- /* attempt to find the speaker in our list */
- for (sndnum = 0; sndnum < totalsnd; sndnum++)
- if (sound[sndnum].sound->tag && !strcmp(sound[sndnum].sound->tag, tag))
- return &sound[sndnum];
+ /* index out of range */
return NULL;
}
@@ -180,7 +191,6 @@ INLINE sound_info *find_sound_by_tag(const char *tag)
void sound_init(running_machine *machine)
{
- attotime update_frequency = SOUND_UPDATE_FREQUENCY;
const char *filename;
/* handle -nosound */
@@ -198,15 +208,7 @@ void sound_init(running_machine *machine)
/* allocate a global timer for sound timing */
sound_update_timer = timer_alloc(machine, sound_update, NULL);
- timer_adjust_periodic(sound_update_timer, update_frequency, 0, update_frequency);
-
- /* initialize the streams engine */
- VPRINTF(("streams_init\n"));
- streams_init(machine, update_frequency.attoseconds);
-
- /* now start up the sound chips and tag their streams */
- VPRINTF(("start_sound_chips\n"));
- start_sound_chips(machine);
+ timer_adjust_periodic(sound_update_timer, STREAMS_UPDATE_FREQUENCY, 0, STREAMS_UPDATE_FREQUENCY);
/* finally, do all the routing */
VPRINTF(("route_sound\n"));
@@ -236,118 +238,129 @@ void sound_init(running_machine *machine)
static void sound_exit(running_machine *machine)
{
- int sndnum;
-
/* close any open WAV file */
if (wavfile != NULL)
wav_close(wavfile);
- /* stop all the sound chips */
- for (sndnum = 0; sndnum < MAX_SOUND; sndnum++)
- if (machine->config->sound[sndnum].type != SOUND_DUMMY)
- sndintrf_exit_sound(sndnum);
-
/* reset variables */
totalsnd = 0;
- memset(sound, 0, sizeof(sound));
}
/***************************************************************************
- INITIALIZATION HELPERS
+ SOUND DEVICE INTERFACE
***************************************************************************/
/*-------------------------------------------------
- start_sound_chips - loop over all sound chips
- and initialize them
+ device_start_sound - device start callback
-------------------------------------------------*/
-static void start_sound_chips(running_machine *machine)
+static DEVICE_START( sound )
{
- int sndnum;
-
- /* reset the sound array */
- memset(sound, 0, sizeof(sound));
+ sound_class_data *classdata;
+ const sound_config *config;
+ deviceinfo devinfo;
+ int num_regs, outputnum;
- /* start up all the sound chips */
- for (sndnum = 0; sndnum < MAX_SOUND; sndnum++)
+ /* validate some basic stuff */
+ assert(device != NULL);
+ assert(device->inline_config != NULL);
+ assert(device->machine != NULL);
+ assert(device->machine->config != NULL);
+
+ /* get pointers to our data */
+ config = device->inline_config;
+ classdata = get_class_data(device);
+
+ /* get the chip's start function */
+ devinfo.start = NULL;
+ (*config->type)(device, DEVINFO_FCT_START, &devinfo);
+ assert(devinfo.start != NULL);
+
+ /* initialize this sound chip */
+ num_regs = state_save_get_reg_count(device->machine);
+ (*devinfo.start)(device);
+ num_regs = state_save_get_reg_count(device->machine) - num_regs;
+
+ /* now count the outputs */
+ VPRINTF(("Counting outputs\n"));
+ for (outputnum = 0; outputnum < MAX_OUTPUTS; outputnum++)
{
- const sound_config *msound = &machine->config->sound[sndnum];
- sound_info *info;
- int num_regs;
- int index;
-
- /* stop when we hit an empty entry */
- if (msound->type == SOUND_DUMMY)
+ sound_stream *stream = stream_find_by_device(device, outputnum);
+ int curoutput, numoutputs;
+
+ /* stop when we run out of streams */
+ if (stream == NULL)
break;
- totalsnd++;
+
+ /* accumulate the number of outputs from this stream */
+ numoutputs = stream_get_outputs(stream);
+ assert(classdata->outputs < MAX_OUTPUTS);
- /* zap all the info */
- info = &sound[sndnum];
- memset(info, 0, sizeof(*info));
+ /* fill in the array */
+ for (curoutput = 0; curoutput < numoutputs; curoutput++)
+ {
+ sound_output *output = &classdata->output[classdata->outputs++];
+ output->stream = stream;
+ output->output = curoutput;
+ }
+ }
- /* copy in all the relevant info */
- info->sound = msound;
+ /* if no state registered for saving, we can't save */
+ if (num_regs == 0)
+ {
+ logerror("Sound chip '%s' did not register any state to save!\n", device->tag);
+ if (device->machine->gamedrv->flags & GAME_SUPPORTS_SAVE)
+ fatalerror("Sound chip '%s' did not register any state to save!", device->tag);
+ }
+}
- /* start the chip, tagging all its streams */
- VPRINTF(("sndnum = %d -- sound_type = %s\n", sndnum, sndtype_get_name(msound->type)));
- num_regs = state_save_get_reg_count(machine);
- streams_set_tag(machine, info);
- if (sndintrf_init_sound(machine, sndnum, msound->tag, msound->type, msound->clock, msound->config) != 0)
- fatalerror("Sound chip #%d (%s) failed to initialize!", sndnum, sndnum_get_name(sndnum));
- /* if no state registered for saving, we can't save */
- num_regs = state_save_get_reg_count(machine) - num_regs;
- if (num_regs == 0)
- {
- logerror("Sound chip #%d (%s) did not register any state to save!\n", sndnum, sndnum_get_name(sndnum));
- if (machine->gamedrv->flags & GAME_SUPPORTS_SAVE)
- fatalerror("Sound chip #%d (%s) did not register any state to save!", sndnum, sndnum_get_name(sndnum));
- }
+/*-------------------------------------------------
+ device_get_info_sound - device get info
+ callback
+-------------------------------------------------*/
- /* now count the outputs */
- VPRINTF(("Counting outputs\n"));
- for (index = 0; ; index++)
- {
- sound_stream *stream = stream_find_by_tag(machine, info, index);
- if (!stream)
- break;
- info->outputs += stream_get_outputs(stream);
- VPRINTF((" stream %p, %d outputs\n", stream, stream_get_outputs(stream)));
- }
+DEVICE_GET_INFO( sound )
+{
+ const sound_config *config = (device != NULL) ? device->inline_config : NULL;
- /* if we have outputs, examine them */
- if (info->outputs)
- {
- /* allocate an array to hold them */
- info->output = auto_malloc(info->outputs * sizeof(*info->output));
- VPRINTF((" %d outputs total\n", info->outputs));
+ switch (state)
+ {
+ /* --- the following bits of info are returned as 64-bit signed integers --- */
+ case DEVINFO_INT_TOKEN_BYTES:
+ (*config->type)(device, DEVINFO_INT_TOKEN_BYTES, info);
+ info->i += sizeof(sound_class_data);
+ break;
- /* now fill the array */
- info->outputs = 0;
- for (index = 0; ; index++)
- {
- sound_stream *stream = stream_find_by_tag(machine, info, index);
- int outputs, outputnum;
+ case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(sound_config); break;
+ case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_SOUND_CHIP; break;
- if (!stream)
- break;
- outputs = stream_get_outputs(stream);
+ /* --- the following bits of info are returned as pointers to data or functions --- */
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(sound); break;
+ case DEVINFO_FCT_SET_INFO: info->set_info = NULL; break;
+
+ /* --- the following bits of info are returned as NULL-terminated strings --- */
+ case DEVINFO_STR_NAME:
+ if (config != NULL)
+ (*config->type)(device, state, info);
+ else
+ strcpy(info->s, "sound");
+ break;
- /* fill in an entry for each output */
- for (outputnum = 0; outputnum < outputs; outputnum++)
- {
- info->output[info->outputs].stream = stream;
- info->output[info->outputs].output = outputnum;
- info->outputs++;
- }
- }
- }
+ default:
+ (*config->type)(device, state, info);
+ break;
}
}
+
+/***************************************************************************
+ INITIALIZATION HELPERS
+***************************************************************************/
+
/*-------------------------------------------------
route_sound - route sound outputs to target
inputs
@@ -355,45 +368,44 @@ static void start_sound_chips(running_machine *machine)
static void route_sound(running_machine *machine)
{
- int sndnum, routenum, outputnum;
+ astring *tempstring = astring_alloc();
+ int routenum, outputnum;
const device_config *curspeak;
+ const device_config *sound;
- /* iterate over all the sound chips */
- for (sndnum = 0; sndnum < totalsnd; sndnum++)
+ /* first count up the inputs for each speaker */
+ for (sound = sound_first(machine->config); sound != NULL; sound = sound_next(sound))
{
- sound_info *info = &sound[sndnum];
-
+ const sound_config *config = sound->inline_config;
+ int numoutputs = stream_get_device_outputs(sound);
+ int numassigned = 0;
+
/* iterate over all routes */
- for (routenum = 0; routenum < info->sound->routes; routenum++)
+ for (routenum = 0; routenum <= ALL_OUTPUTS; routenum++)
{
- const sound_route *mroute = &info->sound->route[routenum];
- speaker_info *speaker;
- sound_info *sound;
-
- /* find the target */
- speaker = find_speaker_by_tag(machine, mroute->target);
- sound = find_sound_by_tag(mroute->target);
-
- /* if neither found, it's fatal */
- if (speaker == NULL && sound == NULL)
- fatalerror("Sound route \"%s\" not found!\n", mroute->target);
-
- /* if we got a speaker, bump its input count */
- if (speaker != NULL)
+ const sound_route *mroute = &config->route[routenum];
+ if (mroute->target != NULL)
{
- if (mroute->output >= 0 && mroute->output < info->outputs)
- speaker->inputs++;
- else if (mroute->output == ALL_OUTPUTS)
- speaker->inputs += info->outputs;
+ const device_config *target_speaker = devtag_get_device(machine, SPEAKER_OUTPUT, mroute->target);
+ const device_config *target_sound = devtag_get_device(machine, SOUND, mroute->target);
+ int numentries = (routenum != ALL_OUTPUTS) ? 1 : (numoutputs - numassigned);
+
+ /* if neither found, it's fatal */
+ if (target_speaker == NULL && target_sound == NULL)
+ fatalerror("Sound route \"%s\" not found!\n", mroute->target);
+
+ /* if we got a speaker, bump its input count */
+ if (target_speaker != NULL)
+ get_safe_token(target_speaker)->inputs += numentries;
+ numassigned += numentries;
}
}
}
-
+
/* now allocate the mixers and input data */
- streams_set_tag(machine, NULL);
for (curspeak = speaker_output_first(machine->config); curspeak != NULL; curspeak = speaker_output_next(curspeak))
{
- speaker_info *info = curspeak->token;
+ speaker_info *info = get_safe_token(curspeak);
if (info->inputs != 0)
{
info->mixer_stream = stream_create(curspeak, info->inputs, 1, machine->sample_rate, info, mixer_update);
@@ -406,84 +418,68 @@ static void route_sound(running_machine *machine)
}
/* iterate again over all the sound chips */
- for (sndnum = 0; sndnum < totalsnd; sndnum++)
+ for (sound = sound_first(machine->config); sound != NULL; sound = sound_next(sound))
{
- sound_info *info = &sound[sndnum];
-
+ const sound_config *config = sound->inline_config;
+ int numoutputs = stream_get_device_outputs(sound);
+ UINT8 assigned[MAX_OUTPUTS] = { FALSE };
+
/* iterate over all routes */
- for (routenum = 0; routenum < info->sound->routes; routenum++)
+ for (routenum = 0; routenum <= ALL_OUTPUTS; routenum++)
{
- const sound_route *mroute = &info->sound->route[routenum];
- speaker_info *speaker;
- sound_info *sound;
-
- /* find the target */
- speaker = find_speaker_by_tag(machine, mroute->target);
- sound = find_sound_by_tag(mroute->target);
-
- /* if it's a speaker, set the input */
- if (speaker != NULL)
+ const sound_route *mroute = &config->route[routenum];
+ if (mroute->target != NULL)
{
- for (outputnum = 0; outputnum < info->outputs; outputnum++)
- if (mroute->output == outputnum || mroute->output == ALL_OUTPUTS)
+ const device_config *target_speaker = devtag_get_device(machine, SPEAKER_OUTPUT, mroute->target);
+ const device_config *target_sound = devtag_get_device(machine, SOUND, mroute->target);
+ int inputnum = mroute->input;
+ sound_stream *stream;
+ int streamoutput;
+
+ /* iterate over all outputs, matching any that apply */
+ for (outputnum = 0; outputnum < numoutputs; outputnum++)
+ if (routenum == outputnum || (routenum == ALL_OUTPUTS && !assigned[outputnum]))
{
- char namebuf[256];
- int index;
-
- sound_type sndtype = sndnum_to_sndti(sndnum, &index);
-
- /* built the display name */
- namebuf[0] = '\0';
-
- /* speaker name, if more than one speaker */
- if (speaker_output_count(machine->config) > 1)
- sprintf(namebuf, "%sSpeaker '%s': ", namebuf, speaker->tag);
-
- /* device name */
- sprintf(namebuf, "%s%s ", namebuf, sndnum_get_name(sndnum));
-
- /* device index, if more than one of this type */
- if (sndtype_count(sndtype) > 1)
- sprintf(namebuf, "%s#%d ", namebuf, index);
-
- /* channel number, if more than channel for this device */
- if (info->outputs > 1)
- sprintf(namebuf, "%sCh.%d", namebuf, outputnum);
-
- /* remove final space */
- if (namebuf[strlen(namebuf) - 1] == ' ')
- namebuf[strlen(namebuf) - 1] = '\0';
-
- /* fill in the input data on this speaker */
- speaker->input[speaker->inputs].gain = mroute->gain;
- speaker->input[speaker->inputs].default_gain = mroute->gain;
- speaker->input[speaker->inputs].name = auto_strdup(namebuf);
-
- /* connect the output to the input */
- stream_set_input(speaker->mixer_stream, speaker->inputs++, info->output[outputnum].stream, info->output[outputnum].output, mroute->gain);
+ /* mark this output as assigned */
+ assigned[outputnum] = TRUE;
+
+ /* if it's a speaker, set the input */
+ if (target_speaker != NULL)
+ {
+ speaker_info *speakerinfo = get_safe_token(target_speaker);
+
+ /* generate text for the UI */
+ astring_printf(tempstring, "Speaker '%s': %s '%s'", target_speaker->tag, device_get_name(sound), sound->tag);
+ if (numoutputs > 1)
+ astring_catprintf(tempstring, " Ch.%d", outputnum);
+
+ /* fill in the input data on this speaker */
+ speakerinfo->input[speakerinfo->inputs].gain = mroute->gain;
+ speakerinfo->input[speakerinfo->inputs].default_gain = mroute->gain;
+ speakerinfo->input[speakerinfo->inputs].name = auto_strdup(astring_c(tempstring));
+
+ /* connect the output to the input */
+ if (stream_device_output_to_stream_output(sound, outputnum, &stream, &streamoutput))
+ stream_set_input(speakerinfo->mixer_stream, speakerinfo->inputs++, stream, streamoutput, mroute->gain);
+ }
+
+ /* otherwise, it's a sound chip */
+ else
+ {
+ sound_stream *inputstream;
+ int streaminput;
+
+ if (stream_device_input_to_stream_input(target_sound, inputnum++, &inputstream, &streaminput))
+ if (stream_device_output_to_stream_output(sound, outputnum, &stream, &streamoutput))
+ stream_set_input(inputstream, streaminput, stream, streamoutput, mroute->gain);
+ }
}
}
-
- /* if it's a sound chip, set the input */
- else
- {
- if (mroute->input < 0)
- {
- for (outputnum = 0; outputnum < info->outputs; outputnum++)
- if (mroute->output == outputnum || mroute->output == ALL_OUTPUTS)
- stream_set_input(sound->output[0].stream, 0, info->output[outputnum].stream, info->output[outputnum].output, mroute->gain);
- }
- else
- {
- assert(mroute->output != ALL_OUTPUTS);
- for (outputnum = 0; outputnum < info->outputs; outputnum++)
- if (mroute->output == outputnum)
- stream_set_input(sound->output[0].stream, mroute->input, info->output[outputnum].stream, info->output[outputnum].output, mroute->gain);
- }
-
- }
}
}
+
+ /* free up our temporary string */
+ astring_free(tempstring);
}
@@ -498,12 +494,11 @@ static void route_sound(running_machine *machine)
static void sound_reset(running_machine *machine)
{
- int sndnum;
+ const device_config *sound;
/* reset all the sound chips */
- for (sndnum = 0; sndnum < MAX_SOUND; sndnum++)
- if (machine->config->sound[sndnum].type != SOUND_DUMMY)
- sndnum_reset(sndnum);
+ for (sound = sound_first(machine->config); sound != NULL; sound = sound_next(sound))
+ device_reset(sound);
}
@@ -842,20 +837,6 @@ static DEVICE_STOP( speaker_output )
/*-------------------------------------------------
- speaker_output_set_info - device set info
- callback
--------------------------------------------------*/
-
-static DEVICE_SET_INFO( speaker_output )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
-/*-------------------------------------------------
speaker_output_get_info - device get info
callback
-------------------------------------------------*/
@@ -870,7 +851,6 @@ DEVICE_GET_INFO( speaker_output )
case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_AUDIO; break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(speaker_output); break;
case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(speaker_output); break;
case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME(speaker_output); break;
case DEVINFO_FCT_RESET: /* Nothing */ break;
@@ -891,25 +871,17 @@ DEVICE_GET_INFO( speaker_output )
***************************************************************************/
/*-------------------------------------------------
- sndti_set_output_gain - set the gain of a
+ sound_set_output_gain - set the gain of a
particular output
-------------------------------------------------*/
-void sndti_set_output_gain(sound_type type, int index, int output, float gain)
+void sound_set_output_gain(const device_config *device, int output, float gain)
{
- int sndnum = sndti_to_sndnum(type, index);
-
- if (sndnum < 0)
- {
- logerror("sndti_set_output_gain called for invalid sound type %s, index %d\n", sndtype_get_name(type), index);
- return;
- }
- if (output >= sound[sndnum].outputs)
- {
- logerror("sndti_set_output_gain called for invalid sound output %d (type %s, index %d)\n", output, sndtype_get_name(type), index);
- return;
- }
- stream_set_output_gain(sound[sndnum].output[output].stream, sound[sndnum].output[output].output, gain);
+ sound_stream *stream;
+ int outputnum;
+
+ if (stream_device_output_to_stream_output(device, output, &stream, &outputnum))
+ stream_set_output_gain(stream, outputnum, gain);
}
@@ -919,33 +891,6 @@ void sndti_set_output_gain(sound_type type, int index, int output, float gain)
***************************************************************************/
/*-------------------------------------------------
- index_to_input - map an absolute index to
- a particular input
--------------------------------------------------*/
-
-INLINE speaker_info *index_to_input(running_machine *machine, int index, int *input)
-{
- const device_config *curspeak;
- int count = 0;
-
- /* scan through the speakers until we find the indexed input */
- for (curspeak = speaker_output_first(machine->config); curspeak != NULL; curspeak = speaker_output_next(curspeak))
- {
- speaker_info *info = curspeak->token;
- if (index < count + info->inputs)
- {
- *input = index - count;
- return info;
- }
- count += info->inputs;
- }
-
- /* index out of range */
- return NULL;
-}
-
-
-/*-------------------------------------------------
sound_get_user_gain_count - return the number
of user-controllable gain parameters
-------------------------------------------------*/
@@ -1020,22 +965,3 @@ const char *sound_get_user_gain_name(running_machine *machine, int index)
speaker_info *spk = index_to_input(machine, index, &inputnum);
return (spk != NULL) ? spk->input[inputnum].name : NULL;
}
-
-
-/*-------------------------------------------------
- sound_find_sndnum_by_tag - return a sndnum
- by finding the appropriate tag
--------------------------------------------------*/
-
-int sound_find_sndnum_by_tag(const char *tag)
-{
- int index;
-
- /* find a match */
- for (index = 0; index < MAX_SOUND; index++)
- if (sound[index].sound != NULL && sound[index].sound->tag != NULL)
- if (strcmp(tag, sound[index].sound->tag) == 0)
- return index;
-
- return -1;
-}
diff --git a/src/emu/sound.h b/src/emu/sound.h
index 45b131da923..2f57ae6c040 100644
--- a/src/emu/sound.h
+++ b/src/emu/sound.h
@@ -14,14 +14,15 @@
#ifndef __SOUND_H__
#define __SOUND_H__
-#include "mamecore.h"
+#include "driver.h"
+
/***************************************************************************
CONSTANTS
***************************************************************************/
-#define MAX_ROUTES (16) /* maximum number of streams of any chip */
-#define ALL_OUTPUTS (-1) /* special value indicating all outputs for the current chip */
+#define MAX_OUTPUTS 256 /* maximum number of outputs a sound chip can support */
+#define ALL_OUTPUTS (MAX_OUTPUTS) /* special value indicating all outputs for the current chip */
@@ -31,9 +32,15 @@
/* these functions are macros primarily due to include file ordering */
/* plus, they are very simple */
+#define sound_count(config) device_list_items((config)->devicelist, SOUND)
+#define sound_first(config) device_list_first((config)->devicelist, SOUND)
+#define sound_next(previous) ((previous)->typenext)
+
+/* these functions are macros primarily due to include file ordering */
+/* plus, they are very simple */
#define speaker_output_count(config) device_list_items((config)->devicelist, SPEAKER_OUTPUT)
#define speaker_output_first(config) device_list_first((config)->devicelist, SPEAKER_OUTPUT)
-#define speaker_output_next(previous) device_list_next((previous), SPEAKER_OUTPUT)
+#define speaker_output_next(previous) ((previous)->typenext)
@@ -41,14 +48,17 @@
TYPE DEFINITIONS
***************************************************************************/
+/* sound type is just a device type */
+typedef device_type sound_type;
+
+
/* Sound route for the machine driver */
typedef struct _sound_route sound_route;
struct _sound_route
{
- int output; /* output ID */
- const char *target; /* tag of the target */
- float gain; /* gain */
- int input; /* input ID, -1 is default behavior */
+ const char * target; /* tag of the target */
+ int input; /* input ID, -1 is default behavior */
+ float gain; /* gain */
};
@@ -56,12 +66,8 @@ struct _sound_route
typedef struct _sound_config sound_config;
struct _sound_config
{
- sound_type type; /* what type of sound chip? */
- int clock; /* clock speed */
- const void *config; /* configuration for this chip */
- const char *tag; /* tag for this chip */
- int routes; /* number of routes we have */
- sound_route route[MAX_ROUTES]; /* routes for the various streams */
+ sound_type type; /* type of sound chip */
+ sound_route route[ALL_OUTPUTS+1]; /* one route per output */
};
@@ -69,18 +75,86 @@ struct _sound_config
typedef struct _speaker_config speaker_config;
struct _speaker_config
{
- float x, y, z; /* positioning vector */
+ float x, y, z; /* positioning vector */
};
/***************************************************************************
+ SOUND DEVICE CONFIGURATION MACROS
+***************************************************************************/
+
+#define MDRV_SOUND_ADD(_tag, _type, _clock) \
+ MDRV_DEVICE_ADD(_tag, SOUND, _clock) \
+ MDRV_DEVICE_CONFIG_DATAPTR(sound_config, type, SOUND_##_type)
+
+#define MDRV_SOUND_REMOVE(_tag) \
+ MDRV_DEVICE_REMOVE(_tag, SOUND)
+
+#define MDRV_SOUND_MODIFY(_tag) \
+ MDRV_DEVICE_MODIFY(_tag, SOUND)
+
+#define MDRV_SOUND_TYPE(_type) \
+ MDRV_DEVICE_CONFIG_DATAPTR(sound_config, type, SOUND_##_type)
+
+#define MDRV_SOUND_CLOCK(_clock) \
+ MDRV_DEVICE_CLOCK(_clock)
+
+#define MDRV_SOUND_REPLACE(_tag, _type, _clock) \
+ MDRV_DEVICE_MODIFY(_tag, SOUND) \
+ MDRV_DEVICE_CONFIG_CLEAR() \
+ MDRV_DEVICE_CONFIG_DATAPTR(sound_config, type, SOUND_##_type) \
+ MDRV_DEVICE_CLOCK(_clock)
+
+#define MDRV_SOUND_CONFIG(_config) \
+ MDRV_DEVICE_CONFIG(_config)
+
+#define MDRV_SOUND_ROUTE_EX(_output, _target, _gain, _input) \
+ MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(sound_config, route, _output, sound_route, target, _target) \
+ MDRV_DEVICE_CONFIG_DATA32_ARRAY_MEMBER(sound_config, route, _output, sound_route, input, _input) \
+ MDRV_DEVICE_CONFIG_DATAFP32_ARRAY_MEMBER(sound_config, route, _output, sound_route, gain, _gain, 24)
+
+#define MDRV_SOUND_ROUTE(_output, _target, _gain) \
+ MDRV_SOUND_ROUTE_EX(_output, _target, _gain, 0)
+
+
+
+/* add/remove speakers */
+#define MDRV_SPEAKER_ADD(_tag, _x, _y, _z) \
+ MDRV_DEVICE_ADD(_tag, SPEAKER_OUTPUT, 0) \
+ MDRV_DEVICE_CONFIG_DATAFP32(speaker_config, x, _x, 24) \
+ MDRV_DEVICE_CONFIG_DATAFP32(speaker_config, y, _y, 24) \
+ MDRV_DEVICE_CONFIG_DATAFP32(speaker_config, z, _z, 24)
+
+#define MDRV_SPEAKER_REMOVE(_tag) \
+ MDRV_DEVICE_REMOVE(_tag, SPEAKER_OUTPUT)
+
+#define MDRV_SPEAKER_STANDARD_MONO(_tag) \
+ MDRV_SPEAKER_ADD(_tag, 0.0, 0.0, 1.0)
+
+#define MDRV_SPEAKER_STANDARD_STEREO(_tagl, _tagr) \
+ MDRV_SPEAKER_ADD(_tagl, -0.2, 0.0, 1.0) \
+ MDRV_SPEAKER_ADD(_tagr, 0.2, 0.0, 1.0)
+
+
+
+/***************************************************************************
FUNCTION PROTOTYPES
***************************************************************************/
/* core interfaces */
void sound_init(running_machine *machine);
+
+
+/* ----- sound device interface ----- */
+
+/* device get info callback */
+#define SOUND DEVICE_GET_INFO_NAME(sound)
+DEVICE_GET_INFO( sound );
+
+
+
/* global sound controls */
void sound_mute(int mute);
void sound_set_attenuation(int attenuation);
@@ -94,8 +168,9 @@ float sound_get_user_gain(running_machine *machine, int index);
float sound_get_default_gain(running_machine *machine, int index);
const char *sound_get_user_gain_name(running_machine *machine, int index);
-/* misc helpers */
-int sound_find_sndnum_by_tag(const char *tag);
+
+/* driver gain controls on chip outputs */
+void sound_set_output_gain(const device_config *device, int output, float gain);
/* ----- sound speaker device interface ----- */
@@ -105,4 +180,21 @@ int sound_find_sndnum_by_tag(const char *tag);
DEVICE_GET_INFO( speaker_output );
+
+/***************************************************************************
+ INLINE FUNCTIONS
+***************************************************************************/
+
+/*-------------------------------------------------
+ sound_get_type - return the type of the
+ specified sound chip
+-------------------------------------------------*/
+
+INLINE sound_type sound_get_type(const device_config *device)
+{
+ const sound_config *config = device->inline_config;
+ return config->type;
+}
+
+
#endif /* __SOUND_H__ */
diff --git a/src/emu/sound/2151intf.c b/src/emu/sound/2151intf.c
index 7f8f1b3b4f3..6c2e5b59625 100644
--- a/src/emu/sound/2151intf.c
+++ b/src/emu/sound/2151intf.c
@@ -13,43 +13,55 @@
#include "ym2151.h"
-struct ym2151_info
+typedef struct _ym2151_state ym2151_state;
+struct _ym2151_state
{
- sound_stream * stream;
- emu_timer * timer[2];
- void * chip;
+ sound_stream * stream;
+ emu_timer * timer[2];
+ void * chip;
+ UINT8 lastreg;
const ym2151_interface *intf;
};
+INLINE ym2151_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_YM2151);
+ return (ym2151_state *)device->token;
+}
+
+
static STREAM_UPDATE( ym2151_update )
{
- struct ym2151_info *info = param;
+ ym2151_state *info = param;
ym2151_update_one(info->chip, outputs, samples);
}
static STATE_POSTLOAD( ym2151intf_postload )
{
- struct ym2151_info *info = param;
+ ym2151_state *info = param;
ym2151_postload(machine, info->chip);
}
-static SND_START( ym2151 )
+static DEVICE_START( ym2151 )
{
static const ym2151_interface dummy = { 0 };
- struct ym2151_info *info = device->token;
+ ym2151_state *info = device->token;
int rate;
info->intf = device->static_config ? device->static_config : &dummy;
- rate = clock/64;
+ rate = device->clock/64;
/* stream setup */
info->stream = stream_create(device,0,2,rate,info,ym2151_update);
- info->chip = ym2151_init(device,clock,rate);
+ info->chip = ym2151_init(device,device->clock,rate);
assert_always(info->chip != NULL, "Error creating YM2151 chip");
state_save_register_postload(device->machine, ym2151intf_postload, info);
@@ -59,175 +71,66 @@ static SND_START( ym2151 )
}
-static SND_STOP( ym2151 )
+static DEVICE_STOP( ym2151 )
{
- struct ym2151_info *info = device->token;
+ ym2151_state *info = device->token;
ym2151_shutdown(info->chip);
}
-static SND_RESET( ym2151 )
+static DEVICE_RESET( ym2151 )
{
- struct ym2151_info *info = device->token;
+ ym2151_state *info = device->token;
ym2151_reset_chip(info->chip);
}
-static int lastreg0,lastreg1,lastreg2;
-
-READ8_HANDLER( ym2151_status_port_0_r )
-{
- struct ym2151_info *token = sndti_token(SOUND_YM2151, 0);
- stream_update(token->stream);
- return ym2151_read_status(token->chip);
-}
-
-READ8_HANDLER( ym2151_status_port_1_r )
-{
- struct ym2151_info *token = sndti_token(SOUND_YM2151, 1);
- stream_update(token->stream);
- return ym2151_read_status(token->chip);
-}
-
-READ8_HANDLER( ym2151_status_port_2_r )
-{
- struct ym2151_info *token = sndti_token(SOUND_YM2151, 2);
- stream_update(token->stream);
- return ym2151_read_status(token->chip);
-}
-
-WRITE8_HANDLER( ym2151_register_port_0_w )
-{
- lastreg0 = data;
-}
-WRITE8_HANDLER( ym2151_register_port_1_w )
-{
- lastreg1 = data;
-}
-WRITE8_HANDLER( ym2151_register_port_2_w )
-{
- lastreg2 = data;
-}
-
-WRITE8_HANDLER( ym2151_data_port_0_w )
-{
- struct ym2151_info *token = sndti_token(SOUND_YM2151, 0);
- stream_update(token->stream);
- ym2151_write_reg(token->chip,lastreg0,data);
-}
-WRITE8_HANDLER( ym2151_data_port_1_w )
+READ8_DEVICE_HANDLER( ym2151_r )
{
- struct ym2151_info *token = sndti_token(SOUND_YM2151, 1);
- stream_update(token->stream);
- ym2151_write_reg(token->chip,lastreg1,data);
-}
-
-WRITE8_HANDLER( ym2151_data_port_2_w )
-{
- struct ym2151_info *token = sndti_token(SOUND_YM2151, 2);
- stream_update(token->stream);
- ym2151_write_reg(token->chip,lastreg2,data);
-}
-
-WRITE8_HANDLER( ym2151_word_0_w )
-{
- if (offset)
- ym2151_data_port_0_w(space,0,data);
+ ym2151_state *token = get_safe_token(device);
+ if (offset & 1)
+ return ym2151_read_status(token->chip);
else
- ym2151_register_port_0_w(space,0,data);
+ return 0xff; /* confirmed on a real YM2151 */
}
-WRITE8_HANDLER( ym2151_word_1_w )
+WRITE8_DEVICE_HANDLER( ym2151_w )
{
- if (offset)
- ym2151_data_port_1_w(space,0,data);
+ ym2151_state *token = get_safe_token(device);
+ if (offset & 1)
+ ym2151_write_reg(token->chip, token->lastreg, data);
else
- ym2151_register_port_1_w(space,0,data);
-}
-
-READ16_HANDLER( ym2151_status_port_0_lsb_r )
-{
- return ym2151_status_port_0_r(space,0);
-}
-
-READ16_HANDLER( ym2151_status_port_1_lsb_r )
-{
- return ym2151_status_port_1_r(space,0);
-}
-
-READ16_HANDLER( ym2151_status_port_2_lsb_r )
-{
- return ym2151_status_port_2_r(space,0);
-}
-
-
-WRITE16_HANDLER( ym2151_register_port_0_lsb_w )
-{
- if (ACCESSING_BITS_0_7)
- ym2151_register_port_0_w(space, 0, data & 0xff);
-}
-
-WRITE16_HANDLER( ym2151_register_port_1_lsb_w )
-{
- if (ACCESSING_BITS_0_7)
- ym2151_register_port_1_w(space, 0, data & 0xff);
+ token->lastreg = data;
}
-WRITE16_HANDLER( ym2151_register_port_2_lsb_w )
-{
- if (ACCESSING_BITS_0_7)
- ym2151_register_port_2_w(space, 0, data & 0xff);
-}
-WRITE16_HANDLER( ym2151_data_port_0_lsb_w )
-{
- if (ACCESSING_BITS_0_7)
- ym2151_data_port_0_w(space, 0, data & 0xff);
-}
+READ8_DEVICE_HANDLER( ym2151_status_port_r ) { return ym2151_r(device, 1); }
-WRITE16_HANDLER( ym2151_data_port_1_lsb_w )
-{
- if (ACCESSING_BITS_0_7)
- ym2151_data_port_1_w(space, 0, data & 0xff);
-}
+WRITE8_DEVICE_HANDLER( ym2151_register_port_w ) { ym2151_w(device, 0, data); }
+WRITE8_DEVICE_HANDLER( ym2151_data_port_w ) { ym2151_w(device, 1, data); }
-WRITE16_HANDLER( ym2151_data_port_2_lsb_w )
-{
- if (ACCESSING_BITS_0_7)
- ym2151_data_port_2_w(space, 0, data & 0xff);
-}
/**************************************************************************
* Generic get_info
**************************************************************************/
-static SND_SET_INFO( ym2151 )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
-SND_GET_INFO( ym2151 )
+DEVICE_GET_INFO( ym2151 )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym2151_info); break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ym2151_state); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( ym2151 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ym2151 ); break;
- case SNDINFO_PTR_STOP: info->stop = SND_STOP_NAME( ym2151 ); break;
- case SNDINFO_PTR_RESET: info->reset = SND_RESET_NAME( ym2151 ); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ym2151 ); break;
+ case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME( ym2151 ); break;
+ case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( ym2151 ); break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "YM2151"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Yamaha FM"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "YM2151"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "Yamaha FM"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}
diff --git a/src/emu/sound/2151intf.h b/src/emu/sound/2151intf.h
index f05bc35ce71..fb9bb6e3f00 100644
--- a/src/emu/sound/2151intf.h
+++ b/src/emu/sound/2151intf.h
@@ -6,40 +6,18 @@
typedef struct _ym2151_interface ym2151_interface;
struct _ym2151_interface
{
- void (*irqhandler)(running_machine *machine, int irq);
- write8_space_func portwritehandler;
+ void (*irqhandler)(const device_config *device, int irq);
+ write8_device_func portwritehandler;
};
-READ8_HANDLER( ym2151_status_port_0_r );
-READ8_HANDLER( ym2151_status_port_1_r );
-READ8_HANDLER( ym2151_status_port_2_r );
+READ8_DEVICE_HANDLER( ym2151_r );
+WRITE8_DEVICE_HANDLER( ym2151_w );
-WRITE8_HANDLER( ym2151_register_port_0_w );
-WRITE8_HANDLER( ym2151_register_port_1_w );
-WRITE8_HANDLER( ym2151_register_port_2_w );
+READ8_DEVICE_HANDLER( ym2151_status_port_r );
+WRITE8_DEVICE_HANDLER( ym2151_register_port_w );
+WRITE8_DEVICE_HANDLER( ym2151_data_port_w );
-WRITE8_HANDLER( ym2151_data_port_0_w );
-WRITE8_HANDLER( ym2151_data_port_1_w );
-WRITE8_HANDLER( ym2151_data_port_2_w );
-
-WRITE8_HANDLER( ym2151_word_0_w );
-WRITE8_HANDLER( ym2151_word_1_w );
-
-READ16_HANDLER( ym2151_status_port_0_lsb_r );
-READ16_HANDLER( ym2151_status_port_1_lsb_r );
-READ16_HANDLER( ym2151_status_port_2_lsb_r );
-
-WRITE16_HANDLER( ym2151_register_port_0_lsb_w );
-WRITE16_HANDLER( ym2151_register_port_1_lsb_w );
-WRITE16_HANDLER( ym2151_register_port_2_lsb_w );
-
-WRITE16_HANDLER( ym2151_data_port_0_lsb_w );
-WRITE16_HANDLER( ym2151_data_port_1_lsb_w );
-WRITE16_HANDLER( ym2151_data_port_2_lsb_w );
-
-SND_GET_INFO( ym2151 );
-#define SOUND_YM2151 SND_GET_INFO_NAME( ym2151 )
+DEVICE_GET_INFO( ym2151 );
+#define SOUND_YM2151 DEVICE_GET_INFO_NAME( ym2151 )
#endif /* __2151INTF_H__ */
-
-
diff --git a/src/emu/sound/2203intf.c b/src/emu/sound/2203intf.c
index 209e9657298..ba3e2074f3e 100644
--- a/src/emu/sound/2203intf.c
+++ b/src/emu/sound/2203intf.c
@@ -5,10 +5,11 @@
#include "fm.h"
-struct ym2203_info
+typedef struct _ym2203_state ym2203_state;
+struct _ym2203_state
{
sound_stream * stream;
- emu_timer * timer[2];
+ emu_timer * timer[2];
void * chip;
void * psg;
const ym2203_interface *intf;
@@ -16,27 +17,37 @@ struct ym2203_info
};
+INLINE ym2203_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_YM2203);
+ return (ym2203_state *)device->token;
+}
+
+
static void psg_set_clock(void *param, int clock)
{
- struct ym2203_info *info = param;
+ ym2203_state *info = param;
ay8910_set_clock_ym(info->psg, clock);
}
static void psg_write(void *param, int address, int data)
{
- struct ym2203_info *info = param;
+ ym2203_state *info = param;
ay8910_write_ym(info->psg, address, data);
}
static int psg_read(void *param)
{
- struct ym2203_info *info = param;
+ ym2203_state *info = param;
return ay8910_read_ym(info->psg);
}
static void psg_reset(void *param)
{
- struct ym2203_info *info = param;
+ ym2203_state *info = param;
ay8910_reset_ym(info->psg);
}
@@ -51,34 +62,35 @@ static const ssg_callbacks psgintf =
/* IRQ Handler */
static void IRQHandler(void *param,int irq)
{
- struct ym2203_info *info = param;
- if(info->intf->handler) info->intf->handler(info->device->machine, irq);
+ ym2203_state *info = param;
+ if (info->intf->handler != NULL)
+ (*info->intf->handler)(info->device, irq);
}
/* Timer overflow callback from timer.c */
static TIMER_CALLBACK( timer_callback_2203_0 )
{
- struct ym2203_info *info = ptr;
+ ym2203_state *info = ptr;
ym2203_timer_over(info->chip,0);
}
static TIMER_CALLBACK( timer_callback_2203_1 )
{
- struct ym2203_info *info = ptr;
+ ym2203_state *info = ptr;
ym2203_timer_over(info->chip,1);
}
/* update request from fm.c */
void ym2203_update_request(void *param)
{
- struct ym2203_info *info = param;
+ ym2203_state *info = param;
stream_update(info->stream);
}
static void timer_handler(void *param,int c,int count,int clock)
{
- struct ym2203_info *info = param;
+ ym2203_state *info = param;
if( count == 0 )
{ /* Reset FM Timer */
timer_enable(info->timer[c], 0);
@@ -93,36 +105,36 @@ static void timer_handler(void *param,int c,int count,int clock)
static STREAM_UPDATE( ym2203_stream_update )
{
- struct ym2203_info *info = param;
+ ym2203_state *info = param;
ym2203_update_one(info->chip, outputs[0], samples);
}
static STATE_POSTLOAD( ym2203_intf_postload )
{
- struct ym2203_info *info = param;
+ ym2203_state *info = param;
ym2203_postload(info->chip);
}
-static SND_START( ym2203 )
+static DEVICE_START( ym2203 )
{
static const ym2203_interface generic_2203 =
{
{
AY8910_LEGACY_OUTPUT,
AY8910_DEFAULT_LOADS,
- NULL, NULL, NULL, NULL
+ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
},
NULL
};
const ym2203_interface *intf = device->static_config ? device->static_config : &generic_2203;
- struct ym2203_info *info = device->token;
- int rate = clock/72; /* ??? */
+ ym2203_state *info = device->token;
+ int rate = device->clock/72; /* ??? */
info->intf = intf;
info->device = device;
- info->psg = ay8910_start_ym(NULL, SOUND_YM2203, device, clock, &intf->ay8910_intf);
+ info->psg = ay8910_start_ym(NULL, SOUND_YM2203, device, device->clock, &intf->ay8910_intf);
assert_always(info->psg != NULL, "Error creating YM2203/AY8910 chip");
/* Timer Handler set */
@@ -133,218 +145,67 @@ static SND_START( ym2203 )
info->stream = stream_create(device,0,1,rate,info,ym2203_stream_update);
/* Initialize FM emurator */
- info->chip = ym2203_init(info,device,clock,rate,timer_handler,IRQHandler,&psgintf);
+ info->chip = ym2203_init(info,device,device->clock,rate,timer_handler,IRQHandler,&psgintf);
assert_always(info->chip != NULL, "Error creating YM2203 chip");
state_save_register_postload(device->machine, ym2203_intf_postload, info);
}
-static SND_STOP( ym2203 )
+static DEVICE_STOP( ym2203 )
{
- struct ym2203_info *info = device->token;
+ ym2203_state *info = device->token;
ym2203_shutdown(info->chip);
ay8910_stop_ym(info->psg);
}
-static SND_RESET( ym2203 )
+static DEVICE_RESET( ym2203 )
{
- struct ym2203_info *info = device->token;
+ ym2203_state *info = device->token;
ym2203_reset_chip(info->chip);
}
-READ8_HANDLER( ym2203_status_port_0_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 0); return ym2203_read(info->chip,0); }
-READ8_HANDLER( ym2203_status_port_1_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 1); return ym2203_read(info->chip,0); }
-READ8_HANDLER( ym2203_status_port_2_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 2); return ym2203_read(info->chip,0); }
-READ8_HANDLER( ym2203_status_port_3_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 3); return ym2203_read(info->chip,0); }
-READ8_HANDLER( ym2203_status_port_4_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 4); return ym2203_read(info->chip,0); }
-
-READ8_HANDLER( ym2203_read_port_0_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 0); return ym2203_read(info->chip,1); }
-READ8_HANDLER( ym2203_read_port_1_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 1); return ym2203_read(info->chip,1); }
-READ8_HANDLER( ym2203_read_port_2_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 2); return ym2203_read(info->chip,1); }
-READ8_HANDLER( ym2203_read_port_3_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 3); return ym2203_read(info->chip,1); }
-READ8_HANDLER( ym2203_read_port_4_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 4); return ym2203_read(info->chip,1); }
-
-WRITE8_HANDLER( ym2203_control_port_0_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 0);
- ym2203_write(info->chip,0,data);
-}
-WRITE8_HANDLER( ym2203_control_port_1_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 1);
- ym2203_write(info->chip,0,data);
-}
-WRITE8_HANDLER( ym2203_control_port_2_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 2);
- ym2203_write(info->chip,0,data);
-}
-WRITE8_HANDLER( ym2203_control_port_3_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 3);
- ym2203_write(info->chip,0,data);
-}
-WRITE8_HANDLER( ym2203_control_port_4_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 4);
- ym2203_write(info->chip,0,data);
-}
-
-WRITE8_HANDLER( ym2203_write_port_0_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 0);
- ym2203_write(info->chip,1,data);
-}
-WRITE8_HANDLER( ym2203_write_port_1_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 1);
- ym2203_write(info->chip,1,data);
-}
-WRITE8_HANDLER( ym2203_write_port_2_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 2);
- ym2203_write(info->chip,1,data);
-}
-WRITE8_HANDLER( ym2203_write_port_3_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 3);
- ym2203_write(info->chip,1,data);
-}
-WRITE8_HANDLER( ym2203_write_port_4_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 4);
- ym2203_write(info->chip,1,data);
-}
-
-
-READ16_HANDLER( ym2203_status_port_0_lsb_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 0); return ym2203_read(info->chip,0) | 0xff00; }
-READ16_HANDLER( ym2203_status_port_1_lsb_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 1); return ym2203_read(info->chip,0) | 0xff00; }
-READ16_HANDLER( ym2203_status_port_2_lsb_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 2); return ym2203_read(info->chip,0) | 0xff00; }
-READ16_HANDLER( ym2203_status_port_3_lsb_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 3); return ym2203_read(info->chip,0) | 0xff00; }
-READ16_HANDLER( ym2203_status_port_4_lsb_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 4); return ym2203_read(info->chip,0) | 0xff00; }
-
-READ16_HANDLER( ym2203_read_port_0_lsb_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 0); return ym2203_read(info->chip,1) | 0xff00; }
-READ16_HANDLER( ym2203_read_port_1_lsb_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 1); return ym2203_read(info->chip,1) | 0xff00; }
-READ16_HANDLER( ym2203_read_port_2_lsb_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 2); return ym2203_read(info->chip,1) | 0xff00; }
-READ16_HANDLER( ym2203_read_port_3_lsb_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 3); return ym2203_read(info->chip,1) | 0xff00; }
-READ16_HANDLER( ym2203_read_port_4_lsb_r ) { struct ym2203_info *info = sndti_token(SOUND_YM2203, 4); return ym2203_read(info->chip,1) | 0xff00; }
-
-WRITE16_HANDLER( ym2203_control_port_0_lsb_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 0);
- if (ACCESSING_BITS_0_7)
- ym2203_write(info->chip,0,data);
-}
-WRITE16_HANDLER( ym2203_control_port_1_lsb_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 1);
- if (ACCESSING_BITS_0_7)
- ym2203_write(info->chip,0,data);
-}
-WRITE16_HANDLER( ym2203_control_port_2_lsb_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 2);
- if (ACCESSING_BITS_0_7)
- ym2203_write(info->chip,0,data);
-}
-WRITE16_HANDLER( ym2203_control_port_3_lsb_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 3);
- if (ACCESSING_BITS_0_7)
- ym2203_write(info->chip,0,data);
-}
-WRITE16_HANDLER( ym2203_control_port_4_lsb_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 4);
- if (ACCESSING_BITS_0_7)
- ym2203_write(info->chip,0,data);
-}
-
-WRITE16_HANDLER( ym2203_write_port_0_lsb_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 0);
- if (ACCESSING_BITS_0_7)
- ym2203_write(info->chip,1,data);
-}
-WRITE16_HANDLER( ym2203_write_port_1_lsb_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 1);
- if (ACCESSING_BITS_0_7)
- ym2203_write(info->chip,1,data);
-}
-WRITE16_HANDLER( ym2203_write_port_2_lsb_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 2);
- if (ACCESSING_BITS_0_7)
- ym2203_write(info->chip,1,data);
-}
-WRITE16_HANDLER( ym2203_write_port_3_lsb_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 3);
- if (ACCESSING_BITS_0_7)
- ym2203_write(info->chip,1,data);
-}
-WRITE16_HANDLER( ym2203_write_port_4_lsb_w )
-{
- struct ym2203_info *info = sndti_token(SOUND_YM2203, 4);
- if (ACCESSING_BITS_0_7)
- ym2203_write(info->chip,1,data);
-}
-
-
-WRITE8_HANDLER( ym2203_word_0_w )
+READ8_DEVICE_HANDLER( ym2203_r )
{
- if (offset)
- ym2203_write_port_0_w(space,0,data);
- else
- ym2203_control_port_0_w(space,0,data);
+ ym2203_state *info = get_safe_token(device);
+ return ym2203_read(info->chip, offset & 1);
}
-WRITE8_HANDLER( ym2203_word_1_w )
+WRITE8_DEVICE_HANDLER( ym2203_w )
{
- if (offset)
- ym2203_write_port_1_w(space,0,data);
- else
- ym2203_control_port_1_w(space,0,data);
+ ym2203_state *info = get_safe_token(device);
+ ym2203_write(info->chip, offset & 1, data);
}
-
+READ8_DEVICE_HANDLER( ym2203_status_port_r ) { return ym2203_r(device, 0); }
+READ8_DEVICE_HANDLER( ym2203_read_port_r ) { return ym2203_r(device, 1); }
+WRITE8_DEVICE_HANDLER( ym2203_control_port_w ) { ym2203_w(device, 0, data); }
+WRITE8_DEVICE_HANDLER( ym2203_write_port_w ) { ym2203_w(device, 1, data); }
/**************************************************************************
* Generic get_info
**************************************************************************/
-static SND_SET_INFO( ym2203 )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
-SND_GET_INFO( ym2203 )
+DEVICE_GET_INFO( ym2203 )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym2203_info); break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ym2203_state); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( ym2203 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ym2203 ); break;
- case SNDINFO_PTR_STOP: info->stop = SND_STOP_NAME( ym2203 ); break;
- case SNDINFO_PTR_RESET: info->reset = SND_RESET_NAME( ym2203 ); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ym2203 ); break;
+ case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME( ym2203 ); break;
+ case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( ym2203 ); break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "YM2203"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Yamaha FM"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "YM2203"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "Yamaha FM"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}
diff --git a/src/emu/sound/2203intf.h b/src/emu/sound/2203intf.h
index cd34a9cde26..48d64ad1a06 100644
--- a/src/emu/sound/2203intf.h
+++ b/src/emu/sound/2203intf.h
@@ -11,62 +11,18 @@ typedef struct _ym2203_interface ym2203_interface;
struct _ym2203_interface
{
const ay8910_interface ay8910_intf;
- void (*handler)(running_machine *machine, int irq);
+ void (*handler)(const device_config *device, int irq);
};
+READ8_DEVICE_HANDLER( ym2203_r );
+WRITE8_DEVICE_HANDLER( ym2203_w );
-READ8_HANDLER( ym2203_status_port_0_r );
-READ8_HANDLER( ym2203_status_port_1_r );
-READ8_HANDLER( ym2203_status_port_2_r );
-READ8_HANDLER( ym2203_status_port_3_r );
-READ8_HANDLER( ym2203_status_port_4_r );
+READ8_DEVICE_HANDLER( ym2203_status_port_r );
+READ8_DEVICE_HANDLER( ym2203_read_port_r );
+WRITE8_DEVICE_HANDLER( ym2203_control_port_w );
+WRITE8_DEVICE_HANDLER( ym2203_write_port_w );
-READ8_HANDLER( ym2203_read_port_0_r );
-READ8_HANDLER( ym2203_read_port_1_r );
-READ8_HANDLER( ym2203_read_port_2_r );
-READ8_HANDLER( ym2203_read_port_3_r );
-READ8_HANDLER( ym2203_read_port_4_r );
-
-WRITE8_HANDLER( ym2203_control_port_0_w );
-WRITE8_HANDLER( ym2203_control_port_1_w );
-WRITE8_HANDLER( ym2203_control_port_2_w );
-WRITE8_HANDLER( ym2203_control_port_3_w );
-WRITE8_HANDLER( ym2203_control_port_4_w );
-
-WRITE8_HANDLER( ym2203_write_port_0_w );
-WRITE8_HANDLER( ym2203_write_port_1_w );
-WRITE8_HANDLER( ym2203_write_port_2_w );
-WRITE8_HANDLER( ym2203_write_port_3_w );
-WRITE8_HANDLER( ym2203_write_port_4_w );
-
-READ16_HANDLER( ym2203_status_port_0_lsb_r );
-READ16_HANDLER( ym2203_status_port_1_lsb_r );
-READ16_HANDLER( ym2203_status_port_2_lsb_r );
-READ16_HANDLER( ym2203_status_port_3_lsb_r );
-READ16_HANDLER( ym2203_status_port_4_lsb_r );
-
-READ16_HANDLER( ym2203_read_port_0_lsb_r );
-READ16_HANDLER( ym2203_read_port_1_lsb_r );
-READ16_HANDLER( ym2203_read_port_2_lsb_r );
-READ16_HANDLER( ym2203_read_port_3_lsb_r );
-READ16_HANDLER( ym2203_read_port_4_lsb_r );
-
-WRITE16_HANDLER( ym2203_control_port_0_lsb_w );
-WRITE16_HANDLER( ym2203_control_port_1_lsb_w );
-WRITE16_HANDLER( ym2203_control_port_2_lsb_w );
-WRITE16_HANDLER( ym2203_control_port_3_lsb_w );
-WRITE16_HANDLER( ym2203_control_port_4_lsb_w );
-
-WRITE16_HANDLER( ym2203_write_port_0_lsb_w );
-WRITE16_HANDLER( ym2203_write_port_1_lsb_w );
-WRITE16_HANDLER( ym2203_write_port_2_lsb_w );
-WRITE16_HANDLER( ym2203_write_port_3_lsb_w );
-WRITE16_HANDLER( ym2203_write_port_4_lsb_w );
-
-WRITE8_HANDLER( ym2203_word_0_w );
-WRITE8_HANDLER( ym2203_word_1_w );
-
-SND_GET_INFO( ym2203 );
-#define SOUND_YM2203 SND_GET_INFO_NAME( ym2203 )
+DEVICE_GET_INFO( ym2203 );
+#define SOUND_YM2203 DEVICE_GET_INFO_NAME( ym2203 )
#endif /* __2203INTF_H__ */
diff --git a/src/emu/sound/2413intf.c b/src/emu/sound/2413intf.c
index 7d8b634b9c8..4f274bc6c45 100644
--- a/src/emu/sound/2413intf.c
+++ b/src/emu/sound/2413intf.c
@@ -9,19 +9,26 @@
#include "ym2413.h"
#include "2413intf.h"
-//#define YM2413ISA
-#ifdef YM2413ISA
- #include <pc.h>
-#endif
-
/* for stream system */
-struct ym2413_info
+typedef struct _ym2413_state ym2413_state;
+struct _ym2413_state
{
sound_stream * stream;
void * chip;
};
+
+INLINE ym2413_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_YM2413);
+ return (ym2413_state *)device->token;
+}
+
+
#ifdef UNUSED_FUNCTION
void YM2413DAC_update(int chip,stream_sample_t **inputs, stream_sample_t **_buffer,int length)
{
@@ -38,23 +45,23 @@ void YM2413DAC_update(int chip,stream_sample_t **inputs, stream_sample_t **_buff
static STREAM_UPDATE( ym2413_stream_update )
{
- struct ym2413_info *info = param;
+ ym2413_state *info = param;
ym2413_update_one(info->chip, outputs, samples);
}
static void _stream_update(void *param, int interval)
{
- struct ym2413_info *info = param;
+ ym2413_state *info = param;
stream_update(info->stream);
}
-static SND_START( ym2413 )
+static DEVICE_START( ym2413 )
{
- int rate = clock/72;
- struct ym2413_info *info = device->token;
+ ym2413_state *info = get_safe_token(device);
+ int rate = device->clock/72;
/* emulator create */
- info->chip = ym2413_init(device, clock, rate);
+ info->chip = ym2413_init(device, device->clock, rate);
assert_always(info->chip != NULL, "Error creating YM2413 chip");
/* stream system initialize */
@@ -79,7 +86,7 @@ static SND_START( ym2413 )
{
ym2413_reset (i);
- ym2413[i].DAC_stream = stream_create(device, 0, 1, clock/72, i, YM2413DAC_update);
+ ym2413[i].DAC_stream = stream_create(device, 0, 1, device->clock/72, i, YM2413DAC_update);
if (ym2413[i].DAC_stream == -1)
return 1;
@@ -89,93 +96,50 @@ static SND_START( ym2413 )
}
-static SND_STOP( ym2413 )
+static DEVICE_STOP( ym2413 )
{
- struct ym2413_info *info = device->token;
+ ym2413_state *info = get_safe_token(device);
ym2413_shutdown(info->chip);
}
-static SND_RESET( ym2413 )
+static DEVICE_RESET( ym2413 )
{
- struct ym2413_info *info = device->token;
+ ym2413_state *info = get_safe_token(device);
ym2413_reset_chip(info->chip);
}
-#ifdef YM2413ISA
-WRITE8_HANDLER( ym2413_register_port_0_w ) {
-int i,a;
- outportb(0x308,data); // ym2413_write (0, 0, data);
- //add delay
- for (i=0; i<0x20; i++)
- a = inportb(0x80);
+WRITE8_DEVICE_HANDLER( ym2413_w )
+{
+ ym2413_state *info = get_safe_token(device);
+ ym2413_write(info->chip, offset & 1, data);
+}
- } /* 1st chip */
-#else
-WRITE8_HANDLER( ym2413_register_port_0_w ) { struct ym2413_info *info = sndti_token(SOUND_YM2413, 0); ym2413_write (info->chip, 0, data); } /* 1st chip */
-#endif
-WRITE8_HANDLER( ym2413_register_port_1_w ) { struct ym2413_info *info = sndti_token(SOUND_YM2413, 1); ym2413_write (info->chip, 0, data); } /* 2nd chip */
-WRITE8_HANDLER( ym2413_register_port_2_w ) { struct ym2413_info *info = sndti_token(SOUND_YM2413, 2); ym2413_write (info->chip, 0, data); } /* 3rd chip */
-WRITE8_HANDLER( ym2413_register_port_3_w ) { struct ym2413_info *info = sndti_token(SOUND_YM2413, 3); ym2413_write (info->chip, 0, data); } /* 4th chip */
-
-#ifdef YM2413ISA
-WRITE8_HANDLER( ym2413_data_port_0_w ) {
-int i,a;
- outportb(0x309,data);// ym2413_write (sndti_token(SOUND_YM2413, 0), 1, data);
- //add delay
- for (i=0; i<0x40; i++)
- a = inportb(0x80);
- } /* 1st chip */
-#else
-WRITE8_HANDLER( ym2413_data_port_0_w ) { struct ym2413_info *info = sndti_token(SOUND_YM2413, 0); ym2413_write (info->chip, 1, data); } /* 1st chip */
-#endif
-WRITE8_HANDLER( ym2413_data_port_1_w ) { struct ym2413_info *info = sndti_token(SOUND_YM2413, 1); ym2413_write (info->chip, 1, data); } /* 2nd chip */
-WRITE8_HANDLER( ym2413_data_port_2_w ) { struct ym2413_info *info = sndti_token(SOUND_YM2413, 2); ym2413_write (info->chip, 1, data); } /* 3rd chip */
-WRITE8_HANDLER( ym2413_data_port_3_w ) { struct ym2413_info *info = sndti_token(SOUND_YM2413, 3); ym2413_write (info->chip, 1, data); } /* 4th chip */
-
-WRITE16_HANDLER( ym2413_register_port_0_lsb_w ) { if (ACCESSING_BITS_0_7) ym2413_register_port_0_w(space,offset,data & 0xff); }
-WRITE16_HANDLER( ym2413_register_port_0_msb_w ) { if (ACCESSING_BITS_8_15) ym2413_register_port_0_w(space,offset,((data & 0xff00) >> 8)); }
-WRITE16_HANDLER( ym2413_register_port_1_lsb_w ) { if (ACCESSING_BITS_0_7) ym2413_register_port_1_w(space,offset,data & 0xff); }
-WRITE16_HANDLER( ym2413_register_port_2_lsb_w ) { if (ACCESSING_BITS_0_7) ym2413_register_port_2_w(space,offset,data & 0xff); }
-WRITE16_HANDLER( ym2413_register_port_3_lsb_w ) { if (ACCESSING_BITS_0_7) ym2413_register_port_3_w(space,offset,data & 0xff); }
-WRITE16_HANDLER( ym2413_data_port_0_lsb_w ) { if (ACCESSING_BITS_0_7) ym2413_data_port_0_w(space,offset,data & 0xff); }
-WRITE16_HANDLER( ym2413_data_port_0_msb_w ) { if (ACCESSING_BITS_8_15) ym2413_data_port_0_w(space,offset,((data & 0xff00) >> 8)); }
-WRITE16_HANDLER( ym2413_data_port_1_lsb_w ) { if (ACCESSING_BITS_0_7) ym2413_data_port_1_w(space,offset,data & 0xff); }
-WRITE16_HANDLER( ym2413_data_port_2_lsb_w ) { if (ACCESSING_BITS_0_7) ym2413_data_port_2_w(space,offset,data & 0xff); }
-WRITE16_HANDLER( ym2413_data_port_3_lsb_w ) { if (ACCESSING_BITS_0_7) ym2413_data_port_3_w(space,offset,data & 0xff); }
+WRITE8_DEVICE_HANDLER( ym2413_register_port_w ) { ym2413_w(device, 0, data); }
+WRITE8_DEVICE_HANDLER( ym2413_data_port_w ) { ym2413_w(device, 1, data); }
/**************************************************************************
* Generic get_info
**************************************************************************/
-static SND_SET_INFO( ym2413 )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
-SND_GET_INFO( ym2413 )
+DEVICE_GET_INFO( ym2413 )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym2413_info); break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ym2413_state); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( ym2413 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ym2413 ); break;
- case SNDINFO_PTR_STOP: info->stop = SND_STOP_NAME( ym2413 ); break;
- case SNDINFO_PTR_RESET: info->reset = SND_RESET_NAME( ym2413 ); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ym2413 ); break;
+ case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME( ym2413 ); break;
+ case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( ym2413 ); break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "YM2413"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Yamaha FM"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "YM2413"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "Yamaha FM"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}
diff --git a/src/emu/sound/2413intf.h b/src/emu/sound/2413intf.h
index d63be022024..80154e52042 100644
--- a/src/emu/sound/2413intf.h
+++ b/src/emu/sound/2413intf.h
@@ -3,28 +3,12 @@
#ifndef __2413INTF_H__
#define __2413INTF_H__
+WRITE8_DEVICE_HANDLER( ym2413_w );
-WRITE8_HANDLER( ym2413_register_port_0_w );
-WRITE8_HANDLER( ym2413_register_port_1_w );
-WRITE8_HANDLER( ym2413_register_port_2_w );
-WRITE8_HANDLER( ym2413_register_port_3_w );
-WRITE8_HANDLER( ym2413_data_port_0_w );
-WRITE8_HANDLER( ym2413_data_port_1_w );
-WRITE8_HANDLER( ym2413_data_port_2_w );
-WRITE8_HANDLER( ym2413_data_port_3_w );
+WRITE8_DEVICE_HANDLER( ym2413_register_port_w );
+WRITE8_DEVICE_HANDLER( ym2413_data_port_w );
-WRITE16_HANDLER( ym2413_register_port_0_lsb_w );
-WRITE16_HANDLER( ym2413_register_port_0_msb_w );
-WRITE16_HANDLER( ym2413_register_port_1_lsb_w );
-WRITE16_HANDLER( ym2413_register_port_2_lsb_w );
-WRITE16_HANDLER( ym2413_register_port_3_lsb_w );
-WRITE16_HANDLER( ym2413_data_port_0_lsb_w );
-WRITE16_HANDLER( ym2413_data_port_0_msb_w );
-WRITE16_HANDLER( ym2413_data_port_1_lsb_w );
-WRITE16_HANDLER( ym2413_data_port_2_lsb_w );
-WRITE16_HANDLER( ym2413_data_port_3_lsb_w );
-
-SND_GET_INFO( ym2413 );
-#define SOUND_YM2413 SND_GET_INFO_NAME( ym2413 )
+DEVICE_GET_INFO( ym2413 );
+#define SOUND_YM2413 DEVICE_GET_INFO_NAME( ym2413 )
#endif /* __2413INTF_H__ */
diff --git a/src/emu/sound/2608intf.c b/src/emu/sound/2608intf.c
index 517f2f060db..712787118ac 100644
--- a/src/emu/sound/2608intf.c
+++ b/src/emu/sound/2608intf.c
@@ -17,7 +17,8 @@
#include "2608intf.h"
#include "fm.h"
-struct ym2608_info
+typedef struct _ym2608_state ym2608_state;
+struct _ym2608_state
{
sound_stream * stream;
emu_timer * timer[2];
@@ -28,28 +29,38 @@ struct ym2608_info
};
+INLINE ym2608_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_YM2608);
+ return (ym2608_state *)device->token;
+}
+
+
static void psg_set_clock(void *param, int clock)
{
- struct ym2608_info *info = param;
+ ym2608_state *info = param;
ay8910_set_clock_ym(info->psg, clock);
}
static void psg_write(void *param, int address, int data)
{
- struct ym2608_info *info = param;
+ ym2608_state *info = param;
ay8910_write_ym(info->psg, address, data);
}
static int psg_read(void *param)
{
- struct ym2608_info *info = param;
+ ym2608_state *info = param;
return ay8910_read_ym(info->psg);
}
static void psg_reset(void *param)
{
- struct ym2608_info *info = param;
+ ym2608_state *info = param;
ay8910_reset_ym(info->psg);
}
@@ -65,26 +76,26 @@ static const ssg_callbacks psgintf =
/* IRQ Handler */
static void IRQHandler(void *param,int irq)
{
- struct ym2608_info *info = param;
- if(info->intf->handler) info->intf->handler(info->device->machine, irq);
+ ym2608_state *info = param;
+ if(info->intf->handler) info->intf->handler(info->device, irq);
}
/* Timer overflow callback from timer.c */
static TIMER_CALLBACK( timer_callback_2608_0 )
{
- struct ym2608_info *info = ptr;
+ ym2608_state *info = ptr;
ym2608_timer_over(info->chip,0);
}
static TIMER_CALLBACK( timer_callback_2608_1 )
{
- struct ym2608_info *info = ptr;
+ ym2608_state *info = ptr;
ym2608_timer_over(info->chip,1);
}
static void timer_handler(void *param,int c,int count,int clock)
{
- struct ym2608_info *info = param;
+ ym2608_state *info = param;
if( count == 0 )
{ /* Reset FM Timer */
timer_enable(info->timer[c], 0);
@@ -100,47 +111,47 @@ static void timer_handler(void *param,int c,int count,int clock)
/* update request from fm.c */
void ym2608_update_request(void *param)
{
- struct ym2608_info *info = param;
+ ym2608_state *info = param;
stream_update(info->stream);
}
static STREAM_UPDATE( ym2608_stream_update )
{
- struct ym2608_info *info = param;
+ ym2608_state *info = param;
ym2608_update_one(info->chip, outputs, samples);
}
static STATE_POSTLOAD( ym2608_intf_postload )
{
- struct ym2608_info *info = param;
+ ym2608_state *info = param;
ym2608_postload(info->chip);
}
-static SND_START( ym2608 )
+static DEVICE_START( ym2608 )
{
static const ym2608_interface generic_2608 =
{
{
AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
AY8910_DEFAULT_LOADS,
- NULL, NULL, NULL, NULL
+ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
},
NULL
};
const ym2608_interface *intf = device->static_config ? device->static_config : &generic_2608;
- int rate = clock/72;
+ int rate = device->clock/72;
void *pcmbufa;
int pcmsizea;
- struct ym2608_info *info = device->token;
+ ym2608_state *info = get_safe_token(device);
info->intf = intf;
info->device = device;
/* FIXME: Force to use simgle output */
- info->psg = ay8910_start_ym(NULL, SOUND_YM2608, device, clock, &intf->ay8910_intf);
+ info->psg = ay8910_start_ym(NULL, SOUND_YM2608, device, device->clock, &intf->ay8910_intf);
assert_always(info->psg != NULL, "Error creating YM2608/AY8910 chip");
/* Timer Handler set */
@@ -154,7 +165,7 @@ static SND_START( ym2608 )
pcmsizea = device->regionbytes;
/* initialize YM2608 */
- info->chip = ym2608_init(info,device,clock,rate,
+ info->chip = ym2608_init(info,device,device->clock,rate,
pcmbufa,pcmsizea,
timer_handler,IRQHandler,&psgintf);
assert_always(info->chip != NULL, "Error creating YM2608 chip");
@@ -162,158 +173,64 @@ static SND_START( ym2608 )
state_save_register_postload(device->machine, ym2608_intf_postload, info);
}
-static SND_STOP( ym2608 )
+static DEVICE_STOP( ym2608 )
{
- struct ym2608_info *info = device->token;
+ ym2608_state *info = get_safe_token(device);
ym2608_shutdown(info->chip);
ay8910_stop_ym(info->psg);
}
-static SND_RESET( ym2608 )
+static DEVICE_RESET( ym2608 )
{
- struct ym2608_info *info = device->token;
+ ym2608_state *info = get_safe_token(device);
ym2608_reset_chip(info->chip);
}
-/************************************************/
-/* Status Read for YM2608 - Chip 0 */
-/************************************************/
-READ8_HANDLER( ym2608_status_port_0_a_r )
-{
-//logerror("PC %04x: 2608 S0A=%02X\n",cpu_get_pc(space->cpu),ym2608_read(sndti_token(SOUND_YM2608, 0),0));
- struct ym2608_info *info = sndti_token(SOUND_YM2608, 0);
- return ym2608_read(info->chip,0);
-}
-READ8_HANDLER( ym2608_status_port_0_b_r )
+READ8_DEVICE_HANDLER( ym2608_r )
{
-//logerror("PC %04x: 2608 S0B=%02X\n",cpu_get_pc(space->cpu),ym2608_read(sndti_token(SOUND_YM2608, 0),2));
- struct ym2608_info *info = sndti_token(SOUND_YM2608, 0);
- return ym2608_read(info->chip,2);
-}
-
-/************************************************/
-/* Status Read for YM2608 - Chip 1 */
-/************************************************/
-READ8_HANDLER( ym2608_status_port_1_a_r ) {
- struct ym2608_info *info = sndti_token(SOUND_YM2608, 1);
- return ym2608_read(info->chip,0);
-}
-
-READ8_HANDLER( ym2608_status_port_1_b_r ) {
- struct ym2608_info *info = sndti_token(SOUND_YM2608, 1);
- return ym2608_read(info->chip,2);
-}
-
-/************************************************/
-/* Port Read for YM2608 - Chip 0 */
-/************************************************/
-READ8_HANDLER( ym2608_read_port_0_r ){
- struct ym2608_info *info = sndti_token(SOUND_YM2608, 0);
- return ym2608_read(info->chip,1);
-}
-
-/************************************************/
-/* Port Read for YM2608 - Chip 1 */
-/************************************************/
-READ8_HANDLER( ym2608_read_port_1_r ){
- struct ym2608_info *info = sndti_token(SOUND_YM2608, 1);
- return ym2608_read(info->chip,1);
+ ym2608_state *info = get_safe_token(device);
+ return ym2608_read(info->chip, offset & 3);
}
-/************************************************/
-/* Control Write for YM2608 - Chip 0 */
-/* Consists of 2 addresses */
-/************************************************/
-WRITE8_HANDLER( ym2608_control_port_0_a_w )
+WRITE8_DEVICE_HANDLER( ym2608_w )
{
- struct ym2608_info *info = sndti_token(SOUND_YM2608, 0);
- ym2608_write(info->chip,0,data);
+ ym2608_state *info = get_safe_token(device);
+ ym2608_write(info->chip, offset & 3, data);
}
-WRITE8_HANDLER( ym2608_control_port_0_b_w )
-{
- struct ym2608_info *info = sndti_token(SOUND_YM2608, 0);
- ym2608_write(info->chip,2,data);
-}
+READ8_DEVICE_HANDLER( ym2608_read_port_r ) { return ym2608_r(device, 1); }
+READ8_DEVICE_HANDLER( ym2608_status_port_a_r ) { return ym2608_r(device, 0); }
+READ8_DEVICE_HANDLER( ym2608_status_port_b_r ) { return ym2608_r(device, 2); }
-/************************************************/
-/* Control Write for YM2608 - Chip 1 */
-/* Consists of 2 addresses */
-/************************************************/
-WRITE8_HANDLER( ym2608_control_port_1_a_w ){
- struct ym2608_info *info = sndti_token(SOUND_YM2608, 1);
- ym2608_write(info->chip,0,data);
-}
+WRITE8_DEVICE_HANDLER( ym2608_control_port_a_w ) { ym2608_w(device, 0, data); }
+WRITE8_DEVICE_HANDLER( ym2608_control_port_b_w ) { ym2608_w(device, 2, data); }
+WRITE8_DEVICE_HANDLER( ym2608_data_port_a_w ) { ym2608_w(device, 1, data); }
+WRITE8_DEVICE_HANDLER( ym2608_data_port_b_w ) { ym2608_w(device, 3, data); }
-WRITE8_HANDLER( ym2608_control_port_1_b_w ){
- struct ym2608_info *info = sndti_token(SOUND_YM2608, 1);
- ym2608_write(info->chip,2,data);
-}
-
-/************************************************/
-/* Data Write for YM2608 - Chip 0 */
-/* Consists of 2 addresses */
-/************************************************/
-WRITE8_HANDLER( ym2608_data_port_0_a_w )
-{
- struct ym2608_info *info = sndti_token(SOUND_YM2608, 0);
- ym2608_write(info->chip,1,data);
-}
-
-WRITE8_HANDLER( ym2608_data_port_0_b_w )
-{
- struct ym2608_info *info = sndti_token(SOUND_YM2608, 0);
- ym2608_write(info->chip,3,data);
-}
-
-/************************************************/
-/* Data Write for YM2608 - Chip 1 */
-/* Consists of 2 addresses */
-/************************************************/
-WRITE8_HANDLER( ym2608_data_port_1_a_w ){
- struct ym2608_info *info = sndti_token(SOUND_YM2608, 1);
- ym2608_write(info->chip,1,data);
-}
-WRITE8_HANDLER( ym2608_data_port_1_b_w ){
- struct ym2608_info *info = sndti_token(SOUND_YM2608, 1);
- ym2608_write(info->chip,3,data);
-}
-
-/**************** end of file ****************/
/**************************************************************************
* Generic get_info
**************************************************************************/
-static SND_SET_INFO( ym2608 )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
-SND_GET_INFO( ym2608 )
+DEVICE_GET_INFO( ym2608 )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym2608_info); break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ym2608_state); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( ym2608 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ym2608 ); break;
- case SNDINFO_PTR_STOP: info->stop = SND_STOP_NAME( ym2608 ); break;
- case SNDINFO_PTR_RESET: info->reset = SND_RESET_NAME( ym2608 ); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ym2608 ); break;
+ case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME( ym2608 ); break;
+ case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( ym2608 ); break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "YM2608"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Yamaha FM"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "YM2608"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "Yamaha FM"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}
diff --git a/src/emu/sound/2608intf.h b/src/emu/sound/2608intf.h
index b3a9b8ec3f6..f541742c068 100644
--- a/src/emu/sound/2608intf.h
+++ b/src/emu/sound/2608intf.h
@@ -12,32 +12,22 @@ typedef struct _ym2608_interface ym2608_interface;
struct _ym2608_interface
{
const ay8910_interface ay8910_intf;
- void ( *handler )( running_machine *machine, int irq ); /* IRQ handler for the YM2608 */
+ void ( *handler )( const device_config *device, int irq ); /* IRQ handler for the YM2608 */
};
-/************************************************/
-/* Chip 0 functions */
-/************************************************/
-READ8_HANDLER( ym2608_status_port_0_a_r );
-READ8_HANDLER( ym2608_status_port_0_b_r );
-READ8_HANDLER( ym2608_read_port_0_r );
-WRITE8_HANDLER( ym2608_control_port_0_a_w );
-WRITE8_HANDLER( ym2608_control_port_0_b_w );
-WRITE8_HANDLER( ym2608_data_port_0_a_w );
-WRITE8_HANDLER( ym2608_data_port_0_b_w );
-
-/************************************************/
-/* Chip 1 functions */
-/************************************************/
-READ8_HANDLER( ym2608_status_port_1_a_r );
-READ8_HANDLER( ym2608_status_port_1_b_r );
-READ8_HANDLER( ym2608_read_port_1_r );
-WRITE8_HANDLER( ym2608_control_port_1_a_w );
-WRITE8_HANDLER( ym2608_control_port_1_b_w );
-WRITE8_HANDLER( ym2608_data_port_1_a_w );
-WRITE8_HANDLER( ym2608_data_port_1_b_w );
-
-SND_GET_INFO( ym2608 );
-#define SOUND_YM2608 SND_GET_INFO_NAME( ym2608 )
+READ8_DEVICE_HANDLER( ym2608_r );
+WRITE8_DEVICE_HANDLER( ym2608_w );
+
+READ8_DEVICE_HANDLER( ym2608_read_port_r );
+READ8_DEVICE_HANDLER( ym2608_status_port_a_r );
+READ8_DEVICE_HANDLER( ym2608_status_port_b_r );
+
+WRITE8_DEVICE_HANDLER( ym2608_control_port_a_w );
+WRITE8_DEVICE_HANDLER( ym2608_control_port_b_w );
+WRITE8_DEVICE_HANDLER( ym2608_data_port_a_w );
+WRITE8_DEVICE_HANDLER( ym2608_data_port_b_w );
+
+DEVICE_GET_INFO( ym2608 );
+#define SOUND_YM2608 DEVICE_GET_INFO_NAME( ym2608 )
#endif /* __2608INTF_H__ */
diff --git a/src/emu/sound/2610intf.c b/src/emu/sound/2610intf.c
index 3c515449ae0..e6c8804d488 100644
--- a/src/emu/sound/2610intf.c
+++ b/src/emu/sound/2610intf.c
@@ -17,11 +17,11 @@
#include "2610intf.h"
#include "fm.h"
-static sound_type chip_type = SOUND_YM2610;
-struct ym2610_info
+typedef struct _ym2610_state ym2610_state;
+struct _ym2610_state
{
sound_stream * stream;
- emu_timer * timer[2];
+ emu_timer * timer[2];
void * chip;
void * psg;
const ym2610_interface *intf;
@@ -29,27 +29,37 @@ struct ym2610_info
};
+INLINE ym2610_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_YM2610 || sound_get_type(device) == SOUND_YM2610B);
+ return (ym2610_state *)device->token;
+}
+
+
static void psg_set_clock(void *param, int clock)
{
- struct ym2610_info *info = param;
+ ym2610_state *info = param;
ay8910_set_clock_ym(info->psg, clock);
}
static void psg_write(void *param, int address, int data)
{
- struct ym2610_info *info = param;
+ ym2610_state *info = param;
ay8910_write_ym(info->psg, address, data);
}
static int psg_read(void *param)
{
- struct ym2610_info *info = param;
+ ym2610_state *info = param;
return ay8910_read_ym(info->psg);
}
static void psg_reset(void *param)
{
- struct ym2610_info *info = param;
+ ym2610_state *info = param;
ay8910_reset_ym(info->psg);
}
@@ -65,26 +75,26 @@ static const ssg_callbacks psgintf =
/* IRQ Handler */
static void IRQHandler(void *param,int irq)
{
- struct ym2610_info *info = param;
- if(info->intf->handler) info->intf->handler(info->device->machine, irq);
+ ym2610_state *info = param;
+ if(info->intf->handler) info->intf->handler(info->device, irq);
}
/* Timer overflow callback from timer.c */
static TIMER_CALLBACK( timer_callback_0 )
{
- struct ym2610_info *info = ptr;
+ ym2610_state *info = ptr;
ym2610_timer_over(info->chip,0);
}
static TIMER_CALLBACK( timer_callback_1 )
{
- struct ym2610_info *info = ptr;
+ ym2610_state *info = ptr;
ym2610_timer_over(info->chip,1);
}
static void timer_handler(void *param,int c,int count,int clock)
{
- struct ym2610_info *info = param;
+ ym2610_state *info = param;
if( count == 0 )
{ /* Reset FM Timer */
timer_enable(info->timer[c], 0);
@@ -101,46 +111,51 @@ static void timer_handler(void *param,int c,int count,int clock)
/* update request from fm.c */
void ym2610_update_request(void *param)
{
- struct ym2610_info *info = param;
+ ym2610_state *info = param;
stream_update(info->stream);
}
-#if BUILD_YM2610
+
static STREAM_UPDATE( ym2610_stream_update )
{
- struct ym2610_info *info = param;
+ ym2610_state *info = param;
ym2610_update_one(info->chip, outputs, samples);
}
+static STREAM_UPDATE( ym2610b_stream_update )
+{
+ ym2610_state *info = param;
+ ym2610b_update_one(info->chip, outputs, samples);
+}
+
static STATE_POSTLOAD( ym2610_intf_postload )
{
- struct ym2610_info *info = param;
+ ym2610_state *info = param;
ym2610_postload(info->chip);
}
-static SND_START( ym2610 )
+static DEVICE_START( ym2610 )
{
static const ym2610_interface generic_2610 = { 0 };
static const ay8910_interface generic_ay8910 =
{
AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
AY8910_DEFAULT_LOADS,
- NULL, NULL, NULL, NULL
+ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
};
const ym2610_interface *intf = device->static_config ? device->static_config : &generic_2610;
- int rate = clock/72;
+ int rate = device->clock/72;
void *pcmbufa,*pcmbufb;
int pcmsizea,pcmsizeb;
- struct ym2610_info *info = device->token;
+ ym2610_state *info = get_safe_token(device);
astring *name = astring_alloc();
-
- chip_type = SOUND_YM2610;
+ sound_type type = sound_get_type(device);
info->intf = intf;
info->device = device;
- info->psg = ay8910_start_ym(NULL, SOUND_YM2610, device, clock, &generic_ay8910);
+ info->psg = ay8910_start_ym(NULL, sound_get_type(device), device, device->clock, &generic_ay8910);
assert_always(info->psg != NULL, "Error creating YM2610/AY8910 chip");
/* Timer Handler set */
@@ -148,7 +163,7 @@ static SND_START( ym2610 )
info->timer[1] = timer_alloc(device->machine, timer_callback_1, info);
/* stream system initialize */
- info->stream = stream_create(device,0,2,rate,info,ym2610_stream_update);
+ info->stream = stream_create(device,0,2,rate,info,(type == SOUND_YM2610) ? ym2610_stream_update : ym2610b_stream_update);
/* setup adpcm buffers */
pcmbufa = device->region;
pcmsizea = device->regionbytes;
@@ -163,376 +178,84 @@ static SND_START( ym2610 )
}
/**** initialize YM2610 ****/
- info->chip = ym2610_init(info,device,clock,rate,
+ info->chip = ym2610_init(info,device,device->clock,rate,
pcmbufa,pcmsizea,pcmbufb,pcmsizeb,
timer_handler,IRQHandler,&psgintf);
assert_always(info->chip != NULL, "Error creating YM2610 chip");
state_save_register_postload(device->machine, ym2610_intf_postload, info);
}
-#endif
-
-#if BUILD_YM2610B
-static STREAM_UPDATE( ym2610b_stream_update )
-{
- struct ym2610_info *info = param;
- ym2610b_update_one(info->chip, outputs, samples);
-}
-
-static SND_START( ym2610b )
-{
- static const ym2610_interface generic_2610 = { 0 };
- static const ay8910_interface generic_ay8910 =
- {
- AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
- AY8910_DEFAULT_LOADS,
- NULL, NULL, NULL, NULL
- };
- const ym2610_interface *intf = device->static_config ? device->static_config : &generic_2610;
- int rate = clock/72;
- void *pcmbufa,*pcmbufb;
- int pcmsizea,pcmsizeb;
- struct ym2610_info *info = device->token;
- astring *name = astring_alloc();
-
- chip_type = SOUND_YM2610B;
-
- info->intf = intf;
- info->device = device;
- info->psg = ay8910_start_ym(NULL, SOUND_YM2610B, device, clock, &generic_ay8910);
- assert_always(info->psg != NULL, "Error creating YM2610B/AY8910 chip");
-
- /* Timer Handler set */
- info->timer[0] =timer_alloc(device->machine, timer_callback_0, info);
- info->timer[1] =timer_alloc(device->machine, timer_callback_1, info);
-
- /* stream system initialize */
- info->stream = stream_create(device, 0,2,rate,info,ym2610b_stream_update);
- /* setup adpcm buffers */
- pcmbufa = device->region;
- pcmsizea = device->regionbytes;
- astring_printf(name, "%s.deltat", device->tag);
- pcmbufb = (void *)(memory_region(device->machine, astring_c(name)));
- pcmsizeb = memory_region_length(device->machine, astring_c(name));
- astring_free(name);
- if (pcmbufb == NULL || pcmsizeb == 0)
- {
- pcmbufb = pcmbufa;
- pcmsizeb = pcmsizea;
- }
-
- /**** initialize YM2610 ****/
- info->chip = ym2610_init(info,device,clock,rate,
- pcmbufa,pcmsizea,pcmbufb,pcmsizeb,
- timer_handler,IRQHandler,&psgintf);
- assert_always(info->chip != NULL, "Error creating YM2610B chip");
-}
-#endif
-static SND_STOP( ym2610 )
+static DEVICE_STOP( ym2610 )
{
- struct ym2610_info *info = device->token;
+ ym2610_state *info = get_safe_token(device);
ym2610_shutdown(info->chip);
ay8910_stop_ym(info->psg);
}
-static SND_RESET( ym2610 )
+static DEVICE_RESET( ym2610 )
{
- struct ym2610_info *info = device->token;
+ ym2610_state *info = get_safe_token(device);
ym2610_reset_chip(info->chip);
}
-/************************************************/
-/* Status Read for YM2610 - Chip 0 */
-/************************************************/
-READ8_HANDLER( ym2610_status_port_0_a_r )
-{
-//logerror("PC %04x: 2610 S0A=%02X\n",cpu_get_pc(space->cpu),ym2610_read(sndti_token(chip_type,0,0));
- struct ym2610_info *info = sndti_token(chip_type,0);
- return ym2610_read(info->chip,0);
-}
-
-READ16_HANDLER( ym2610_status_port_0_a_lsb_r )
-{
-//logerror("PC %04x: 2610 S0A=%02X\n",cpu_get_pc(space->cpu),ym2610_read(sndti_token(chip_type,0,0));
- struct ym2610_info *info = sndti_token(chip_type,0);
- return ym2610_read(info->chip,0);
-}
-
-READ8_HANDLER( ym2610_status_port_0_b_r )
-{
-//logerror("PC %04x: 2610 S0B=%02X\n",cpu_get_pc(space->cpu),ym2610_read(sndti_token(chip_type,0,2));
- struct ym2610_info *info = sndti_token(chip_type,0);
- return ym2610_read(info->chip,2);
-}
-
-READ16_HANDLER( ym2610_status_port_0_b_lsb_r )
-{
-//logerror("PC %04x: 2610 S0B=%02X\n",cpu_get_pc(space->cpu),ym2610_read(sndti_token(chip_type,0,2));
- struct ym2610_info *info = sndti_token(chip_type,0);
- return ym2610_read(info->chip,2);
-}
-
-/************************************************/
-/* Status Read for YM2610 - Chip 1 */
-/************************************************/
-READ8_HANDLER( ym2610_status_port_1_a_r ) {
- struct ym2610_info *info = sndti_token(chip_type,1);
- return ym2610_read(info->chip,0);
-}
-
-READ16_HANDLER( ym2610_status_port_1_a_lsb_r ) {
- struct ym2610_info *info = sndti_token(chip_type,1);
- return ym2610_read(info->chip,0);
-}
-
-READ8_HANDLER( ym2610_status_port_1_b_r ) {
- struct ym2610_info *info = sndti_token(chip_type,1);
- return ym2610_read(info->chip,2);
-}
-
-READ16_HANDLER( ym2610_status_port_1_b_lsb_r ) {
- struct ym2610_info *info = sndti_token(chip_type,1);
- return ym2610_read(info->chip,2);
-}
-
-/************************************************/
-/* Port Read for YM2610 - Chip 0 */
-/************************************************/
-READ8_HANDLER( ym2610_read_port_0_r ){
- struct ym2610_info *info = sndti_token(chip_type,0);
- return ym2610_read(info->chip,1);
-}
-
-READ16_HANDLER( ym2610_read_port_0_lsb_r ){
- struct ym2610_info *info = sndti_token(chip_type,0);
- return ym2610_read(info->chip,1);
-}
-
-/************************************************/
-/* Port Read for YM2610 - Chip 1 */
-/************************************************/
-READ8_HANDLER( ym2610_read_port_1_r ){
- struct ym2610_info *info = sndti_token(chip_type,1);
- return ym2610_read(info->chip,1);
-}
-
-READ16_HANDLER( ym2610_read_port_1_lsb_r ){
- struct ym2610_info *info = sndti_token(chip_type,1);
- return ym2610_read(info->chip,1);
-}
-
-/************************************************/
-/* Control Write for YM2610 - Chip 0 */
-/* Consists of 2 addresses */
-/************************************************/
-WRITE8_HANDLER( ym2610_control_port_0_a_w )
-{
-//logerror("PC %04x: 2610 Reg A %02X",cpu_get_pc(space->cpu),data);
- struct ym2610_info *info = sndti_token(chip_type,0);
- ym2610_write(info->chip,0,data);
-}
-
-WRITE16_HANDLER( ym2610_control_port_0_a_lsb_w )
-{
-//logerror("PC %04x: 2610 Reg A %02X",cpu_get_pc(space->cpu),data);
- if (ACCESSING_BITS_0_7)
- {
- struct ym2610_info *info = sndti_token(chip_type,0);
- ym2610_write(info->chip,0,data);
- }
-}
-
-WRITE8_HANDLER( ym2610_control_port_0_b_w )
-{
-//logerror("PC %04x: 2610 Reg B %02X",cpu_get_pc(space->cpu),data);
- struct ym2610_info *info = sndti_token(chip_type,0);
- ym2610_write(info->chip,2,data);
-}
-
-WRITE16_HANDLER( ym2610_control_port_0_b_lsb_w )
-{
-//logerror("PC %04x: 2610 Reg B %02X",cpu_get_pc(space->cpu),data);
- if (ACCESSING_BITS_0_7)
- {
- struct ym2610_info *info = sndti_token(chip_type,0);
- ym2610_write(info->chip,2,data);
- }
-}
-
-/************************************************/
-/* Control Write for YM2610 - Chip 1 */
-/* Consists of 2 addresses */
-/************************************************/
-WRITE8_HANDLER( ym2610_control_port_1_a_w ){
- struct ym2610_info *info = sndti_token(chip_type,1);
- ym2610_write(info->chip,0,data);
-}
-
-WRITE16_HANDLER( ym2610_control_port_1_a_lsb_w ){
- if (ACCESSING_BITS_0_7)
- {
- struct ym2610_info *info = sndti_token(chip_type,1);
- ym2610_write(info->chip,0,data);
- }
-}
-
-WRITE8_HANDLER( ym2610_control_port_1_b_w ){
- struct ym2610_info *info = sndti_token(chip_type,1);
- ym2610_write(info->chip,2,data);
-}
-
-WRITE16_HANDLER( ym2610_control_port_1_b_lsb_w ){
- if (ACCESSING_BITS_0_7)
- {
- struct ym2610_info *info = sndti_token(chip_type,1);
- ym2610_write(info->chip,2,data);
- }
-}
-
-/************************************************/
-/* Data Write for YM2610 - Chip 0 */
-/* Consists of 2 addresses */
-/************************************************/
-WRITE8_HANDLER( ym2610_data_port_0_a_w )
-{
-//logerror(" =%02X\n",data);
- struct ym2610_info *info = sndti_token(chip_type,0);
- ym2610_write(info->chip,1,data);
-}
-
-WRITE16_HANDLER( ym2610_data_port_0_a_lsb_w )
-{
-//logerror(" =%02X\n",data);
- if (ACCESSING_BITS_0_7)
- {
- struct ym2610_info *info = sndti_token(chip_type,0);
- ym2610_write(info->chip,1,data);
- }
-}
-WRITE8_HANDLER( ym2610_data_port_0_b_w )
+READ8_DEVICE_HANDLER( ym2610_r )
{
-//logerror(" =%02X\n",data);
- struct ym2610_info *info = sndti_token(chip_type,0);
- ym2610_write(info->chip,3,data);
+ ym2610_state *info = get_safe_token(device);
+ return ym2610_read(info->chip, offset & 3);
}
-WRITE16_HANDLER( ym2610_data_port_0_b_lsb_w )
+WRITE8_DEVICE_HANDLER( ym2610_w )
{
-//logerror(" =%02X\n",data);
- if (ACCESSING_BITS_0_7)
- {
- struct ym2610_info *info = sndti_token(chip_type,0);
- ym2610_write(info->chip,3,data);
- }
+ ym2610_state *info = get_safe_token(device);
+ ym2610_write(info->chip, offset & 3, data);
}
-/************************************************/
-/* Data Write for YM2610 - Chip 1 */
-/* Consists of 2 addresses */
-/************************************************/
-WRITE8_HANDLER( ym2610_data_port_1_a_w ){
- struct ym2610_info *info = sndti_token(chip_type,1);
- ym2610_write(info->chip,1,data);
-}
-WRITE16_HANDLER( ym2610_data_port_1_a_lsb_w ){
- if (ACCESSING_BITS_0_7)
- {
- struct ym2610_info *info = sndti_token(chip_type,1);
- ym2610_write(info->chip,1,data);
- }
-}
+READ8_DEVICE_HANDLER( ym2610_status_port_a_r ) { return ym2610_r(device, 0); }
+READ8_DEVICE_HANDLER( ym2610_status_port_b_r ) { return ym2610_r(device, 2); }
+READ8_DEVICE_HANDLER( ym2610_read_port_r ) { return ym2610_r(device, 1); }
-WRITE8_HANDLER( ym2610_data_port_1_b_w ){
- struct ym2610_info *info = sndti_token(chip_type,1);
- ym2610_write(info->chip,3,data);
-}
+WRITE8_DEVICE_HANDLER( ym2610_control_port_a_w ) { ym2610_w(device, 0, data); }
+WRITE8_DEVICE_HANDLER( ym2610_control_port_b_w ) { ym2610_w(device, 2, data); }
+WRITE8_DEVICE_HANDLER( ym2610_data_port_a_w ) { ym2610_w(device, 1, data); }
+WRITE8_DEVICE_HANDLER( ym2610_data_port_b_w ) { ym2610_w(device, 3, data); }
-WRITE16_HANDLER( ym2610_data_port_1_b_lsb_w ){
- if (ACCESSING_BITS_0_7)
- {
- struct ym2610_info *info = sndti_token(chip_type,1);
- ym2610_write(info->chip,3,data);
- }
-}
-
-/**************** end of file ****************/
/**************************************************************************
* Generic get_info
**************************************************************************/
-#if BUILD_YM2610
-static SND_SET_INFO( ym2610 )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
-SND_GET_INFO( ym2610 )
+DEVICE_GET_INFO( ym2610 )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym2610_info); break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ym2610_state); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( ym2610 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ym2610 ); break;
- case SNDINFO_PTR_STOP: info->stop = SND_STOP_NAME( ym2610 ); break;
- case SNDINFO_PTR_RESET: info->reset = SND_RESET_NAME( ym2610 ); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ym2610 ); break;
+ case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME( ym2610 ); break;
+ case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( ym2610 ); break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "YM2610"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Yamaha FM"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "YM2610"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "Yamaha FM"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}
-#endif
-
-
-/**************************************************************************
- * Generic get_info
- **************************************************************************/
-#if BUILD_YM2610B
-static SND_SET_INFO( ym2610b )
+DEVICE_GET_INFO( ym2610b )
{
switch (state)
{
- /* no parameters to set */
- }
-}
-
-
-SND_GET_INFO( ym2610b )
-{
- switch (state)
- {
- /* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym2610_info); break;
-
- /* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( ym2610b ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ym2610b ); break;
- case SNDINFO_PTR_STOP: info->stop = SND_STOP_NAME( ym2610 ); break;
- case SNDINFO_PTR_RESET: info->reset = SND_RESET_NAME( ym2610 ); break;
-
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "YM2610B"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Yamaha FM"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "YM2610B"); break;
+
+ default: DEVICE_GET_INFO_CALL(ym2610); break;
}
}
-
-#endif
diff --git a/src/emu/sound/2610intf.h b/src/emu/sound/2610intf.h
index 39050bf5af2..31129b477e5 100644
--- a/src/emu/sound/2610intf.h
+++ b/src/emu/sound/2610intf.h
@@ -11,49 +11,26 @@ void ym2610_update_request(void *param);
typedef struct _ym2610_interface ym2610_interface;
struct _ym2610_interface
{
- void ( *handler )( running_machine *machine, int irq ); /* IRQ handler for the YM2610 */
+ void ( *handler )( const device_config *device, int irq ); /* IRQ handler for the YM2610 */
};
-/************************************************/
-/* Chip 0 functions */
-/************************************************/
-READ8_HANDLER( ym2610_status_port_0_a_r );
-READ16_HANDLER( ym2610_status_port_0_a_lsb_r );
-READ8_HANDLER( ym2610_status_port_0_b_r );
-READ16_HANDLER( ym2610_status_port_0_b_lsb_r );
-READ8_HANDLER( ym2610_read_port_0_r );
-READ16_HANDLER( ym2610_read_port_0_lsb_r );
-WRITE8_HANDLER( ym2610_control_port_0_a_w );
-WRITE16_HANDLER( ym2610_control_port_0_a_lsb_w );
-WRITE8_HANDLER( ym2610_control_port_0_b_w );
-WRITE16_HANDLER( ym2610_control_port_0_b_lsb_w );
-WRITE8_HANDLER( ym2610_data_port_0_a_w );
-WRITE16_HANDLER( ym2610_data_port_0_a_lsb_w );
-WRITE8_HANDLER( ym2610_data_port_0_b_w );
-WRITE16_HANDLER( ym2610_data_port_0_b_lsb_w );
-
-/************************************************/
-/* Chip 1 functions */
-/************************************************/
-READ8_HANDLER( ym2610_status_port_1_a_r );
-READ16_HANDLER( ym2610_status_port_1_a_lsb_r );
-READ8_HANDLER( ym2610_status_port_1_b_r );
-READ16_HANDLER( ym2610_status_port_1_b_lsb_r );
-READ8_HANDLER( ym2610_read_port_1_r );
-READ16_HANDLER( ym2610_read_port_1_lsb_r );
-WRITE8_HANDLER( ym2610_control_port_1_a_w );
-WRITE16_HANDLER( ym2610_control_port_1_a_lsb_w );
-WRITE8_HANDLER( ym2610_control_port_1_b_w );
-WRITE16_HANDLER( ym2610_control_port_1_b_lsb_w );
-WRITE8_HANDLER( ym2610_data_port_1_a_w );
-WRITE16_HANDLER( ym2610_data_port_1_a_lsb_w );
-WRITE8_HANDLER( ym2610_data_port_1_b_w );
-WRITE16_HANDLER( ym2610_data_port_1_b_lsb_w );
-
-SND_GET_INFO( ym2610 );
-SND_GET_INFO( ym2610b );
-
-#define SOUND_YM2610 SND_GET_INFO_NAME( ym2610 )
-#define SOUND_YM2610B SND_GET_INFO_NAME( ym2610b )
+READ8_DEVICE_HANDLER( ym2610_r );
+WRITE8_DEVICE_HANDLER( ym2610_w );
+
+READ8_DEVICE_HANDLER( ym2610_status_port_a_r );
+READ8_DEVICE_HANDLER( ym2610_status_port_b_r );
+READ8_DEVICE_HANDLER( ym2610_read_port_r );
+
+WRITE8_DEVICE_HANDLER( ym2610_control_port_a_w );
+WRITE8_DEVICE_HANDLER( ym2610_control_port_b_w );
+WRITE8_DEVICE_HANDLER( ym2610_data_port_a_w );
+WRITE8_DEVICE_HANDLER( ym2610_data_port_b_w );
+
+
+DEVICE_GET_INFO( ym2610 );
+DEVICE_GET_INFO( ym2610b );
+
+#define SOUND_YM2610 DEVICE_GET_INFO_NAME( ym2610 )
+#define SOUND_YM2610B DEVICE_GET_INFO_NAME( ym2610b )
#endif /* __2610INTF_H__ */
diff --git a/src/emu/sound/2612intf.c b/src/emu/sound/2612intf.c
index aa11a9dcfc9..be1e6db2d75 100644
--- a/src/emu/sound/2612intf.c
+++ b/src/emu/sound/2612intf.c
@@ -17,39 +17,52 @@
#include "sound/2612intf.h"
-struct ym2612_info
+typedef struct _ym2612_state ym2612_state;
+struct _ym2612_state
{
sound_stream * stream;
- emu_timer * timer[2];
+ emu_timer * timer[2];
void * chip;
const ym2612_interface *intf;
const device_config *device;
};
+
+INLINE ym2612_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_YM2612 || sound_get_type(device) == SOUND_YM3438);
+ return (ym2612_state *)device->token;
+}
+
+
+
/*------------------------- TM2612 -------------------------------*/
/* IRQ Handler */
static void IRQHandler(void *param,int irq)
{
- struct ym2612_info *info = param;
- if(info->intf->handler) info->intf->handler(info->device->machine, irq);
+ ym2612_state *info = param;
+ if(info->intf->handler) info->intf->handler(info->device, irq);
}
/* Timer overflow callback from timer.c */
static TIMER_CALLBACK( timer_callback_2612_0 )
{
- struct ym2612_info *info = ptr;
+ ym2612_state *info = ptr;
ym2612_timer_over(info->chip,0);
}
static TIMER_CALLBACK( timer_callback_2612_1 )
{
- struct ym2612_info *info = ptr;
+ ym2612_state *info = ptr;
ym2612_timer_over(info->chip,1);
}
static void timer_handler(void *param,int c,int count,int clock)
{
- struct ym2612_info *info = param;
+ ym2612_state *info = param;
if( count == 0 )
{ /* Reset FM Timer */
timer_enable(info->timer[c], 0);
@@ -65,7 +78,7 @@ static void timer_handler(void *param,int c,int count,int clock)
/* update request from fm.c */
void ym2612_update_request(void *param)
{
- struct ym2612_info *info = param;
+ ym2612_state *info = param;
stream_update(info->stream);
}
@@ -75,23 +88,23 @@ void ym2612_update_request(void *param)
static STREAM_UPDATE( ym2612_stream_update )
{
- struct ym2612_info *info = param;
+ ym2612_state *info = param;
ym2612_update_one(info->chip, outputs, samples);
}
static STATE_POSTLOAD( ym2612_intf_postload )
{
- struct ym2612_info *info = param;
+ ym2612_state *info = param;
ym2612_postload(info->chip);
}
-static SND_START( ym2612 )
+static DEVICE_START( ym2612 )
{
static const ym2612_interface dummy = { 0 };
- struct ym2612_info *info = device->token;
- int rate = clock/72;
+ ym2612_state *info = get_safe_token(device);
+ int rate = device->clock/72;
info->intf = device->static_config ? device->static_config : &dummy;
info->device = device;
@@ -105,308 +118,85 @@ static SND_START( ym2612 )
info->stream = stream_create(device,0,2,rate,info,ym2612_stream_update);
/**** initialize YM2612 ****/
- info->chip = ym2612_init(info,device,clock,rate,timer_handler,IRQHandler);
+ info->chip = ym2612_init(info,device,device->clock,rate,timer_handler,IRQHandler);
assert_always(info->chip != NULL, "Error creating YM2612 chip");
state_save_register_postload(device->machine, ym2612_intf_postload, info);
}
-static SND_STOP( ym2612 )
+static DEVICE_STOP( ym2612 )
{
- struct ym2612_info *info = device->token;
+ ym2612_state *info = get_safe_token(device);
ym2612_shutdown(info->chip);
}
-static SND_RESET( ym2612 )
+static DEVICE_RESET( ym2612 )
{
- struct ym2612_info *info = device->token;
+ ym2612_state *info = get_safe_token(device);
ym2612_reset_chip(info->chip);
}
-/************************************************/
-/* Status Read for YM2612 - Chip 0 */
-/************************************************/
-READ8_HANDLER( ym2612_status_port_0_a_r )
-{
- struct ym2612_info *info = sndti_token(SOUND_YM2612,0);
- return ym2612_read(info->chip,0);
-}
-
-READ8_HANDLER( ym2612_status_port_0_b_r )
-{
- struct ym2612_info *info = sndti_token(SOUND_YM2612,0);
- return ym2612_read(info->chip,2);
-}
-
-/************************************************/
-/* Status Read for YM2612 - Chip 1 */
-/************************************************/
-READ8_HANDLER( ym2612_status_port_1_a_r ) {
- struct ym2612_info *info = sndti_token(SOUND_YM2612,1);
- return ym2612_read(info->chip,0);
-}
-
-READ8_HANDLER( ym2612_status_port_1_b_r ) {
- struct ym2612_info *info = sndti_token(SOUND_YM2612,1);
- return ym2612_read(info->chip,2);
-}
-
-/************************************************/
-/* Port Read for YM2612 - Chip 0 */
-/************************************************/
-READ8_HANDLER( ym2612_read_port_0_r ){
- struct ym2612_info *info = sndti_token(SOUND_YM2612,0);
- return ym2612_read(info->chip,1);
-}
-
-/************************************************/
-/* Port Read for YM2612 - Chip 1 */
-/************************************************/
-READ8_HANDLER( ym2612_read_port_1_r ){
- struct ym2612_info *info = sndti_token(SOUND_YM2612,1);
- return ym2612_read(info->chip,1);
-}
-
-/************************************************/
-/* Control Write for YM2612 - Chip 0 */
-/* Consists of 2 addresses */
-/************************************************/
-WRITE8_HANDLER( ym2612_control_port_0_a_w )
-{
- struct ym2612_info *info = sndti_token(SOUND_YM2612,0);
- ym2612_write(info->chip,0,data);
-}
-
-WRITE8_HANDLER( ym2612_control_port_0_b_w )
-{
- struct ym2612_info *info = sndti_token(SOUND_YM2612,0);
- ym2612_write(info->chip,2,data);
-}
-
-/************************************************/
-/* Control Write for YM2612 - Chip 1 */
-/* Consists of 2 addresses */
-/************************************************/
-WRITE8_HANDLER( ym2612_control_port_1_a_w ){
- struct ym2612_info *info = sndti_token(SOUND_YM2612,1);
- ym2612_write(info->chip,0,data);
-}
-
-WRITE8_HANDLER( ym2612_control_port_1_b_w ){
- struct ym2612_info *info = sndti_token(SOUND_YM2612,1);
- ym2612_write(info->chip,2,data);
-}
-
-/************************************************/
-/* Data Write for YM2612 - Chip 0 */
-/* Consists of 2 addresses */
-/************************************************/
-WRITE8_HANDLER( ym2612_data_port_0_a_w )
-{
- struct ym2612_info *info = sndti_token(SOUND_YM2612,0);
- ym2612_write(info->chip,1,data);
-}
-
-WRITE8_HANDLER( ym2612_data_port_0_b_w )
-{
- struct ym2612_info *info = sndti_token(SOUND_YM2612,0);
- ym2612_write(info->chip,3,data);
-}
-
-/************************************************/
-/* Data Write for YM2612 - Chip 1 */
-/* Consists of 2 addresses */
-/************************************************/
-WRITE8_HANDLER( ym2612_data_port_1_a_w ){
- struct ym2612_info *info = sndti_token(SOUND_YM2612,1);
- ym2612_write(info->chip,1,data);
-}
-WRITE8_HANDLER( ym2612_data_port_1_b_w ){
- struct ym2612_info *info = sndti_token(SOUND_YM2612,1);
- ym2612_write(info->chip,3,data);
-}
-
-#if BUILD_YM3438
-
-/************************************************/
-/* Status Read for YM3438 - Chip 0 */
-/************************************************/
-READ8_HANDLER( ym3438_status_port_0_a_r )
-{
- struct ym2612_info *info = sndti_token(SOUND_YM3438,0);
- return ym2612_read(info->chip,0);
-}
-
-READ8_HANDLER( ym3438_status_port_0_b_r )
-{
- struct ym2612_info *info = sndti_token(SOUND_YM3438,0);
- return ym2612_read(info->chip,2);
-}
-
-/************************************************/
-/* Status Read for YM3438 - Chip 1 */
-/************************************************/
-READ8_HANDLER( ym3438_status_port_1_a_r ) {
- struct ym2612_info *info = sndti_token(SOUND_YM3438,1);
- return ym2612_read(info->chip,0);
-}
-
-READ8_HANDLER( ym3438_status_port_1_b_r ) {
- struct ym2612_info *info = sndti_token(SOUND_YM3438,1);
- return ym2612_read(info->chip,2);
-}
-
-/************************************************/
-/* Port Read for YM3438 - Chip 0 */
-/************************************************/
-READ8_HANDLER( ym3438_read_port_0_r ){
- struct ym2612_info *info = sndti_token(SOUND_YM3438,0);
- return ym2612_read(info->chip,1);
-}
-
-/************************************************/
-/* Port Read for YM3438 - Chip 1 */
-/************************************************/
-READ8_HANDLER( ym3438_read_port_1_r ){
- struct ym2612_info *info = sndti_token(SOUND_YM3438,1);
- return ym2612_read(info->chip,1);
-}
-
-/************************************************/
-/* Control Write for YM3438 - Chip 0 */
-/* Consists of 2 addresses */
-/************************************************/
-WRITE8_HANDLER( ym3438_control_port_0_a_w )
+READ8_DEVICE_HANDLER( ym2612_r )
{
- struct ym2612_info *info = sndti_token(SOUND_YM3438,0);
- ym2612_write(info->chip,0,data);
+ ym2612_state *info = get_safe_token(device);
+ return ym2612_read(info->chip, offset & 3);
}
-WRITE8_HANDLER( ym3438_control_port_0_b_w )
+WRITE8_DEVICE_HANDLER( ym2612_w )
{
- struct ym2612_info *info = sndti_token(SOUND_YM3438,0);
- ym2612_write(info->chip,2,data);
+ ym2612_state *info = get_safe_token(device);
+ ym2612_write(info->chip, offset & 3, data);
}
-/************************************************/
-/* Control Write for YM3438 - Chip 1 */
-/* Consists of 2 addresses */
-/************************************************/
-WRITE8_HANDLER( ym3438_control_port_1_a_w ){
- struct ym2612_info *info = sndti_token(SOUND_YM3438,1);
- ym2612_write(info->chip,0,data);
-}
-WRITE8_HANDLER( ym3438_control_port_1_b_w ){
- struct ym2612_info *info = sndti_token(SOUND_YM3438,1);
- ym2612_write(info->chip,2,data);
-}
+READ8_DEVICE_HANDLER( ym2612_status_port_a_r ) { return ym2612_r(device, 0); }
+READ8_DEVICE_HANDLER( ym2612_status_port_b_r ) { return ym2612_r(device, 2); }
+READ8_DEVICE_HANDLER( ym2612_data_port_a_r ) { return ym2612_r(device, 1); }
+READ8_DEVICE_HANDLER( ym2612_data_port_b_r ) { return ym2612_r(device, 3); }
-/************************************************/
-/* Data Write for YM3438 - Chip 0 */
-/* Consists of 2 addresses */
-/************************************************/
-WRITE8_HANDLER( ym3438_data_port_0_a_w )
-{
- struct ym2612_info *info = sndti_token(SOUND_YM3438,0);
- ym2612_write(info->chip,1,data);
-}
+WRITE8_DEVICE_HANDLER( ym2612_control_port_a_w ) { ym2612_w(device, 0, data); }
+WRITE8_DEVICE_HANDLER( ym2612_control_port_b_w ) { ym2612_w(device, 2, data); }
+WRITE8_DEVICE_HANDLER( ym2612_data_port_a_w ) { ym2612_w(device, 1, data); }
+WRITE8_DEVICE_HANDLER( ym2612_data_port_b_w ) { ym2612_w(device, 3, data); }
-WRITE8_HANDLER( ym3438_data_port_0_b_w )
-{
- struct ym2612_info *info = sndti_token(SOUND_YM3438,0);
- ym2612_write(info->chip,3,data);
-}
-/************************************************/
-/* Data Write for YM3438 - Chip 1 */
-/* Consists of 2 addresses */
-/************************************************/
-WRITE8_HANDLER( ym3438_data_port_1_a_w ){
- struct ym2612_info *info = sndti_token(SOUND_YM3438,1);
- ym2612_write(info->chip,1,data);
-}
-WRITE8_HANDLER( ym3438_data_port_1_b_w ){
- struct ym2612_info *info = sndti_token(SOUND_YM3438,1);
- ym2612_write(info->chip,3,data);
-}
-
-#endif
-/**************** end of file ****************/
/**************************************************************************
* Generic get_info
**************************************************************************/
-static SND_SET_INFO( ym2612 )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
-SND_GET_INFO( ym2612 )
+DEVICE_GET_INFO( ym2612 )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym2612_info); break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ym2612_state); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( ym2612 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ym2612 ); break;
- case SNDINFO_PTR_STOP: info->stop = SND_STOP_NAME( ym2612 ); break;
- case SNDINFO_PTR_RESET: info->reset = SND_RESET_NAME( ym2612 ); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ym2612 ); break;
+ case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME( ym2612 ); break;
+ case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( ym2612 ); break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "YM2612"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Yamaha FM"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "YM2612"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "Yamaha FM"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}
-/**************************************************************************
- * Generic get_info
- **************************************************************************/
-
-#if BUILD_YM3438
-static SND_SET_INFO( ym3438 )
+DEVICE_GET_INFO( ym3438 )
{
switch (state)
{
- /* no parameters to set */
- }
-}
-
-
-SND_GET_INFO( ym3438 )
-{
- switch (state)
- {
- /* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym2612_info); break;
-
- /* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( ym3438 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ym2612 ); break;
- case SNDINFO_PTR_STOP: info->stop = SND_STOP_NAME( ym2612 ); break;
- case SNDINFO_PTR_RESET: info->reset = SND_RESET_NAME( ym2612 ); break;
-
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "YM3438"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Yamaha FM"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "YM3438"); break;
+
+ default: DEVICE_GET_INFO_CALL(ym2612); break;
}
}
-
-#endif
diff --git a/src/emu/sound/2612intf.h b/src/emu/sound/2612intf.h
index 16eb800a16d..1cce505d279 100644
--- a/src/emu/sound/2612intf.h
+++ b/src/emu/sound/2612intf.h
@@ -8,66 +8,49 @@ void ym2612_update_request(void *param);
typedef struct _ym2612_interface ym2612_interface;
struct _ym2612_interface
{
- void (*handler)(running_machine *machine, int irq);
+ void (*handler)(const device_config *device, int irq);
};
+READ8_DEVICE_HANDLER( ym2612_r );
+WRITE8_DEVICE_HANDLER( ym2612_w );
-/************************************************/
-/* Chip 0 functions */
-/************************************************/
-READ8_HANDLER( ym2612_status_port_0_a_r ); /* A=0 : OPN status */
-READ8_HANDLER( ym2612_status_port_0_b_r ); /* A=2 : don't care */
-READ8_HANDLER( ym2612_read_port_0_r ); /* A=1 : don't care */
-WRITE8_HANDLER( ym2612_control_port_0_a_w ); /* A=0:OPN address */
-WRITE8_HANDLER( ym2612_control_port_0_b_w ); /* A=2:OPN2 address */
-WRITE8_HANDLER( ym2612_data_port_0_a_w ); /* A=1:OPN data */
-WRITE8_HANDLER( ym2612_data_port_0_b_w ); /* A=3:OPN2 data */
-
-/************************************************/
-/* Chip 1 functions */
-/************************************************/
-READ8_HANDLER( ym2612_status_port_1_a_r );
-READ8_HANDLER( ym2612_status_port_1_b_r );
-READ8_HANDLER( ym2612_read_port_1_r );
-WRITE8_HANDLER( ym2612_control_port_1_a_w );
-WRITE8_HANDLER( ym2612_control_port_1_b_w );
-WRITE8_HANDLER( ym2612_data_port_1_a_w );
-WRITE8_HANDLER( ym2612_data_port_1_b_w );
-
-SND_GET_INFO( ym2612 );
-#define SOUND_YM2612 SND_GET_INFO_NAME( ym2612 )
+READ8_DEVICE_HANDLER( ym2612_status_port_a_r );
+READ8_DEVICE_HANDLER( ym2612_status_port_b_r );
+READ8_DEVICE_HANDLER( ym2612_data_port_a_r );
+READ8_DEVICE_HANDLER( ym2612_data_port_b_r );
+
+WRITE8_DEVICE_HANDLER( ym2612_control_port_a_w );
+WRITE8_DEVICE_HANDLER( ym2612_control_port_b_w );
+WRITE8_DEVICE_HANDLER( ym2612_data_port_a_w );
+WRITE8_DEVICE_HANDLER( ym2612_data_port_b_w );
+
+
+DEVICE_GET_INFO( ym2612 );
+#define SOUND_YM2612 DEVICE_GET_INFO_NAME( ym2612 )
typedef struct _ym3438_interface ym3438_interface;
struct _ym3438_interface
{
- void (*handler)(running_machine *machine, int irq);
+ void (*handler)(const device_config *device, int irq);
};
-/************************************************/
-/* Chip 0 functions */
-/************************************************/
-READ8_HANDLER( ym3438_status_port_0_a_r ); /* A=0 : OPN status */
-READ8_HANDLER( ym3438_status_port_0_b_r ); /* A=2 : don't care */
-READ8_HANDLER( ym3438_read_port_0_r ); /* A=1 : don't care */
-WRITE8_HANDLER( ym3438_control_port_0_a_w ); /* A=0:OPN address */
-WRITE8_HANDLER( ym3438_control_port_0_b_w ); /* A=2:OPN2 address */
-WRITE8_HANDLER( ym3438_data_port_0_a_w ); /* A=1:OPN data */
-WRITE8_HANDLER( ym3438_data_port_0_b_w ); /* A=3:OPN2 data */
-
-/************************************************/
-/* Chip 1 functions */
-/************************************************/
-READ8_HANDLER( ym3438_status_port_1_a_r );
-READ8_HANDLER( ym3438_status_port_1_b_r );
-READ8_HANDLER( ym3438_read_port_1_r );
-WRITE8_HANDLER( ym3438_control_port_1_a_w );
-WRITE8_HANDLER( ym3438_control_port_1_b_w );
-WRITE8_HANDLER( ym3438_data_port_1_a_w );
-WRITE8_HANDLER( ym3438_data_port_1_b_w );
-
-SND_GET_INFO( ym3438 );
-#define SOUND_YM3438 SND_GET_INFO_NAME( ym3438 )
+#define ym3438_r ym2612_r
+#define ym3438_w ym2612_w
+
+#define ym3438_status_port_a_r ym2612_status_port_a_r
+#define ym3438_status_port_b_r ym2612_status_port_b_r
+#define ym3438_data_port_a_r ym2612_data_port_a_r
+#define ym3438_data_port_b_r ym2612_data_port_b_r
+
+#define ym3438_control_port_a_w ym2612_control_port_a_w
+#define ym3438_control_port_b_w ym2612_control_port_b_w
+#define ym3438_data_port_a_w ym2612_data_port_a_w
+#define ym3438_data_port_b_w ym2612_data_port_b_w
+
+
+DEVICE_GET_INFO( ym3438 );
+#define SOUND_YM3438 DEVICE_GET_INFO_NAME( ym3438 )
#endif /* __2612INTF_H__ */
diff --git a/src/emu/sound/262intf.c b/src/emu/sound/262intf.c
index bbb3bff6319..30369f8f61d 100644
--- a/src/emu/sound/262intf.c
+++ b/src/emu/sound/262intf.c
@@ -11,39 +11,50 @@
#include "ymf262.h"
-struct ymf262_info
+typedef struct _ymf262_state ymf262_state;
+struct _ymf262_state
{
sound_stream * stream;
- emu_timer * timer[2];
+ emu_timer * timer[2];
void * chip;
const ymf262_interface *intf;
const device_config *device;
};
+INLINE ymf262_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_YMF262);
+ return (ymf262_state *)device->token;
+}
+
+
static void IRQHandler_262(void *param,int irq)
{
- struct ymf262_info *info = param;
- if (info->intf->handler) (info->intf->handler)(info->device->machine, irq);
+ ymf262_state *info = param;
+ if (info->intf->handler) (info->intf->handler)(info->device, irq);
}
static TIMER_CALLBACK( timer_callback_262_0 )
{
- struct ymf262_info *info = ptr;
+ ymf262_state *info = ptr;
ymf262_timer_over(info->chip, 0);
}
static TIMER_CALLBACK( timer_callback_262_1 )
{
- struct ymf262_info *info = ptr;
+ ymf262_state *info = ptr;
ymf262_timer_over(info->chip, 1);
}
static void timer_handler_262(void *param,int timer, attotime period)
{
- struct ymf262_info *info = param;
+ ymf262_state *info = param;
if( attotime_compare(period, attotime_zero) == 0 )
{ /* Reset FM Timer */
timer_enable(info->timer[timer], 0);
@@ -56,28 +67,28 @@ static void timer_handler_262(void *param,int timer, attotime period)
static STREAM_UPDATE( ymf262_stream_update )
{
- struct ymf262_info *info = param;
+ ymf262_state *info = param;
ymf262_update_one(info->chip, outputs, samples);
}
static void _stream_update(void *param, int interval)
{
- struct ymf262_info *info = param;
+ ymf262_state *info = param;
stream_update(info->stream);
}
-static SND_START( ymf262 )
+static DEVICE_START( ymf262 )
{
static const ymf262_interface dummy = { 0 };
- struct ymf262_info *info = device->token;
- int rate = clock/288;
+ ymf262_state *info = get_safe_token(device);
+ int rate = device->clock/288;
info->intf = device->static_config ? device->static_config : &dummy;
info->device = device;
/* stream system initialize */
- info->chip = ymf262_init(device,clock,rate);
+ info->chip = ymf262_init(device,device->clock,rate);
assert_always(info->chip != NULL, "Error creating YMF262 chip");
info->stream = stream_create(device,0,4,rate,info,ymf262_stream_update);
@@ -91,96 +102,61 @@ static SND_START( ymf262 )
info->timer[1] = timer_alloc(device->machine, timer_callback_262_1, info);
}
-static SND_STOP( ymf262 )
+static DEVICE_STOP( ymf262 )
{
- struct ymf262_info *info = device->token;
+ ymf262_state *info = get_safe_token(device);
ymf262_shutdown(info->chip);
}
/* reset */
-static SND_RESET( ymf262 )
+static DEVICE_RESET( ymf262 )
{
- struct ymf262_info *info = device->token;
+ ymf262_state *info = get_safe_token(device);
ymf262_reset_chip(info->chip);
}
-/* chip #0 */
-READ8_HANDLER( ymf262_status_0_r ) {
- struct ymf262_info *info = sndti_token(SOUND_YMF262, 0);
- return ymf262_read(info->chip, 0);
-}
-WRITE8_HANDLER( ymf262_register_a_0_w ) {
- struct ymf262_info *info = sndti_token(SOUND_YMF262, 0);
- ymf262_write(info->chip, 0, data);
-}
-WRITE8_HANDLER( ymf262_data_a_0_w ) {
- struct ymf262_info *info = sndti_token(SOUND_YMF262, 0);
- ymf262_write(info->chip, 1, data);
-}
-WRITE8_HANDLER( ymf262_register_b_0_w ) {
- struct ymf262_info *info = sndti_token(SOUND_YMF262, 0);
- ymf262_write(info->chip, 2, data);
-}
-WRITE8_HANDLER( ymf262_data_b_0_w ) {
- struct ymf262_info *info = sndti_token(SOUND_YMF262, 0);
- ymf262_write(info->chip, 3, data);
-}
-/* chip #1 */
-READ8_HANDLER( ymf262_status_1_r ) {
- struct ymf262_info *info = sndti_token(SOUND_YMF262, 1);
- return ymf262_read(info->chip, 0);
-}
-WRITE8_HANDLER( ymf262_register_a_1_w ) {
- struct ymf262_info *info = sndti_token(SOUND_YMF262, 1);
- ymf262_write(info->chip, 0, data);
-}
-WRITE8_HANDLER( ymf262_data_a_1_w ) {
- struct ymf262_info *info = sndti_token(SOUND_YMF262, 1);
- ymf262_write(info->chip, 1, data);
-}
-WRITE8_HANDLER( ymf262_register_b_1_w ) {
- struct ymf262_info *info = sndti_token(SOUND_YMF262, 1);
- ymf262_write(info->chip, 2, data);
+READ8_DEVICE_HANDLER( ymf262_r )
+{
+ ymf262_state *info = get_safe_token(device);
+ return ymf262_read(info->chip, offset & 3);
}
-WRITE8_HANDLER( ymf262_data_b_1_w ) {
- struct ymf262_info *info = sndti_token(SOUND_YMF262, 1);
- ymf262_write(info->chip, 3, data);
+
+WRITE8_DEVICE_HANDLER( ymf262_w )
+{
+ ymf262_state *info = get_safe_token(device);
+ ymf262_write(info->chip, offset & 3, data);
}
+READ8_DEVICE_HANDLER ( ymf262_status_r ) { return ymf262_r(device, 0); }
+WRITE8_DEVICE_HANDLER( ymf262_register_a_w ) { ymf262_w(device, 0, data); }
+WRITE8_DEVICE_HANDLER( ymf262_register_b_w ) { ymf262_w(device, 2, data); }
+WRITE8_DEVICE_HANDLER( ymf262_data_a_w ) { ymf262_w(device, 1, data); }
+WRITE8_DEVICE_HANDLER( ymf262_data_b_w ) { ymf262_w(device, 3, data); }
+
/**************************************************************************
* Generic get_info
**************************************************************************/
-static SND_SET_INFO( ymf262 )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
-SND_GET_INFO( ymf262 )
+DEVICE_GET_INFO( ymf262 )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ymf262_info); break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ymf262_state); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( ymf262 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ymf262 ); break;
- case SNDINFO_PTR_STOP: info->stop = SND_STOP_NAME( ymf262 ); break;
- case SNDINFO_PTR_RESET: info->reset = SND_RESET_NAME( ymf262 ); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ymf262 ); break;
+ case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME( ymf262 ); break;
+ case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( ymf262 ); break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "YMF262"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Yamaha FM"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "YMF262"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "Yamaha FM"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}
diff --git a/src/emu/sound/262intf.h b/src/emu/sound/262intf.h
index 10818a575df..7bcf1a69da3 100644
--- a/src/emu/sound/262intf.h
+++ b/src/emu/sound/262intf.h
@@ -7,26 +7,21 @@
typedef struct _ymf262_interface ymf262_interface;
struct _ymf262_interface
{
- void (*handler)(running_machine *machine, int irq);
+ void (*handler)(const device_config *device, int irq);
};
+READ8_DEVICE_HANDLER( ymf262_r );
+WRITE8_DEVICE_HANDLER( ymf262_w );
-/* YMF262 */
-READ8_HANDLER ( ymf262_status_0_r );
-WRITE8_HANDLER( ymf262_register_a_0_w );
-WRITE8_HANDLER( ymf262_register_b_0_w );
-WRITE8_HANDLER( ymf262_data_a_0_w );
-WRITE8_HANDLER( ymf262_data_b_0_w );
+READ8_DEVICE_HANDLER ( ymf262_status_r );
+WRITE8_DEVICE_HANDLER( ymf262_register_a_w );
+WRITE8_DEVICE_HANDLER( ymf262_register_b_w );
+WRITE8_DEVICE_HANDLER( ymf262_data_a_w );
+WRITE8_DEVICE_HANDLER( ymf262_data_b_w );
-READ8_HANDLER ( ymf262_status_1_r );
-WRITE8_HANDLER( ymf262_register_a_1_w );
-WRITE8_HANDLER( ymf262_register_b_1_w );
-WRITE8_HANDLER( ymf262_data_a_1_w );
-WRITE8_HANDLER( ymf262_data_b_1_w );
-
-SND_GET_INFO( ymf262 );
-#define SOUND_YMF262 SND_GET_INFO_NAME( ymf262 )
+DEVICE_GET_INFO( ymf262 );
+#define SOUND_YMF262 DEVICE_GET_INFO_NAME( ymf262 )
#endif /* __262INTF_H__ */
diff --git a/src/emu/sound/3526intf.c b/src/emu/sound/3526intf.c
new file mode 100644
index 00000000000..53146bb3e69
--- /dev/null
+++ b/src/emu/sound/3526intf.c
@@ -0,0 +1,170 @@
+/******************************************************************************
+* FILE
+* Yamaha 3812 emulator interface - MAME VERSION
+*
+* CREATED BY
+* Ernesto Corvi
+*
+* UPDATE LOG
+* JB 28-04-2002 Fixed simultaneous usage of all three different chip types.
+* Used real sample rate when resample filter is active.
+* AAT 12-28-2001 Protected Y8950 from accessing unmapped port and keyboard handlers.
+* CHS 1999-01-09 Fixes new ym3812 emulation interface.
+* CHS 1998-10-23 Mame streaming sound chip update
+* EC 1998 Created Interface
+*
+* NOTES
+*
+******************************************************************************/
+#include "sndintrf.h"
+#include "streams.h"
+#include "cpuintrf.h"
+#include "3526intf.h"
+#include "fm.h"
+#include "sound/fmopl.h"
+
+
+typedef struct _ym3526_state ym3526_state;
+struct _ym3526_state
+{
+ sound_stream * stream;
+ emu_timer * timer[2];
+ void * chip;
+ const ym3526_interface *intf;
+ const device_config *device;
+};
+
+
+INLINE ym3526_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_YM3526);
+ return (ym3526_state *)device->token;
+}
+
+
+/* IRQ Handler */
+static void IRQHandler(void *param,int irq)
+{
+ ym3526_state *info = param;
+ if (info->intf->handler) (info->intf->handler)(info->device, irq ? ASSERT_LINE : CLEAR_LINE);
+}
+/* Timer overflow callback from timer.c */
+static TIMER_CALLBACK( timer_callback_0 )
+{
+ ym3526_state *info = ptr;
+ ym3526_timer_over(info->chip,0);
+}
+static TIMER_CALLBACK( timer_callback_1 )
+{
+ ym3526_state *info = ptr;
+ ym3526_timer_over(info->chip,1);
+}
+/* TimerHandler from fm.c */
+static void TimerHandler(void *param,int c,attotime period)
+{
+ ym3526_state *info = param;
+ if( attotime_compare(period, attotime_zero) == 0 )
+ { /* Reset FM Timer */
+ timer_enable(info->timer[c], 0);
+ }
+ else
+ { /* Start FM Timer */
+ timer_adjust_oneshot(info->timer[c], period, 0);
+ }
+}
+
+
+static STREAM_UPDATE( ym3526_stream_update )
+{
+ ym3526_state *info = param;
+ ym3526_update_one(info->chip, outputs[0], samples);
+}
+
+static void _stream_update(void *param, int interval)
+{
+ ym3526_state *info = param;
+ stream_update(info->stream);
+}
+
+
+static DEVICE_START( ym3526 )
+{
+ static const ym3526_interface dummy = { 0 };
+ ym3526_state *info = get_safe_token(device);
+ int rate = device->clock/72;
+
+ info->intf = device->static_config ? device->static_config : &dummy;
+ info->device = device;
+
+ /* stream system initialize */
+ info->chip = ym3526_init(device,device->clock,rate);
+ assert_always(info->chip != NULL, "Error creating YM3526 chip");
+
+ info->stream = stream_create(device,0,1,rate,info,ym3526_stream_update);
+ /* YM3526 setup */
+ ym3526_set_timer_handler (info->chip, TimerHandler, info);
+ ym3526_set_irq_handler (info->chip, IRQHandler, info);
+ ym3526_set_update_handler(info->chip, _stream_update, info);
+
+ info->timer[0] = timer_alloc(device->machine, timer_callback_0, info);
+ info->timer[1] = timer_alloc(device->machine, timer_callback_1, info);
+}
+
+static DEVICE_STOP( ym3526 )
+{
+ ym3526_state *info = get_safe_token(device);
+ ym3526_shutdown(info->chip);
+}
+
+static DEVICE_RESET( ym3526 )
+{
+ ym3526_state *info = get_safe_token(device);
+ ym3526_reset_chip(info->chip);
+}
+
+
+READ8_DEVICE_HANDLER( ym3526_r )
+{
+ ym3526_state *info = get_safe_token(device);
+ return ym3526_read(info->chip, offset & 1);
+}
+
+WRITE8_DEVICE_HANDLER( ym3526_w )
+{
+ ym3526_state *info = get_safe_token(device);
+ ym3526_write(info->chip, offset & 1, data);
+}
+
+READ8_DEVICE_HANDLER( ym3526_status_port_r ) { return ym3526_r(device, 0); }
+READ8_DEVICE_HANDLER( ym3526_read_port_r ) { return ym3526_r(device, 1); }
+WRITE8_DEVICE_HANDLER( ym3526_control_port_w ) { ym3526_w(device, 0, data); }
+WRITE8_DEVICE_HANDLER( ym3526_write_port_w ) { ym3526_w(device, 1, data); }
+
+
+/**************************************************************************
+ * Generic get_info
+ **************************************************************************/
+
+DEVICE_GET_INFO( ym3526 )
+{
+ switch (state)
+ {
+ /* --- the following bits of info are returned as 64-bit signed integers --- */
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ym3526_state); break;
+
+ /* --- the following bits of info are returned as pointers to data or functions --- */
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ym3526 ); break;
+ case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME( ym3526 ); break;
+ case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( ym3526 ); break;
+
+ /* --- the following bits of info are returned as NULL-terminated strings --- */
+ case DEVINFO_STR_NAME: strcpy(info->s, "YM3526"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "Yamaha FM"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ }
+}
diff --git a/src/emu/sound/3526intf.h b/src/emu/sound/3526intf.h
new file mode 100644
index 00000000000..b61928928b5
--- /dev/null
+++ b/src/emu/sound/3526intf.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#ifndef __3526INTF_H__
+#define __3526INTF_H__
+
+typedef struct _ym3526_interface ym3526_interface;
+struct _ym3526_interface
+{
+ void (*handler)(const device_config *device, int linestate);
+};
+
+READ8_DEVICE_HANDLER( ym3526_r );
+WRITE8_DEVICE_HANDLER( ym3526_w );
+
+READ8_DEVICE_HANDLER( ym3526_status_port_r );
+READ8_DEVICE_HANDLER( ym3526_read_port_r );
+WRITE8_DEVICE_HANDLER( ym3526_control_port_w );
+WRITE8_DEVICE_HANDLER( ym3526_write_port_w );
+
+DEVICE_GET_INFO( ym3526 );
+#define SOUND_YM3526 DEVICE_GET_INFO_NAME( ym3526 )
+
+#endif /* __3526INTF_H__ */
diff --git a/src/emu/sound/3812intf.c b/src/emu/sound/3812intf.c
index 07d845dad38..a784ea54ffd 100644
--- a/src/emu/sound/3812intf.c
+++ b/src/emu/sound/3812intf.c
@@ -24,37 +24,48 @@
#include "sound/fmopl.h"
-#if BUILD_YM3812
-
-struct ym3812_info
+typedef struct _ym3812_state ym3812_state;
+struct _ym3812_state
{
sound_stream * stream;
- emu_timer * timer[2];
+ emu_timer * timer[2];
void * chip;
const ym3812_interface *intf;
const device_config *device;
};
-static void IRQHandler_3812(void *param,int irq)
+
+INLINE ym3812_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_YM3812);
+ return (ym3812_state *)device->token;
+}
+
+
+
+static void IRQHandler(void *param,int irq)
{
- struct ym3812_info *info = param;
- if (info->intf->handler) (info->intf->handler)(info->device->machine, irq ? ASSERT_LINE : CLEAR_LINE);
+ ym3812_state *info = param;
+ if (info->intf->handler) (info->intf->handler)(info->device, irq ? ASSERT_LINE : CLEAR_LINE);
}
-static TIMER_CALLBACK( timer_callback_3812_0 )
+static TIMER_CALLBACK( timer_callback_0 )
{
- struct ym3812_info *info = ptr;
+ ym3812_state *info = ptr;
ym3812_timer_over(info->chip,0);
}
-static TIMER_CALLBACK( timer_callback_3812_1 )
+static TIMER_CALLBACK( timer_callback_1 )
{
- struct ym3812_info *info = ptr;
+ ym3812_state *info = ptr;
ym3812_timer_over(info->chip,1);
}
-static void TimerHandler_3812(void *param,int c,attotime period)
+static void TimerHandler(void *param,int c,attotime period)
{
- struct ym3812_info *info = param;
+ ym3812_state *info = param;
if( attotime_compare(period, attotime_zero) == 0 )
{ /* Reset FM Timer */
timer_enable(info->timer[c], 0);
@@ -68,485 +79,93 @@ static void TimerHandler_3812(void *param,int c,attotime period)
static STREAM_UPDATE( ym3812_stream_update )
{
- struct ym3812_info *info = param;
+ ym3812_state *info = param;
ym3812_update_one(info->chip, outputs[0], samples);
}
-static void _stream_update_3812(void * param, int interval)
+static void _stream_update(void * param, int interval)
{
- struct ym3812_info *info = param;
+ ym3812_state *info = param;
stream_update(info->stream);
}
-static SND_START( ym3812 )
+static DEVICE_START( ym3812 )
{
static const ym3812_interface dummy = { 0 };
- struct ym3812_info *info = device->token;
- int rate = clock/72;
+ ym3812_state *info = get_safe_token(device);
+ int rate = device->clock/72;
info->intf = device->static_config ? device->static_config : &dummy;
info->device = device;
/* stream system initialize */
- info->chip = ym3812_init(device,clock,rate);
+ info->chip = ym3812_init(device,device->clock,rate);
assert_always(info->chip != NULL, "Error creating YM3812 chip");
info->stream = stream_create(device,0,1,rate,info,ym3812_stream_update);
/* YM3812 setup */
- ym3812_set_timer_handler (info->chip, TimerHandler_3812, info);
- ym3812_set_irq_handler (info->chip, IRQHandler_3812, info);
- ym3812_set_update_handler(info->chip, _stream_update_3812, info);
+ ym3812_set_timer_handler (info->chip, TimerHandler, info);
+ ym3812_set_irq_handler (info->chip, IRQHandler, info);
+ ym3812_set_update_handler(info->chip, _stream_update, info);
- info->timer[0] = timer_alloc(device->machine, timer_callback_3812_0, info);
- info->timer[1] = timer_alloc(device->machine, timer_callback_3812_1, info);
+ info->timer[0] = timer_alloc(device->machine, timer_callback_0, info);
+ info->timer[1] = timer_alloc(device->machine, timer_callback_1, info);
}
-static SND_STOP( ym3812 )
+static DEVICE_STOP( ym3812 )
{
- struct ym3812_info *info = device->token;
+ ym3812_state *info = get_safe_token(device);
ym3812_shutdown(info->chip);
}
-static SND_RESET( ym3812 )
+static DEVICE_RESET( ym3812 )
{
- struct ym3812_info *info = device->token;
+ ym3812_state *info = get_safe_token(device);
ym3812_reset_chip(info->chip);
}
-WRITE8_HANDLER( ym3812_control_port_0_w ) {
- struct ym3812_info *info = sndti_token(SOUND_YM3812, 0);
- ym3812_write(info->chip, 0, data);
-}
-WRITE8_HANDLER( ym3812_write_port_0_w ) {
- struct ym3812_info *info = sndti_token(SOUND_YM3812, 0);
- ym3812_write(info->chip, 1, data);
-}
-READ8_HANDLER( ym3812_status_port_0_r ) {
- struct ym3812_info *info = sndti_token(SOUND_YM3812, 0);
- return ym3812_read(info->chip, 0);
-}
-READ8_HANDLER( ym3812_read_port_0_r ) {
- struct ym3812_info *info = sndti_token(SOUND_YM3812, 0);
- return ym3812_read(info->chip, 1);
-}
-
-
-WRITE8_HANDLER( ym3812_control_port_1_w ) {
- struct ym3812_info *info = sndti_token(SOUND_YM3812, 1);
- ym3812_write(info->chip, 0, data);
-}
-WRITE8_HANDLER( ym3812_write_port_1_w ) {
- struct ym3812_info *info = sndti_token(SOUND_YM3812, 1);
- ym3812_write(info->chip, 1, data);
-}
-READ8_HANDLER( ym3812_status_port_1_r ) {
- struct ym3812_info *info = sndti_token(SOUND_YM3812, 1);
- return ym3812_read(info->chip, 0);
-}
-READ8_HANDLER( ym3812_read_port_1_r ) {
- struct ym3812_info *info = sndti_token(SOUND_YM3812, 1);
- return ym3812_read(info->chip, 1);
-}
-
-/**************************************************************************
- * Generic get_info
- **************************************************************************/
-static SND_SET_INFO( ym3812 )
+READ8_DEVICE_HANDLER( ym3812_r )
{
- switch (state)
- {
- /* no parameters to set */
- }
+ ym3812_state *info = get_safe_token(device);
+ return ym3812_read(info->chip, offset & 1);
}
-
-SND_GET_INFO( ym3812 )
+WRITE8_DEVICE_HANDLER( ym3812_w )
{
- switch (state)
- {
- /* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym3812_info); break;
-
- /* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( ym3812 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ym3812 ); break;
- case SNDINFO_PTR_STOP: info->stop = SND_STOP_NAME( ym3812 ); break;
- case SNDINFO_PTR_RESET: info->reset = SND_RESET_NAME( ym3812 ); break;
-
- /* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "YM3812"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Yamaha FM"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
- }
+ ym3812_state *info = get_safe_token(device);
+ ym3812_write(info->chip, offset & 1, data);
}
-#endif
+READ8_DEVICE_HANDLER( ym3812_status_port_r ) { return ym3812_r(device, 0); }
+READ8_DEVICE_HANDLER( ym3812_read_port_r ) { return ym3812_r(device, 1); }
+WRITE8_DEVICE_HANDLER( ym3812_control_port_w ) { ym3812_w(device, 0, data); }
+WRITE8_DEVICE_HANDLER( ym3812_write_port_w ) { ym3812_w(device, 1, data); }
-#if BUILD_YM3526
-
-struct ym3526_info
-{
- sound_stream * stream;
- emu_timer * timer[2];
- void * chip;
- const ym3526_interface *intf;
- const device_config *device;
-};
-
-
-/* IRQ Handler */
-static void IRQHandler_3526(void *param,int irq)
-{
- struct ym3526_info *info = param;
- if (info->intf->handler) (info->intf->handler)(info->device->machine, irq ? ASSERT_LINE : CLEAR_LINE);
-}
-/* Timer overflow callback from timer.c */
-static TIMER_CALLBACK( timer_callback_3526_0 )
-{
- struct ym3526_info *info = ptr;
- ym3526_timer_over(info->chip,0);
-}
-static TIMER_CALLBACK( timer_callback_3526_1 )
-{
- struct ym3526_info *info = ptr;
- ym3526_timer_over(info->chip,1);
-}
-/* TimerHandler from fm.c */
-static void TimerHandler_3526(void *param,int c,attotime period)
-{
- struct ym3526_info *info = param;
- if( attotime_compare(period, attotime_zero) == 0 )
- { /* Reset FM Timer */
- timer_enable(info->timer[c], 0);
- }
- else
- { /* Start FM Timer */
- timer_adjust_oneshot(info->timer[c], period, 0);
- }
-}
-
-
-static STREAM_UPDATE( ym3526_stream_update )
-{
- struct ym3526_info *info = param;
- ym3526_update_one(info->chip, outputs[0], samples);
-}
-
-static void _stream_update_3526(void *param, int interval)
-{
- struct ym3526_info *info = param;
- stream_update(info->stream);
-}
-
-
-static SND_START( ym3526 )
-{
- static const ym3526_interface dummy = { 0 };
- struct ym3526_info *info = device->token;
- int rate = clock/72;
-
- info->intf = device->static_config ? device->static_config : &dummy;
- info->device = device;
-
- /* stream system initialize */
- info->chip = ym3526_init(device,clock,rate);
- assert_always(info->chip != NULL, "Error creating YM3526 chip");
-
- info->stream = stream_create(device,0,1,rate,info,ym3526_stream_update);
- /* YM3526 setup */
- ym3526_set_timer_handler (info->chip, TimerHandler_3526, info);
- ym3526_set_irq_handler (info->chip, IRQHandler_3526, info);
- ym3526_set_update_handler(info->chip, _stream_update_3526, info);
-
- info->timer[0] = timer_alloc(device->machine, timer_callback_3526_0, info);
- info->timer[1] = timer_alloc(device->machine, timer_callback_3526_1, info);
-}
-
-static SND_STOP( ym3526 )
-{
- struct ym3526_info *info = device->token;
- ym3526_shutdown(info->chip);
-}
-
-static SND_RESET( ym3526 )
-{
- struct ym3526_info *info = device->token;
- ym3526_reset_chip(info->chip);
-}
-
-WRITE8_HANDLER( ym3526_control_port_0_w ) {
- struct ym3526_info *info = sndti_token(SOUND_YM3526, 0);
- ym3526_write(info->chip, 0, data);
-}
-WRITE8_HANDLER( ym3526_write_port_0_w ) {
- struct ym3526_info *info = sndti_token(SOUND_YM3526, 0);
- ym3526_write(info->chip, 1, data);
-}
-READ8_HANDLER( ym3526_status_port_0_r ) {
- struct ym3526_info *info = sndti_token(SOUND_YM3526, 0);
- return ym3526_read(info->chip, 0);
-}
-READ8_HANDLER( ym3526_read_port_0_r ) {
- struct ym3526_info *info = sndti_token(SOUND_YM3526, 0);
- return ym3526_read(info->chip, 1);
-}
-
-
-WRITE8_HANDLER( ym3526_control_port_1_w ) {
- struct ym3526_info *info = sndti_token(SOUND_YM3526, 1);
- ym3526_write(info->chip, 0, data);
-}
-WRITE8_HANDLER( ym3526_write_port_1_w ) {
- struct ym3526_info *info = sndti_token(SOUND_YM3526, 1);
- ym3526_write(info->chip, 1, data);
-}
-READ8_HANDLER( ym3526_status_port_1_r ) {
- struct ym3526_info *info = sndti_token(SOUND_YM3526, 1);
- return ym3526_read(info->chip, 0);
-}
-READ8_HANDLER( ym3526_read_port_1_r ) {
- struct ym3526_info *info = sndti_token(SOUND_YM3526, 1);
- return ym3526_read(info->chip, 1);
-}
-
/**************************************************************************
* Generic get_info
**************************************************************************/
-static SND_SET_INFO( ym3526 )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
-SND_GET_INFO( ym3526 )
+DEVICE_GET_INFO( ym3812 )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct ym3526_info); break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ym3812_state); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( ym3526 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ym3526 ); break;
- case SNDINFO_PTR_STOP: info->stop = SND_STOP_NAME( ym3526 ); break;
- case SNDINFO_PTR_RESET: info->reset = SND_RESET_NAME( ym3526 ); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ym3812 ); break;
+ case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME( ym3812 ); break;
+ case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( ym3812 ); break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "YM3526"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Yamaha FM"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "YM3812"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "Yamaha FM"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}
-
-#endif
-
-
-#if BUILD_Y8950
-
-struct y8950_info
-{
- sound_stream * stream;
- emu_timer * timer[2];
- void * chip;
- const y8950_interface *intf;
- const device_config *device;
-};
-
-static void IRQHandler_8950(void *param,int irq)
-{
- struct y8950_info *info = param;
- if (info->intf->handler) (info->intf->handler)(info->device->machine, irq ? ASSERT_LINE : CLEAR_LINE);
-}
-static TIMER_CALLBACK( timer_callback_8950_0 )
-{
- struct y8950_info *info = ptr;
- y8950_timer_over(info->chip,0);
-}
-static TIMER_CALLBACK( timer_callback_8950_1 )
-{
- struct y8950_info *info = ptr;
- y8950_timer_over(info->chip,1);
-}
-static void TimerHandler_8950(void *param,int c,attotime period)
-{
- struct y8950_info *info = param;
- if( attotime_compare(period, attotime_zero) == 0 )
- { /* Reset FM Timer */
- timer_enable(info->timer[c], 0);
- }
- else
- { /* Start FM Timer */
- timer_adjust_oneshot(info->timer[c], period, 0);
- }
-}
-
-
-static unsigned char Y8950PortHandler_r(void *param)
-{
- struct y8950_info *info = param;
- if (info->intf->portread)
- return info->intf->portread(info->device,0);
- return 0;
-}
-
-static void Y8950PortHandler_w(void *param,unsigned char data)
-{
- struct y8950_info *info = param;
- if (info->intf->portwrite)
- info->intf->portwrite(info->device,0,data);
-}
-
-static unsigned char Y8950KeyboardHandler_r(void *param)
-{
- struct y8950_info *info = param;
- if (info->intf->keyboardread)
- return info->intf->keyboardread(info->device,0);
- return 0;
-}
-
-static void Y8950KeyboardHandler_w(void *param,unsigned char data)
-{
- struct y8950_info *info = param;
- if (info->intf->keyboardwrite)
- info->intf->keyboardwrite(info->device,0,data);
-}
-
-static STREAM_UPDATE( y8950_stream_update )
-{
- struct y8950_info *info = param;
- y8950_update_one(info->chip, outputs[0], samples);
-}
-
-static void _stream_update_8950(void *param, int interval)
-{
- struct y8950_info *info = param;
- stream_update(info->stream);
-}
-
-
-static SND_START( y8950 )
-{
- static const y8950_interface dummy = { 0 };
- struct y8950_info *info = device->token;
- int rate = clock/72;
-
- info->intf = device->static_config ? device->static_config : &dummy;
- info->device = device;
-
- /* stream system initialize */
- info->chip = y8950_init(device,clock,rate);
- assert_always(info->chip != NULL, "Error creating Y8950 chip");
-
- /* ADPCM ROM data */
- y8950_set_delta_t_memory(info->chip, device->region, device->regionbytes);
-
- info->stream = stream_create(device,0,1,rate,info,y8950_stream_update);
-
- /* port and keyboard handler */
- y8950_set_port_handler(info->chip, Y8950PortHandler_w, Y8950PortHandler_r, info);
- y8950_set_keyboard_handler(info->chip, Y8950KeyboardHandler_w, Y8950KeyboardHandler_r, info);
-
- /* Y8950 setup */
- y8950_set_timer_handler (info->chip, TimerHandler_8950, info);
- y8950_set_irq_handler (info->chip, IRQHandler_8950, info);
- y8950_set_update_handler(info->chip, _stream_update_8950, info);
-
- info->timer[0] = timer_alloc(device->machine, timer_callback_8950_0, info);
- info->timer[1] = timer_alloc(device->machine, timer_callback_8950_1, info);
-}
-
-static SND_STOP( y8950 )
-{
- struct y8950_info *info = device->token;
- y8950_shutdown(info->chip);
-}
-
-static SND_RESET( y8950 )
-{
- struct y8950_info *info = device->token;
- y8950_reset_chip(info->chip);
-}
-
-WRITE8_HANDLER( y8950_control_port_0_w ) {
- struct y8950_info *info = sndti_token(SOUND_Y8950, 0);
- y8950_write(info->chip, 0, data);
-}
-WRITE8_HANDLER( y8950_write_port_0_w ) {
- struct y8950_info *info = sndti_token(SOUND_Y8950, 0);
- y8950_write(info->chip, 1, data);
-}
-READ8_HANDLER( y8950_status_port_0_r ) {
- struct y8950_info *info = sndti_token(SOUND_Y8950, 0);
- return y8950_read(info->chip, 0);
-}
-READ8_HANDLER( y8950_read_port_0_r ) {
- struct y8950_info *info = sndti_token(SOUND_Y8950, 0);
- return y8950_read(info->chip, 1);
-}
-
-
-WRITE8_HANDLER( y8950_control_port_1_w ) {
- struct y8950_info *info = sndti_token(SOUND_Y8950, 1);
- y8950_write(info->chip, 0, data);
-}
-WRITE8_HANDLER( y8950_write_port_1_w ) {
- struct y8950_info *info = sndti_token(SOUND_Y8950, 1);
- y8950_write(info->chip, 1, data);
-}
-READ8_HANDLER( y8950_status_port_1_r ) {
- struct y8950_info *info = sndti_token(SOUND_Y8950, 1);
- return y8950_read(info->chip, 0);
-}
-READ8_HANDLER( y8950_read_port_1_r ) {
- struct y8950_info *info = sndti_token(SOUND_Y8950, 1);
- return y8950_read(info->chip, 1);
-}
-
-/**************************************************************************
- * Generic get_info
- **************************************************************************/
-
-static SND_SET_INFO( y8950 )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
-SND_GET_INFO( y8950 )
-{
- switch (state)
- {
- /* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct y8950_info); break;
-
- /* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( y8950 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( y8950 ); break;
- case SNDINFO_PTR_STOP: info->stop = SND_STOP_NAME( y8950 ); break;
- case SNDINFO_PTR_RESET: info->reset = SND_RESET_NAME( y8950 ); break;
-
- /* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "Y8950"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Yamaha FM"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
- }
-}
-
-#endif
diff --git a/src/emu/sound/3812intf.h b/src/emu/sound/3812intf.h
index bd7c5ac818c..7f1fe932cdb 100644
--- a/src/emu/sound/3812intf.h
+++ b/src/emu/sound/3812intf.h
@@ -3,67 +3,21 @@
#ifndef __3812INTF_H__
#define __3812INTF_H__
-
typedef struct _ym3812_interface ym3812_interface;
struct _ym3812_interface
{
- void (*handler)(running_machine *machine, int linestate);
+ void (*handler)(const device_config *device, int linestate);
};
-#define ym3526_interface ym3812_interface
-
-typedef struct _y8950_interface y8950_interface;
-struct _y8950_interface
-{
- void (*handler)(running_machine *machine, int linestate);
-
- read8_device_func keyboardread;
- write8_device_func keyboardwrite;
- read8_device_func portread;
- write8_device_func portwrite;
-};
-
-
-/* YM3812 */
-READ8_HANDLER ( ym3812_status_port_0_r );
-WRITE8_HANDLER( ym3812_control_port_0_w );
-READ8_HANDLER( ym3812_read_port_0_r );
-WRITE8_HANDLER( ym3812_write_port_0_w );
-
-READ8_HANDLER ( ym3812_status_port_1_r );
-WRITE8_HANDLER( ym3812_control_port_1_w );
-READ8_HANDLER( ym3812_read_port_1_r );
-WRITE8_HANDLER( ym3812_write_port_1_w );
-
-SND_GET_INFO( ym3812 );
-#define SOUND_YM3812 SND_GET_INFO_NAME( ym3812 )
-
-/* YM3526 */
-READ8_HANDLER ( ym3526_status_port_0_r );
-WRITE8_HANDLER( ym3526_control_port_0_w );
-READ8_HANDLER( ym3526_read_port_0_r );
-WRITE8_HANDLER( ym3526_write_port_0_w );
-
-READ8_HANDLER ( ym3526_status_port_1_r );
-WRITE8_HANDLER( ym3526_control_port_1_w );
-READ8_HANDLER( ym3526_read_port_1_r );
-WRITE8_HANDLER( ym3526_write_port_1_w );
-
-SND_GET_INFO( ym3526 );
-#define SOUND_YM3526 SND_GET_INFO_NAME( ym3526 )
-
-/* Y8950 */
-READ8_HANDLER ( y8950_status_port_0_r );
-WRITE8_HANDLER( y8950_control_port_0_w );
-READ8_HANDLER ( y8950_read_port_0_r );
-WRITE8_HANDLER( y8950_write_port_0_w );
+READ8_DEVICE_HANDLER( ym3812_r );
+WRITE8_DEVICE_HANDLER( ym3812_w );
-READ8_HANDLER ( y8950_status_port_1_r );
-WRITE8_HANDLER( y8950_control_port_1_w );
-READ8_HANDLER ( y8950_read_port_1_r );
-WRITE8_HANDLER( y8950_write_port_1_w );
+READ8_DEVICE_HANDLER( ym3812_status_port_r );
+READ8_DEVICE_HANDLER( ym3812_read_port_r );
+WRITE8_DEVICE_HANDLER( ym3812_control_port_w );
+WRITE8_DEVICE_HANDLER( ym3812_write_port_w );
-SND_GET_INFO( y8950 );
-#define SOUND_Y8950 SND_GET_INFO_NAME( y8950 )
+DEVICE_GET_INFO( ym3812 );
+#define SOUND_YM3812 DEVICE_GET_INFO_NAME( ym3812 )
#endif /* __3812INTF_H__ */
diff --git a/src/emu/sound/5110intf.c b/src/emu/sound/5110intf.c
index 893973f8dc2..53e95538314 100644
--- a/src/emu/sound/5110intf.c
+++ b/src/emu/sound/5110intf.c
@@ -22,7 +22,8 @@
/* the state of the streamed output */
-struct tms5110_info
+typedef struct _tms5110_state tms5110_state;
+struct _tms5110_state
{
const tms5110_interface *intf;
const UINT8 *table;
@@ -32,12 +33,28 @@ struct tms5110_info
};
+INLINE tms5110_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_TMS5110 ||
+ sound_get_type(device) == SOUND_TMS5100 ||
+ sound_get_type(device) == SOUND_TMS5110A ||
+ sound_get_type(device) == SOUND_CD2801 ||
+ sound_get_type(device) == SOUND_TMC0281 ||
+ sound_get_type(device) == SOUND_CD2802 ||
+ sound_get_type(device) == SOUND_M58817);
+ return (tms5110_state *)device->token;
+}
+
+
/* static function prototypes */
static STREAM_UPDATE( tms5110_update );
static int speech_rom_read_bit(const device_config *device)
{
- struct tms5110_info *info = sndti_token(SOUND_TMS5110, 0);
+ tms5110_state *info = get_safe_token(device);
int r;
@@ -51,23 +68,23 @@ static int speech_rom_read_bit(const device_config *device)
return r;
}
-static void speech_rom_set_addr(int addr)
+static void speech_rom_set_addr(const device_config *device, int addr)
{
- struct tms5110_info *info = sndti_token(SOUND_TMS5110, 0);
+ tms5110_state *info = get_safe_token(device);
info->speech_rom_bitnum = addr * 8 - 1;
}
/******************************************************************************
- SND_START( tms5110 ) -- allocate buffers and reset the 5110
+ DEVICE_START( tms5110 ) -- allocate buffers and reset the 5110
******************************************************************************/
-static SND_START( tms5110 )
+static DEVICE_START( tms5110 )
{
static const tms5110_interface dummy = { 0 };
- struct tms5110_info *info = device->token;
+ tms5110_state *info = get_safe_token(device);
info->intf = device->static_config ? device->static_config : &dummy;
info->table = device->region;
@@ -76,7 +93,7 @@ static SND_START( tms5110 )
assert_always(info->chip != NULL, "Error creating TMS5110 chip");
/* initialize a stream */
- info->stream = stream_create(device, 0, 1, clock / 80, info, tms5110_update);
+ info->stream = stream_create(device, 0, 1, device->clock / 80, info, tms5110_update);
if (info->table == NULL)
{
@@ -94,65 +111,65 @@ static SND_START( tms5110 )
tms5110_reset_chip(info->chip);
}
-static SND_START( tms5100 )
+static DEVICE_START( tms5100 )
{
- struct tms5110_info *info = device->token;
- SND_START_CALL( tms5110 );
+ tms5110_state *info = get_safe_token(device);
+ DEVICE_START_CALL( tms5110 );
tms5110_set_variant(info->chip, TMS5110_IS_5100);
}
-static SND_START( tms5110a )
+static DEVICE_START( tms5110a )
{
- struct tms5110_info *info = device->token;
- SND_START_CALL( tms5110 );
+ tms5110_state *info = get_safe_token(device);
+ DEVICE_START_CALL( tms5110 );
tms5110_set_variant(info->chip, TMS5110_IS_5110A);
}
-static SND_START( cd2801 )
+static DEVICE_START( cd2801 )
{
- struct tms5110_info *info = device->token;
- SND_START_CALL( tms5110 );
+ tms5110_state *info = get_safe_token(device);
+ DEVICE_START_CALL( tms5110 );
tms5110_set_variant(info->chip, TMS5110_IS_CD2801);
}
-static SND_START( tmc0281 )
+static DEVICE_START( tmc0281 )
{
- struct tms5110_info *info = device->token;
- SND_START_CALL( tms5110 );
+ tms5110_state *info = get_safe_token(device);
+ DEVICE_START_CALL( tms5110 );
tms5110_set_variant(info->chip, TMS5110_IS_TMC0281);
}
-static SND_START( cd2802 )
+static DEVICE_START( cd2802 )
{
- struct tms5110_info *info = device->token;
- SND_START_CALL( tms5110 );
+ tms5110_state *info = get_safe_token(device);
+ DEVICE_START_CALL( tms5110 );
tms5110_set_variant(info->chip, TMS5110_IS_CD2802);
}
-static SND_START( m58817 )
+static DEVICE_START( m58817 )
{
- struct tms5110_info *info = device->token;
- SND_START_CALL( tms5110 );
+ tms5110_state *info = get_safe_token(device);
+ DEVICE_START_CALL( tms5110 );
tms5110_set_variant(info->chip, TMS5110_IS_M58817);
}
/******************************************************************************
- SND_STOP( tms5110 ) -- free buffers
+ DEVICE_STOP( tms5110 ) -- free buffers
******************************************************************************/
-static SND_STOP( tms5110 )
+static DEVICE_STOP( tms5110 )
{
- struct tms5110_info *info = device->token;
+ tms5110_state *info = get_safe_token(device);
tms5110_destroy(info->chip);
}
-static SND_RESET( tms5110 )
+static DEVICE_RESET( tms5110 )
{
- struct tms5110_info *info = device->token;
+ tms5110_state *info = get_safe_token(device);
tms5110_reset_chip(info->chip);
}
@@ -165,9 +182,9 @@ commands like Speech, Reset, etc., are loaded into the chip via the CTL pins
******************************************************************************/
-WRITE8_HANDLER( tms5110_ctl_w )
+WRITE8_DEVICE_HANDLER( tms5110_ctl_w )
{
- struct tms5110_info *info = sndti_token(SOUND_TMS5110, 0);
+ tms5110_state *info = get_safe_token(device);
/* bring up to date first */
stream_update(info->stream);
@@ -180,9 +197,9 @@ WRITE8_HANDLER( tms5110_ctl_w )
******************************************************************************/
-WRITE8_HANDLER( tms5110_pdc_w )
+WRITE8_DEVICE_HANDLER( tms5110_pdc_w )
{
- struct tms5110_info *info = sndti_token(SOUND_TMS5110, 0);
+ tms5110_state *info = get_safe_token(device);
/* bring up to date first */
stream_update(info->stream);
@@ -197,9 +214,9 @@ WRITE8_HANDLER( tms5110_pdc_w )
******************************************************************************/
-READ8_HANDLER( tms5110_status_r )
+READ8_DEVICE_HANDLER( tms5110_status_r )
{
- struct tms5110_info *info = sndti_token(SOUND_TMS5110, 0);
+ tms5110_state *info = get_safe_token(device);
/* bring up to date first */
stream_update(info->stream);
@@ -214,9 +231,9 @@ READ8_HANDLER( tms5110_status_r )
******************************************************************************/
-int tms5110_ready_r(void)
+int tms5110_ready_r(const device_config *device)
{
- struct tms5110_info *info = sndti_token(SOUND_TMS5110, 0);
+ tms5110_state *info = get_safe_token(device);
/* bring up to date first */
stream_update(info->stream);
@@ -233,7 +250,7 @@ int tms5110_ready_r(void)
static STREAM_UPDATE( tms5110_update )
{
- struct tms5110_info *info = param;
+ tms5110_state *info = param;
INT16 sample_data[MAX_SAMPLE_CHUNK];
stream_sample_t *buffer = outputs[0];
@@ -261,9 +278,9 @@ static STREAM_UPDATE( tms5110_update )
******************************************************************************/
-void tms5110_set_frequency(int frequency)
+void tms5110_set_frequency(const device_config *device, int frequency)
{
- struct tms5110_info *info = sndti_token(SOUND_TMS5110, 0);
+ tms5110_state *info = get_safe_token(device);
stream_set_sample_rate(info->stream, frequency / 80);
}
@@ -274,96 +291,83 @@ void tms5110_set_frequency(int frequency)
* Generic get_info
**************************************************************************/
-static SND_SET_INFO( tms5110 )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-SND_GET_INFO( tms5110 )
+DEVICE_GET_INFO( tms5110 )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct tms5110_info); break;
- case SNDINFO_FCT_ALIAS: info->type = SOUND_TMS5110; break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(tms5110_state); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( tms5110 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( tms5110 ); break;
- case SNDINFO_PTR_STOP: info->stop = SND_STOP_NAME( tms5110 ); break;
- case SNDINFO_PTR_RESET: info->reset = SND_RESET_NAME( tms5110 ); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( tms5110 ); break;
+ case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME( tms5110 ); break;
+ case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( tms5110 ); break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "TMS5110"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "TI Speech"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "TMS5110"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "TI Speech"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}
-SND_GET_INFO( tms5100 )
+DEVICE_GET_INFO( tms5100 )
{
switch (state)
{
- case SNDINFO_PTR_START: info->start = SND_START_NAME( tms5100 ); break;
- case SNDINFO_STR_NAME: strcpy(info->s, "TMS5100"); break;
- default: SND_GET_INFO_CALL(tms5110); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( tms5100 ); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "TMS5100"); break;
+ default: DEVICE_GET_INFO_CALL(tms5110); break;
}
}
-SND_GET_INFO( tms5110a )
+DEVICE_GET_INFO( tms5110a )
{
switch (state)
{
- case SNDINFO_PTR_START: info->start = SND_START_NAME( tms5110a ); break;
- case SNDINFO_STR_NAME: strcpy(info->s, "TMS5100A"); break;
- default: SND_GET_INFO_CALL(tms5110); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( tms5110a ); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "TMS5100A"); break;
+ default: DEVICE_GET_INFO_CALL(tms5110); break;
}
}
-SND_GET_INFO( cd2801 )
+DEVICE_GET_INFO( cd2801 )
{
switch (state)
{
- case SNDINFO_PTR_START: info->start = SND_START_NAME( cd2801 ); break;
- case SNDINFO_STR_NAME: strcpy(info->s, "CD2801"); break;
- default: SND_GET_INFO_CALL(tms5110); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( cd2801 ); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "CD2801"); break;
+ default: DEVICE_GET_INFO_CALL(tms5110); break;
}
}
-SND_GET_INFO( tmc0281 )
+DEVICE_GET_INFO( tmc0281 )
{
switch (state)
{
- case SNDINFO_PTR_START: info->start = SND_START_NAME( tmc0281 ); break;
- case SNDINFO_STR_NAME: strcpy(info->s, "TMS5100"); break;
- default: SND_GET_INFO_CALL(tms5110); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( tmc0281 ); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "TMS5100"); break;
+ default: DEVICE_GET_INFO_CALL(tms5110); break;
}
}
-SND_GET_INFO( cd2802 )
+DEVICE_GET_INFO( cd2802 )
{
switch (state)
{
- case SNDINFO_PTR_START: info->start = SND_START_NAME( cd2802 ); break;
- case SNDINFO_STR_NAME: strcpy(info->s, "CD2802"); break;
- default: SND_GET_INFO_CALL(tms5110); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( cd2802 ); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "CD2802"); break;
+ default: DEVICE_GET_INFO_CALL(tms5110); break;
}
}
-SND_GET_INFO( m58817 )
+DEVICE_GET_INFO( m58817 )
{
switch (state)
{
- case SNDINFO_PTR_START: info->start = SND_START_NAME( m58817 ); break;
- case SNDINFO_STR_NAME: strcpy(info->s, "M58817"); break;
- default: SND_GET_INFO_CALL(tms5110); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( m58817 ); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "M58817"); break;
+ default: DEVICE_GET_INFO_CALL(tms5110); break;
}
}
-
-
-
diff --git a/src/emu/sound/5110intf.h b/src/emu/sound/5110intf.h
index 8ec02891475..5834fbbdc5b 100644
--- a/src/emu/sound/5110intf.h
+++ b/src/emu/sound/5110intf.h
@@ -11,31 +11,31 @@ typedef struct _tms5110_interface tms5110_interface;
struct _tms5110_interface
{
int (*M0_callback)(const device_config *device); /* function to be called when chip requests another bit */
- void (*load_address)(int addr); /* speech ROM load address callback */
+ void (*load_address)(const device_config *device, int addr); /* speech ROM load address callback */
};
-WRITE8_HANDLER( tms5110_ctl_w );
-WRITE8_HANDLER( tms5110_pdc_w );
-
-READ8_HANDLER( tms5110_status_r );
-int tms5110_ready_r(void);
-
-void tms5110_set_frequency(int frequency);
-
-SND_GET_INFO( tms5110 );
-SND_GET_INFO( tms5100 );
-SND_GET_INFO( tms5110a );
-SND_GET_INFO( cd2801 );
-SND_GET_INFO( tmc0281 );
-SND_GET_INFO( cd2802 );
-SND_GET_INFO( m58817 );
-
-#define SOUND_TMS5110 SND_GET_INFO_NAME( tms5110 )
-#define SOUND_TMS5100 SND_GET_INFO_NAME( tms5100 )
-#define SOUND_TMS5110A SND_GET_INFO_NAME( tms5110a )
-#define SOUND_CD2801 SND_GET_INFO_NAME( cd2801 )
-#define SOUND_TMC0281 SND_GET_INFO_NAME( tmc0281 )
-#define SOUND_CD2802 SND_GET_INFO_NAME( cd2802 )
-#define SOUND_M58817 SND_GET_INFO_NAME( m58817 )
+WRITE8_DEVICE_HANDLER( tms5110_ctl_w );
+WRITE8_DEVICE_HANDLER( tms5110_pdc_w );
+
+READ8_DEVICE_HANDLER( tms5110_status_r );
+int tms5110_ready_r(const device_config *device);
+
+void tms5110_set_frequency(const device_config *device, int frequency);
+
+DEVICE_GET_INFO( tms5110 );
+DEVICE_GET_INFO( tms5100 );
+DEVICE_GET_INFO( tms5110a );
+DEVICE_GET_INFO( cd2801 );
+DEVICE_GET_INFO( tmc0281 );
+DEVICE_GET_INFO( cd2802 );
+DEVICE_GET_INFO( m58817 );
+
+#define SOUND_TMS5110 DEVICE_GET_INFO_NAME( tms5110 )
+#define SOUND_TMS5100 DEVICE_GET_INFO_NAME( tms5100 )
+#define SOUND_TMS5110A DEVICE_GET_INFO_NAME( tms5110a )
+#define SOUND_CD2801 DEVICE_GET_INFO_NAME( cd2801 )
+#define SOUND_TMC0281 DEVICE_GET_INFO_NAME( tmc0281 )
+#define SOUND_CD2802 DEVICE_GET_INFO_NAME( cd2802 )
+#define SOUND_M58817 DEVICE_GET_INFO_NAME( m58817 )
#endif /* __5110INTF_H__ */
diff --git a/src/emu/sound/5220intf.c b/src/emu/sound/5220intf.c
index 0a24db7dc10..f3daac7c3fb 100644
--- a/src/emu/sound/5220intf.c
+++ b/src/emu/sound/5220intf.c
@@ -21,7 +21,8 @@
/* the state of the streamed output */
-struct tms5220_info
+typedef struct _tms5220_state tms5220_state;
+struct _tms5220_state
{
const tms5220_interface *intf;
sound_stream *stream;
@@ -30,6 +31,18 @@ struct tms5220_info
};
+INLINE tms5220_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_TMS5220 ||
+ sound_get_type(device) == SOUND_TMC0285 ||
+ sound_get_type(device) == SOUND_TMS5200);
+ return (tms5220_state *)device->token;
+}
+
+
/* static function prototypes */
static STREAM_UPDATE( tms5220_update );
@@ -37,14 +50,14 @@ static STREAM_UPDATE( tms5220_update );
/**********************************************************************************************
- SND_START( tms5220 ) -- allocate buffers and reset the 5220
+ DEVICE_START( tms5220 ) -- allocate buffers and reset the 5220
***********************************************************************************************/
-static SND_START( tms5220 )
+static DEVICE_START( tms5220 )
{
static const tms5220_interface dummy = { 0 };
- struct tms5220_info *info = device->token;
+ tms5220_state *info = get_safe_token(device);
info->intf = device->static_config ? device->static_config : &dummy;
@@ -52,8 +65,8 @@ static SND_START( tms5220 )
assert_always(info->chip != NULL, "Error creating TMS5220 chip");
/* initialize a info->stream */
- info->stream = stream_create(device, 0, 1, clock / 80, info, tms5220_update);
- info->clock = clock;
+ info->stream = stream_create(device, 0, 1, device->clock / 80, info, tms5220_update);
+ info->clock = device->clock;
/* reset the 5220 */
tms5220_reset_chip(info->chip);
@@ -67,10 +80,10 @@ static SND_START( tms5220 )
#if (HAS_TMC0285 || HAS_TMS5200)
-static SND_START( tms5200 )
+static DEVICE_START( tms5200 )
{
- struct tms5220_info *info = device->token;
- SND_START_CALL( tms5220 );
+ tms5220_state *info = get_safe_token(device);
+ DEVICE_START_CALL( tms5220 );
tms5220_set_variant(info->chip, variant_tmc0285);
}
#endif /* (HAS_TMC0285) && (HAS_TMS5200) */
@@ -79,21 +92,21 @@ static SND_START( tms5200 )
/**********************************************************************************************
- SND_STOP( tms5220 ) -- free buffers
+ DEVICE_STOP( tms5220 ) -- free buffers
***********************************************************************************************/
-static SND_STOP( tms5220 )
+static DEVICE_STOP( tms5220 )
{
- struct tms5220_info *info = device->token;
+ tms5220_state *info = get_safe_token(device);
tms5220_destroy(info->chip);
}
-static SND_RESET( tms5220 )
+static DEVICE_RESET( tms5220 )
{
- struct tms5220_info *info = device->token;
+ tms5220_state *info = get_safe_token(device);
tms5220_reset_chip(info->chip);
}
@@ -105,9 +118,9 @@ static SND_RESET( tms5220 )
***********************************************************************************************/
-WRITE8_HANDLER( tms5220_data_w )
+WRITE8_DEVICE_HANDLER( tms5220_data_w )
{
- struct tms5220_info *info = sndti_token(SOUND_TMS5220, 0);
+ tms5220_state *info = get_safe_token(device);
/* bring up to date first */
stream_update(info->stream);
tms5220_data_write(info->chip, data);
@@ -121,9 +134,9 @@ WRITE8_HANDLER( tms5220_data_w )
***********************************************************************************************/
-READ8_HANDLER( tms5220_status_r )
+READ8_DEVICE_HANDLER( tms5220_status_r )
{
- struct tms5220_info *info = sndti_token(SOUND_TMS5220, 0);
+ tms5220_state *info = get_safe_token(device);
/* bring up to date first */
stream_update(info->stream);
return tms5220_status_read(info->chip);
@@ -137,9 +150,9 @@ READ8_HANDLER( tms5220_status_r )
***********************************************************************************************/
-int tms5220_ready_r(void)
+int tms5220_ready_r(const device_config *device)
{
- struct tms5220_info *info = sndti_token(SOUND_TMS5220, 0);
+ tms5220_state *info = get_safe_token(device);
/* bring up to date first */
stream_update(info->stream);
return tms5220_ready_read(info->chip);
@@ -149,13 +162,13 @@ int tms5220_ready_r(void)
/**********************************************************************************************
- tms5220_ready_r -- return the time in seconds until the ready line is asserted
+ tms5220_time_to_ready -- return the time in seconds until the ready line is asserted
***********************************************************************************************/
-double tms5220_time_to_ready(void)
+double tms5220_time_to_ready(const device_config *device)
{
- struct tms5220_info *info = sndti_token(SOUND_TMS5220, 0);
+ tms5220_state *info = get_safe_token(device);
double cycles;
/* bring up to date first */
@@ -172,9 +185,9 @@ double tms5220_time_to_ready(void)
***********************************************************************************************/
-int tms5220_int_r(void)
+int tms5220_int_r(const device_config *device)
{
- struct tms5220_info *info = sndti_token(SOUND_TMS5220, 0);
+ tms5220_state *info = get_safe_token(device);
/* bring up to date first */
stream_update(info->stream);
return tms5220_int_read(info->chip);
@@ -190,7 +203,7 @@ int tms5220_int_r(void)
static STREAM_UPDATE( tms5220_update )
{
- struct tms5220_info *info = param;
+ tms5220_state *info = param;
INT16 sample_data[MAX_SAMPLE_CHUNK];
stream_sample_t *buffer = outputs[0];
@@ -218,9 +231,9 @@ static STREAM_UPDATE( tms5220_update )
***********************************************************************************************/
-void tms5220_set_frequency(int frequency)
+void tms5220_set_frequency(const device_config *device, int frequency)
{
- struct tms5220_info *info = sndti_token(SOUND_TMS5220, 0);
+ tms5220_state *info = get_safe_token(device);
stream_set_sample_rate(info->stream, frequency / 80);
info->clock = frequency;
}
@@ -231,60 +244,47 @@ void tms5220_set_frequency(int frequency)
* Generic get_info
**************************************************************************/
-static SND_SET_INFO( tms5220 )
-{
- struct tms5220_info *ti = device->token;
-
- switch (state)
- {
- case SNDINFO_INT_TMS5220_VARIANT: tms5220_set_variant(ti->chip, (tms5220_variant) info->i); break;
- }
-}
-
-
-SND_GET_INFO( tms5220 )
+DEVICE_GET_INFO( tms5220 )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct tms5220_info); break;
- case SNDINFO_FCT_ALIAS: info->type = SOUND_TMS5220; break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(tms5220_state); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( tms5220 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( tms5220 ); break;
- case SNDINFO_PTR_STOP: info->stop = SND_STOP_NAME( tms5220 ); break;
- case SNDINFO_PTR_RESET: info->reset = SND_RESET_NAME( tms5220 ); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( tms5220 ); break;
+ case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME( tms5220 ); break;
+ case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( tms5220 ); break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "TMS5220"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "TI Speech"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "TMS5220"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "TI Speech"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}
#if (HAS_TMC0285)
-SND_GET_INFO( tmc0285 )
+DEVICE_GET_INFO( tmc0285 )
{
switch (state)
{
- case SNDINFO_PTR_START: info->start = SND_START_NAME( tms5200 ); break;
- case SNDINFO_STR_NAME: strcpy(info->s, "TMC0285"); break;
- default: SND_GET_INFO_CALL( tms5220 ); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( tms5200 ); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "TMC0285"); break;
+ default: DEVICE_GET_INFO_CALL( tms5220 ); break;
}
}
#endif
#if (HAS_TMS5200)
-SND_GET_INFO( tms5200 )
+DEVICE_GET_INFO( tms5200 )
{
switch (state)
{
- case SNDINFO_PTR_START: info->start = SND_START_NAME( tms5200 ); break;
- case SNDINFO_STR_NAME: strcpy(info->s, "TMS5200"); break;
- default: SND_GET_INFO_CALL( tms5220 ); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( tms5200 ); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "TMS5200"); break;
+ default: DEVICE_GET_INFO_CALL( tms5220 ); break;
}
}
#endif
diff --git a/src/emu/sound/5220intf.h b/src/emu/sound/5220intf.h
index d52b89373de..1fcdc86b8fa 100644
--- a/src/emu/sound/5220intf.h
+++ b/src/emu/sound/5220intf.h
@@ -1,7 +1,7 @@
#pragma once
-#ifndef __5200INTF_H__
-#define __5200INTF_H__
+#ifndef __5220INTF_H__
+#define __5220INTF_H__
/* clock rate = 80 * output sample rate, */
/* usually 640000 for 8000 Hz sample rate or */
@@ -10,32 +10,27 @@
typedef struct _tms5220_interface tms5220_interface;
struct _tms5220_interface
{
- void (*irq)(running_machine *machine, int state); /* IRQ callback function */
+ void (*irq)(const device_config *device, int state); /* IRQ callback function */
- int (*read)(int count); /* speech ROM read callback */
- void (*load_address)(int data); /* speech ROM load address callback */
- void (*read_and_branch)(void); /* speech ROM read and branch callback */
+ int (*read)(const device_config *device, int count); /* speech ROM read callback */
+ void (*load_address)(const device_config *device, int data); /* speech ROM load address callback */
+ void (*read_and_branch)(const device_config *device); /* speech ROM read and branch callback */
};
-WRITE8_HANDLER( tms5220_data_w );
-READ8_HANDLER( tms5220_status_r );
-int tms5220_ready_r(void);
-double tms5220_time_to_ready(void);
-int tms5220_int_r(void);
+WRITE8_DEVICE_HANDLER( tms5220_data_w );
+READ8_DEVICE_HANDLER( tms5220_status_r );
+int tms5220_ready_r(const device_config *device);
+double tms5220_time_to_ready(const device_config *device);
+int tms5220_int_r(const device_config *device);
-void tms5220_set_frequency(int frequency);
+void tms5220_set_frequency(const device_config *device, int frequency);
-enum
-{
- SNDINFO_INT_TMS5220_VARIANT = SNDINFO_INT_CORE_SPECIFIC
-};
-
-SND_GET_INFO( tms5220 );
-SND_GET_INFO( tmc0285 );
-SND_GET_INFO( tms5200 );
+DEVICE_GET_INFO( tms5220 );
+DEVICE_GET_INFO( tmc0285 );
+DEVICE_GET_INFO( tms5200 );
-#define SOUND_TMS5220 SND_GET_INFO_NAME( tms5220 )
-#define SOUND_TMC0285 SND_GET_INFO_NAME( tmc0285 )
-#define SOUND_TMS5200 SND_GET_INFO_NAME( tms5200 )
+#define SOUND_TMS5220 DEVICE_GET_INFO_NAME( tms5220 )
+#define SOUND_TMC0285 DEVICE_GET_INFO_NAME( tmc0285 )
+#define SOUND_TMS5200 DEVICE_GET_INFO_NAME( tms5200 )
-#endif /* __5200INTF_H__ */
+#endif /* __5220INTF_H__ */
diff --git a/src/emu/sound/8950intf.c b/src/emu/sound/8950intf.c
new file mode 100644
index 00000000000..a435102fa80
--- /dev/null
+++ b/src/emu/sound/8950intf.c
@@ -0,0 +1,205 @@
+/******************************************************************************
+* FILE
+* Yamaha 3812 emulator interface - MAME VERSION
+*
+* CREATED BY
+* Ernesto Corvi
+*
+* UPDATE LOG
+* JB 28-04-2002 Fixed simultaneous usage of all three different chip types.
+* Used real sample rate when resample filter is active.
+* AAT 12-28-2001 Protected Y8950 from accessing unmapped port and keyboard handlers.
+* CHS 1999-01-09 Fixes new ym3812 emulation interface.
+* CHS 1998-10-23 Mame streaming sound chip update
+* EC 1998 Created Interface
+*
+* NOTES
+*
+******************************************************************************/
+#include "sndintrf.h"
+#include "streams.h"
+#include "cpuintrf.h"
+#include "8950intf.h"
+#include "fm.h"
+#include "sound/fmopl.h"
+
+
+typedef struct _y8950_state y8950_state;
+struct _y8950_state
+{
+ sound_stream * stream;
+ emu_timer * timer[2];
+ void * chip;
+ const y8950_interface *intf;
+ const device_config *device;
+};
+
+
+INLINE y8950_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_Y8950);
+ return (y8950_state *)device->token;
+}
+
+
+static void IRQHandler(void *param,int irq)
+{
+ y8950_state *info = param;
+ if (info->intf->handler) (info->intf->handler)(info->device, irq ? ASSERT_LINE : CLEAR_LINE);
+}
+static TIMER_CALLBACK( timer_callback_0 )
+{
+ y8950_state *info = ptr;
+ y8950_timer_over(info->chip,0);
+}
+static TIMER_CALLBACK( timer_callback_1 )
+{
+ y8950_state *info = ptr;
+ y8950_timer_over(info->chip,1);
+}
+static void TimerHandler(void *param,int c,attotime period)
+{
+ y8950_state *info = param;
+ if( attotime_compare(period, attotime_zero) == 0 )
+ { /* Reset FM Timer */
+ timer_enable(info->timer[c], 0);
+ }
+ else
+ { /* Start FM Timer */
+ timer_adjust_oneshot(info->timer[c], period, 0);
+ }
+}
+
+
+static unsigned char Y8950PortHandler_r(void *param)
+{
+ y8950_state *info = param;
+ if (info->intf->portread)
+ return info->intf->portread(info->device,0);
+ return 0;
+}
+
+static void Y8950PortHandler_w(void *param,unsigned char data)
+{
+ y8950_state *info = param;
+ if (info->intf->portwrite)
+ info->intf->portwrite(info->device,0,data);
+}
+
+static unsigned char Y8950KeyboardHandler_r(void *param)
+{
+ y8950_state *info = param;
+ if (info->intf->keyboardread)
+ return info->intf->keyboardread(info->device,0);
+ return 0;
+}
+
+static void Y8950KeyboardHandler_w(void *param,unsigned char data)
+{
+ y8950_state *info = param;
+ if (info->intf->keyboardwrite)
+ info->intf->keyboardwrite(info->device,0,data);
+}
+
+static STREAM_UPDATE( y8950_stream_update )
+{
+ y8950_state *info = param;
+ y8950_update_one(info->chip, outputs[0], samples);
+}
+
+static void _stream_update(void *param, int interval)
+{
+ y8950_state *info = param;
+ stream_update(info->stream);
+}
+
+
+static DEVICE_START( y8950 )
+{
+ static const y8950_interface dummy = { 0 };
+ y8950_state *info = get_safe_token(device);
+ int rate = device->clock/72;
+
+ info->intf = device->static_config ? device->static_config : &dummy;
+ info->device = device;
+
+ /* stream system initialize */
+ info->chip = y8950_init(device,device->clock,rate);
+ assert_always(info->chip != NULL, "Error creating Y8950 chip");
+
+ /* ADPCM ROM data */
+ y8950_set_delta_t_memory(info->chip, device->region, device->regionbytes);
+
+ info->stream = stream_create(device,0,1,rate,info,y8950_stream_update);
+
+ /* port and keyboard handler */
+ y8950_set_port_handler(info->chip, Y8950PortHandler_w, Y8950PortHandler_r, info);
+ y8950_set_keyboard_handler(info->chip, Y8950KeyboardHandler_w, Y8950KeyboardHandler_r, info);
+
+ /* Y8950 setup */
+ y8950_set_timer_handler (info->chip, TimerHandler, info);
+ y8950_set_irq_handler (info->chip, IRQHandler, info);
+ y8950_set_update_handler(info->chip, _stream_update, info);
+
+ info->timer[0] = timer_alloc(device->machine, timer_callback_0, info);
+ info->timer[1] = timer_alloc(device->machine, timer_callback_1, info);
+}
+
+static DEVICE_STOP( y8950 )
+{
+ y8950_state *info = get_safe_token(device);
+ y8950_shutdown(info->chip);
+}
+
+static DEVICE_RESET( y8950 )
+{
+ y8950_state *info = get_safe_token(device);
+ y8950_reset_chip(info->chip);
+}
+
+
+READ8_DEVICE_HANDLER( y8950_r )
+{
+ y8950_state *info = get_safe_token(device);
+ return y8950_read(info->chip, offset & 1);
+}
+
+WRITE8_DEVICE_HANDLER( y8950_w )
+{
+ y8950_state *info = get_safe_token(device);
+ y8950_write(info->chip, offset & 1, data);
+}
+
+READ8_DEVICE_HANDLER( y8950_status_port_r ) { return y8950_r(device, 0); }
+READ8_DEVICE_HANDLER( y8950_read_port_r ) { return y8950_r(device, 1); }
+WRITE8_DEVICE_HANDLER( y8950_control_port_w ) { y8950_w(device, 0, data); }
+WRITE8_DEVICE_HANDLER( y8950_write_port_w ) { y8950_w(device, 1, data); }
+
+
+/**************************************************************************
+ * Generic get_info
+ **************************************************************************/
+
+DEVICE_GET_INFO( y8950 )
+{
+ switch (state)
+ {
+ /* --- the following bits of info are returned as 64-bit signed integers --- */
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(y8950_state); break;
+
+ /* --- the following bits of info are returned as pointers to data or functions --- */
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( y8950 ); break;
+ case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME( y8950 ); break;
+ case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( y8950 ); break;
+
+ /* --- the following bits of info are returned as NULL-terminated strings --- */
+ case DEVINFO_STR_NAME: strcpy(info->s, "Y8950"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "Yamaha FM"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ }
+}
diff --git a/src/emu/sound/8950intf.h b/src/emu/sound/8950intf.h
new file mode 100644
index 00000000000..d4ad63fbd36
--- /dev/null
+++ b/src/emu/sound/8950intf.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#ifndef __8950INTF_H__
+#define __8950INTF_H__
+
+typedef struct _y8950_interface y8950_interface;
+struct _y8950_interface
+{
+ void (*handler)(const device_config *device, int linestate);
+
+ read8_device_func keyboardread;
+ write8_device_func keyboardwrite;
+ read8_device_func portread;
+ write8_device_func portwrite;
+};
+
+READ8_DEVICE_HANDLER( y8950_r );
+WRITE8_DEVICE_HANDLER( y8950_w );
+
+READ8_DEVICE_HANDLER( y8950_status_port_r );
+READ8_DEVICE_HANDLER( y8950_read_port_r );
+WRITE8_DEVICE_HANDLER( y8950_control_port_w );
+WRITE8_DEVICE_HANDLER( y8950_write_port_w );
+
+DEVICE_GET_INFO( y8950 );
+#define SOUND_Y8950 DEVICE_GET_INFO_NAME( y8950 )
+
+#endif /* __8950INTF_H__ */
diff --git a/src/emu/sound/aica.c b/src/emu/sound/aica.c
index 775208445f7..2c6e10f0d3c 100644
--- a/src/emu/sound/aica.c
+++ b/src/emu/sound/aica.c
@@ -157,6 +157,7 @@ struct _SLOT
#define SCITMA 6
#define SCITMB 7
+typedef struct _AICA aica_state;
struct _AICA
{
union
@@ -172,7 +173,7 @@ struct _AICA
unsigned char *AICARAM;
UINT32 AICARAM_LENGTH, RAM_MASK, RAM_MASK16;
char Master;
- void (*IntARMCB)(running_machine *machine, int irq);
+ void (*IntARMCB)(const device_config *device, int irq);
sound_stream * stream;
INT32 *buffertmpl, *buffertmpr;
@@ -214,7 +215,16 @@ static int length;
static signed short *RBUFDST; //this points to where the sample will be stored in the RingBuf
-static unsigned char DecodeSCI(struct _AICA *AICA, unsigned char irq)
+INLINE aica_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_AICA);
+ return (aica_state *)device->token;
+}
+
+static unsigned char DecodeSCI(aica_state *AICA, unsigned char irq)
{
unsigned char SCI=0;
unsigned char v;
@@ -227,29 +237,27 @@ static unsigned char DecodeSCI(struct _AICA *AICA, unsigned char irq)
return SCI;
}
-static void ResetInterrupts(struct _AICA *AICA)
+static void ResetInterrupts(aica_state *AICA)
{
#if 0
UINT32 reset = AICA->udata.data[0xa4/2];
- running_machine *machine = AICA->device->machine;
if (reset & 0x40)
- AICA->IntARMCB(machine, -AICA->IrqTimA);
+ AICA->IntARMCB(AICA->device, -AICA->IrqTimA);
if (reset & 0x180)
- AICA->IntARMCB(machine, -AICA->IrqTimBC);
+ AICA->IntARMCB(AICA->device, -AICA->IrqTimBC);
#endif
}
-static void CheckPendingIRQ(struct _AICA *AICA)
+static void CheckPendingIRQ(aica_state *AICA)
{
UINT32 pend=AICA->udata.data[0xa0/2];
UINT32 en=AICA->udata.data[0x9c/2];
- running_machine *machine = AICA->device->machine;
if(AICA->MidiW!=AICA->MidiR)
{
AICA->IRQL = AICA->IrqMidi;
- AICA->IntARMCB(machine, 1);
+ AICA->IntARMCB(AICA->device, 1);
return;
}
if(!pend)
@@ -258,28 +266,28 @@ static void CheckPendingIRQ(struct _AICA *AICA)
if(en&0x40)
{
AICA->IRQL = AICA->IrqTimA;
- AICA->IntARMCB(machine, 1);
+ AICA->IntARMCB(AICA->device, 1);
return;
}
if(pend&0x80)
if(en&0x80)
{
AICA->IRQL = AICA->IrqTimBC;
- AICA->IntARMCB(machine, 1);
+ AICA->IntARMCB(AICA->device, 1);
return;
}
if(pend&0x100)
if(en&0x100)
{
AICA->IRQL = AICA->IrqTimBC;
- AICA->IntARMCB(machine, 1);
+ AICA->IntARMCB(AICA->device, 1);
return;
}
}
static TIMER_CALLBACK( timerA_cb )
{
- struct _AICA *AICA = (struct _AICA *)ptr;
+ aica_state *AICA = (aica_state *)ptr;
AICA->TimCnt[0] = 0xFFFF;
AICA->udata.data[0xa0/2]|=0x40;
@@ -291,7 +299,7 @@ static TIMER_CALLBACK( timerA_cb )
static TIMER_CALLBACK( timerB_cb )
{
- struct _AICA *AICA = (struct _AICA *)ptr;
+ aica_state *AICA = (aica_state *)ptr;
AICA->TimCnt[1] = 0xFFFF;
AICA->udata.data[0xa0/2]|=0x80;
@@ -303,7 +311,7 @@ static TIMER_CALLBACK( timerB_cb )
static TIMER_CALLBACK( timerC_cb )
{
- struct _AICA *AICA = (struct _AICA *)ptr;
+ aica_state *AICA = (aica_state *)ptr;
AICA->TimCnt[2] = 0xFFFF;
AICA->udata.data[0xa0/2]|=0x100;
@@ -313,7 +321,7 @@ static TIMER_CALLBACK( timerC_cb )
CheckPendingIRQ(AICA);
}
-static int Get_AR(struct _AICA *AICA,int base,int R)
+static int Get_AR(aica_state *AICA,int base,int R)
{
int Rate=base+(R<<1);
if(Rate>63) Rate=63;
@@ -321,7 +329,7 @@ static int Get_AR(struct _AICA *AICA,int base,int R)
return AICA->ARTABLE[Rate];
}
-static int Get_DR(struct _AICA *AICA,int base,int R)
+static int Get_DR(aica_state *AICA,int base,int R)
{
int Rate=base+(R<<1);
if(Rate>63) Rate=63;
@@ -329,7 +337,7 @@ static int Get_DR(struct _AICA *AICA,int base,int R)
return AICA->DRTABLE[Rate];
}
-static int Get_RR(struct _AICA *AICA,int base,int R)
+static int Get_RR(aica_state *AICA,int base,int R)
{
int Rate=base+(R<<1);
if(Rate>63) Rate=63;
@@ -337,7 +345,7 @@ static int Get_RR(struct _AICA *AICA,int base,int R)
return AICA->DRTABLE[Rate];
}
-static void Compute_EG(struct _AICA *AICA,struct _SLOT *slot)
+static void Compute_EG(aica_state *AICA,struct _SLOT *slot)
{
int octave=OCT(slot);
int rate;
@@ -450,7 +458,7 @@ INLINE signed short DecodeADPCM(int *PrevSignal, unsigned char Delta, int *PrevQ
return *PrevSignal;
}
-static void AICA_StartSlot(struct _AICA *AICA, struct _SLOT *slot)
+static void AICA_StartSlot(aica_state *AICA, struct _SLOT *slot)
{
UINT64 start_offset;
@@ -513,7 +521,7 @@ static void AICA_StopSlot(struct _SLOT *slot,int keyoff)
#define log_base_2(n) (log((float) n)/log((float) 2))
-static void AICA_Init(const device_config *device, struct _AICA *AICA, const aica_interface *intf)
+static void AICA_Init(const device_config *device, aica_state *AICA, const aica_interface *intf)
{
int i;
@@ -652,7 +660,7 @@ static void AICA_Init(const device_config *device, struct _AICA *AICA, const aic
AICA->TimCnt[2] = 0xffff;
}
-static void AICA_UpdateSlotReg(struct _AICA *AICA,int s,int r)
+static void AICA_UpdateSlotReg(aica_state *AICA,int s,int r)
{
struct _SLOT *slot=AICA->Slots+s;
int sl;
@@ -708,10 +716,8 @@ static void AICA_UpdateSlotReg(struct _AICA *AICA,int s,int r)
}
}
-static void AICA_UpdateReg(struct _AICA *AICA, int reg)
+static void AICA_UpdateReg(aica_state *AICA, int reg)
{
- /* temporary hack until this is converted to a device */
- const address_space *space = memory_find_address_space(AICA->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
switch(reg&0xff)
{
case 0x4:
@@ -731,7 +737,7 @@ static void AICA_UpdateReg(struct _AICA *AICA, int reg)
break;
case 0x8:
case 0x9:
- aica_midi_in(space, 0, AICA->udata.data[0x8/2]&0xff, 0);
+ aica_midi_in(AICA->device, 0, AICA->udata.data[0x8/2]&0xff, 0xffff);
break;
case 0x12:
case 0x13:
@@ -837,12 +843,12 @@ static void AICA_UpdateReg(struct _AICA *AICA, int reg)
}
}
-static void AICA_UpdateSlotRegR(struct _AICA *AICA, int slot,int reg)
+static void AICA_UpdateSlotRegR(aica_state *AICA, int slot,int reg)
{
}
-static void AICA_UpdateRegR(struct _AICA *AICA, int reg)
+static void AICA_UpdateRegR(aica_state *AICA, int reg)
{
switch(reg&0xff)
{
@@ -852,7 +858,7 @@ static void AICA_UpdateRegR(struct _AICA *AICA, int reg)
unsigned short v=AICA->udata.data[0x8/2];
v&=0xff00;
v|=AICA->MidiStack[AICA->MidiR];
- AICA->IntARMCB(AICA->device->machine, 0); // cancel the IRQ
+ AICA->IntARMCB(AICA->device, 0); // cancel the IRQ
if(AICA->MidiR!=AICA->MidiW)
{
++AICA->MidiR;
@@ -881,7 +887,7 @@ static void AICA_UpdateRegR(struct _AICA *AICA, int reg)
}
}
-static void AICA_w16(struct _AICA *AICA,unsigned int addr,unsigned short val)
+static void AICA_w16(aica_state *AICA,unsigned int addr,unsigned short val)
{
addr&=0xffff;
if(addr<0x2000)
@@ -918,7 +924,7 @@ static void AICA_w16(struct _AICA *AICA,unsigned int addr,unsigned short val)
if (val)
{
- AICA->IntARMCB(AICA->device->machine, 0);
+ AICA->IntARMCB(AICA->device, 0);
}
}
}
@@ -941,7 +947,7 @@ static void AICA_w16(struct _AICA *AICA,unsigned int addr,unsigned short val)
}
}
-static unsigned short AICA_r16(struct _AICA *AICA, unsigned int addr)
+static unsigned short AICA_r16(aica_state *AICA, unsigned int addr)
{
unsigned short v=0;
addr&=0xffff;
@@ -982,7 +988,7 @@ static unsigned short AICA_r16(struct _AICA *AICA, unsigned int addr)
#define REVSIGN(v) ((~v)+1)
#ifdef UNUSED_FUNCTION
-static void AICA_TimersAddTicks(struct _AICA *AICA, int ticks)
+static void AICA_TimersAddTicks(aica_state *AICA, int ticks)
{
if(AICA->TimCnt[0]<=0xff00)
{
@@ -1022,7 +1028,7 @@ static void AICA_TimersAddTicks(struct _AICA *AICA, int ticks)
}
#endif
-INLINE INT32 AICA_UpdateSlot(struct _AICA *AICA, struct _SLOT *slot)
+INLINE INT32 AICA_UpdateSlot(aica_state *AICA, struct _SLOT *slot)
{
INT32 sample;
int step=slot->step;
@@ -1201,7 +1207,7 @@ INLINE INT32 AICA_UpdateSlot(struct _AICA *AICA, struct _SLOT *slot)
return sample;
}
-static void AICA_DoMasterSamples(struct _AICA *AICA, int nsamples)
+static void AICA_DoMasterSamples(aica_state *AICA, int nsamples)
{
stream_sample_t *bufr,*bufl;
int sl, s, i;
@@ -1269,18 +1275,18 @@ static int AICA_IRQCB(void *param)
static STREAM_UPDATE( AICA_Update )
{
- struct _AICA *AICA = param;
+ aica_state *AICA = param;
bufferl = outputs[0];
bufferr = outputs[1];
length = samples;
AICA_DoMasterSamples(AICA, samples);
}
-static SND_START( aica )
+static DEVICE_START( aica )
{
const aica_interface *intf;
- struct _AICA *AICA = device->token;
+ aica_state *AICA = get_safe_token(device);
intf = device->static_config;
@@ -1296,14 +1302,14 @@ static SND_START( aica )
}
#ifdef UNUSED_FUNCTION
-static SND_STOP( aica )
+static DEVICE_STOP( aica )
{
}
#endif
-void aica_set_ram_base(int which, void *base, int size)
+void aica_set_ram_base(const device_config *device, void *base, int size)
{
- struct _AICA *AICA = sndti_token(SOUND_AICA, which);
+ aica_state *AICA = get_safe_token(device);
if (AICA)
{
AICA->AICARAM = base;
@@ -1315,34 +1321,32 @@ void aica_set_ram_base(int which, void *base, int size)
}
}
-READ16_HANDLER( aica_0_r )
+READ16_DEVICE_HANDLER( aica_r )
{
- struct _AICA *AICA = sndti_token(SOUND_AICA, 0);
- UINT16 res = AICA_r16(AICA, offset*2);
-
- return res;
+ aica_state *AICA = get_safe_token(device);
+ return AICA_r16(AICA, offset*2);
}
-WRITE16_HANDLER( aica_0_w )
+WRITE16_DEVICE_HANDLER( aica_w )
{
- struct _AICA *AICA = sndti_token(SOUND_AICA, 0);
+ aica_state *AICA = get_safe_token(device);
UINT16 tmp;
tmp = AICA_r16(AICA, offset*2);
COMBINE_DATA(&tmp);
- AICA_w16(AICA,offset*2, tmp);
+ AICA_w16(AICA, offset*2, tmp);
}
-WRITE16_HANDLER( aica_midi_in )
+WRITE16_DEVICE_HANDLER( aica_midi_in )
{
- struct _AICA *AICA = sndti_token(SOUND_AICA, 0);
+ aica_state *AICA = get_safe_token(device);
AICA->MidiStack[AICA->MidiW++]=data;
AICA->MidiW &= 15;
}
-READ16_HANDLER( aica_midi_out_r )
+READ16_DEVICE_HANDLER( aica_midi_out_r )
{
- struct _AICA *AICA = sndti_token(SOUND_AICA, 0);
+ aica_state *AICA = get_safe_token(device);
unsigned char val;
val=AICA->MidiStack[AICA->MidiR++];
@@ -1354,34 +1358,22 @@ READ16_HANDLER( aica_midi_out_r )
* Generic get_info
**************************************************************************/
-static SND_SET_INFO( aica )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
-SND_GET_INFO( aica )
+DEVICE_GET_INFO( aica )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct _AICA); break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(aica_state); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( aica ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( aica ); break;
- case SNDINFO_PTR_STOP: /* Nothing */ break;
- case SNDINFO_PTR_RESET: /* Nothing */ break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( aica ); break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "AICA"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Sega/Yamaha custom"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0.1"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "AICA"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "Sega/Yamaha custom"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0.1"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}
diff --git a/src/emu/sound/aica.h b/src/emu/sound/aica.h
index 136ca6d122b..ac31e89b075 100644
--- a/src/emu/sound/aica.h
+++ b/src/emu/sound/aica.h
@@ -6,27 +6,25 @@
#ifndef __AICA_H__
#define __AICA_H__
-#define MAX_AICA (2)
-
typedef struct _aica_interface aica_interface;
struct _aica_interface
{
int master;
int roffset; /* offset in the region */
- void (*irq_callback)(running_machine *machine, int state); /* irq callback */
+ void (*irq_callback)(const device_config *device, int state); /* irq callback */
};
-void aica_set_ram_base(int which, void *base, int size);
+void aica_set_ram_base(const device_config *device, void *base, int size);
// AICA register access
-READ16_HANDLER( aica_0_r );
-WRITE16_HANDLER( aica_0_w );
+READ16_DEVICE_HANDLER( aica_r );
+WRITE16_DEVICE_HANDLER( aica_w );
// MIDI I/O access
-WRITE16_HANDLER( aica_midi_in );
-READ16_HANDLER( aica_midi_out_r );
+WRITE16_DEVICE_HANDLER( aica_midi_in );
+READ16_DEVICE_HANDLER( aica_midi_out_r );
-SND_GET_INFO( aica );
-#define SOUND_AICA SND_GET_INFO_NAME( aica )
+DEVICE_GET_INFO( aica );
+#define SOUND_AICA DEVICE_GET_INFO_NAME( aica )
#endif /* __AICA_H__ */
diff --git a/src/emu/sound/astrocde.c b/src/emu/sound/astrocde.c
index 6f8481adb0e..7a6e21823c6 100644
--- a/src/emu/sound/astrocde.c
+++ b/src/emu/sound/astrocde.c
@@ -44,7 +44,8 @@
#include "astrocde.h"
-struct astrocade_info
+typedef struct _astrocade_state astrocade_state;
+struct _astrocade_state
{
sound_stream *stream; /* sound stream */
@@ -69,6 +70,16 @@ struct astrocade_info
};
+INLINE astrocade_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_ASTROCADE);
+ return (astrocade_state *)device->token;
+}
+
+
/*************************************
*
@@ -78,7 +89,7 @@ struct astrocade_info
static STREAM_UPDATE( astrocade_update )
{
- struct astrocade_info *chip = param;
+ astrocade_state *chip = param;
stream_sample_t *dest = outputs[0];
UINT16 noise_state;
UINT8 master_count;
@@ -196,8 +207,10 @@ static STREAM_UPDATE( astrocade_update )
*
*************************************/
-static void astrocade_reset(struct astrocade_info *chip)
+static DEVICE_RESET( astrocade )
{
+ astrocade_state *chip = get_safe_token(device);
+
memset(chip->reg, 0, sizeof(chip->reg));
chip->master_count = 0;
@@ -216,11 +229,6 @@ static void astrocade_reset(struct astrocade_info *chip)
chip->c_state = 0;
}
-static SND_RESET( astrocade )
-{
- astrocade_reset(device->token);
-}
-
/*************************************
*
@@ -228,7 +236,7 @@ static SND_RESET( astrocade )
*
*************************************/
-static void astrocade_state_save_register(struct astrocade_info *chip, const device_config *device)
+static void astrocade_state_save_register(astrocade_state *chip, const device_config *device)
{
state_save_register_device_item_array(device, 0, chip->reg);
@@ -256,9 +264,9 @@ static void astrocade_state_save_register(struct astrocade_info *chip, const dev
*
*************************************/
-static SND_START( astrocade )
+static DEVICE_START( astrocade )
{
- struct astrocade_info *chip = device->token;
+ astrocade_state *chip = get_safe_token(device);
int i;
/* generate a bitswap table for the noise */
@@ -266,10 +274,10 @@ static SND_START( astrocade )
chip->bitswap[i] = BITSWAP8(i, 0,1,2,3,4,5,6,7);
/* allocate a stream for output */
- chip->stream = stream_create(device, 0, 1, clock, chip, astrocade_update);
+ chip->stream = stream_create(device, 0, 1, device->clock, chip, astrocade_update);
/* reset state */
- astrocade_reset(chip);
+ DEVICE_RESET_CALL(astrocade);
astrocade_state_save_register(chip, device);
}
@@ -281,9 +289,14 @@ static SND_START( astrocade )
*
*************************************/
-static void astrocade_sound_w(UINT8 num, offs_t offset, UINT8 data)
+WRITE8_DEVICE_HANDLER( astrocade_sound_w )
{
- struct astrocade_info *chip = sndti_token(SOUND_ASTROCADE, num);
+ astrocade_state *chip = get_safe_token(device);
+
+ if ((offset & 8) != 0)
+ offset = (offset >> 8) & 7;
+ else
+ offset &= 7;
/* update */
stream_update(chip->stream);
@@ -293,24 +306,6 @@ static void astrocade_sound_w(UINT8 num, offs_t offset, UINT8 data)
}
-WRITE8_HANDLER( astrocade_sound1_w )
-{
- if ((offset & 8) != 0)
- astrocade_sound_w(0, (offset >> 8) & 7, data);
- else
- astrocade_sound_w(0, offset & 7, data);
-}
-
-
-WRITE8_HANDLER( astrocade_sound2_w )
-{
- if ((offset & 8) != 0)
- astrocade_sound_w(1, (offset >> 8) & 7, data);
- else
- astrocade_sound_w(1, offset & 7, data);
-}
-
-
/*************************************
*
@@ -318,33 +313,22 @@ WRITE8_HANDLER( astrocade_sound2_w )
*
*************************************/
-static SND_SET_INFO( astrocade )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
-SND_GET_INFO( astrocade )
+DEVICE_GET_INFO( astrocade )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct astrocade_info); break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(astrocade_state); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( astrocade ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( astrocade ); break;
- case SNDINFO_PTR_STOP: /* nothing */ break;
- case SNDINFO_PTR_RESET: info->reset = SND_RESET_NAME( astrocade ); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( astrocade ); break;
+ case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( astrocade ); break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "Astrocade"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Bally"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "2.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "Astrocade"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "Bally"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "2.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}
diff --git a/src/emu/sound/astrocde.h b/src/emu/sound/astrocde.h
index e5363176862..555c549f2ba 100644
--- a/src/emu/sound/astrocde.h
+++ b/src/emu/sound/astrocde.h
@@ -3,10 +3,9 @@
#ifndef __ASTROCDE_H__
#define __ASTROCDE_H__
-WRITE8_HANDLER( astrocade_sound1_w );
-WRITE8_HANDLER( astrocade_sound2_w );
+WRITE8_DEVICE_HANDLER( astrocade_sound_w );
-SND_GET_INFO( astrocade );
-#define SOUND_ASTROCADE SND_GET_INFO_NAME( astrocade )
+DEVICE_GET_INFO( astrocade );
+#define SOUND_ASTROCADE DEVICE_GET_INFO_NAME( astrocade )
#endif /* __ASTROCDE_H__ */
diff --git a/src/emu/sound/ay8910.c b/src/emu/sound/ay8910.c
index e9a614487d6..c12ef2f3999 100644
--- a/src/emu/sound/ay8910.c
+++ b/src/emu/sound/ay8910.c
@@ -187,8 +187,29 @@ struct _ay8910_context
INT32 vol_table[NUM_CHANNELS][16];
INT32 env_table[NUM_CHANNELS][32];
INT32 vol3d_table[8*32*32*32];
+ devcb_resolved_read8 portAread;
+ devcb_resolved_read8 portBread;
+ devcb_resolved_write8 portAwrite;
+ devcb_resolved_write8 portBwrite;
};
+INLINE ay8910_context *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_AY8910 ||
+ sound_get_type(device) == SOUND_AY8912 ||
+ sound_get_type(device) == SOUND_AY8913 ||
+ sound_get_type(device) == SOUND_AY8930 ||
+ sound_get_type(device) == SOUND_YM2149 ||
+ sound_get_type(device) == SOUND_YM3439 ||
+ sound_get_type(device) == SOUND_YMZ284 ||
+ sound_get_type(device) == SOUND_YMZ294);
+ return (ay8910_context *)device->token;
+}
+
+
/*************************************
*
* Static
@@ -386,9 +407,6 @@ INLINE UINT16 mix_3D(ay8910_context *psg)
static void ay8910_write_reg(ay8910_context *psg, int r, int v)
{
- /* temporary hack until this is converted to a device */
- const address_space *space = memory_find_address_space(psg->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
-
//if (r >= 11 && r <= 13 ) printf("%d %x %02x\n", PSG->index, r, v);
psg->regs[r] = v;
@@ -413,16 +431,14 @@ static void ay8910_write_reg(ay8910_context *psg, int r, int v)
((psg->last_enable & 0x40) != (psg->regs[AY_ENABLE] & 0x40)))
{
/* write out 0xff if port set to input */
- if (psg->intf->portAwrite)
- (*psg->intf->portAwrite)(space, 0, (psg->regs[AY_ENABLE] & 0x40) ? psg->regs[AY_PORTA] : 0xff);
+ devcb_call_write8(&psg->portAwrite, 0, (psg->regs[AY_ENABLE] & 0x40) ? psg->regs[AY_PORTA] : 0xff);
}
if ((psg->last_enable == -1) ||
((psg->last_enable & 0x80) != (psg->regs[AY_ENABLE] & 0x80)))
{
/* write out 0xff if port set to input */
- if (psg->intf->portBwrite)
- (*psg->intf->portBwrite)(space, 0, (psg->regs[AY_ENABLE] & 0x80) ? psg->regs[AY_PORTB] : 0xff);
+ devcb_call_write8(&psg->portBwrite, 0, (psg->regs[AY_ENABLE] & 0x80) ? psg->regs[AY_PORTB] : 0xff);
}
psg->last_enable = psg->regs[AY_ENABLE];
@@ -447,8 +463,8 @@ static void ay8910_write_reg(ay8910_context *psg, int r, int v)
case AY_PORTA:
if (psg->regs[AY_ENABLE] & 0x40)
{
- if (psg->intf->portAwrite)
- (*psg->intf->portAwrite)(space, 0, psg->regs[AY_PORTA]);
+ if (psg->portAwrite.write)
+ devcb_call_write8(&psg->portAwrite, 0, psg->regs[AY_PORTA]);
else
logerror("warning - write %02x to 8910 '%s' Port A\n",psg->regs[AY_PORTA],psg->device->tag);
}
@@ -460,8 +476,8 @@ static void ay8910_write_reg(ay8910_context *psg, int r, int v)
case AY_PORTB:
if (psg->regs[AY_ENABLE] & 0x80)
{
- if (psg->intf->portBwrite)
- (*psg->intf->portBwrite)(space, 0, psg->regs[AY_PORTB]);
+ if (psg->portBwrite.write)
+ devcb_call_write8(&psg->portBwrite, 0, psg->regs[AY_PORTB]);
else
logerror("warning - write %02x to 8910 '%s' Port B\n",psg->regs[AY_PORTB],psg->device->tag);
}
@@ -670,6 +686,10 @@ void *ay8910_start_ym(void *infoptr, sound_type chip_type, const device_config *
}
info->device = device;
info->intf = intf;
+ devcb_resolve_read8(&info->portAread, &intf->portAread, device);
+ devcb_resolve_read8(&info->portBread, &intf->portBread, device);
+ devcb_resolve_write8(&info->portAwrite, &intf->portAwrite, device);
+ devcb_resolve_write8(&info->portBwrite, &intf->portBwrite, device);
if ((info->intf->flags & AY8910_SINGLE_OUTPUT) != 0)
{
logerror("AY-3-8910/YM2149 using single output!\n");
@@ -699,9 +719,9 @@ void *ay8910_start_ym(void *infoptr, sound_type chip_type, const device_config *
/* The envelope is pacing twice as fast for the YM2149 as for the AY-3-8910, */
/* This handled by the step parameter. Consequently we use a divider of 8 here. */
- info->channel = stream_create(device, 0, info->streams, clock / 8, info, ay8910_update);
+ info->channel = stream_create(device, 0, info->streams, device->clock / 8, info, ay8910_update);
- ay8910_set_clock_ym(info,clock);
+ ay8910_set_clock_ym(info,device->clock);
ay8910_statesave(info, device);
return info;
@@ -733,9 +753,9 @@ void ay8910_reset_ym(void *chip)
psg->ready = 1;
}
-void ay8910_set_volume(int chip,int channel,int volume)
+void ay8910_set_volume(const device_config *device,int channel,int volume)
{
- ay8910_context *psg = sndti_token(SOUND_AY8910, chip);
+ ay8910_context *psg = get_safe_token(device);
int ch;
for (ch = 0; ch < psg->streams; ch++)
@@ -775,8 +795,6 @@ void ay8910_write_ym(void *chip, int addr, int data)
int ay8910_read_ym(void *chip)
{
ay8910_context *psg = chip;
- /* temporary hack until this is converted to a device */
- const address_space *space = memory_find_address_space(psg->device->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
int r = psg->register_latch;
if (r > 15) return 0;
@@ -790,16 +808,16 @@ int ay8910_read_ym(void *chip)
even if the port is set as output, we still need to return the external
data. Some games, like kidniki, need this to work.
*/
- if (psg->intf->portAread)
- psg->regs[AY_PORTA] = (*psg->intf->portAread)(space, 0);
+ if (psg->portAread.read)
+ psg->regs[AY_PORTA] = devcb_call_read8(&psg->portAread, 0);
else
logerror("%s: warning - read 8910 '%s' Port A\n",cpuexec_describe_context(psg->device->machine),psg->device->tag);
break;
case AY_PORTB:
if ((psg->regs[AY_ENABLE] & 0x80) != 0)
logerror("warning: read from 8910 '%s' Port B set as output\n",psg->device->tag);
- if (psg->intf->portBread)
- psg->regs[AY_PORTB] = (*psg->intf->portBread)(space, 0);
+ if (psg->portBread.read)
+ psg->regs[AY_PORTB] = devcb_call_read8(&psg->portBread, 0);
else
logerror("%s: warning - read 8910 '%s' Port B\n",cpuexec_describe_context(psg->device->machine),psg->device->tag);
break;
@@ -813,138 +831,128 @@ int ay8910_read_ym(void *chip)
*
*************************************/
-static SND_START( ay8910 )
+static DEVICE_START( ay8910 )
{
static const ay8910_interface generic_ay8910 =
{
AY8910_LEGACY_OUTPUT,
AY8910_DEFAULT_LOADS,
- NULL, NULL, NULL, NULL
+ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
};
const ay8910_interface *intf = (device->static_config ? device->static_config : &generic_ay8910);
- ay8910_start_ym(device->token, SOUND_AY8910, device, clock, intf);
+ ay8910_start_ym(get_safe_token(device), SOUND_AY8910, device, device->clock, intf);
}
-static SND_START( ym2149 )
+static DEVICE_START( ym2149 )
{
static const ay8910_interface generic_ay8910 =
{
AY8910_LEGACY_OUTPUT,
AY8910_DEFAULT_LOADS,
- NULL, NULL, NULL, NULL
+ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
};
const ay8910_interface *intf = (device->static_config ? device->static_config : &generic_ay8910);
- ay8910_start_ym(device->token, SOUND_YM2149, device, clock, intf);
-}
-
-static SND_STOP( ay8910 )
-{
- ay8910_stop_ym(device->token);
+ ay8910_start_ym(get_safe_token(device), SOUND_YM2149, device, device->clock, intf);
}
-static SND_RESET( ay8910 )
+static DEVICE_STOP( ay8910 )
{
- ay8910_reset_ym(device->token);
+ ay8910_stop_ym(get_safe_token(device));
}
-static SND_SET_INFO( ay8910 )
+static DEVICE_RESET( ay8910 )
{
- switch (state)
- {
- /* no parameters to set */
- }
+ ay8910_reset_ym(get_safe_token(device));
}
-SND_GET_INFO( ay8910 )
+DEVICE_GET_INFO( ay8910 )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(ay8910_context); break;
- case SNDINFO_FCT_ALIAS: info->type = SOUND_AY8910; break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ay8910_context); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( ay8910 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ay8910 ); break;
- case SNDINFO_PTR_STOP: info->stop = SND_STOP_NAME( ay8910 ); break;
- case SNDINFO_PTR_RESET: info->reset = SND_RESET_NAME( ay8910 ); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ay8910 ); break;
+ case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME( ay8910 ); break;
+ case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( ay8910 ); break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "AY-3-8910A"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "PSG"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "AY-3-8910A"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "PSG"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}
-SND_GET_INFO( ay8912 )
+DEVICE_GET_INFO( ay8912 )
{
switch (state)
{
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ay8910 ); break;
- case SNDINFO_STR_NAME: strcpy(info->s, "AY-3-8912A"); break;
- default: SND_GET_INFO_CALL(ay8910); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ay8910 ); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "AY-3-8912A"); break;
+ default: DEVICE_GET_INFO_CALL(ay8910); break;
}
}
-SND_GET_INFO( ay8913 )
+DEVICE_GET_INFO( ay8913 )
{
switch (state)
{
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ay8910 ); break;
- case SNDINFO_STR_NAME: strcpy(info->s, "AY-3-8913A"); break;
- default: SND_GET_INFO_CALL(ay8910); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ay8910 ); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "AY-3-8913A"); break;
+ default: DEVICE_GET_INFO_CALL(ay8910); break;
}
}
-SND_GET_INFO( ay8930 )
+DEVICE_GET_INFO( ay8930 )
{
switch (state)
{
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ay8910 ); break;
- case SNDINFO_STR_NAME: strcpy(info->s, "AY8930"); break;
- default: SND_GET_INFO_CALL(ay8910); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ay8910 ); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "AY8930"); break;
+ default: DEVICE_GET_INFO_CALL(ay8910); break;
}
}
-SND_GET_INFO( ym2149 )
+DEVICE_GET_INFO( ym2149 )
{
switch (state)
{
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ym2149 ); break;
- case SNDINFO_STR_NAME: strcpy(info->s, "YM2149"); break;
- default: SND_GET_INFO_CALL(ay8910); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ym2149 ); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "YM2149"); break;
+ default: DEVICE_GET_INFO_CALL(ay8910); break;
}
}
-SND_GET_INFO( ym3439 )
+DEVICE_GET_INFO( ym3439 )
{
switch (state)
{
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ym2149 ); break;
- case SNDINFO_STR_NAME: strcpy(info->s, "YM3439"); break;
- default: SND_GET_INFO_CALL(ay8910); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ym2149 ); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "YM3439"); break;
+ default: DEVICE_GET_INFO_CALL(ay8910); break;
}
}
-SND_GET_INFO( ymz284 )
+DEVICE_GET_INFO( ymz284 )
{
switch (state)
{
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ym2149 ); break;
- case SNDINFO_STR_NAME: strcpy(info->s, "YMZ284"); break;
- default: SND_GET_INFO_CALL(ay8910); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ym2149 ); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "YMZ284"); break;
+ default: DEVICE_GET_INFO_CALL(ay8910); break;
}
}
-SND_GET_INFO( ymz294 )
+DEVICE_GET_INFO( ymz294 )
{
switch (state)
{
- case SNDINFO_PTR_START: info->start = SND_START_NAME( ym2149 ); break;
- case SNDINFO_STR_NAME: strcpy(info->s, "YMZ294"); break;
- default: SND_GET_INFO_CALL(ay8910); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( ym2149 ); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "YMZ294"); break;
+ default: DEVICE_GET_INFO_CALL(ay8910); break;
}
}
@@ -954,50 +962,28 @@ SND_GET_INFO( ymz294 )
*
*************************************/
-READ8_HANDLER( ay8910_read_port_0_r ) { return ay8910_read_ym(sndti_token(SOUND_AY8910, 0)); }
-READ8_HANDLER( ay8910_read_port_1_r ) { return ay8910_read_ym(sndti_token(SOUND_AY8910, 1)); }
-READ8_HANDLER( ay8910_read_port_2_r ) { return ay8910_read_ym(sndti_token(SOUND_AY8910, 2)); }
-READ8_HANDLER( ay8910_read_port_3_r ) { return ay8910_read_ym(sndti_token(SOUND_AY8910, 3)); }
-READ8_HANDLER( ay8910_read_port_4_r ) { return ay8910_read_ym(sndti_token(SOUND_AY8910, 4)); }
-READ16_HANDLER( ay8910_read_port_0_lsb_r ) { return ay8910_read_ym(sndti_token(SOUND_AY8910, 0)); }
-READ16_HANDLER( ay8910_read_port_1_lsb_r ) { return ay8910_read_ym(sndti_token(SOUND_AY8910, 1)); }
-READ16_HANDLER( ay8910_read_port_2_lsb_r ) { return ay8910_read_ym(sndti_token(SOUND_AY8910, 2)); }
-READ16_HANDLER( ay8910_read_port_3_lsb_r ) { return ay8910_read_ym(sndti_token(SOUND_AY8910, 3)); }
-READ16_HANDLER( ay8910_read_port_4_lsb_r ) { return ay8910_read_ym(sndti_token(SOUND_AY8910, 4)); }
-READ16_HANDLER( ay8910_read_port_0_msb_r ) { return ay8910_read_ym(sndti_token(SOUND_AY8910, 0)) << 8; }
-READ16_HANDLER( ay8910_read_port_1_msb_r ) { return ay8910_read_ym(sndti_token(SOUND_AY8910, 1)) << 8; }
-READ16_HANDLER( ay8910_read_port_2_msb_r ) { return ay8910_read_ym(sndti_token(SOUND_AY8910, 2)) << 8; }
-READ16_HANDLER( ay8910_read_port_3_msb_r ) { return ay8910_read_ym(sndti_token(SOUND_AY8910, 3)) << 8; }
-READ16_HANDLER( ay8910_read_port_4_msb_r ) { return ay8910_read_ym(sndti_token(SOUND_AY8910, 4)) << 8; }
-
-WRITE8_HANDLER( ay8910_control_port_0_w ) { ay8910_write_ym(sndti_token(SOUND_AY8910, 0),0,data); }
-WRITE8_HANDLER( ay8910_control_port_1_w ) { ay8910_write_ym(sndti_token(SOUND_AY8910, 1),0,data); }
-WRITE8_HANDLER( ay8910_control_port_2_w ) { ay8910_write_ym(sndti_token(SOUND_AY8910, 2),0,data); }
-WRITE8_HANDLER( ay8910_control_port_3_w ) { ay8910_write_ym(sndti_token(SOUND_AY8910, 3),0,data); }
-WRITE8_HANDLER( ay8910_control_port_4_w ) { ay8910_write_ym(sndti_token(SOUND_AY8910, 4),0,data); }
-WRITE16_HANDLER( ay8910_control_port_0_lsb_w ) { if (ACCESSING_BITS_0_7) ay8910_write_ym(sndti_token(SOUND_AY8910, 0),0,data & 0xff); }
-WRITE16_HANDLER( ay8910_control_port_1_lsb_w ) { if (ACCESSING_BITS_0_7) ay8910_write_ym(sndti_token(SOUND_AY8910, 1),0,data & 0xff); }
-WRITE16_HANDLER( ay8910_control_port_2_lsb_w ) { if (ACCESSING_BITS_0_7) ay8910_write_ym(sndti_token(SOUND_AY8910, 2),0,data & 0xff); }
-WRITE16_HANDLER( ay8910_control_port_3_lsb_w ) { if (ACCESSING_BITS_0_7) ay8910_write_ym(sndti_token(SOUND_AY8910, 3),0,data & 0xff); }
-WRITE16_HANDLER( ay8910_control_port_4_lsb_w ) { if (ACCESSING_BITS_0_7) ay8910_write_ym(sndti_token(SOUND_AY8910, 4),0,data & 0xff); }
-WRITE16_HANDLER( ay8910_control_port_0_msb_w ) { if (ACCESSING_BITS_8_15) ay8910_write_ym(sndti_token(SOUND_AY8910, 0),0,data >> 8); }
-WRITE16_HANDLER( ay8910_control_port_1_msb_w ) { if (ACCESSING_BITS_8_15) ay8910_write_ym(sndti_token(SOUND_AY8910, 1),0,data >> 8); }
-WRITE16_HANDLER( ay8910_control_port_2_msb_w ) { if (ACCESSING_BITS_8_15) ay8910_write_ym(sndti_token(SOUND_AY8910, 2),0,data >> 8); }
-WRITE16_HANDLER( ay8910_control_port_3_msb_w ) { if (ACCESSING_BITS_8_15) ay8910_write_ym(sndti_token(SOUND_AY8910, 3),0,data >> 8); }
-WRITE16_HANDLER( ay8910_control_port_4_msb_w ) { if (ACCESSING_BITS_8_15) ay8910_write_ym(sndti_token(SOUND_AY8910, 4),0,data >> 8); }
-
-WRITE8_HANDLER( ay8910_write_port_0_w ) { ay8910_write_ym(sndti_token(SOUND_AY8910, 0),1,data); }
-WRITE8_HANDLER( ay8910_write_port_1_w ) { ay8910_write_ym(sndti_token(SOUND_AY8910, 1),1,data); }
-WRITE8_HANDLER( ay8910_write_port_2_w ) { ay8910_write_ym(sndti_token(SOUND_AY8910, 2),1,data); }
-WRITE8_HANDLER( ay8910_write_port_3_w ) { ay8910_write_ym(sndti_token(SOUND_AY8910, 3),1,data); }
-WRITE8_HANDLER( ay8910_write_port_4_w ) { ay8910_write_ym(sndti_token(SOUND_AY8910, 4),1,data); }
-WRITE16_HANDLER( ay8910_write_port_0_lsb_w ) { if (ACCESSING_BITS_0_7) ay8910_write_ym(sndti_token(SOUND_AY8910, 0),1,data & 0xff); }
-WRITE16_HANDLER( ay8910_write_port_1_lsb_w ) { if (ACCESSING_BITS_0_7) ay8910_write_ym(sndti_token(SOUND_AY8910, 1),1,data & 0xff); }
-WRITE16_HANDLER( ay8910_write_port_2_lsb_w ) { if (ACCESSING_BITS_0_7) ay8910_write_ym(sndti_token(SOUND_AY8910, 2),1,data & 0xff); }
-WRITE16_HANDLER( ay8910_write_port_3_lsb_w ) { if (ACCESSING_BITS_0_7) ay8910_write_ym(sndti_token(SOUND_AY8910, 3),1,data & 0xff); }
-WRITE16_HANDLER( ay8910_write_port_4_lsb_w ) { if (ACCESSING_BITS_0_7) ay8910_write_ym(sndti_token(SOUND_AY8910, 4),1,data & 0xff); }
-WRITE16_HANDLER( ay8910_write_port_0_msb_w ) { if (ACCESSING_BITS_8_15) ay8910_write_ym(sndti_token(SOUND_AY8910, 0),1,data >> 8); }
-WRITE16_HANDLER( ay8910_write_port_1_msb_w ) { if (ACCESSING_BITS_8_15) ay8910_write_ym(sndti_token(SOUND_AY8910, 1),1,data >> 8); }
-WRITE16_HANDLER( ay8910_write_port_2_msb_w ) { if (ACCESSING_BITS_8_15) ay8910_write_ym(sndti_token(SOUND_AY8910, 2),1,data >> 8); }
-WRITE16_HANDLER( ay8910_write_port_3_msb_w ) { if (ACCESSING_BITS_8_15) ay8910_write_ym(sndti_token(SOUND_AY8910, 3),1,data >> 8); }
-WRITE16_HANDLER( ay8910_write_port_4_msb_w ) { if (ACCESSING_BITS_8_15) ay8910_write_ym(sndti_token(SOUND_AY8910, 4),1,data >> 8); }
+READ8_DEVICE_HANDLER( ay8910_r )
+{
+ return ay8910_read_ym(get_safe_token(device));
+}
+
+WRITE8_DEVICE_HANDLER( ay8910_data_address_w )
+{
+ /* note that directly connecting BC1 to A0 puts data on 0 and address on 1 */
+ ay8910_write_ym(get_safe_token(device), ~offset & 1, data);
+}
+
+WRITE8_DEVICE_HANDLER( ay8910_address_data_w )
+{
+ ay8910_write_ym(get_safe_token(device), offset & 1, data);
+}
+
+WRITE8_DEVICE_HANDLER( ay8910_address_w )
+{
+ ay8910_data_address_w(device, 1, data);
+}
+
+WRITE8_DEVICE_HANDLER( ay8910_data_w )
+{
+ ay8910_data_address_w(device, 0, data);
+}
diff --git a/src/emu/sound/ay8910.h b/src/emu/sound/ay8910.h
index 73580224c00..b6e49f8a3e3 100644
--- a/src/emu/sound/ay8910.h
+++ b/src/emu/sound/ay8910.h
@@ -3,6 +3,8 @@
#ifndef __AY8910_H__
#define __AY8910_H__
+#include "devcb.h"
+
/*
AY-3-8910A: 2 I/O ports
AY-3-8912A: 1 I/O port
@@ -66,63 +68,25 @@ struct _ay8910_interface
{
int flags; /* Flags */
int res_load[3]; /* Load on channel in ohms */
- read8_space_func portAread;
- read8_space_func portBread;
- write8_space_func portAwrite;
- write8_space_func portBwrite;
+ devcb_read8 portAread;
+ devcb_read8 portBread;
+ devcb_write8 portAwrite;
+ devcb_write8 portBwrite;
};
-void ay8910_set_volume(int chip,int channel,int volume);
-
-
-READ8_HANDLER( ay8910_read_port_0_r );
-READ8_HANDLER( ay8910_read_port_1_r );
-READ8_HANDLER( ay8910_read_port_2_r );
-READ8_HANDLER( ay8910_read_port_3_r );
-READ8_HANDLER( ay8910_read_port_4_r );
-READ16_HANDLER( ay8910_read_port_0_lsb_r );
-READ16_HANDLER( ay8910_read_port_1_lsb_r );
-READ16_HANDLER( ay8910_read_port_2_lsb_r );
-READ16_HANDLER( ay8910_read_port_3_lsb_r );
-READ16_HANDLER( ay8910_read_port_4_lsb_r );
-READ16_HANDLER( ay8910_read_port_0_msb_r );
-READ16_HANDLER( ay8910_read_port_1_msb_r );
-READ16_HANDLER( ay8910_read_port_2_msb_r );
-READ16_HANDLER( ay8910_read_port_3_msb_r );
-READ16_HANDLER( ay8910_read_port_4_msb_r );
-
-WRITE8_HANDLER( ay8910_control_port_0_w );
-WRITE8_HANDLER( ay8910_control_port_1_w );
-WRITE8_HANDLER( ay8910_control_port_2_w );
-WRITE8_HANDLER( ay8910_control_port_3_w );
-WRITE8_HANDLER( ay8910_control_port_4_w );
-WRITE16_HANDLER( ay8910_control_port_0_lsb_w );
-WRITE16_HANDLER( ay8910_control_port_1_lsb_w );
-WRITE16_HANDLER( ay8910_control_port_2_lsb_w );
-WRITE16_HANDLER( ay8910_control_port_3_lsb_w );
-WRITE16_HANDLER( ay8910_control_port_4_lsb_w );
-WRITE16_HANDLER( ay8910_control_port_0_msb_w );
-WRITE16_HANDLER( ay8910_control_port_1_msb_w );
-WRITE16_HANDLER( ay8910_control_port_2_msb_w );
-WRITE16_HANDLER( ay8910_control_port_3_msb_w );
-WRITE16_HANDLER( ay8910_control_port_4_msb_w );
-
-WRITE8_HANDLER( ay8910_write_port_0_w );
-WRITE8_HANDLER( ay8910_write_port_1_w );
-WRITE8_HANDLER( ay8910_write_port_2_w );
-WRITE8_HANDLER( ay8910_write_port_3_w );
-WRITE8_HANDLER( ay8910_write_port_4_w );
-WRITE16_HANDLER( ay8910_write_port_0_lsb_w );
-WRITE16_HANDLER( ay8910_write_port_1_lsb_w );
-WRITE16_HANDLER( ay8910_write_port_2_lsb_w );
-WRITE16_HANDLER( ay8910_write_port_3_lsb_w );
-WRITE16_HANDLER( ay8910_write_port_4_lsb_w );
-WRITE16_HANDLER( ay8910_write_port_0_msb_w );
-WRITE16_HANDLER( ay8910_write_port_1_msb_w );
-WRITE16_HANDLER( ay8910_write_port_2_msb_w );
-WRITE16_HANDLER( ay8910_write_port_3_msb_w );
-WRITE16_HANDLER( ay8910_write_port_4_msb_w );
+void ay8910_set_volume(const device_config *device,int channel,int volume);
+
+READ8_DEVICE_HANDLER( ay8910_r );
+WRITE8_DEVICE_HANDLER( ay8910_address_w );
+WRITE8_DEVICE_HANDLER( ay8910_data_w );
+
+/* use this when BC1 == A0; here, BC1=0 selects 'data' and BC1=1 selects 'latch address' */
+WRITE8_DEVICE_HANDLER( ay8910_data_address_w );
+
+/* use this when BC1 == !A0; here, BC1=0 selects 'latch address' and BC1=1 selects 'data' */
+WRITE8_DEVICE_HANDLER( ay8910_address_data_w );
+
/*********** An interface for SSG of YM2203 ***********/
@@ -134,22 +98,22 @@ void ay8910_set_clock_ym(void *chip, int clock);
void ay8910_write_ym(void *chip, int addr, int data);
int ay8910_read_ym(void *chip);
-SND_GET_INFO( ay8910 );
-SND_GET_INFO( ay8912 );
-SND_GET_INFO( ay8913 );
-SND_GET_INFO( ay8930 );
-SND_GET_INFO( ym2149 );
-SND_GET_INFO( ym3439 );
-SND_GET_INFO( ymz284 );
-SND_GET_INFO( ymz294 );
-
-#define SOUND_AY8910 SND_GET_INFO_NAME( ay8910 )
-#define SOUND_AY8912 SND_GET_INFO_NAME( ay8912 )
-#define SOUND_AY8913 SND_GET_INFO_NAME( ay8913 )
-#define SOUND_AY8930 SND_GET_INFO_NAME( ay8930 )
-#define SOUND_YM2149 SND_GET_INFO_NAME( ym2149 )
-#define SOUND_YM3439 SND_GET_INFO_NAME( ym3439 )
-#define SOUND_YMZ284 SND_GET_INFO_NAME( ymz284 )
-#define SOUND_YMZ294 SND_GET_INFO_NAME( ymz294 )
+DEVICE_GET_INFO( ay8910 );
+DEVICE_GET_INFO( ay8912 );
+DEVICE_GET_INFO( ay8913 );
+DEVICE_GET_INFO( ay8930 );
+DEVICE_GET_INFO( ym2149 );
+DEVICE_GET_INFO( ym3439 );
+DEVICE_GET_INFO( ymz284 );
+DEVICE_GET_INFO( ymz294 );
+
+#define SOUND_AY8910 DEVICE_GET_INFO_NAME( ay8910 )
+#define SOUND_AY8912 DEVICE_GET_INFO_NAME( ay8912 )
+#define SOUND_AY8913 DEVICE_GET_INFO_NAME( ay8913 )
+#define SOUND_AY8930 DEVICE_GET_INFO_NAME( ay8930 )
+#define SOUND_YM2149 DEVICE_GET_INFO_NAME( ym2149 )
+#define SOUND_YM3439 DEVICE_GET_INFO_NAME( ym3439 )
+#define SOUND_YMZ284 DEVICE_GET_INFO_NAME( ymz284 )
+#define SOUND_YMZ294 DEVICE_GET_INFO_NAME( ymz294 )
#endif /* __AY8910_H__ */
diff --git a/src/emu/sound/beep.c b/src/emu/sound/beep.c
index ca07ea59aaf..e320f39d845 100644
--- a/src/emu/sound/beep.c
+++ b/src/emu/sound/beep.c
@@ -18,8 +18,8 @@
#define BEEP_RATE 48000
-
-struct beep_sound
+typedef struct _beep_state beep_state;
+struct _beep_state
{
sound_stream *stream; /* stream number */
int enable; /* enable beep */
@@ -29,6 +29,16 @@ struct beep_sound
};
+INLINE beep_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_BEEP);
+ return (beep_state *)device->token;
+}
+
+
/*************************************
*
@@ -38,7 +48,7 @@ struct beep_sound
static STREAM_UPDATE( beep_sound_update )
{
- struct beep_sound *bs = (struct beep_sound *) param;
+ beep_state *bs = (beep_state *) param;
stream_sample_t *buffer = outputs[0];
INT16 signal = bs->signal;
int clock = 0, rate = BEEP_RATE / 2;
@@ -81,9 +91,9 @@ static STREAM_UPDATE( beep_sound_update )
*
*************************************/
-static SND_START( beep )
+static DEVICE_START( beep )
{
- struct beep_sound *pBeep = device->token;
+ beep_state *pBeep = get_safe_token(device);
pBeep->stream = stream_create(device, 0, 1, BEEP_RATE, pBeep, beep_sound_update );
pBeep->enable = 0;
@@ -100,9 +110,9 @@ static SND_START( beep )
*
*************************************/
-void beep_set_state( int num, int on )
+void beep_set_state(const device_config *device, int on)
{
- struct beep_sound *info = sndti_token(SOUND_BEEP, num);
+ beep_state *info = get_safe_token(device);
/* only update if new state is not the same as old state */
if (info->enable == on)
@@ -124,9 +134,9 @@ void beep_set_state( int num, int on )
*
*************************************/
-void beep_set_frequency(int num,int frequency)
+void beep_set_frequency(const device_config *device,int frequency)
{
- struct beep_sound *info = sndti_token(SOUND_BEEP, num);
+ beep_state *info = get_safe_token(device);
if (info->frequency == frequency)
return;
@@ -145,15 +155,15 @@ void beep_set_frequency(int num,int frequency)
*
*************************************/
-void beep_set_volume(int num, int volume)
+void beep_set_volume(const device_config *device, int volume)
{
- struct beep_sound *info = sndti_token(SOUND_BEEP, num);
+ beep_state *info = get_safe_token(device);
stream_update(info->stream);
volume = 100 * volume / 7;
- sndti_set_output_gain(SOUND_BEEP, num, 0, volume );
+ sound_set_output_gain(device, 0, volume);
}
@@ -162,33 +172,21 @@ void beep_set_volume(int num, int volume)
* Generic get_info
**************************************************************************/
-static SND_SET_INFO( beep )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
-SND_GET_INFO( beep )
+DEVICE_GET_INFO( beep )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct beep_sound); break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(beep_state); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( beep ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( beep ); break;
- case SNDINFO_PTR_STOP: /* nothing */ break;
- case SNDINFO_PTR_RESET: /* nothing */ break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( beep ); break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "Beep"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Beep"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright The MESS Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "Beep"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "Beep"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright The MESS Team"); break;
}
}
diff --git a/src/emu/sound/beep.h b/src/emu/sound/beep.h
index 2b01ed48dbb..41784e553bf 100644
--- a/src/emu/sound/beep.h
+++ b/src/emu/sound/beep.h
@@ -3,19 +3,11 @@
#ifndef __BEEP_H__
#define __BEEP_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
+void beep_set_state(const device_config *device, int on);
+void beep_set_frequency(const device_config *device, int frequency);
+void beep_set_volume(const device_config *device, int volume);
-void beep_set_state(int,int);
-void beep_set_frequency(int,int);
-void beep_set_volume(int,int);
-
-SND_GET_INFO( beep );
-#define SOUND_BEEP SND_GET_INFO_NAME( beep )
-
-#ifdef __cplusplus
-}
-#endif
+DEVICE_GET_INFO( beep );
+#define SOUND_BEEP DEVICE_GET_INFO_NAME( beep )
#endif /* __BEEP_H__ */
diff --git a/src/emu/sound/bsmt2000.c b/src/emu/sound/bsmt2000.c
index 8a09d46f02d..1a93826dc54 100644
--- a/src/emu/sound/bsmt2000.c
+++ b/src/emu/sound/bsmt2000.c
@@ -85,12 +85,8 @@ struct _bsmt2000_chip
***************************************************************************/
/* core implementation */
-static void bsmt2000_reset(bsmt2000_chip *chip);
static STREAM_UPDATE( bsmt2000_update );
-/* read/write access */
-static void bsmt2000_reg_write(bsmt2000_chip *chip, offs_t offset, UINT16 data);
-
/* local functions */
static void set_mode(bsmt2000_chip *chip);
static void set_regmap(bsmt2000_chip *chip, UINT8 posbase, UINT8 ratebase, UINT8 endbase, UINT8 loopbase, UINT8 bankbase, UINT8 rvolbase, UINT8 lvolbase);
@@ -98,21 +94,36 @@ static void set_regmap(bsmt2000_chip *chip, UINT8 posbase, UINT8 ratebase, UINT8
/***************************************************************************
+ INLINE FUNCTIONS
+***************************************************************************/
+
+INLINE bsmt2000_chip *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_BSMT2000);
+ return (bsmt2000_chip *)device->token;
+}
+
+
+
+/***************************************************************************
CORE IMPLEMENTATION
***************************************************************************/
/*-------------------------------------------------
- SND_START( bsmt2000 ) - initialization callback
+ DEVICE_START( bsmt2000 ) - initialization callback
-------------------------------------------------*/
-static SND_START( bsmt2000 )
+static DEVICE_START( bsmt2000 )
{
- bsmt2000_chip *chip = device->token;
+ bsmt2000_chip *chip = get_safe_token(device);
int voicenum;
/* create a stream at a nominal sample rate (real one specified later) */
- chip->stream = stream_create(device, 0, 2, clock / 1000, chip, bsmt2000_update);
- chip->clock = clock;
+ chip->stream = stream_create(device, 0, 2, device->clock / 1000, chip, bsmt2000_update);
+ chip->clock = device->clock;
/* initialize the regions */
chip->region_base = (INT8 *)device->region;
@@ -140,18 +151,16 @@ static SND_START( bsmt2000 )
state_save_register_device_item(device, voicenum, voice->rightvol);
state_save_register_device_item(device, voicenum, voice->fraction);
}
-
- /* reset the chip -- this also configures the default mode */
- bsmt2000_reset(chip);
}
/*-------------------------------------------------
- SND_RESET( bsmt2000 ) - chip reset callback
+ DEVICE_RESET( bsmt2000 ) - chip reset callback
-------------------------------------------------*/
-static void bsmt2000_reset(bsmt2000_chip *chip)
+static DEVICE_RESET( bsmt2000 )
{
+ bsmt2000_chip *chip = get_safe_token(device);
int voicenum;
/* reset all the voice data */
@@ -167,11 +176,6 @@ static void bsmt2000_reset(bsmt2000_chip *chip)
set_mode(chip);
}
-static SND_RESET( bsmt2000 )
-{
- bsmt2000_reset(device->token);
-}
-
/*-------------------------------------------------
bsmt2000_update - update callback for
@@ -316,8 +320,10 @@ static STREAM_UPDATE( bsmt2000_update )
bsmt2000_reg_write - handle a register write
-------------------------------------------------*/
-static void bsmt2000_reg_write(bsmt2000_chip *chip, offs_t offset, UINT16 data)
+WRITE16_DEVICE_HANDLER( bsmt2000_data_w )
{
+ bsmt2000_chip *chip = get_safe_token(device);
+
if (LOG_COMMANDS) mame_printf_debug("BSMT write: reg %02X = %04X\n", offset, data);
/* remember the last write */
@@ -344,21 +350,6 @@ static void bsmt2000_reg_write(bsmt2000_chip *chip, offs_t offset, UINT16 data)
/***************************************************************************
- PER-CHIP READ/WRITE HANDLERS
-***************************************************************************/
-
-/*-------------------------------------------------
- bsmt2000_data_0_w - write to chip 0
--------------------------------------------------*/
-
-WRITE16_HANDLER( bsmt2000_data_0_w )
-{
- bsmt2000_reg_write(sndti_token(SOUND_BSMT2000, 0), offset, data);
-}
-
-
-
-/***************************************************************************
LOCAL FUNCTIONS
***************************************************************************/
@@ -472,42 +463,26 @@ static void set_regmap(bsmt2000_chip *chip, UINT8 posbase, UINT8 ratebase, UINT8
***************************************************************************/
/*-------------------------------------------------
- SND_SET_INFO( bsmt2000 ) - callback for
- setting chip information
--------------------------------------------------*/
-
-static SND_SET_INFO( bsmt2000 )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
-/*-------------------------------------------------
- SND_GET_INFO( bsmt2000 ) - callback for
+ DEVICE_GET_INFO( bsmt2000 ) - callback for
retrieving chip information
-------------------------------------------------*/
-SND_GET_INFO( bsmt2000 )
+DEVICE_GET_INFO( bsmt2000 )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(bsmt2000_chip); break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(bsmt2000_chip); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( bsmt2000 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( bsmt2000 ); break;
- case SNDINFO_PTR_STOP: /* nothing */ break;
- case SNDINFO_PTR_RESET: info->reset = SND_RESET_NAME( bsmt2000 ); break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( bsmt2000 ); break;
+ case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( bsmt2000 ); break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "BSMT2000"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Data East Wavetable"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "BSMT2000"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "Data East Wavetable"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}
diff --git a/src/emu/sound/bsmt2000.h b/src/emu/sound/bsmt2000.h
index cc3fc2d12a4..02f7a9418fe 100644
--- a/src/emu/sound/bsmt2000.h
+++ b/src/emu/sound/bsmt2000.h
@@ -10,9 +10,9 @@
#ifndef __BSMT2000_H__
#define __BSMT2000_H__
-WRITE16_HANDLER( bsmt2000_data_0_w );
+WRITE16_DEVICE_HANDLER( bsmt2000_data_w );
-SND_GET_INFO( bsmt2000 );
-#define SOUND_BSMT2000 SND_GET_INFO_NAME( bsmt2000 )
+DEVICE_GET_INFO( bsmt2000 );
+#define SOUND_BSMT2000 DEVICE_GET_INFO_NAME( bsmt2000 )
#endif /* __BSMT2000_H__ */
diff --git a/src/emu/sound/c140.c b/src/emu/sound/c140.c
index d8867e9846e..68bb3ec66e8 100644
--- a/src/emu/sound/c140.c
+++ b/src/emu/sound/c140.c
@@ -88,7 +88,8 @@ typedef struct
long sample_loop;
} VOICE;
-struct c140_info
+typedef struct _c140_state c140_state;
+struct _c140_state
{
int sample_rate;
sound_stream *stream;
@@ -106,6 +107,16 @@ struct c140_info
VOICE voi[MAX_VOICE];
};
+INLINE c140_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_C140);
+ return (c140_state *)device->token;
+}
+
+
static void init_voice( VOICE *v )
{
v->key=0;
@@ -119,9 +130,9 @@ static void init_voice( VOICE *v )
v->sample_end=0;
v->sample_loop=0;
}
-READ8_HANDLER( c140_r )
+READ8_DEVICE_HANDLER( c140_r )
{
- struct c140_info *info = sndti_token(SOUND_C140, 0);
+ c140_state *info = get_safe_token(device);
offset&=0x1ff;
return info->REG[offset];
}
@@ -134,7 +145,7 @@ READ8_HANDLER( c140_r )
is done by a small PAL or GAL external to the sound chip, which can be switched
per-game or at least per-PCB revision as addressing range needs grow.
*/
-static long find_sample(struct c140_info *info, long adrs, long bank, int voice)
+static long find_sample(c140_state *info, long adrs, long bank, int voice)
{
long newadr = 0;
@@ -184,9 +195,9 @@ static long find_sample(struct c140_info *info, long adrs, long bank, int voice)
return (newadr);
}
-WRITE8_HANDLER( c140_w )
+WRITE8_DEVICE_HANDLER( c140_w )
{
- struct c140_info *info = sndti_token(SOUND_C140, 0);
+ c140_state *info = get_safe_token(device);
stream_update(info->stream);
offset&=0x1ff;
@@ -246,9 +257,9 @@ WRITE8_HANDLER( c140_w )
}
}
-void c140_set_base(int which, void *base)
+void c140_set_base(const device_config *device, void *base)
{
- struct c140_info *info = sndti_token(SOUND_C140, 0);
+ c140_state *info = get_safe_token(device);
info->pRom = base;
}
@@ -261,7 +272,7 @@ INLINE int limit(INT32 in)
static STREAM_UPDATE( update_stereo )
{
- struct c140_info *info = param;
+ c140_state *info = param;
int i,j;
INT32 rvol,lvol;
@@ -454,12 +465,12 @@ static STREAM_UPDATE( update_stereo )
}
}
-static SND_START( c140 )
+static DEVICE_START( c140 )
{
const c140_interface *intf = device->static_config;
- struct c140_info *info = device->token;
+ c140_state *info = get_safe_token(device);
- info->sample_rate=info->baserate=clock;
+ info->sample_rate=info->baserate=device->clock;
info->banking_type = intf->banking_type;
@@ -496,34 +507,24 @@ static SND_START( c140 )
* Generic get_info
**************************************************************************/
-static SND_SET_INFO( c140 )
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
-SND_GET_INFO( c140 )
+DEVICE_GET_INFO( c140 )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
- case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct c140_info); break;
+ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(c140_state); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( c140 ); break;
- case SNDINFO_PTR_START: info->start = SND_START_NAME( c140 ); break;
- case SNDINFO_PTR_STOP: /* nothing */ break;
- case SNDINFO_PTR_RESET: /* nothing */ break;
+ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( c140 ); break;
+ case DEVINFO_FCT_STOP: /* nothing */ break;
+ case DEVINFO_FCT_RESET: /* nothing */ break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: strcpy(info->s, "C140"); break;
- case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Namco PCM"); break;
- case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
- case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
- case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
+ case DEVINFO_STR_NAME: strcpy(info->s, "C140"); break;
+ case DEVINFO_STR_FAMILY: strcpy(info->s, "Namco PCM"); break;
+ case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
+ case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
+ case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}
diff --git a/src/emu/sound/c140.h b/src/emu/sound/c140.h
index 5d78c7eb264..f814e9c242e 100644
--- a/src/emu/sound/c140.h
+++ b/src/emu/sound/c140.h
@@ -5,10 +5,10 @@
#ifndef __C140_H__
#define __C140_H__
-READ8_HANDLER( c140_r );
-WRITE8_HANDLER( c140_w );
+READ8_DEVICE_HANDLER( c140_r );
+WRITE8_DEVICE_HANDLER( c140_w );
-void c140_set_base(int which, void *base);
+void c140_set_base(const device_config *device, void *base);
enum
{
@@ -23,7 +23,7 @@ struct _c140_interface {
int banking_type;
};
-SND_GET_INFO( c140 );
-#define SOUND_C140 SND_GET_INFO_NAME( c140 )
+DEVICE_GET_INFO( c140 );
+#define SOUND_C140 DEVICE_GET_INFO_NAME( c140 )
#endif /* __C140_H__ */
diff --git a/src/emu/sound/c352.c b/src/emu/sound/c352.c
index d6a8ca6502b..71c2df438d8 100644
--- a/src/emu/sound/c352.c
+++ b/src/emu/sound/c352.c
@@ -65,7 +65,8 @@ typedef struct
UINT32 pos;
} c352_ch_t;
-struct c352_info
+typedef struct _c352_state c352_state;
+struct _c352_state
{
sound_stream *stream;
c352_ch_t c352_ch[32];
@@ -82,8 +83,17 @@ struct c352_info
unsigned int mseq_reg;
};
+INLINE c352_state *get_safe_token(const device_config *device)
+{
+ assert(device != NULL);
+ assert(device->token != NULL);
+ assert(device->type == SOUND);
+ assert(sound_get_type(device) == SOUND_C352);
+ return (c352_state *)device->token;
+}
+
// noise generator
-static int get_mseq_bit(struct c352_info *info)
+static int get_mseq_bit(c352_state *info)
{
unsigned int mask = (1 << (7 - 1));
unsigned int reg = info->mseq_reg;
@@ -103,7 +113,7 @@ static int get_mseq_bit(struct c352_info *info)
return (reg & 1);
}
-static void c352_mix_one_channel(struct c352_info *info, unsigned long ch, long sample_count)
+static void c352_mix_one_channel(c352_state *info, unsigned long ch, long sample_count)
{
int i;
@@ -327,7 +337,7 @@ static void c352_mix_one_channel(struct c352_info *info, unsigned long ch, long
static STREAM_UPDATE( c352_update )
{
- struct c352_info *info = param;
+ c352_state *info = param;
int i, j;
stream_sample_t *bufferl = outputs[0];
stream_sample_t *bufferr = outputs[1];
@@ -353,7 +363,7 @@ static STREAM_UPDATE( c352_update )
}
}
-static unsigned short c352_read_reg16(struct c352_info *info, unsigned long address)
+s