Previous 199869 Revisions Next

r21176 Tuesday 19th February, 2013 at 06:33:21 UTC by Andrew Gardner
Modernized tms3615, es8712, cem3394, k051649, and rf5c400 sound devices. [Andrew
Gardner]
[src/emu/sound]cem3394.c cem3394.h es8712.c es8712.h k051649.c k051649.h rf5c400.c rf5c400.h tms3615.c tms3615.h
[src/mame/audio]laserbat.c
[src/mame/drivers]balsente.c cobra.c gticlub.c hcastle.c hexion.c hornet.c laserbat.c metro.c nemesis.c nwk-tr.c twinkle.c witch.c
[src/mame/includes]laserbat.h
[src/mame/machine]balsente.c
[src/mess/includes]msx.h
[src/mess/machine]msx_slot.c

trunk/src/mame/drivers/laserbat.c
r21175r21176
687687   m_s2636_3 = machine().device("s2636_3");
688688   m_pia = machine().device<pia6821_device>("pia");
689689   m_sn = machine().device("snsnd");
690   m_tms1 = machine().device("tms1");
691   m_tms2 = machine().device("tms2");
690   m_tms1 = machine().device<tms3615_device>("tms1");
691   m_tms2 = machine().device<tms3615_device>("tms2");
692692   m_ay1 = machine().device("ay1");
693693   m_ay2 = machine().device("ay2");
694694
r21175r21176
769769   MCFG_SOUND_ADD("snsnd", SN76477, 0) // output not connected
770770   MCFG_SOUND_CONFIG(laserbat_sn76477_interface)
771771
772   MCFG_SOUND_ADD("tms1", TMS3615, 4000000/8/2) // 250 kHz, from second chip's clock out
772   MCFG_TMS3615_ADD("tms1", 4000000/8/2) // 250 kHz, from second chip's clock out
773773   MCFG_SOUND_ROUTE(TMS3615_FOOTAGE_8, "mono", 1.0)
774774
775   MCFG_SOUND_ADD("tms2", TMS3615, 4000000/8) // 500 kHz
775   MCFG_TMS3615_ADD("tms2", 4000000/8) // 500 kHz
776776   MCFG_SOUND_ROUTE(TMS3615_FOOTAGE_8, "mono", 1.0)
777777MACHINE_CONFIG_END
778778
trunk/src/mame/drivers/hexion.c
r21175r21176
118118   AM_RANGE(0xa000, 0xbfff) AM_RAM
119119   AM_RANGE(0xc000, 0xdffe) AM_READWRITE(hexion_bankedram_r, hexion_bankedram_w)
120120   AM_RANGE(0xdfff, 0xdfff) AM_WRITE(hexion_bankctrl_w)
121   AM_RANGE(0xe800, 0xe87f) AM_DEVREADWRITE_LEGACY("konami", k051649_waveform_r, k051649_waveform_w)
122   AM_RANGE(0xe880, 0xe889) AM_DEVWRITE_LEGACY("konami", k051649_frequency_w)
123   AM_RANGE(0xe88a, 0xe88e) AM_DEVWRITE_LEGACY("konami", k051649_volume_w)
124   AM_RANGE(0xe88f, 0xe88f) AM_DEVWRITE_LEGACY("konami", k051649_keyonoff_w)
125   AM_RANGE(0xe8e0, 0xe8ff) AM_DEVREADWRITE_LEGACY("konami", k051649_test_r, k051649_test_w)
121   AM_RANGE(0xe800, 0xe87f) AM_DEVREADWRITE("konami", k051649_device, k051649_waveform_r, k051649_waveform_w)
122   AM_RANGE(0xe880, 0xe889) AM_DEVWRITE("konami", k051649_device, k051649_frequency_w)
123   AM_RANGE(0xe88a, 0xe88e) AM_DEVWRITE("konami", k051649_device, k051649_volume_w)
124   AM_RANGE(0xe88f, 0xe88f) AM_DEVWRITE("konami", k051649_device, k051649_keyonoff_w)
125   AM_RANGE(0xe8e0, 0xe8ff) AM_DEVREADWRITE("konami", k051649_device, k051649_test_r, k051649_test_w)
126126   AM_RANGE(0xf000, 0xf00f) AM_DEVREADWRITE_LEGACY("k053252",k053252_r,k053252_w)
127127   AM_RANGE(0xf200, 0xf200) AM_DEVWRITE("oki", okim6295_device, write)
128128   AM_RANGE(0xf400, 0xf400) AM_READ_PORT("DSW1")
r21175r21176
247247   MCFG_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified
248248   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5)
249249
250   MCFG_SOUND_ADD("konami", K051649, 24000000/16)
250   MCFG_K051649_ADD("konami", 24000000/16)
251251   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5)
252252MACHINE_CONFIG_END
253253
trunk/src/mame/drivers/twinkle.c
r21175r21176
748748   AM_RANGE(0x280000, 0x280fff) AM_READWRITE(shared_68k_r, shared_68k_w )
749749   AM_RANGE(0x300000, 0x30000f) AM_READWRITE(twinkle_ide_r, twinkle_ide_w)
750750   // 34000E = ???
751   AM_RANGE(0x400000, 0x400fff) AM_DEVREADWRITE_LEGACY("rfsnd", rf5c400_r, rf5c400_w)
751   AM_RANGE(0x400000, 0x400fff) AM_DEVREADWRITE("rfsnd", rf5c400_device, rf5c400_r, rf5c400_w)
752752   AM_RANGE(0x800000, 0xffffff) AM_READWRITE(twinkle_waveram_r, twinkle_waveram_w )    // 8 MB window wave RAM
753753ADDRESS_MAP_END
754754
r21175r21176
884884   MCFG_SOUND_ROUTE( 0, "speakerleft", 0.75 )
885885   MCFG_SOUND_ROUTE( 1, "speakerright", 0.75 )
886886
887   MCFG_SOUND_ADD("rfsnd", RF5C400, 32000000/2)
887   MCFG_RF5C400_ADD("rfsnd", 32000000/2)
888888   MCFG_SOUND_ROUTE(0, "speakerleft", 1.0)
889889   MCFG_SOUND_ROUTE(1, "speakerright", 1.0)
890890
trunk/src/mame/drivers/gticlub.c
r21175r21176
449449   AM_RANGE(0x000000, 0x07ffff) AM_ROM
450450   AM_RANGE(0x200000, 0x20ffff) AM_RAM
451451   AM_RANGE(0x300000, 0x30000f) AM_DEVREADWRITE_LEGACY("k056800", k056800_sound_r, k056800_sound_w)
452   AM_RANGE(0x400000, 0x400fff) AM_DEVREADWRITE_LEGACY("rfsnd", rf5c400_r, rf5c400_w)      /* Ricoh RF5C400 */
452   AM_RANGE(0x400000, 0x400fff) AM_DEVREADWRITE("rfsnd", rf5c400_device, rf5c400_r, rf5c400_w)      /* Ricoh RF5C400 */
453453   AM_RANGE(0x580000, 0x580001) AM_WRITENOP
454454   AM_RANGE(0x600000, 0x600001) AM_WRITENOP
455455ADDRESS_MAP_END
r21175r21176
853853
854854   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
855855
856   MCFG_SOUND_ADD("rfsnd", RF5C400, 33868800/2)
856   MCFG_RF5C400_ADD("rfsnd", 33868800/2)
857857   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
858858   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
859859MACHINE_CONFIG_END
r21175r21176
970970
971971   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
972972
973   MCFG_SOUND_ADD("rfsnd", RF5C400, 33868800/2)
973   MCFG_RF5C400_ADD("rfsnd", 33868800/2)
974974   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
975975   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
976976MACHINE_CONFIG_END
trunk/src/mame/drivers/nemesis.c
r21175r21176
557557static ADDRESS_MAP_START( city_sound_map, AS_PROGRAM, 8, nemesis_state )
558558   AM_RANGE(0x0000, 0x7fff) AM_ROM
559559   AM_RANGE(0x8000, 0x87ff) AM_RAM
560   AM_RANGE(0x9800, 0x987f) AM_DEVREADWRITE_LEGACY("k051649", k051649_waveform_r, k051649_waveform_w)
561   AM_RANGE(0x9880, 0x9889) AM_DEVWRITE_LEGACY("k051649", k051649_frequency_w)
562   AM_RANGE(0x988a, 0x988e) AM_DEVWRITE_LEGACY("k051649", k051649_volume_w)
563   AM_RANGE(0x988f, 0x988f) AM_DEVWRITE_LEGACY("k051649", k051649_keyonoff_w)
564   AM_RANGE(0x98e0, 0x98ff) AM_DEVREADWRITE_LEGACY("k051649", k051649_test_r, k051649_test_w)
560   AM_RANGE(0x9800, 0x987f) AM_DEVREADWRITE("k051649", k051649_device, k051649_waveform_r, k051649_waveform_w)
561   AM_RANGE(0x9880, 0x9889) AM_DEVWRITE("k051649", k051649_device, k051649_frequency_w)
562   AM_RANGE(0x988a, 0x988e) AM_DEVWRITE("k051649", k051649_device, k051649_volume_w)
563   AM_RANGE(0x988f, 0x988f) AM_DEVWRITE("k051649", k051649_device, k051649_keyonoff_w)
564   AM_RANGE(0x98e0, 0x98ff) AM_DEVREADWRITE("k051649", k051649_device, k051649_test_r, k051649_test_w)
565565   AM_RANGE(0xa000, 0xa001) AM_DEVREADWRITE_LEGACY("ymsnd", ym3812_r, ym3812_w)
566566   AM_RANGE(0xb000, 0xb00d) AM_DEVREADWRITE_LEGACY("k007232", k007232_r, k007232_w)
567567   AM_RANGE(0xc000, 0xc000) AM_WRITE(city_sound_bank_w) /* 7232 bankswitch */
r21175r21176
18351835   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0)
18361836   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0)
18371837
1838   MCFG_SOUND_ADD("k051649", K051649, 3579545/2)
1838   MCFG_K051649_ADD("k051649", 3579545/2)
18391839   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.38)
18401840   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.38)
18411841MACHINE_CONFIG_END
r21175r21176
18811881   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0)
18821882   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0)
18831883
1884   MCFG_SOUND_ADD("k051649", K051649, 3579545/2)
1884   MCFG_K051649_ADD("k051649", 3579545/2)
18851885   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.38)
18861886   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.38)
18871887MACHINE_CONFIG_END
trunk/src/mame/drivers/nwk-tr.c
r21175r21176
553553static ADDRESS_MAP_START( sound_memmap, AS_PROGRAM, 16, nwktr_state )
554554   AM_RANGE(0x000000, 0x07ffff) AM_ROM
555555   AM_RANGE(0x100000, 0x10ffff) AM_RAM     /* Work RAM */
556   AM_RANGE(0x200000, 0x200fff) AM_DEVREADWRITE_LEGACY("rfsnd", rf5c400_r, rf5c400_w)      /* Ricoh RF5C400 */
556   AM_RANGE(0x200000, 0x200fff) AM_DEVREADWRITE("rfsnd", rf5c400_device, rf5c400_r, rf5c400_w)      /* Ricoh RF5C400 */
557557   AM_RANGE(0x300000, 0x30000f) AM_DEVREADWRITE_LEGACY("k056800", k056800_sound_r, k056800_sound_w)
558558   AM_RANGE(0x600000, 0x600001) AM_NOP
559559ADDRESS_MAP_END
r21175r21176
756756
757757   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
758758
759   MCFG_SOUND_ADD("rfsnd", RF5C400, 16934400)  // as per Guru readme above
759   MCFG_RF5C400_ADD("rfsnd", 16934400)  // as per Guru readme above
760760   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
761761   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
762762
trunk/src/mame/drivers/hornet.c
r21175r21176
661661static ADDRESS_MAP_START( sound_memmap, AS_PROGRAM, 16, hornet_state )
662662   AM_RANGE(0x000000, 0x07ffff) AM_ROM
663663   AM_RANGE(0x100000, 0x10ffff) AM_RAM     /* Work RAM */
664   AM_RANGE(0x200000, 0x200fff) AM_DEVREADWRITE_LEGACY("rfsnd", rf5c400_r, rf5c400_w)      /* Ricoh RF5C400 */
664   AM_RANGE(0x200000, 0x200fff) AM_DEVREADWRITE("rfsnd", rf5c400_device, rf5c400_r, rf5c400_w)      /* Ricoh RF5C400 */
665665   AM_RANGE(0x300000, 0x30000f) AM_DEVREADWRITE_LEGACY("k056800", k056800_sound_r, k056800_sound_w)
666666   AM_RANGE(0x480000, 0x480001) AM_WRITENOP
667667   AM_RANGE(0x4c0000, 0x4c0001) AM_WRITENOP
r21175r21176
10301030
10311031   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
10321032
1033   MCFG_SOUND_ADD("rfsnd", RF5C400, 16934400)  // value from Guru readme, gives 44100 Hz sample rate
1033   MCFG_RF5C400_ADD("rfsnd", 16934400)  // value from Guru readme, gives 44100 Hz sample rate
10341034   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
10351035   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
10361036
trunk/src/mame/drivers/metro.c
r21175r21176
18281828
18291829WRITE8_MEMBER(metro_state::vmetal_control_w)
18301830{
1831   device_t *device = machine().device("essnd");
1831   es8712_device *device = machine().device<es8712_device>("essnd");
18321832   /* Lower nibble is the coin control bits shown in
18331833      service mode, but in game mode they're different */
18341834   coin_counter_w(machine(), 0, data & 0x04);
r21175r21176
18391839   if ((data & 0x40) == 0)
18401840      device->reset();
18411841   else
1842      es8712_play(device);
1842      device->play();
18431843
18441844   if (data & 0x10)
1845      es8712_set_bank_base(device, 0x100000);
1845      device->set_bank_base(0x100000);
18461846   else
1847      es8712_set_bank_base(device, 0x000000);
1847      device->set_bank_base(0x000000);
18481848
18491849   if (data & 0xa0)
18501850      logerror("%s: Writing unknown bits %04x to $200000\n",machine().describe_context(),data);
r21175r21176
18821882   16   002a 000e 0083 00ee 000f 0069 0069   0e832a-0f69ee
18831883   */
18841884
1885   device_t *device = machine().device("essnd");
1886   es8712_w(device, space, offset, data);
1885   es8712_device *device = machine().device<es8712_device>("essnd");
1886   device->es8712_w(space, offset, data);
18871887   logerror("%s: Writing %04x to ES8712 offset %02x\n", machine().describe_context(), data, offset);
18881888}
18891889
r21175r21176
44094409   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.75)
44104410   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.75)
44114411
4412   MCFG_SOUND_ADD("essnd", ES8712, 12000)
4412   MCFG_ES8712_ADD("essnd", 12000)
44134413   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50)
44144414   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50)
44154415
trunk/src/mame/drivers/hcastle.c
r21175r21176
7474static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8, hcastle_state )
7575   AM_RANGE(0x0000, 0x7fff) AM_ROM
7676   AM_RANGE(0x8000, 0x87ff) AM_RAM
77   AM_RANGE(0x9800, 0x987f) AM_DEVREADWRITE_LEGACY("konami2", k051649_waveform_r, k051649_waveform_w)
78   AM_RANGE(0x9880, 0x9889) AM_DEVWRITE_LEGACY("konami2", k051649_frequency_w)
79   AM_RANGE(0x988a, 0x988e) AM_DEVWRITE_LEGACY("konami2", k051649_volume_w)
80   AM_RANGE(0x988f, 0x988f) AM_DEVWRITE_LEGACY("konami2", k051649_keyonoff_w)
81   AM_RANGE(0x98e0, 0x98ff) AM_DEVREADWRITE_LEGACY("konami2", k051649_test_r, k051649_test_w)
77   AM_RANGE(0x9800, 0x987f) AM_DEVREADWRITE("konami2", k051649_device, k051649_waveform_r, k051649_waveform_w)
78   AM_RANGE(0x9880, 0x9889) AM_DEVWRITE("konami2", k051649_device, k051649_frequency_w)
79   AM_RANGE(0x988a, 0x988e) AM_DEVWRITE("konami2", k051649_device, k051649_volume_w)
80   AM_RANGE(0x988f, 0x988f) AM_DEVWRITE("konami2", k051649_device, k051649_keyonoff_w)
81   AM_RANGE(0x98e0, 0x98ff) AM_DEVREADWRITE("konami2", k051649_device, k051649_test_r, k051649_test_w)
8282   AM_RANGE(0xa000, 0xa001) AM_DEVREADWRITE_LEGACY("ymsnd", ym3812_r, ym3812_w)
8383   AM_RANGE(0xb000, 0xb00d) AM_DEVREADWRITE_LEGACY("konami1", k007232_r, k007232_w)
8484   AM_RANGE(0xc000, 0xc000) AM_WRITE(sound_bank_w) /* 7232 bankswitch */
r21175r21176
244244   MCFG_SOUND_CONFIG(ym3812_config)
245245   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.70)
246246
247   MCFG_SOUND_ADD("konami2", K051649, 3579545/2)
247   MCFG_K051649_ADD("konami2", 3579545/2)
248248   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.45)
249249MACHINE_CONFIG_END
250250
trunk/src/mame/drivers/balsente.c
r21175r21176
12301230   /* sound hardware */
12311231   MCFG_SPEAKER_STANDARD_MONO("mono")
12321232
1233   MCFG_SOUND_ADD("cem1", CEM3394, 0)
1233   MCFG_CEM3394_ADD("cem1", 0)
12341234   MCFG_SOUND_CONFIG(cem_interface)
12351235   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90)
12361236
1237   MCFG_SOUND_ADD("cem2", CEM3394, 0)
1237   MCFG_CEM3394_ADD("cem2", 0)
12381238   MCFG_SOUND_CONFIG(cem_interface)
12391239   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90)
12401240
1241   MCFG_SOUND_ADD("cem3", CEM3394, 0)
1241   MCFG_CEM3394_ADD("cem3", 0)
12421242   MCFG_SOUND_CONFIG(cem_interface)
12431243   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90)
12441244
1245   MCFG_SOUND_ADD("cem4", CEM3394, 0)
1245   MCFG_CEM3394_ADD("cem4", 0)
12461246   MCFG_SOUND_CONFIG(cem_interface)
12471247   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90)
12481248
1249   MCFG_SOUND_ADD("cem5", CEM3394, 0)
1249   MCFG_CEM3394_ADD("cem5", 0)
12501250   MCFG_SOUND_CONFIG(cem_interface)
12511251   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90)
12521252
1253   MCFG_SOUND_ADD("cem6", CEM3394, 0)
1253   MCFG_CEM3394_ADD("cem6", 0)
12541254   MCFG_SOUND_CONFIG(cem_interface)
12551255   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90)
12561256MACHINE_CONFIG_END
trunk/src/mame/drivers/cobra.c
r21175r21176
19861986   AM_RANGE(0x00000000, 0x003fffff) AM_MIRROR(0x80000000) AM_RAM                                           // Main RAM
19871987   AM_RANGE(0x70000000, 0x7003ffff) AM_MIRROR(0x80000000) AM_READWRITE(sub_comram_r, sub_comram_w)         // Double buffered shared RAM between Main and Sub
19881988//  AM_RANGE(0x78000000, 0x780000ff) AM_MIRROR(0x80000000) AM_NOP                                           // SCSI controller (unused)
1989   AM_RANGE(0x78040000, 0x7804ffff) AM_MIRROR(0x80000000) AM_DEVREADWRITE16_LEGACY("rfsnd", rf5c400_r, rf5c400_w, 0xffffffff)
1989   AM_RANGE(0x78040000, 0x7804ffff) AM_MIRROR(0x80000000) AM_DEVREADWRITE16("rfsnd", rf5c400_device, rf5c400_r, rf5c400_w, 0xffffffff)
19901990   AM_RANGE(0x78080000, 0x7808000f) AM_MIRROR(0x80000000) AM_READWRITE(sub_ata0_r, sub_ata0_w)
19911991   AM_RANGE(0x780c0010, 0x780c001f) AM_MIRROR(0x80000000) AM_READWRITE(sub_ata1_r, sub_ata1_w)
19921992   AM_RANGE(0x78200000, 0x782000ff) AM_MIRROR(0x80000000) AM_DEVREADWRITE_LEGACY("k001604", k001604_reg_r, k001604_reg_w)              // PSAC registers
r21175r21176
32513251
32523252   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
32533253
3254   MCFG_SOUND_ADD("rfsnd", RF5C400, XTAL_16_9344MHz)
3254   MCFG_RF5C400_ADD("rfsnd", XTAL_16_9344MHz)
32553255   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
32563256   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
32573257
trunk/src/mame/drivers/witch.c
r21175r21176
524524   AM_RANGE(0x0000, 0x7fff) AM_ROM
525525   AM_RANGE(0x8000, 0x8001) AM_DEVREADWRITE_LEGACY("ym1", ym2203_r, ym2203_w)
526526   AM_RANGE(0x8008, 0x8009) AM_DEVREADWRITE_LEGACY("ym2", ym2203_r, ym2203_w)
527   AM_RANGE(0x8010, 0x8016) AM_READ(read_8010) AM_DEVWRITE_LEGACY("essnd", es8712_w)
527   AM_RANGE(0x8010, 0x8016) AM_READ(read_8010) AM_DEVWRITE("essnd", es8712_device, es8712_w)
528528   AM_RANGE(0xa000, 0xa00f) AM_READWRITE(read_a00x, write_a00x)
529529   AM_RANGE(0xf000, 0xf0ff) AM_RAM AM_SHARE("share1")
530530   AM_RANGE(0xf180, 0xffff) AM_RAM AM_SHARE("share2")
r21175r21176
855855   /* sound hardware */
856856   MCFG_SPEAKER_STANDARD_MONO("mono")
857857
858   MCFG_SOUND_ADD("essnd", ES8712, 8000) /* ?? */
858   MCFG_ES8712_ADD("essnd", 8000) /* ?? */
859859   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
860860
861861   MCFG_SOUND_ADD("ym1", YM2203, XTAL_12MHz / 8)   /* 1.5MHz?? */
trunk/src/mame/audio/laserbat.c
r21175r21176
9595
9696   ksound = ((data & 0x02) << 23) + (m_ksound3 << 16) + (m_ksound2 << 8) + m_ksound1;
9797
98   tms3615_enable_w(m_tms1, ksound & 0x1fff);
99   tms3615_enable_w(m_tms2, (ksound >> 13) << 1);
98   m_tms1->enable_w(ksound & 0x1fff);
99   m_tms2->enable_w((ksound >> 13) << 1);
100100
101101   m_bit14 = (data & 0x20) ? 1 : 0;
102102
trunk/src/mame/machine/balsente.c
r21175r21176
875875   /* find the counter with the maximum frequency */
876876   /* this is used to calibrate the timers at startup */
877877   for (i = 0; i < 6; i++)
878      if (cem3394_get_parameter(m_cem_device[i], CEM3394_FINAL_GAIN) < 10.0)
878      if (m_cem_device[i]->get_parameter(CEM3394_FINAL_GAIN) < 10.0)
879879      {
880880         double tempfreq;
881881
882882         /* if the filter resonance is high, then they're calibrating the filter frequency */
883         if (cem3394_get_parameter(m_cem_device[i], CEM3394_FILTER_RESONANCE) > 0.9)
884            tempfreq = cem3394_get_parameter(m_cem_device[i], CEM3394_FILTER_FREQENCY);
883         if (m_cem_device[i]->get_parameter(CEM3394_FILTER_RESONANCE) > 0.9)
884            tempfreq = m_cem_device[i]->get_parameter(CEM3394_FILTER_FREQENCY);
885885
886886         /* otherwise, they're calibrating the VCO frequency */
887887         else
888            tempfreq = cem3394_get_parameter(m_cem_device[i], CEM3394_VCO_FREQUENCY);
888            tempfreq = m_cem_device[i]->get_parameter(CEM3394_VCO_FREQUENCY);
889889
890890         if (tempfreq > maxfreq) maxfreq = tempfreq;
891891      }
r21175r21176
997997         /* remember the previous value */
998998         temp =
999999#endif
1000            cem3394_get_parameter(m_cem_device[i], reg);
1000            m_cem_device[i]->get_parameter(reg);
10011001
10021002         /* set the voltage */
1003         cem3394_set_voltage(m_cem_device[i], reg, voltage);
1003         m_cem_device[i]->set_voltage(reg, voltage);
10041004
10051005         /* only log changes */
10061006#if LOG_CEM_WRITES
1007         if (temp != cem3394_get_parameter(m_cem_device[i], reg))
1007         if (temp != m_cem_device[i]->get_parameter(reg))
10081008         {
10091009            static const char *const names[] =
10101010            {
trunk/src/mame/includes/laserbat.h
r21175r21176
5555   device_t *m_s2636_3;
5656   pia6821_device *m_pia;
5757   device_t *m_sn;
58   device_t *m_tms1;
59   device_t *m_tms2;
58   tms3615_device *m_tms1;
59   tms3615_device *m_tms2;
6060   device_t *m_ay1;
6161   device_t *m_ay2;
6262
trunk/src/emu/sound/es8712.c
r21175r21176
1818#define MAX_SAMPLE_CHUNK    10000
1919
2020
21/* struct describing a playing ADPCM chip */
22struct es8712_state
21/* step size index shift table */
22static const int index_shift[8] = { -1, -1, -1, -1, 2, 4, 6, 8 };
23
24/* lookup table for the precomputed difference */
25static int diff_lookup[49*16];
26
27
28// device type definition
29const device_type ES8712 = &device_creator<es8712_device>;
30
31
32//**************************************************************************
33//  LIVE DEVICE
34//**************************************************************************
35
36//-------------------------------------------------
37//  es8712_device - constructor
38//-------------------------------------------------
39
40es8712_device::es8712_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
41   : device_t(mconfig, ES8712, "ES8712", tag, owner, clock),
42     device_sound_interface(mconfig, *this),
43     m_playing(0),
44     m_base_offset(0),
45     m_sample(0),
46     m_count(0),
47     m_signal(0),
48     m_step(0),
49     m_start(0),
50     m_end(0),
51     m_repeat(0),
52     m_bank_offset(0),
53     m_region_base(NULL),
54     m_stream(NULL)
2355{
24   UINT8 playing;          /* 1 if we're actively playing */
56}
2557
26   UINT32 base_offset;     /* pointer to the base memory location */
27   UINT32 sample;          /* current sample number */
28   UINT32 count;           /* total samples to play */
2958
30   UINT32 signal;          /* current ADPCM signal */
31   UINT32 step;            /* current ADPCM step */
59//-------------------------------------------------
60//  device_start - start emulation of an ES8712 chip
61//-------------------------------------------------
3262
33   UINT32 start;           /* starting address for the next loop */
34   UINT32 end;             /* ending address for the next loop */
35   UINT8  repeat;          /* Repeat current sample when 1 */
63void es8712_device::device_start()
64{
65   compute_tables();
3666
37   INT32 bank_offset;
38   UINT8 *region_base;     /* pointer to the base of the region */
39   sound_stream *stream;   /* which stream are we playing on? */
40};
67   m_start = 0;
68   m_end = 0;
69   m_repeat = 0;
4170
42/* step size index shift table */
43static const int index_shift[8] = { -1, -1, -1, -1, 2, 4, 6, 8 };
71   m_bank_offset = 0;
72   m_region_base = *region();
4473
45/* lookup table for the precomputed difference */
46static int diff_lookup[49*16];
74   /* generate the name and create the stream */
75   m_stream = stream_alloc(0, 1, clock());
4776
77   /* initialize the rest of the structure */
78   m_signal = -2;
4879
49INLINE es8712_state *get_safe_token(device_t *device)
80   es8712_state_save_register();
81}
82
83
84//-------------------------------------------------
85//  device_reset - stop emulation of an ES8712-compatible chip
86//-------------------------------------------------
87
88void es8712_device::device_reset()
5089{
51   assert(device != NULL);
52   assert(device->type() == ES8712);
53   return (es8712_state *)downcast<es8712_device *>(device)->token();
90   if (m_playing)
91   {
92      /* update the stream, then turn it off */
93      m_stream->update();
94      m_playing = 0;
95      m_repeat = 0;
96   }
5497}
5598
5699
57/**********************************************************************************************
100//-------------------------------------------------
101//  sound_stream_update - update the sound chip so that it is in sync with CPU execution
102//-------------------------------------------------
58103
59     compute_tables -- compute the difference tables
104void es8712_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
105{
106   stream_sample_t *buffer = outputs[0];
60107
61***********************************************************************************************/
108   /* generate them into our buffer */
109   generate_adpcm(buffer, samples);
110}
62111
63static void compute_tables(void)
112
113//-------------------------------------------------
114//   compute_tables -- compute the difference tables
115//-------------------------------------------------
116
117void es8712_device::compute_tables()
64118{
65119   /* nibble to bit map */
66120   static const int nbl2bit[16][4] =
r21175r21176
92146}
93147
94148
149//-------------------------------------------------
150//  generate_adpcm -- general ADPCM decoding routine
151//-------------------------------------------------
95152
96/**********************************************************************************************
97
98    generate_adpcm -- general ADPCM decoding routine
99
100***********************************************************************************************/
101
102static void generate_adpcm(es8712_state *chip, stream_sample_t *buffer, int samples)
153void es8712_device::generate_adpcm(stream_sample_t *buffer, int samples)
103154{
104155   /* if this chip is active */
105   if (chip->playing)
156   if (m_playing)
106157   {
107      UINT8 *base = chip->region_base + chip->bank_offset + chip->base_offset;
108      int sample = chip->sample;
109      int signal = chip->signal;
110      int count = chip->count;
111      int step = chip->step;
158      UINT8 *base = m_region_base + m_bank_offset + m_base_offset;
159      int sample = m_sample;
160      int signal = m_signal;
161      int count = m_count;
162      int step = m_step;
112163      int val;
113164
114165      /* loop while we still have samples to generate */
r21175r21176
138189         /* next! */
139190         if (++sample >= count)
140191         {
141            if (chip->repeat)
192            if (m_repeat)
142193            {
143194               sample = 0;
144195               signal = -2;
r21175r21176
146197            }
147198            else
148199            {
149               chip->playing = 0;
200               m_playing = 0;
150201               break;
151202            }
152203         }
153204      }
154205
155206      /* update the parameters */
156      chip->sample = sample;
157      chip->signal = signal;
158      chip->step = step;
207      m_sample = sample;
208      m_signal = signal;
209      m_step = step;
159210   }
160211
161212   /* fill the rest with silence */
r21175r21176
164215}
165216
166217
167/**********************************************************************************************
168218
169    es8712_update -- update the sound chip so that it is in sync with CPU execution
219//-------------------------------------------------
220//   state save support for MAME
221//-------------------------------------------------
170222
171***********************************************************************************************/
172
173static STREAM_UPDATE( es8712_update )
223void es8712_device::es8712_state_save_register()
174224{
175   stream_sample_t *buffer = outputs[0];
176   es8712_state *chip = (es8712_state *)param;
225   save_item(NAME(m_bank_offset));
177226
178   /* generate them into our buffer */
179   generate_adpcm(chip, buffer, samples);
180}
227   save_item(NAME(m_playing));
228   save_item(NAME(m_sample));
229   save_item(NAME(m_count));
230   save_item(NAME(m_signal));
231   save_item(NAME(m_step));
181232
233   save_item(NAME(m_base_offset));
182234
183
184/**********************************************************************************************
185
186     state save support for MAME
187
188***********************************************************************************************/
189
190static void es8712_state_save_register(es8712_state *chip, device_t *device)
191{
192   device->save_item(NAME(chip->bank_offset));
193
194   device->save_item(NAME(chip->playing));
195   device->save_item(NAME(chip->sample));
196   device->save_item(NAME(chip->count));
197   device->save_item(NAME(chip->signal));
198   device->save_item(NAME(chip->step));
199
200   device->save_item(NAME(chip->base_offset));
201
202   device->save_item(NAME(chip->start));
203   device->save_item(NAME(chip->end));
204   device->save_item(NAME(chip->repeat));
235   save_item(NAME(m_start));
236   save_item(NAME(m_end));
237   save_item(NAME(m_repeat));
205238}
206239
207240
208241
209/**********************************************************************************************
210242
211    DEVICE_START( es8712 ) -- start emulation of an ES8712 chip
243//-------------------------------------------------
244//   es8712_set_bank_base -- set the base of the bank on a given chip
245//-------------------------------------------------
212246
213***********************************************************************************************/
214
215static DEVICE_START( es8712 )
247void es8712_device::set_bank_base(int base)
216248{
217   es8712_state *chip = get_safe_token(device);
218
219   compute_tables();
220
221   chip->start = 0;
222   chip->end = 0;
223   chip->repeat = 0;
224
225   chip->bank_offset = 0;
226   chip->region_base = *device->region();
227
228   /* generate the name and create the stream */
229   chip->stream = device->machine().sound().stream_alloc(*device, 0, 1, device->clock(), chip, es8712_update);
230
231   /* initialize the rest of the structure */
232   chip->signal = -2;
233
234   es8712_state_save_register(chip, device);
249   m_stream->update();
250   m_bank_offset = base;
235251}
236252
237253
254//-------------------------------------------------
255//  es8712_set_frequency -- dynamically adjusts the frequency of a given ADPCM chip
256//-------------------------------------------------
238257
239/*************************************************************************************
240
241     DEVICE_RESET( es8712 ) -- stop emulation of an ES8712-compatible chip
242
243**************************************************************************************/
244
245static DEVICE_RESET( es8712 )
258void es8712_device::set_frequency(int frequency)
246259{
247   es8712_state *chip = get_safe_token(device);
248
249   if (chip->playing)
250   {
251      /* update the stream, then turn it off */
252      chip->stream->update();
253      chip->playing = 0;
254      chip->repeat = 0;
255   }
256}
257
258
259/****************************************************************************
260
261    es8712_set_bank_base -- set the base of the bank on a given chip
262
263*****************************************************************************/
264
265void es8712_set_bank_base(device_t *device, int base)
266{
267   es8712_state *chip = get_safe_token(device);
268   chip->stream->update();
269   chip->bank_offset = base;
270}
271
272
273/****************************************************************************
274
275    es8712_set_frequency -- dynamically adjusts the frequency of a given ADPCM chip
276
277*****************************************************************************/
278
279void es8712_set_frequency(device_t *device, int frequency)
280{
281   es8712_state *chip = get_safe_token(device);
282
283260   /* update the stream and set the new base */
284   chip->stream->update();
285   chip->stream->set_sample_rate(frequency);
261   m_stream->update();
262   m_stream->set_sample_rate(frequency);
286263}
287264
288265
266//-------------------------------------------------
267//  play -- Begin playing the addressed sample
268//-------------------------------------------------
289269
290/**********************************************************************************************
291
292    es8712_play -- Begin playing the addressed sample
293
294***********************************************************************************************/
295
296void es8712_play(device_t *device)
270void es8712_device::play()
297271{
298   es8712_state *chip = get_safe_token(device);
299
300
301   if (chip->start < chip->end)
272   if (m_start < m_end)
302273   {
303      if (!chip->playing)
274      if (!m_playing)
304275      {
305         chip->playing = 1;
306         chip->base_offset = chip->start;
307         chip->sample = 0;
308         chip->count = 2 * (chip->end - chip->start + 1);
309         chip->repeat = 0;//1;
276         m_playing = 1;
277         m_base_offset = m_start;
278         m_sample = 0;
279         m_count = 2 * (m_end - m_start + 1);
280         m_repeat = 0;//1;
310281
311282         /* also reset the ADPCM parameters */
312         chip->signal = -2;
313         chip->step = 0;
283         m_signal = -2;
284         m_step = 0;
314285      }
315286   }
316287   /* invalid samples go here */
317288   else
318289   {
319      logerror("ES871295:'%s' requested to play invalid sample range %06x-%06x\n",device->tag(),chip->start,chip->end);
290      logerror("ES871295:'%s' requested to play invalid sample range %06x-%06x\n", tag(), m_start, m_end);
320291
321      if (chip->playing)
292      if (m_playing)
322293      {
323294         /* update the stream */
324         chip->stream->update();
325         chip->playing = 0;
295         m_stream->update();
296         m_playing = 0;
326297      }
327298   }
328299}
r21175r21176
353324 *
354325***********************************************************************************************/
355326
356WRITE8_DEVICE_HANDLER( es8712_w )
327WRITE8_MEMBER( es8712_device::es8712_w )
357328{
358   es8712_state *chip = get_safe_token(device);
359329   switch (offset)
360330   {
361      case 00:    chip->start &= 0x000fff00;
362               chip->start |= ((data & 0xff) <<  0); break;
363      case 01:    chip->start &= 0x000f00ff;
364               chip->start |= ((data & 0xff) <<  8); break;
365      case 02:    chip->start &= 0x0000ffff;
366               chip->start |= ((data & 0x0f) << 16); break;
367      case 03:    chip->end   &= 0x000fff00;
368               chip->end   |= ((data & 0xff) <<  0); break;
369      case 04:    chip->end   &= 0x000f00ff;
370               chip->end   |= ((data & 0xff) <<  8); break;
371      case 05:    chip->end   &= 0x0000ffff;
372               chip->end   |= ((data & 0x0f) << 16); break;
331      case 00:    m_start &= 0x000fff00;
332               m_start |= ((data & 0xff) <<  0); break;
333      case 01:    m_start &= 0x000f00ff;
334               m_start |= ((data & 0xff) <<  8); break;
335      case 02:    m_start &= 0x0000ffff;
336               m_start |= ((data & 0x0f) << 16); break;
337      case 03:    m_end   &= 0x000fff00;
338               m_end   |= ((data & 0xff) <<  0); break;
339      case 04:    m_end   &= 0x000f00ff;
340               m_end   |= ((data & 0xff) <<  8); break;
341      case 05:    m_end   &= 0x0000ffff;
342               m_end   |= ((data & 0x0f) << 16); break;
373343      case 06:
374            es8712_play(device);
375            break;
344               play(); break;
376345      default:    break;
377346   }
378   chip->start &= 0xfffff; chip->end &= 0xfffff;
347   m_start &= 0xfffff; m_end &= 0xfffff;
379348}
380
381const device_type ES8712 = &device_creator<es8712_device>;
382
383es8712_device::es8712_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
384   : device_t(mconfig, ES8712, "ES8712", tag, owner, clock),
385      device_sound_interface(mconfig, *this)
386{
387   m_token = global_alloc_clear(es8712_state);
388}
389
390//-------------------------------------------------
391//  device_config_complete - perform any
392//  operations now that the configuration is
393//  complete
394//-------------------------------------------------
395
396void es8712_device::device_config_complete()
397{
398}
399
400//-------------------------------------------------
401//  device_start - device-specific startup
402//-------------------------------------------------
403
404void es8712_device::device_start()
405{
406   DEVICE_START_NAME( es8712 )(this);
407}
408
409//-------------------------------------------------
410//  device_reset - device-specific reset
411//-------------------------------------------------
412
413void es8712_device::device_reset()
414{
415   DEVICE_RESET_NAME( es8712 )(this);
416}
417
418//-------------------------------------------------
419//  sound_stream_update - handle a stream update
420//-------------------------------------------------
421
422void es8712_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
423{
424   // should never get here
425   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
426}
trunk/src/emu/sound/es8712.h
r21175r21176
1/* An interface for the ES8712 ADPCM chip */
2
13#pragma once
24
35#ifndef __ES8712_H__
r21175r21176
35#define __ES8712_H__
46
5#include "devlegcy.h"
7//**************************************************************************
8//  INTERFACE CONFIGURATION MACROS
9//**************************************************************************
610
7/* An interface for the ES8712 ADPCM chip */
11#define MCFG_ES8712_ADD(_tag, _clock) \
12   MCFG_DEVICE_ADD(_tag, ES8712, _clock)
13#define MCFG_ES8712_REPLACE(_tag, _clock) \
14   MCFG_DEVICE_REPLACE(_tag, ES8712, _clock)
815
9void es8712_play(device_t *device);
10void es8712_set_bank_base(device_t *device, int base);
11void es8712_set_frequency(device_t *device, int frequency);
1216
13DECLARE_WRITE8_DEVICE_HANDLER( es8712_w );
17//**************************************************************************
18//  TYPE DEFINITIONS
19//**************************************************************************
1420
21
22// ======================> es8712_device
23
1524class es8712_device : public device_t,
16                           public device_sound_interface
25                 public device_sound_interface
1726{
1827public:
1928   es8712_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
20   ~es8712_device() { global_free(m_token); }
29   ~es8712_device() { }
2130
22   // access to legacy token
23   void *token() const { assert(m_token != NULL); return m_token; }
2431protected:
2532   // device-level overrides
26   virtual void device_config_complete();
2733   virtual void device_start();
2834   virtual void device_reset();
2935
3036   // sound stream update overrides
3137   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
38
39public:
40    DECLARE_WRITE8_MEMBER( es8712_w );
41
42public:
43    void play();
44    void set_bank_base(int base);
45    void set_frequency(int frequency);
46
3247private:
33   // internal state
34   void *m_token;
48    void compute_tables();
49    void generate_adpcm(stream_sample_t *buffer, int samples);
50    void es8712_state_save_register();
51
52private:
53   UINT8 m_playing;          /* 1 if we're actively playing */
54
55   UINT32 m_base_offset;     /* pointer to the base memory location */
56   UINT32 m_sample;          /* current sample number */
57   UINT32 m_count;           /* total samples to play */
58
59   UINT32 m_signal;          /* current ADPCM signal */
60   UINT32 m_step;            /* current ADPCM step */
61
62   UINT32 m_start;           /* starting address for the next loop */
63   UINT32 m_end;             /* ending address for the next loop */
64   UINT8  m_repeat;          /* Repeat current sample when 1 */
65
66   INT32 m_bank_offset;
67   UINT8 *m_region_base;     /* pointer to the base of the region */
68   sound_stream *m_stream;   /* which stream are we playing on? */
3569};
3670
trunk/src/emu/sound/k051649.c
r21175r21176
2929#define DEF_GAIN    8
3030
3131
32/* this structure defines the parameters for a channel */
33struct k051649_sound_channel
34{
35   unsigned long counter;
36   int frequency;
37   int volume;
38   int key;
39   signed char waveram[32];
40};
32// device type definition
33const device_type K051649 = &device_creator<k051649_device>;
4134
42struct k051649_state
43{
44   k051649_sound_channel channel_list[5];
4535
46   /* global sound parameters */
47   sound_stream * stream;
48   int mclock,rate;
36//**************************************************************************
37//  LIVE DEVICE
38//**************************************************************************
4939
50   /* mixer tables and internal buffers */
51   INT16 *mixer_table;
52   INT16 *mixer_lookup;
53   short *mixer_buffer;
40//-------------------------------------------------
41//  k051649_device - constructor
42//-------------------------------------------------
5443
55   /* chip registers */
56   UINT8 test;
57};
58
59INLINE k051649_state *get_safe_token(device_t *device)
44k051649_device::k051649_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
45   : device_t(mconfig, K051649, "K051649", tag, owner, clock),
46     device_sound_interface(mconfig, *this),
47     m_stream(NULL),
48     m_mclock(0),
49      m_rate(0),
50     m_mixer_table(NULL),
51     m_mixer_lookup(NULL),
52     m_mixer_buffer(NULL),
53     m_test(0)
6054{
61   assert(device != NULL);
62   assert(device->type() == K051649);
63   return (k051649_state *)downcast<k051649_device *>(device)->token();
6455}
6556
66/* build a table to divide by the number of voices */
67static void make_mixer_table(running_machine &machine, k051649_state *info, int voices)
57
58//-------------------------------------------------
59//  device_start - device-specific startup
60//-------------------------------------------------
61
62void k051649_device::device_start()
6863{
69   int i;
64   // get stream channels
65   m_rate = clock()/16;
66   m_stream = stream_alloc(0, 1, m_rate);
67   m_mclock = clock();
7068
71   /* allocate memory */
72   info->mixer_table = auto_alloc_array(machine, INT16, 512 * voices);
69   // allocate a buffer to mix into - 1 second's worth should be more than enough
70   m_mixer_buffer = auto_alloc_array(machine(), short, 2 * m_rate);
7371
74   /* find the middle of the table */
75   info->mixer_lookup = info->mixer_table + (256 * voices);
72   // build the mixer table
73   make_mixer_table(5);
74}
7675
77   /* fill in the table - 16 bit case */
78   for (i = 0; i < (voices * 256); i++)
79   {
80      int val = i * DEF_GAIN * 16 / voices;
81      if (val > 32767) val = 32767;
82      info->mixer_lookup[ i] = val;
83      info->mixer_lookup[-i] = -val;
76
77//-------------------------------------------------
78//  device_reset - device-specific reset
79//-------------------------------------------------
80
81void k051649_device::device_reset()
82{
83   k051649_sound_channel *voice = m_channel_list;
84   int i;
85
86   // reset all the voices
87   for (i = 0; i < 5; i++)
88    {
89      voice[i].frequency = 0;
90      voice[i].volume = 0xf;
91      voice[i].counter = 0;
92      voice[i].key = 0;
8493   }
94
95   // other parameters
96   m_test = 0;
8597}
8698
8799
88/* generate sound to the mix buffer */
89static STREAM_UPDATE( k051649_update )
100//-------------------------------------------------
101//  sound_stream_update - handle a stream update
102//-------------------------------------------------
103
104void k051649_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
90105{
91   k051649_state *info = (k051649_state *)param;
92   k051649_sound_channel *voice=info->channel_list;
106   k051649_sound_channel *voice=m_channel_list;
93107   stream_sample_t *buffer = outputs[0];
94108   short *mix;
95109   int i,j;
96110
97   /* zap the contents of the mixer buffer */
98   memset(info->mixer_buffer, 0, samples * sizeof(short));
111   // zap the contents of the mixer buffer
112   memset(m_mixer_buffer, 0, samples * sizeof(short));
99113
100   for (j = 0; j < 5; j++) {
101      /* channel is halted for freq < 9 */
114   for (j = 0; j < 5; j++)
115    {
116      // channel is halted for freq < 9
102117      if (voice[j].frequency > 8)
103118      {
104119         const signed char *w = voice[j].waveram;
105120         int v=voice[j].volume * voice[j].key;
106121         int c=voice[j].counter;
107         int step = ((INT64)info->mclock * (1 << FREQ_BITS)) / (float)((voice[j].frequency + 1) * 16 * (info->rate / 32)) + 0.5;
122         int step = ((INT64)m_mclock * (1 << FREQ_BITS)) / (float)((voice[j].frequency + 1) * 16 * (m_rate / 32)) + 0.5;
108123
109         mix = info->mixer_buffer;
124         mix = m_mixer_buffer;
110125
111         /* add our contribution */
126         // add our contribution
112127         for (i = 0; i < samples; i++)
113128         {
114129            int offs;
r21175r21176
118133            *mix++ += (w[offs] * v)>>3;
119134         }
120135
121         /* update the counter for this voice */
136         // update the counter for this voice
122137         voice[j].counter = c;
123138      }
124139   }
125140
126   /* mix it down */
127   mix = info->mixer_buffer;
141   // mix it down
142   mix = m_mixer_buffer;
128143   for (i = 0; i < samples; i++)
129      *buffer++ = info->mixer_lookup[*mix++];
144      *buffer++ = m_mixer_lookup[*mix++];
130145}
131146
132static DEVICE_START( k051649 )
133{
134   k051649_state *info = get_safe_token(device);
135147
136   /* get stream channels */
137   info->rate = device->clock()/16;
138   info->stream = device->machine().sound().stream_alloc(*device, 0, 1, info->rate, info, k051649_update);
139   info->mclock = device->clock();
140
141   /* allocate a buffer to mix into - 1 second's worth should be more than enough */
142   info->mixer_buffer = auto_alloc_array(device->machine(), short, 2 * info->rate);
143
144   /* build the mixer table */
145   make_mixer_table(device->machine(), info, 5);
146}
147
148static DEVICE_RESET( k051649 )
149{
150   k051649_state *info = get_safe_token(device);
151   k051649_sound_channel *voice = info->channel_list;
152   int i;
153
154   /* reset all the voices */
155   for (i = 0; i < 5; i++) {
156      voice[i].frequency = 0;
157      voice[i].volume = 0xf;
158      voice[i].counter = 0;
159      voice[i].key = 0;
160   }
161
162   /* other parameters */
163   info->test = 0;
164}
165
166148/********************************************************************************/
167149
168WRITE8_DEVICE_HANDLER( k051649_waveform_w )
169{
170   k051649_state *info = get_safe_token(device);
171150
172   /* waveram is read-only? */
173   if (info->test & 0x40 || (info->test & 0x80 && offset >= 0x60))
151WRITE8_MEMBER( k051649_device::k051649_waveform_w )
152{
153   // waveram is read-only?
154   if (m_test & 0x40 || (m_test & 0x80 && offset >= 0x60))
174155      return;
175156
176   info->stream->update();
157   m_stream->update();
177158
178159   if (offset >= 0x60)
179160   {
180      /* channel 5 shares waveram with channel 4 */
181      info->channel_list[3].waveram[offset&0x1f]=data;
182      info->channel_list[4].waveram[offset&0x1f]=data;
161      // channel 5 shares waveram with channel 4
162      m_channel_list[3].waveram[offset&0x1f]=data;
163      m_channel_list[4].waveram[offset&0x1f]=data;
183164   }
184165   else
185      info->channel_list[offset>>5].waveram[offset&0x1f]=data;
166      m_channel_list[offset>>5].waveram[offset&0x1f]=data;
186167}
187168
188READ8_DEVICE_HANDLER ( k051649_waveform_r )
189{
190   k051649_state *info = get_safe_token(device);
191169
192   /* test-register bits 6/7 expose the internal counter */
193   if (info->test & 0xc0)
170READ8_MEMBER ( k051649_device::k051649_waveform_r )
171{
172   // test-register bits 6/7 expose the internal counter
173   if (m_test & 0xc0)
194174   {
195      info->stream->update();
175      m_stream->update();
196176
197177      if (offset >= 0x60)
198         offset += (info->channel_list[3 + (info->test >> 6 & 1)].counter >> FREQ_BITS);
199      else if (info->test & 0x40)
200         offset += (info->channel_list[offset>>5].counter >> FREQ_BITS);
178         offset += (m_channel_list[3 + (m_test >> 6 & 1)].counter >> FREQ_BITS);
179      else if (m_test & 0x40)
180         offset += (m_channel_list[offset>>5].counter >> FREQ_BITS);
201181   }
202   return info->channel_list[offset>>5].waveram[offset&0x1f];
182   return m_channel_list[offset>>5].waveram[offset&0x1f];
203183}
204184
205WRITE8_DEVICE_HANDLER( k052539_waveform_w )
206{
207   k051649_state *info = get_safe_token(device);
208185
209   /* waveram is read-only? */
210   if (info->test & 0x40)
186WRITE8_MEMBER( k051649_device::k052539_waveform_w )
187{
188   // waveram is read-only?
189   if (m_test & 0x40)
211190      return;
212191
213   info->stream->update();
214   info->channel_list[offset>>5].waveram[offset&0x1f]=data;
192   m_stream->update();
193   m_channel_list[offset>>5].waveram[offset&0x1f]=data;
215194}
216195
217READ8_DEVICE_HANDLER ( k052539_waveform_r )
218{
219   k051649_state *info = get_safe_token(device);
220196
221   /* test-register bit 6 exposes the internal counter */
222   if (info->test & 0x40)
197READ8_MEMBER ( k051649_device::k052539_waveform_r )
198{
199   // test-register bit 6 exposes the internal counter
200   if (m_test & 0x40)
223201   {
224      info->stream->update();
225      offset += (info->channel_list[offset>>5].counter >> FREQ_BITS);
202      m_stream->update();
203      offset += (m_channel_list[offset>>5].counter >> FREQ_BITS);
226204   }
227   return info->channel_list[offset>>5].waveram[offset&0x1f];
205   return m_channel_list[offset>>5].waveram[offset&0x1f];
228206}
229207
230WRITE8_DEVICE_HANDLER( k051649_volume_w )
208
209WRITE8_MEMBER( k051649_device::k051649_volume_w )
231210{
232   k051649_state *info = get_safe_token(device);
233   info->stream->update();
234   info->channel_list[offset&0x7].volume=data&0xf;
211   m_stream->update();
212   m_channel_list[offset&0x7].volume=data&0xf;
235213}
236214
237WRITE8_DEVICE_HANDLER( k051649_frequency_w )
215
216WRITE8_MEMBER( k051649_device::k051649_frequency_w )
238217{
239   k051649_state *info = get_safe_token(device);
240218   int freq_hi = offset & 1;
241219   offset >>= 1;
242220
243   info->stream->update();
221   m_stream->update();
244222
245   /* test-register bit 5 resets the internal counter */
246   if (info->test & 0x20)
247      info->channel_list[offset].counter = ~0;
248   else if (info->channel_list[offset].frequency < 9)
249      info->channel_list[offset].counter |= ((1 << FREQ_BITS) - 1);
223   // test-register bit 5 resets the internal counter
224   if (m_test & 0x20)
225      m_channel_list[offset].counter = ~0;
226   else if (m_channel_list[offset].frequency < 9)
227      m_channel_list[offset].counter |= ((1 << FREQ_BITS) - 1);
250228
251   /* update frequency */
229   // update frequency
252230   if (freq_hi)
253      info->channel_list[offset].frequency = (info->channel_list[offset].frequency & 0x0ff) | (data << 8 & 0xf00);
231      m_channel_list[offset].frequency = (m_channel_list[offset].frequency & 0x0ff) | (data << 8 & 0xf00);
254232   else
255      info->channel_list[offset].frequency = (info->channel_list[offset].frequency & 0xf00) | data;
233      m_channel_list[offset].frequency = (m_channel_list[offset].frequency & 0xf00) | data;
256234}
257235
258WRITE8_DEVICE_HANDLER( k051649_keyonoff_w )
236
237WRITE8_MEMBER( k051649_device::k051649_keyonoff_w )
259238{
260239   int i;
261   k051649_state *info = get_safe_token(device);
262   info->stream->update();
240   m_stream->update();
263241
264   for (i = 0; i < 5; i++) {
265      info->channel_list[i].key=data&1;
242   for (i = 0; i < 5; i++)
243    {
244      m_channel_list[i].key=data&1;
266245      data >>= 1;
267246   }
268247}
269248
270WRITE8_DEVICE_HANDLER( k051649_test_w )
271{
272   k051649_state *info = get_safe_token(device);
273   info->test = data;
274}
275249
276READ8_DEVICE_HANDLER ( k051649_test_r )
250WRITE8_MEMBER( k051649_device::k051649_test_w )
277251{
278   /* reading the test register sets it to $ff! */
279   k051649_test_w(device, space, offset, 0xff);
280   return 0xff;
252   m_test = data;
281253}
282254
283const device_type K051649 = &device_creator<k051649_device>;
284255
285k051649_device::k051649_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
286   : device_t(mconfig, K051649, "K051649", tag, owner, clock),
287      device_sound_interface(mconfig, *this)
256READ8_MEMBER ( k051649_device::k051649_test_r )
288257{
289   m_token = global_alloc_clear(k051649_state);
258   // reading the test register sets it to $ff!
259   k051649_test_w(space, offset, 0xff);
260   return 0xff;
290261}
291262
292//-------------------------------------------------
293//  device_config_complete - perform any
294//  operations now that the configuration is
295//  complete
296//-------------------------------------------------
297263
298void k051649_device::device_config_complete()
299{
300}
301
302264//-------------------------------------------------
303// device_start - device-specific startup
265// build a table to divide by the number of voices
304266//-------------------------------------------------
305267
306void k051649_device::device_start()
268void k051649_device::make_mixer_table(int voices)
307269{
308   DEVICE_START_NAME( k051649 )(this);
309}
270   int i;
310271
311//-------------------------------------------------
312//  device_reset - device-specific reset
313//-------------------------------------------------
272   // allocate memory
273   m_mixer_table = auto_alloc_array(machine(), INT16, 512 * voices);
314274
315void k051649_device::device_reset()
316{
317   DEVICE_RESET_NAME( k051649 )(this);
275   // find the middle of the table
276   m_mixer_lookup = m_mixer_table + (256 * voices);
277
278   // fill in the table - 16 bit case
279   for (i = 0; i < (voices * 256); i++)
280   {
281      int val = i * DEF_GAIN * 16 / voices;
282      if (val > 32767) val = 32767;
283      m_mixer_lookup[ i] = val;
284      m_mixer_lookup[-i] = -val;
285   }
318286}
319287
320//-------------------------------------------------
321//  sound_stream_update - handle a stream update
322//-------------------------------------------------
323288
324void k051649_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
325{
326   // should never get here
327   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
328}
trunk/src/emu/sound/k051649.h
r21175r21176
55
66#include "devlegcy.h"
77
8DECLARE_WRITE8_DEVICE_HANDLER( k051649_waveform_w );
9DECLARE_READ8_DEVICE_HANDLER ( k051649_waveform_r );
10DECLARE_WRITE8_DEVICE_HANDLER( k051649_volume_w );
11DECLARE_WRITE8_DEVICE_HANDLER( k051649_frequency_w );
12DECLARE_WRITE8_DEVICE_HANDLER( k051649_keyonoff_w );
13DECLARE_WRITE8_DEVICE_HANDLER( k051649_test_w );
14DECLARE_READ8_DEVICE_HANDLER ( k051649_test_r );
158
16DECLARE_WRITE8_DEVICE_HANDLER( k052539_waveform_w );
17DECLARE_READ8_DEVICE_HANDLER ( k052539_waveform_r );
9//**************************************************************************
10//  INTERFACE CONFIGURATION MACROS
11//**************************************************************************
1812
13#define MCFG_K051649_ADD(_tag, _clock) \
14   MCFG_DEVICE_ADD(_tag, K051649, _clock)
15#define MCFG_K051649_REPLACE(_tag, _clock) \
16   MCFG_DEVICE_REPLACE(_tag, K051649, _clock)
17
18
19//**************************************************************************
20//  TYPE DEFINITIONS
21//**************************************************************************
22
23// Parameters for a channel
24struct k051649_sound_channel
25{
26    k051649_sound_channel() :
27        counter(0),
28        frequency(0),
29        volume(0),
30        key(0)
31    {
32        memset(waveram, 0, sizeof(signed char)*32);
33    }
34   
35   unsigned long counter;
36   int frequency;
37   int volume;
38   int key;
39   signed char waveram[32];
40};
41
42
43// ======================> k051649_device
44
1945class k051649_device : public device_t,
20                           public device_sound_interface
46                  public device_sound_interface
2147{
2248public:
2349   k051649_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
24   ~k051649_device() { global_free(m_token); }
50   ~k051649_device() { }
2551
26   // access to legacy token
27   void *token() const { assert(m_token != NULL); return m_token; }
2852protected:
2953   // device-level overrides
30   virtual void device_config_complete();
3154   virtual void device_start();
3255   virtual void device_reset();
3356
3457   // sound stream update overrides
3558   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
59
60public:
61    DECLARE_WRITE8_MEMBER( k051649_waveform_w );
62    DECLARE_READ8_MEMBER ( k051649_waveform_r );
63    DECLARE_WRITE8_MEMBER( k051649_volume_w );
64    DECLARE_WRITE8_MEMBER( k051649_frequency_w );
65    DECLARE_WRITE8_MEMBER( k051649_keyonoff_w );
66    DECLARE_WRITE8_MEMBER( k051649_test_w );
67    DECLARE_READ8_MEMBER ( k051649_test_r );
68
69    DECLARE_WRITE8_MEMBER( k052539_waveform_w );
70    DECLARE_READ8_MEMBER ( k052539_waveform_r );
71
3672private:
37   // internal state
38   void *m_token;
73    void make_mixer_table(int voices);
74
75private:
76   k051649_sound_channel m_channel_list[5];
77
78   /* global sound parameters */
79   sound_stream *m_stream;
80   int m_mclock;
81    int m_rate;
82
83   /* mixer tables and internal buffers */
84   INT16 *m_mixer_table;
85   INT16 *m_mixer_lookup;
86   short *m_mixer_buffer;
87
88   /* chip registers */
89   UINT8 m_test;
3990};
4091
4192extern const device_type K051649;
trunk/src/emu/sound/tms3615.c
r21175r21176
44#define VMIN    0x0000
55#define VMAX    0x7fff
66
7#define TONES 13
7static const int divisor[TMS3615_TONES] = { 478, 451, 426, 402, 379, 358, 338, 319, 301, 284, 268, 253, 239 };
88
9static const int divisor[TONES] = { 478, 451, 426, 402, 379, 358, 338, 319, 301, 284, 268, 253, 239 };
109
11struct tms_state {
12   sound_stream *channel;  /* returned by stream_create() */
13   int samplerate;         /* output sample rate */
14   int basefreq;           /* chip's base frequency */
15   int counter8[TONES];    /* tone frequency counter for 8' */
16   int counter16[TONES];   /* tone frequency counter for 16'*/
17   int output8;            /* output signal bits for 8' */
18   int output16;           /* output signal bits for 16' */
19   int enable;             /* mask which tones to play */
20};
10// device type definition
11const device_type TMS3615 = &device_creator<tms3615_device>;
2112
22INLINE tms_state *get_safe_token(device_t *device)
13
14//**************************************************************************
15//  LIVE DEVICE
16//**************************************************************************
17
18//-------------------------------------------------
19//  qsound_device - constructor
20//-------------------------------------------------
21
22tms3615_device::tms3615_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
23   : device_t(mconfig, TMS3615, "TMS3615", tag, owner, clock),
24     device_sound_interface(mconfig, *this),
25     m_channel(0),
26     m_samplerate(0),
27     m_basefreq(0),
28     m_output8(0),
29     m_output16(0),
30     m_enable(0)
2331{
24   assert(device != NULL);
25   assert(device->type() == TMS3615);
26   return (tms_state *)downcast<tms3615_device *>(device)->token();
32    memset(m_counter8, 0, TMS3615_TONES);
33    memset(m_counter16, 0, TMS3615_TONES);
2734}
2835
2936
30static STREAM_UPDATE( tms3615_sound_update )
37//-------------------------------------------------
38//  device_start - device-specific startup
39//-------------------------------------------------
40
41void tms3615_device::device_start()
3142{
32   tms_state *tms = (tms_state *)param;
33   int samplerate = tms->samplerate;
43   m_channel = stream_alloc(0, 2, clock()/8);
44   m_samplerate = clock()/8;
45   m_basefreq = clock();
46}
47
48
49//-------------------------------------------------
50//  sound_stream_update - handle a stream update
51//-------------------------------------------------
52
53void tms3615_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
54{
55   int samplerate = m_samplerate;
3456   stream_sample_t *buffer8 = outputs[TMS3615_FOOTAGE_8];
3557   stream_sample_t *buffer16 = outputs[TMS3615_FOOTAGE_16];
3658
r21175r21176
3860   {
3961      int sum8 = 0, sum16 = 0, tone = 0;
4062
41      for (tone = 0; tone < TONES; tone++)
63      for (tone = 0; tone < TMS3615_TONES; tone++)
4264      {
4365         // 8'
4466
45         tms->counter8[tone] -= (tms->basefreq / divisor[tone]);
67         m_counter8[tone] -= (m_basefreq / divisor[tone]);
4668
47         while( tms->counter8[tone] <= 0 )
69         while( m_counter8[tone] <= 0 )
4870         {
49            tms->counter8[tone] += samplerate;
50            tms->output8 ^= 1 << tone;
71            m_counter8[tone] += samplerate;
72            m_output8 ^= 1 << tone;
5173         }
5274
53         if (tms->output8 & tms->enable & (1 << tone))
75         if (m_output8 & m_enable & (1 << tone))
5476         {
5577            sum8 += VMAX;
5678         }
5779
5880         // 16'
5981
60         tms->counter16[tone] -= (tms->basefreq / divisor[tone] / 2);
82         m_counter16[tone] -= (m_basefreq / divisor[tone] / 2);
6183
62         while( tms->counter16[tone] <= 0 )
84         while( m_counter16[tone] <= 0 )
6385         {
64            tms->counter16[tone] += samplerate;
65            tms->output16 ^= 1 << tone;
86            m_counter16[tone] += samplerate;
87            m_output16 ^= 1 << tone;
6688         }
6789
68         if (tms->output16 & tms->enable & (1 << tone))
90         if (m_output16 & m_enable & (1 << tone))
6991         {
7092            sum16 += VMAX;
7193         }
7294      }
7395
74      *buffer8++ = sum8 / TONES;
75      *buffer16++ = sum16 / TONES;
96      *buffer8++ = sum8 / TMS3615_TONES;
97      *buffer16++ = sum16 / TMS3615_TONES;
7698   }
7799
78   tms->enable = 0;
100   m_enable = 0;
79101}
80102
81void tms3615_enable_w(device_t *device, int enable)
82{
83   tms_state *tms = get_safe_token(device);
84   tms->enable = enable;
85}
86103
87static DEVICE_START( tms3615 )
104void tms3615_device::enable_w(int enable)
88105{
89   tms_state *tms = get_safe_token(device);
90
91   tms->channel = device->machine().sound().stream_alloc(*device, 0, 2, device->clock()/8, tms, tms3615_sound_update);
92   tms->samplerate = device->clock()/8;
93   tms->basefreq = device->clock();
106   m_enable = enable;
94107}
95108
96const device_type TMS3615 = &device_creator<tms3615_device>;
97109
98tms3615_device::tms3615_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
99   : device_t(mconfig, TMS3615, "TMS3615", tag, owner, clock),
100      device_sound_interface(mconfig, *this)
101{
102   m_token = global_alloc_clear(tms_state);
103}
104
105//-------------------------------------------------
106//  device_config_complete - perform any
107//  operations now that the configuration is
108//  complete
109//-------------------------------------------------
110
111void tms3615_device::device_config_complete()
112{
113}
114
115//-------------------------------------------------
116//  device_start - device-specific startup
117//-------------------------------------------------
118
119void tms3615_device::device_start()
120{
121   DEVICE_START_NAME( tms3615 )(this);
122}
123
124//-------------------------------------------------
125//  sound_stream_update - handle a stream update
126//-------------------------------------------------
127
128void tms3615_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
129{
130   // should never get here
131   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
132}
trunk/src/emu/sound/tms3615.h
r21175r21176
33#ifndef __TMS3615_H__
44#define __TMS3615_H__
55
6#include "devlegcy.h"
7
8extern void tms3615_enable_w(device_t *device, int enable);
9
6#define TMS3615_TONES 13
107#define TMS3615_FOOTAGE_8   0
118#define TMS3615_FOOTAGE_16  1
129
10
11//**************************************************************************
12//  INTERFACE CONFIGURATION MACROS
13//**************************************************************************
14
15#define MCFG_TMS3615_ADD(_tag, _clock) \
16   MCFG_DEVICE_ADD(_tag, TMS3615, _clock)
17#define MCFG_TMS3615_REPLACE(_tag, _clock) \
18   MCFG_DEVICE_REPLACE(_tag, TMS3615, _clock)
19
20
21//**************************************************************************
22//  TYPE DEFINITIONS
23//**************************************************************************
24
25
26// ======================> tms3615_device
27
1328class tms3615_device : public device_t,
14                           public device_sound_interface
29                  public device_sound_interface
1530{
1631public:
1732   tms3615_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
18   ~tms3615_device() { global_free(m_token); }
33   ~tms3615_device() { }
1934
20   // access to legacy token
21   void *token() const { assert(m_token != NULL); return m_token; }
2235protected:
2336   // device-level overrides
24   virtual void device_config_complete();
2537   virtual void device_start();
2638
2739   // sound stream update overrides
2840   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
41
42public:
43    void enable_w(int enable);
44
2945private:
30   // internal state
31   void *m_token;
46   sound_stream *m_channel;        /* returned by stream_create() */
47   int m_samplerate;               /* output sample rate */
48   int m_basefreq;                 /* chip's base frequency */
49   int m_counter8[TMS3615_TONES];  /* tone frequency counter for 8' */
50   int m_counter16[TMS3615_TONES]; /* tone frequency counter for 16'*/
51   int m_output8;                  /* output signal bits for 8' */
52   int m_output16;                 /* output signal bits for 16' */
53   int m_enable;                   /* mask which tones to play */
3254};
3355
3456extern const device_type TMS3615;
trunk/src/emu/sound/rf5c400.c
r21175r21176
1818#include "emu.h"
1919#include "rf5c400.h"
2020
21struct rf5c400_channel
22{
23   UINT16  startH;
24   UINT16  startL;
25   UINT16  freq;
26   UINT16  endL;
27   UINT16  endHloopH;
28   UINT16  loopL;
29   UINT16  pan;
30   UINT16  effect;
31   UINT16  volume;
32
33   UINT16  attack;
34   UINT16  decay;
35   UINT16  release;
36
37   UINT16  cutoff;
38
39   UINT64 pos;
40   UINT64 step;
41   UINT16 keyon;
42
43   UINT8 env_phase;
44   double env_level;
45   double env_step;
46   double env_scale;
47};
48
49struct rf5c400_state
50{
51   INT16 *rom;
52   UINT32 rom_length;
53
54   sound_stream *stream;
55
56   double env_ar_table[0x9f];
57   double env_dr_table[0x9f];
58   double env_rr_table[0x9f];
59
60   rf5c400_channel channels[32];
61};
62
6321static int volume_table[256];
6422static double pan_table[0x64];
6523
r21175r21176
7533#define ENV_MAX_RR          0x54
7634
7735/* PCM type */
78enum {
36enum
37{
7938   TYPE_MASK       = 0x00C0,
8039   TYPE_16         = 0x0000,
8140   TYPE_8LOW       = 0x0040,
r21175r21176
8342};
8443
8544/* envelope phase */
86enum {
45enum
46{
8747   PHASE_NONE      = 0,
8848   PHASE_ATTACK,
8949   PHASE_DECAY,
r21175r21176
9151};
9252
9353
94INLINE rf5c400_state *get_safe_token(device_t *device)
54// device type definition
55const device_type RF5C400 = &device_creator<rf5c400_device>;
56
57
58//**************************************************************************
59//  LIVE DEVICE
60//**************************************************************************
61
62//-------------------------------------------------
63//  rf5c400_device - constructor
64//-------------------------------------------------
65
66rf5c400_device::rf5c400_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
67   : device_t(mconfig, RF5C400, "RF5C400", tag, owner, clock),
68     device_sound_interface(mconfig, *this),
69     m_rom(NULL),
70     m_rom_length(0),
71     m_stream(NULL)
9572{
96   assert(device != NULL);
97   assert(device->type() == RF5C400);
98   return (rf5c400_state *)downcast<rf5c400_device *>(device)->token();
73   memset(m_env_ar_table, 0, sizeof(double)*0x9f);
74   memset(m_env_dr_table, 0, sizeof(double)*0x9f);
75   memset(m_env_rr_table, 0, sizeof(double)*0x9f);
9976}
10077
10178
102/*****************************************************************************/
10379
104static UINT8 decode80(UINT8 val)
105{
106   if (val & 0x80)
107   {
108      val = (val & 0x7f) + 0x1f;
109   }
80//-------------------------------------------------
81//  device_start - device-specific startup
82//-------------------------------------------------
11083
111   return val;
84void rf5c400_device::device_start()
85{
86   rf5c400_init_chip();
11287}
11388
114static STREAM_UPDATE( rf5c400_update )
89//-------------------------------------------------
90//  sound_stream_update - handle a stream update
91//-------------------------------------------------
92
93void rf5c400_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
11594{
11695   int i, ch;
117   rf5c400_state *info = (rf5c400_state *)param;
118   INT16 *rom = info->rom;
96   INT16 *rom = m_rom;
11997   UINT32 end, loop;
12098   UINT64 pos;
12199   UINT8 vol, lvol, rvol, type;
r21175r21176
127105
128106   for (ch=0; ch < 32; ch++)
129107   {
130      rf5c400_channel *channel = &info->channels[ch];
108      rf5c400_channel *channel = &m_channels[ch];
131109      stream_sample_t *buf0 = outputs[0];
132110      stream_sample_t *buf1 = outputs[1];
133111
r21175r21176
189167               else
190168               {
191169                  env_step =
192                     info->env_dr_table[decode80(channel->decay >> 8)];
170                     m_env_dr_table[decode80(channel->decay >> 8)];
193171               }
194172               env_rstep = env_step * channel->env_scale;
195173            }
r21175r21176
220198         *buf1++ += sample * pan_table[rvol];
221199
222200         pos += channel->step;
223         if ( (pos>>16) > info->rom_length || (pos>>16) > end)
201         if ( (pos>>16) > m_rom_length || (pos>>16) > end)
224202         {
225203            pos -= loop<<16;
226204            pos &= U64(0xFFFFFF0000);
r21175r21176
235213   }
236214}
237215
238static void rf5c400_init_chip(device_t *device, rf5c400_state *info)
216
217/*****************************************************************************/
218
219UINT8 rf5c400_device::decode80(UINT8 val)
239220{
221   if (val & 0x80)
222   {
223      val = (val & 0x7f) + 0x1f;
224   }
225
226   return val;
227}
228
229void rf5c400_device::rf5c400_init_chip()
230{
240231   int i;
241232
242   info->rom = *device->region();
243   info->rom_length = device->region()->bytes() / 2;
233   m_rom = *region();
234   m_rom_length = region()->bytes() / 2;
244235
245236   // init volume table
246237   {
r21175r21176
262253      double r;
263254
264255      // attack
265      r = 1.0 / (ENV_AR_SPEED * (device->clock() / 384));
256      r = 1.0 / (ENV_AR_SPEED * (clock() / 384));
266257      for (i = 0; i < ENV_MIN_AR; i++)
267258      {
268         info->env_ar_table[i] = 1.0;
259         m_env_ar_table[i] = 1.0;
269260      }
270261      for (i = ENV_MIN_AR; i < ENV_MAX_AR; i++)
271262      {
272         info->env_ar_table[i] =
263         m_env_ar_table[i] =
273264            r * (ENV_MAX_AR - i) / (ENV_MAX_AR - ENV_MIN_AR);
274265      }
275266      for (i = ENV_MAX_AR; i < 0x9f; i++)
276267      {
277         info->env_ar_table[i] = 0.0;
268         m_env_ar_table[i] = 0.0;
278269      }
279270
280271      // decay
281      r = -5.0 / (ENV_DR_SPEED * (device->clock() / 384));
272      r = -5.0 / (ENV_DR_SPEED * (clock() / 384));
282273      for (i = 0; i < ENV_MIN_DR; i++)
283274      {
284         info->env_dr_table[i] = r;
275         m_env_dr_table[i] = r;
285276      }
286277      for (i = ENV_MIN_DR; i < ENV_MAX_DR; i++)
287278      {
288         info->env_dr_table[i] =
279         m_env_dr_table[i] =
289280            r * (ENV_MAX_DR - i) / (ENV_MAX_DR - ENV_MIN_DR);
290281      }
291282      for (i = ENV_MAX_DR; i < 0x9f; i++)
292283      {
293         info->env_dr_table[i] = 0.0;
284         m_env_dr_table[i] = 0.0;
294285      }
295286
296287      // release
297      r = -5.0 / (ENV_RR_SPEED * (device->clock() / 384));
288      r = -5.0 / (ENV_RR_SPEED * (clock() / 384));
298289      for (i = 0; i < ENV_MIN_RR; i++)
299290      {
300         info->env_rr_table[i] = r;
291         m_env_rr_table[i] = r;
301292      }
302293      for (i = ENV_MIN_RR; i < ENV_MAX_RR; i++)
303294      {
304         info->env_rr_table[i] =
295         m_env_rr_table[i] =
305296            r * (ENV_MAX_RR - i) / (ENV_MAX_RR - ENV_MIN_RR);
306297      }
307298      for (i = ENV_MAX_RR; i < 0x9f; i++)
308299      {
309         info->env_rr_table[i] = 0.0;
300         m_env_rr_table[i] = 0.0;
310301      }
311302   }
312303
313304   // init channel info
314305   for (i = 0; i < 32; i++)
315306   {
316      info->channels[i].env_phase = PHASE_NONE;
317      info->channels[i].env_level = 0.0;
318      info->channels[i].env_step  = 0.0;
319      info->channels[i].env_scale  = 1.0;
307      m_channels[i].env_phase = PHASE_NONE;
308      m_channels[i].env_level = 0.0;
309      m_channels[i].env_step  = 0.0;
310      m_channels[i].env_scale  = 1.0;
320311   }
321312
322   for (i = 0; i < ARRAY_LENGTH(info->channels); i++)
313   for (i = 0; i < ARRAY_LENGTH(m_channels); i++)
323314   {
324      device->save_item(NAME(info->channels[i].startH), i);
325      device->save_item(NAME(info->channels[i].startL), i);
326      device->save_item(NAME(info->channels[i].freq), i);
327      device->save_item(NAME(info->channels[i].endL), i);
328      device->save_item(NAME(info->channels[i].endHloopH), i);
329      device->save_item(NAME(info->channels[i].loopL), i);
330      device->save_item(NAME(info->channels[i].pan), i);
331      device->save_item(NAME(info->channels[i].effect), i);
332      device->save_item(NAME(info->channels[i].volume), i);
333      device->save_item(NAME(info->channels[i].attack), i);
334      device->save_item(NAME(info->channels[i].decay), i);
335      device->save_item(NAME(info->channels[i].release), i);
336      device->save_item(NAME(info->channels[i].cutoff), i);
337      device->save_item(NAME(info->channels[i].pos), i);
338      device->save_item(NAME(info->channels[i].step), i);
339      device->save_item(NAME(info->channels[i].keyon), i);
340      device->save_item(NAME(info->channels[i].env_phase), i);
341      device->save_item(NAME(info->channels[i].env_level), i);
342      device->save_item(NAME(info->channels[i].env_step), i);
343      device->save_item(NAME(info->channels[i].env_scale), i);
315      save_item(NAME(m_channels[i].startH), i);
316      save_item(NAME(m_channels[i].startL), i);
317      save_item(NAME(m_channels[i].freq), i);
318      save_item(NAME(m_channels[i].endL), i);
319      save_item(NAME(m_channels[i].endHloopH), i);
320      save_item(NAME(m_channels[i].loopL), i);
321      save_item(NAME(m_channels[i].pan), i);
322      save_item(NAME(m_channels[i].effect), i);
323      save_item(NAME(m_channels[i].volume), i);
324      save_item(NAME(m_channels[i].attack), i);
325      save_item(NAME(m_channels[i].decay), i);
326      save_item(NAME(m_channels[i].release), i);
327      save_item(NAME(m_channels[i].cutoff), i);
328      save_item(NAME(m_channels[i].pos), i);
329      save_item(NAME(m_channels[i].step), i);
330      save_item(NAME(m_channels[i].keyon), i);
331      save_item(NAME(m_channels[i].env_phase), i);
332      save_item(NAME(m_channels[i].env_level), i);
333      save_item(NAME(m_channels[i].env_step), i);
334      save_item(NAME(m_channels[i].env_scale), i);
344335   }
345336
346   info->stream = device->machine().sound().stream_alloc(*device, 0, 2, device->clock()/384, info, rf5c400_update);
337   m_stream = stream_alloc(0, 2, clock()/384);
347338}
348339
349340
350static DEVICE_START( rf5c400 )
351{
352   rf5c400_state *info = get_safe_token(device);
353
354   rf5c400_init_chip(device, info);
355}
356
357341/*****************************************************************************/
358342
359343static UINT16 rf5c400_status = 0;
360READ16_DEVICE_HANDLER( rf5c400_r )
344READ16_MEMBER( rf5c400_device::rf5c400_r )
361345{
362346   switch(offset)
363347   {
r21175r21176
375359   return 0;
376360}
377361
378WRITE16_DEVICE_HANDLER( rf5c400_w )
362WRITE16_MEMBER( rf5c400_device::rf5c400_w )
379363{
380   rf5c400_state *info = get_safe_token(device);
381
382364   if (offset < 0x400)
383365   {
384366      switch(offset)
r21175r21176
395377            switch ( data & 0x60 )
396378            {
397379               case 0x60:
398                  info->channels[ch].pos =
399                     ((info->channels[ch].startH & 0xFF00) << 8) | info->channels[ch].startL;
400                  info->channels[ch].pos <<= 16;
380                  m_channels[ch].pos =
381                     ((m_channels[ch].startH & 0xFF00) << 8) | m_channels[ch].startL;
382                  m_channels[ch].pos <<= 16;
401383
402                  info->channels[ch].env_phase = PHASE_ATTACK;
403                  info->channels[ch].env_level = 0.0;
404                  info->channels[ch].env_step  =
405                     info->env_ar_table[decode80(info->channels[ch].attack >> 8)];
384                  m_channels[ch].env_phase = PHASE_ATTACK;
385                  m_channels[ch].env_level = 0.0;
386                  m_channels[ch].env_step  =
387                     m_env_ar_table[decode80(m_channels[ch].attack >> 8)];
406388                  break;
407389               case 0x40:
408                  if (info->channels[ch].env_phase != PHASE_NONE)
390                  if (m_channels[ch].env_phase != PHASE_NONE)
409391                  {
410                     info->channels[ch].env_phase = PHASE_RELEASE;
411                     if (info->channels[ch].release & 0x0080)
392                     m_channels[ch].env_phase = PHASE_RELEASE;
393                     if (m_channels[ch].release & 0x0080)
412394                     {
413                        info->channels[ch].env_step = 0.0;
395                        m_channels[ch].env_step = 0.0;
414396                     }
415397                     else
416398                     {
417                        info->channels[ch].env_step =
418                           info->env_rr_table[decode80(info->channels[ch].release >> 8)];
399                        m_channels[ch].env_step =
400                           m_env_rr_table[decode80(m_channels[ch].release >> 8)];
419401                     }
420402                  }
421403                  break;
422404               default:
423                  info->channels[ch].env_phase = PHASE_NONE;
424                  info->channels[ch].env_level = 0.0;
425                  info->channels[ch].env_step  = 0.0;
405                  m_channels[ch].env_phase = PHASE_NONE;
406                  m_channels[ch].env_level = 0.0;
407                  m_channels[ch].env_step  = 0.0;
426408                  break;
427409            }
428410            break;
r21175r21176
446428
447429         default:
448430         {
449            //mame_printf_debug("%s:rf5c400_w: %08X, %08X, %08X\n", device->machine().describe_context(), data, offset, mem_mask);
431            //mame_printf_debug("%s:rf5c400_w: %08X, %08X, %08X\n", machine().describe_context(), data, offset, mem_mask);
450432            break;
451433         }
452434      }
453      //mame_printf_debug("%s:rf5c400_w: %08X, %08X, %08X at %08X\n", device->machine().describe_context(), data, offset, mem_mask);
435      //mame_printf_debug("%s:rf5c400_w: %08X, %08X, %08X at %08X\n", machine().describe_context(), data, offset, mem_mask);
454436   }
455437   else
456438   {
r21175r21176
458440      int ch = (offset >> 5) & 0x1f;
459441      int reg = (offset & 0x1f);
460442
461      rf5c400_channel *channel = &info->channels[ch];
443      rf5c400_channel *channel = &m_channels[ch];
462444
463445      switch (reg)
464446      {
r21175r21176
555537      }
556538   }
557539}
558
559const device_type RF5C400 = &device_creator<rf5c400_device>;
560
561rf5c400_device::rf5c400_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
562   : device_t(mconfig, RF5C400, "RF5C400", tag, owner, clock),
563      device_sound_interface(mconfig, *this)
564{
565   m_token = global_alloc_clear(rf5c400_state);
566}
567
568//-------------------------------------------------
569//  device_config_complete - perform any
570//  operations now that the configuration is
571//  complete
572//-------------------------------------------------
573
574void rf5c400_device::device_config_complete()
575{
576}
577
578//-------------------------------------------------
579//  device_start - device-specific startup
580//-------------------------------------------------
581
582void rf5c400_device::device_start()
583{
584   DEVICE_START_NAME( rf5c400 )(this);
585}
586
587//-------------------------------------------------
588//  sound_stream_update - handle a stream update
589//-------------------------------------------------
590
591void rf5c400_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
592{
593   // should never get here
594   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
595}
trunk/src/emu/sound/cem3394.c
r21175r21176
8989********************************************************************************/
9090
9191
92/* various waveforms */
92// various waveforms
9393#define WAVE_TRIANGLE       1
9494#define WAVE_SAWTOOTH       2
9595#define WAVE_PULSE          4
9696
97/* keep lots of fractional bits */
97// keep lots of fractional bits
9898#define FRACTION_BITS       28
9999#define FRACTION_ONE        (1 << FRACTION_BITS)
100100#define FRACTION_ONE_D      ((double)(1 << FRACTION_BITS))
r21175r21176
102102#define FRACTION_MULT(a,b)  (((a) >> (FRACTION_BITS / 2)) * ((b) >> (FRACTION_BITS - FRACTION_BITS / 2)))
103103
104104
105/* this structure defines the parameters for a channel */
106struct cem3394_state
107{
108   sound_stream * stream;          /* our stream */
109   void (*external)(device_t *, int, short *);/* callback to generate external samples */
110   double vco_zero_freq;           /* frequency of VCO at 0.0V */
111   double filter_zero_freq;        /* frequency of filter at 0.0V */
105// device type definition
106const device_type CEM3394 = &device_creator<cem3394_device>;
112107
113   double values[8];               /* raw values of registers */
114   UINT8 wave_select;              /* flags which waveforms are enabled */
108//**************************************************************************
109//  LIVE DEVICE
110//**************************************************************************
115111
116   UINT32 volume;                  /* linear overall volume (0-256) */
117   UINT32 mixer_internal;          /* linear internal volume (0-256) */
118   UINT32 mixer_external;          /* linear external volume (0-256) */
112//-------------------------------------------------
113//  cem3394_device - constructor
114//-------------------------------------------------
119115
120   UINT32 position;                /* current VCO frequency position (0.FRACTION_BITS) */
121   UINT32 step;                    /* per-sample VCO step (0.FRACTION_BITS) */
122
123   UINT32 filter_position;         /* current filter frequency position (0.FRACTION_BITS) */
124   UINT32 filter_step;             /* per-sample filter step (0.FRACTION_BITS) */
125   UINT32 modulation_depth;        /* fraction of total by which we modulate (0.FRACTION_BITS) */
126   INT16 last_ext;                 /* last external sample we read */
127
128   UINT32 pulse_width;             /* fractional pulse width (0.FRACTION_BITS) */
129
130   double inv_sample_rate;
131   int sample_rate;
132   device_t *device;
133
134   INT16 *mixer_buffer;
135   INT16 *external_buffer;
136};
137
138
139INLINE cem3394_state *get_safe_token(device_t *device)
116cem3394_device::cem3394_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
117   : device_t(mconfig, CEM3394, "CEM3394", tag, owner, clock),
118     device_sound_interface(mconfig, *this),
119     m_external(NULL),
120     m_stream(NULL),
121     m_vco_zero_freq(0.0),
122     m_filter_zero_freq(0.0),
123     m_wave_select(0),
124     m_volume(0),
125     m_mixer_internal(0),
126     m_mixer_external(0),
127     m_position(0),
128     m_step(0),
129     m_filter_position(0),
130     m_filter_step(0),
131     m_modulation_depth(0),
132     m_last_ext(0),
133     m_pulse_width(0),
134     m_inv_sample_rate(0.0),
135     m_sample_rate(0),
136     m_mixer_buffer(NULL),
137     m_external_buffer(NULL)
140138{
141   assert(device != NULL);
142   assert(device->type() == CEM3394);
143   return (cem3394_state *)downcast<cem3394_device *>(device)->token();
139   memset(m_values, 0, 8*sizeof(double));
144140}
145141
146142
147/* generate sound to the mix buffer in mono */
148static STREAM_UPDATE( cem3394_update )
143//-------------------------------------------------
144//  sound_stream_update - generate sound to the mix buffer in mono
145//-------------------------------------------------
146
147void cem3394_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
149148{
150   cem3394_state *chip = (cem3394_state *)param;
151   int int_volume = (chip->volume * chip->mixer_internal) / 256;
152   int ext_volume = (chip->volume * chip->mixer_external) / 256;
153   UINT32 step = chip->step, position, end_position = 0;
149   int int_volume = (m_volume * m_mixer_internal) / 256;
150   int ext_volume = (m_volume * m_mixer_external) / 256;
151   UINT32 step = m_step, position, end_position = 0;
154152   stream_sample_t *buffer = outputs[0];
155153   INT16 *mix, *ext;
156154   int i;
157155
158156   /* external volume is effectively 0 if no external function */
159   if (!chip->external || !ENABLE_EXTERNAL)
157   if (!m_external || !ENABLE_EXTERNAL)
160158      ext_volume = 0;
161159
162160   /* adjust the volume for the filter */
163   if (step > chip->filter_step)
164      int_volume /= step - chip->filter_step;
161   if (step > m_filter_step)
162      int_volume /= step - m_filter_step;
165163
166164   /* bail if nothing's going on */
167165   if (int_volume == 0 && ext_volume == 0)
r21175r21176
173171   /* if there's external stuff, fetch and process it now */
174172   if (ext_volume != 0)
175173   {
176      UINT32 fposition = chip->filter_position, fstep = chip->filter_step, depth;
177      INT16 last_ext = chip->last_ext;
174      UINT32 fposition = m_filter_position, fstep = m_filter_step, depth;
175      INT16 last_ext = m_last_ext;
178176
179177      /* fetch the external data */
180      (*chip->external)(chip->device, samples, chip->external_buffer);
178      (*m_external)(this, samples, m_external_buffer);
181179
182180      /* compute the modulation depth, and adjust fstep to the maximum frequency */
183181      /* we lop off 13 bits of depth so that we can multiply by stepadjust, below, */
184182      /* which has 13 bits of precision */
185      depth = FRACTION_MULT(fstep, chip->modulation_depth);
183      depth = FRACTION_MULT(fstep, m_modulation_depth);
186184      fstep += depth;
187185      depth >>= 13;
188186
189187      /* "apply" the filter: note this is pretty cheesy; it basically just downsamples the
190188         external sample to filter_freq by allowing only 2 transitions for every cycle */
191      for (i = 0, ext = chip->external_buffer, position = chip->position; i < samples; i++, ext++)
189      for (i = 0, ext = m_external_buffer, position = m_position; i < samples; i++, ext++)
192190      {
193191         UINT32 newposition;
194192         INT32 stepadjust;
r21175r21176
210208      }
211209
212210      /* update the final filter values */
213      chip->filter_position = fposition;
214      chip->last_ext = last_ext;
211      m_filter_position = fposition;
212      m_last_ext = last_ext;
215213   }
216214
217215   /* if there's internal stuff, generate it */
218216   if (int_volume != 0)
219217   {
220      if (chip->wave_select == 0 && !ext_volume)
221         logerror("%f V didn't cut it\n", chip->values[CEM3394_WAVE_SELECT]);
218      if (m_wave_select == 0 && !ext_volume)
219         logerror("%f V didn't cut it\n", m_values[CEM3394_WAVE_SELECT]);
222220
223221      /* handle the pulse component; it maxes out at 0x1932, which is 27% smaller than */
224222      /* the sawtooth (since the value is constant, this is the best place to have an */
225223      /* odd value for volume) */
226      if (ENABLE_PULSE && (chip->wave_select & WAVE_PULSE))
224      if (ENABLE_PULSE && (m_wave_select & WAVE_PULSE))
227225      {
228         UINT32 pulse_width = chip->pulse_width;
226         UINT32 pulse_width = m_pulse_width;
229227
230228         /* if the width is wider than the step, we're guaranteed to hit it once per cycle */
231229         if (pulse_width >= step)
232230         {
233            for (i = 0, mix = chip->mixer_buffer, position = chip->position; i < samples; i++, mix++)
231            for (i = 0, mix = m_mixer_buffer, position = m_position; i < samples; i++, mix++)
234232            {
235233               if (position < pulse_width)
236234                  *mix = 0x1932;
r21175r21176
244242         else
245243         {
246244            INT16 volume = 0x1932 * pulse_width / step;
247            for (i = 0, mix = chip->mixer_buffer, position = chip->position; i < samples; i++, mix++)
245            for (i = 0, mix = m_mixer_buffer, position = m_position; i < samples; i++, mix++)
248246            {
249247               UINT32 newposition = position + step;
250248               if ((newposition ^ position) & ~FRACTION_MASK)
r21175r21176
259257
260258      /* otherwise, clear the mixing buffer */
261259      else
262         memset(chip->mixer_buffer, 0, sizeof(INT16) * samples);
260         memset(m_mixer_buffer, 0, sizeof(INT16) * samples);
263261
264262      /* handle the sawtooth component; it maxes out at 0x2000, which is 27% larger */
265263      /* than the pulse */
266      if (ENABLE_SAWTOOTH && (chip->wave_select & WAVE_SAWTOOTH))
264      if (ENABLE_SAWTOOTH && (m_wave_select & WAVE_SAWTOOTH))
267265      {
268         for (i = 0, mix = chip->mixer_buffer, position = chip->position; i < samples; i++, mix++)
266         for (i = 0, mix = m_mixer_buffer, position = m_position; i < samples; i++, mix++)
269267         {
270268            *mix += ((position >> (FRACTION_BITS - 14)) & 0x3fff) - 0x2000;
271269            position += step;
r21175r21176
276274      /* handle the triangle component; it maxes out at 0x2800, which is 25% larger */
277275      /* than the sawtooth (should be 27% according to the specs, but 25% saves us */
278276      /* a multiplication) */
279      if (ENABLE_TRIANGLE && (chip->wave_select & WAVE_TRIANGLE))
277      if (ENABLE_TRIANGLE && (m_wave_select & WAVE_TRIANGLE))
280278      {
281         for (i = 0, mix = chip->mixer_buffer, position = chip->position; i < samples; i++, mix++)
279         for (i = 0, mix = m_mixer_buffer, position = m_position; i < samples; i++, mix++)
282280         {
283281            INT16 value;
284282            if (position & (1 << (FRACTION_BITS - 1)))
r21175r21176
292290      }
293291
294292      /* update the final position */
295      chip->position = end_position;
293      m_position = end_position;
296294   }
297295
298296   /* mix it down */
299   mix = chip->mixer_buffer;
300   ext = chip->external_buffer;
297   mix = m_mixer_buffer;
298   ext = m_external_buffer;
301299   {
302300      /* internal + external */
303301      if (ext_volume != 0 && int_volume != 0)
r21175r21176
321319}
322320
323321
324static DEVICE_START( cem3394 )
322//-------------------------------------------------
323//  device_start - device-specific startup
324//-------------------------------------------------
325
326void cem3394_device::device_start()
325327{
326   const cem3394_interface *intf = (const cem3394_interface *)device->static_config();
327   cem3394_state *chip = get_safe_token(device);
328   const cem3394_interface *intf = (const cem3394_interface *)static_config();
328329
329   chip->device = device;
330
331330   /* copy global parameters */
332   chip->sample_rate = CEM3394_SAMPLE_RATE;
333   chip->inv_sample_rate = 1.0 / (double)chip->sample_rate;
331   m_sample_rate = CEM3394_SAMPLE_RATE;
332   m_inv_sample_rate = 1.0 / (double)m_sample_rate;
334333
335334   /* allocate stream channels, 1 per chip */
336   chip->stream = device->machine().sound().stream_alloc(*device, 0, 1, chip->sample_rate, chip, cem3394_update);
337   chip->external = intf->external;
338   chip->vco_zero_freq = intf->vco_zero_freq;
339   chip->filter_zero_freq = intf->filter_zero_freq;
335   m_stream = stream_alloc(0, 1, m_sample_rate);
336   m_external = intf->external;
337   m_vco_zero_freq = intf->vco_zero_freq;
338   m_filter_zero_freq = intf->filter_zero_freq;
340339
341340   /* allocate memory for a mixer buffer and external buffer (1 second should do it!) */
342   chip->mixer_buffer = auto_alloc_array(device->machine(), INT16, chip->sample_rate);
343   chip->external_buffer = auto_alloc_array(device->machine(), INT16, chip->sample_rate);
341   m_mixer_buffer = auto_alloc_array(machine(), INT16, m_sample_rate);
342   m_external_buffer = auto_alloc_array(machine(), INT16, m_sample_rate);
344343
345   device->save_item(NAME(chip->values));
346   device->save_item(NAME(chip->wave_select));
347   device->save_item(NAME(chip->volume));
348   device->save_item(NAME(chip->mixer_internal));
349   device->save_item(NAME(chip->mixer_external));
350   device->save_item(NAME(chip->position));
351   device->save_item(NAME(chip->step));
352   device->save_item(NAME(chip->filter_position));
353   device->save_item(NAME(chip->filter_step));
354   device->save_item(NAME(chip->modulation_depth));
355   device->save_item(NAME(chip->last_ext));
356   device->save_item(NAME(chip->pulse_width));
344   save_item(NAME(m_values));
345   save_item(NAME(m_wave_select));
346   save_item(NAME(m_volume));
347   save_item(NAME(m_mixer_internal));
348   save_item(NAME(m_mixer_external));
349   save_item(NAME(m_position));
350   save_item(NAME(m_step));
351   save_item(NAME(m_filter_position));
352   save_item(NAME(m_filter_step));
353   save_item(NAME(m_modulation_depth));
354   save_item(NAME(m_last_ext));
355   save_item(NAME(m_pulse_width));
357356}
358357
359358
360INLINE double compute_db(double voltage)
359double cem3394_device::compute_db(double voltage)
361360{
362361   /* assumes 0.0 == full off, 4.0 == full on, with linear taper, as described in the datasheet */
363362
r21175r21176
383382}
384383
385384
386INLINE UINT32 compute_db_volume(double voltage)
385UINT32 cem3394_device::compute_db_volume(double voltage)
387386{
388387   double temp;
389388
r21175r21176
413412}
414413
415414
416void cem3394_set_voltage(device_t *device, int input, double voltage)
415void cem3394_device::set_voltage(int input, double voltage)
417416{
418   cem3394_state *chip = get_safe_token(device);
419417   double temp;
420418
421419   /* don't do anything if no change */
422   if (voltage == chip->values[input])
420   if (voltage == m_values[input])
423421      return;
424   chip->values[input] = voltage;
422   m_values[input] = voltage;
425423
426424   /* update the stream first */
427   chip->stream->update();
425   m_stream->update();
428426
429427   /* switch off the input */
430428   switch (input)
431429   {
432430      /* frequency varies from -4.0 to +4.0, at 0.75V/octave */
433431      case CEM3394_VCO_FREQUENCY:
434         temp = chip->vco_zero_freq * pow(2.0, -voltage * (1.0 / 0.75));
435         chip->step = (UINT32)(temp * chip->inv_sample_rate * FRACTION_ONE_D);
432         temp = m_vco_zero_freq * pow(2.0, -voltage * (1.0 / 0.75));
433         m_step = (UINT32)(temp * m_inv_sample_rate * FRACTION_ONE_D);
436434         break;
437435
438436      /* wave select determines triangle/sawtooth enable */
439437      case CEM3394_WAVE_SELECT:
440         chip->wave_select &= ~(WAVE_TRIANGLE | WAVE_SAWTOOTH);
438         m_wave_select &= ~(WAVE_TRIANGLE | WAVE_SAWTOOTH);
441439         if (voltage >= -0.5 && voltage <= -0.2)
442            chip->wave_select |= WAVE_TRIANGLE;
440            m_wave_select |= WAVE_TRIANGLE;
443441         else if (voltage >=  0.9 && voltage <=  1.5)
444            chip->wave_select |= WAVE_TRIANGLE | WAVE_SAWTOOTH;
442            m_wave_select |= WAVE_TRIANGLE | WAVE_SAWTOOTH;
445443         else if (voltage >=  2.3 && voltage <=  3.9)
446            chip->wave_select |= WAVE_SAWTOOTH;
444            m_wave_select |= WAVE_SAWTOOTH;
447445         break;
448446
449447      /* pulse width determines duty cycle; 0.0 means 0%, 2.0 means 100% */
450448      case CEM3394_PULSE_WIDTH:
451449         if (voltage < 0.0)
452450         {
453            chip->pulse_width = 0;
454            chip->wave_select &= ~WAVE_PULSE;
451            m_pulse_width = 0;
452            m_wave_select &= ~WAVE_PULSE;
455453         }
456454         else
457455         {
458456            temp = voltage * 0.5;
459457            if (LIMIT_WIDTH)
460458               temp = MINIMUM_WIDTH + (MAXIMUM_WIDTH - MINIMUM_WIDTH) * temp;
461            chip->pulse_width = (UINT32)(temp * FRACTION_ONE_D);
462            chip->wave_select |= WAVE_PULSE;
459            m_pulse_width = (UINT32)(temp * FRACTION_ONE_D);
460            m_wave_select |= WAVE_PULSE;
463461         }
464462         break;
465463
466464      /* final gain is pretty self-explanatory; 0.0 means ~90dB, 4.0 means 0dB */
467465      case CEM3394_FINAL_GAIN:
468         chip->volume = compute_db_volume(voltage);
466         m_volume = compute_db_volume(voltage);
469467         break;
470468
471469      /* mixer balance is a pan between the external input and the internal input */
r21175r21176
473471      case CEM3394_MIXER_BALANCE:
474472         if (voltage >= 0.0)
475473         {
476            chip->mixer_internal = compute_db_volume(3.55 - voltage);
477            chip->mixer_external = compute_db_volume(3.55 + 0.45 * (voltage * 0.25));
474            m_mixer_internal = compute_db_volume(3.55 - voltage);
475            m_mixer_external = compute_db_volume(3.55 + 0.45 * (voltage * 0.25));
478476         }
479477         else
480478         {
481            chip->mixer_internal = compute_db_volume(3.55 - 0.45 * (voltage * 0.25));
482            chip->mixer_external = compute_db_volume(3.55 + voltage);
479            m_mixer_internal = compute_db_volume(3.55 - 0.45 * (voltage * 0.25));
480            m_mixer_external = compute_db_volume(3.55 + voltage);
483481         }
484482         break;
485483
486484      /* filter frequency varies from -4.0 to +4.0, at 0.375V/octave */
487485      case CEM3394_FILTER_FREQENCY:
488         temp = chip->filter_zero_freq * pow(2.0, -voltage * (1.0 / 0.375));
489         chip->filter_step = (UINT32)(temp * chip->inv_sample_rate * FRACTION_ONE_D);
486         temp = m_filter_zero_freq * pow(2.0, -voltage * (1.0 / 0.375));
487         m_filter_step = (UINT32)(temp * m_inv_sample_rate * FRACTION_ONE_D);
490488         break;
491489
492490      /* modulation depth is 0.01 at 0V and 2.0 at 3.5V; how it grows from one to the other */
493491      /* is still unclear at this point */
494492      case CEM3394_MODULATION_AMOUNT:
495493         if (voltage < 0.0)
496            chip->modulation_depth = (UINT32)(0.01 * FRACTION_ONE_D);
494            m_modulation_depth = (UINT32)(0.01 * FRACTION_ONE_D);
497495         else if (voltage > 3.5)
498            chip->modulation_depth = (UINT32)(2.00 * FRACTION_ONE_D);
496            m_modulation_depth = (UINT32)(2.00 * FRACTION_ONE_D);
499497         else
500            chip->modulation_depth = (UINT32)(((voltage * (1.0 / 3.5)) * 1.99 + 0.01) * FRACTION_ONE_D);
498            m_modulation_depth = (UINT32)(((voltage * (1.0 / 3.5)) * 1.99 + 0.01) * FRACTION_ONE_D);
501499         break;
502500
503501      /* this is not yet implemented */
r21175r21176
507505}
508506
509507
510double cem3394_get_parameter(device_t *device, int input)
508double cem3394_device::get_parameter(int input)
511509{
512   cem3394_state *chip = get_safe_token(device);
513   double voltage = chip->values[input];
510   double voltage = m_values[input];
514511
515512   switch (input)
516513   {
517514      case CEM3394_VCO_FREQUENCY:
518         return chip->vco_zero_freq * pow(2.0, -voltage * (1.0 / 0.75));
515         return m_vco_zero_freq * pow(2.0, -voltage * (1.0 / 0.75));
519516
520517      case CEM3394_WAVE_SELECT:
521518         return voltage;
r21175r21176
551548            return voltage * (1.0 / 2.5);
552549
553550      case CEM3394_FILTER_FREQENCY:
554         return chip->filter_zero_freq * pow(2.0, -voltage * (1.0 / 0.375));
551         return m_filter_zero_freq * pow(2.0, -voltage * (1.0 / 0.375));
555552   }
556553   return 0.0;
557554}
558
559const device_type CEM3394 = &device_creator<cem3394_device>;
560
561cem3394_device::cem3394_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
562   : device_t(mconfig, CEM3394, "CEM3394", tag, owner, clock),
563      device_sound_interface(mconfig, *this)
564{
565   m_token = global_alloc_clear(cem3394_state);
566}
567
568//-------------------------------------------------
569//  device_config_complete - perform any
570//  operations now that the configuration is
571//  complete
572//-------------------------------------------------
573
574void cem3394_device::device_config_complete()
575{
576}
577
578//-------------------------------------------------
579//  device_start - device-specific startup
580//-------------------------------------------------
581
582void cem3394_device::device_start()
583{
584   DEVICE_START_NAME( cem3394 )(this);
585}
586
587//-------------------------------------------------
588//  sound_stream_update - handle a stream update
589//-------------------------------------------------
590
591void cem3394_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
592{
593   // should never get here
594   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
595}
trunk/src/emu/sound/rf5c400.h
r21175r21176
55#ifndef __RF5C400_H__
66#define __RF5C400_H__
77
8#include "devlegcy.h"
8//**************************************************************************
9//  INTERFACE CONFIGURATION MACROS
10//**************************************************************************
911
10DECLARE_READ16_DEVICE_HANDLER( rf5c400_r );
11DECLARE_WRITE16_DEVICE_HANDLER( rf5c400_w );
12#define MCFG_RF5C400_ADD(_tag, _clock) \
13   MCFG_DEVICE_ADD(_tag, RF5C400, _clock)
14#define MCFG_RF5C400_REPLACE(_tag, _clock) \
15   MCFG_DEVICE_REPLACE(_tag, RF5C400, _clock)
1216
17
18//**************************************************************************
19//  TYPE DEFINITIONS
20//**************************************************************************
21
22struct rf5c400_channel
23{
24    rf5c400_channel() :
25      startH(0),
26      startL(0),
27      freq(0),
28      endL(0),
29      endHloopH(0),
30      loopL(0),
31      pan(0),
32      effect(0),
33      volume(0),
34      attack(0),
35      decay(0),
36      release(0),
37      cutoff(0),
38      pos(0),
39      step(0),
40      keyon(0),
41      env_phase(0),
42      env_level(0.0),
43      env_step(0.0),
44      env_scale(0.0)
45    { }
46   
47   UINT16  startH;
48   UINT16  startL;
49   UINT16  freq;
50   UINT16  endL;
51   UINT16  endHloopH;
52   UINT16  loopL;
53   UINT16  pan;
54   UINT16  effect;
55   UINT16  volume;
56
57   UINT16  attack;
58   UINT16  decay;
59   UINT16  release;
60
61   UINT16  cutoff;
62
63   UINT64 pos;
64   UINT64 step;
65   UINT16 keyon;
66
67   UINT8 env_phase;
68   double env_level;
69   double env_step;
70   double env_scale;
71};
72
73
74// ======================> rf5c400_device
75
1376class rf5c400_device : public device_t,
14                           public device_sound_interface
77                  public device_sound_interface
1578{
1679public:
1780   rf5c400_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
18   ~rf5c400_device() { global_free(m_token); }
81   ~rf5c400_device() { }
1982
20   // access to legacy token
21   void *token() const { assert(m_token != NULL); return m_token; }
2283protected:
2384   // device-level overrides
24   virtual void device_config_complete();
2585   virtual void device_start();
2686
2787   // sound stream update overrides
2888   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
89
90public:
91    DECLARE_READ16_MEMBER( rf5c400_r );
92    DECLARE_WRITE16_MEMBER( rf5c400_w );
93
2994private:
30   // internal state
31   void *m_token;
95    void rf5c400_init_chip();
96    UINT8 decode80(UINT8 val);
97
98private:
99   INT16 *m_rom;
100   UINT32 m_rom_length;
101
102   sound_stream *m_stream;
103
104   double m_env_ar_table[0x9f];
105   double m_env_dr_table[0x9f];
106   double m_env_rr_table[0x9f];
107
108   rf5c400_channel m_channels[32];
32109};
33110
34111extern const device_type RF5C400;
trunk/src/emu/sound/cem3394.h
r21175r21176
33#ifndef __CEM3394_H__
44#define __CEM3394_H__
55
6#include "devlegcy.h"
7
8
96#define CEM3394_SAMPLE_RATE     (44100*4)
107
118
12/* interface */
9// interface
1310struct cem3394_interface
1411{
15   double vco_zero_freq;               /* frequency at 0V for VCO */
16   double filter_zero_freq;            /* frequency at 0V for filter */
17   void (*external)(device_t *, int, short *);/* external input source */
12   double vco_zero_freq;                    /* frequency at 0V for VCO */
13   double filter_zero_freq;                 /* frequency at 0V for filter */
14   void (*external)(device_t*, int, short*);/* external input source */
1815};
1916
20/* inputs */
17// inputs
2118enum
2219{
2320   CEM3394_VCO_FREQUENCY = 0,
r21175r21176
3027   CEM3394_FINAL_GAIN
3128};
3229
33/* set the voltage going to a particular parameter */
34void cem3394_set_voltage(device_t *device, int input, double voltage);
3530
36/* get the translated parameter associated with the given input as follows:
37    CEM3394_VCO_FREQUENCY:      frequency in Hz
38    CEM3394_MODULATION_AMOUNT:  scale factor, 0.0 to 2.0
39    CEM3394_WAVE_SELECT:        voltage from this line
40    CEM3394_PULSE_WIDTH:        width fraction, from 0.0 to 1.0
41    CEM3394_MIXER_BALANCE:      balance, from -1.0 to 1.0
42    CEM3394_FILTER_RESONANCE:   resonance, from 0.0 to 1.0
43    CEM3394_FILTER_FREQENCY:    frequency, in Hz
44    CEM3394_FINAL_GAIN:         gain, in dB */
45double cem3394_get_parameter(device_t *device, int input);
31//**************************************************************************
32//  INTERFACE CONFIGURATION MACROS
33//**************************************************************************
4634
35#define MCFG_CEM3394_ADD(_tag, _clock) \
36   MCFG_DEVICE_ADD(_tag, CEM3394, _clock)
37#define MCFG_CEM3394_REPLACE(_tag, _clock) \
38   MCFG_DEVICE_REPLACE(_tag, CEM3394, _clock)
39
40
41
4742class cem3394_device : public device_t,
48                           public device_sound_interface
43                  public device_sound_interface
4944{
5045public:
5146   cem3394_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
52   ~cem3394_device() { global_free(m_token); }
47   ~cem3394_device() { }
5348
54   // access to legacy token
55   void *token() const { assert(m_token != NULL); return m_token; }
5649protected:
5750   // device-level overrides
58   virtual void device_config_complete();
5951   virtual void device_start();
6052
6153   // sound stream update overrides
6254   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
55
56public:
57    // Set the voltage going to a particular parameter
58    void set_voltage(int input, double voltage);
59
60    // Get the translated parameter associated with the given input as follows:
61    //    CEM3394_VCO_FREQUENCY:      frequency in Hz
62    //    CEM3394_MODULATION_AMOUNT:  scale factor, 0.0 to 2.0
63    //    CEM3394_WAVE_SELECT:        voltage from this line
64    //    CEM3394_PULSE_WIDTH:        width fraction, from 0.0 to 1.0
65    //    CEM3394_MIXER_BALANCE:      balance, from -1.0 to 1.0
66    //    CEM3394_FILTER_RESONANCE:   resonance, from 0.0 to 1.0
67    //    CEM3394_FILTER_FREQENCY:    frequency, in Hz
68    //    CEM3394_FINAL_GAIN:         gain, in dB
69    double get_parameter(int input);
70
6371private:
64   // internal state
65   void *m_token;
72    double compute_db(double voltage);
73    UINT32 compute_db_volume(double voltage);
74
75private:
76   void (*m_external)(device_t*, int, short*);/* callback to generate external samples */
77
78   sound_stream *m_stream;           /* our stream */
79   double m_vco_zero_freq;           /* frequency of VCO at 0.0V */
80   double m_filter_zero_freq;        /* frequency of filter at 0.0V */
81
82   double m_values[8];               /* raw values of registers */
83   UINT8 m_wave_select;              /* flags which waveforms are enabled */
84
85   UINT32 m_volume;                  /* linear overall volume (0-256) */
86   UINT32 m_mixer_internal;          /* linear internal volume (0-256) */
87   UINT32 m_mixer_external;          /* linear external volume (0-256) */
88
89   UINT32 m_position;                /* current VCO frequency position (0.FRACTION_BITS) */
90   UINT32 m_step;                    /* per-sample VCO step (0.FRACTION_BITS) */
91
92   UINT32 m_filter_position;         /* current filter frequency position (0.FRACTION_BITS) */
93   UINT32 m_filter_step;             /* per-sample filter step (0.FRACTION_BITS) */
94   UINT32 m_modulation_depth;        /* fraction of total by which we modulate (0.FRACTION_BITS) */
95   INT16 m_last_ext;                 /* last external sample we read */
96
97   UINT32 m_pulse_width;             /* fractional pulse width (0.FRACTION_BITS) */
98
99   double m_inv_sample_rate;
100   int m_sample_rate;
101
102   INT16 *m_mixer_buffer;
103   INT16 *m_external_buffer;
66104};
67105
68106extern const device_type CEM3394;
trunk/src/mess/machine/msx_slot.c
r21175r21176
354354   {
355355      if ((offset & 0xff) >= 0xe0)
356356      {
357         return k051649_test_r(drvstate->m_k051649, space, offset & 0xff);
357         return drvstate->m_k051649->test_r(space, offset & 0xff);
358358      }
359359      return 0xff;
360360   }
361361   else
362362   {
363      return k051649_waveform_r(drvstate->m_k051649, space, offset & 0x7f);
363      return drvstate->m_k051649->waveform_r(space, offset & 0x7f);
364364   }
365365}
366366
r21175r21176
431431
432432      if (offset < 0x80)
433433      {
434         k051649_waveform_w (drvstate->m_k051649, space, offset, val);
434         drvstate->m_k051649->waveform_w (space, offset, val);
435435      }
436436      else if (offset < 0xa0)
437437      {
438438         offset &= 0xf;
439439         if (offset < 0xa)
440440         {
441            k051649_frequency_w (drvstate->m_k051649, space, offset, val);
441            drvstate->m_k051649->frequency_w (space, offset, val);
442442         }
443443         else if (offset < 0xf)
444444         {
445            k051649_volume_w (drvstate->m_k051649, space, offset - 0xa, val);
445            drvstate->m_k051649->volume_w (space, offset - 0xa, val);
446446         }
447447         else
448448         {
449            k051649_keyonoff_w (drvstate->m_k051649, space, 0, val);
449            drvstate->m_k051649->keyonoff_w (space, 0, val);
450450         }
451451      }
452452      else if (offset >= 0xe0)
453453      {
454         k051649_test_w (drvstate->m_k051649, space, offset, val);
454         drvstate->m_k051649->test_w (space, offset, val);
455455      }
456456   }
457457   else if (addr >= 0xb000 && addr < 0xb800)
r21175r21176
21972197
21982198   if (reg < 0x80)
21992199   {
2200      return k051649_waveform_r (state->m_k051649, space, reg);
2200      return state->m_k051649->waveform_r (space, reg);
22012201   }
22022202   else if (reg < 0xa0)
22032203   {
r21175r21176
22062206   else if (reg < 0xc0)
22072207   {
22082208      /* read wave 5 */
2209      return k051649_waveform_r (state->m_k051649, space, 0x80 + (reg & 0x1f));
2209      return state->m_k051649->waveform_r (space, 0x80 + (reg & 0x1f));
22102210   }
22112211   else if (reg < 0xe0)
22122212   {
2213      return k051649_test_r (state->m_k051649, space, reg);
2213      return state->m_k051649->test_r (space, reg);
22142214   }
22152215
22162216   return 0xff;
r21175r21176
22312231
22322232   if (reg < 0xa0)
22332233   {
2234      return k052539_waveform_r (state->m_k051649, space, reg);
2234      return state->m_k051649->waveform_r (space, reg);
22352235   }
22362236   else if (reg >= 0xc0 && reg < 0xe0)
22372237   {
2238      return k051649_test_r (state->m_k051649, space, reg);
2238      return state->m_k051649->test_r (space, reg);
22392239   }
22402240
22412241   return 0xff;
r21175r21176
23452345
23462346         if (offset < 0x80)
23472347         {
2348            k051649_waveform_w (drvstate->m_k051649, space, offset, val);
2348            drvstate->m_k051649->waveform_w (space, offset, val);
23492349         }
23502350         else if (offset < 0xa0)
23512351         {
r21175r21176
23532353
23542354            if (offset < 0xa)
23552355            {
2356               k051649_frequency_w (drvstate->m_k051649, space, offset, val);
2356               drvstate->m_k051649->frequency_w (space, offset, val);
23572357            }
23582358            else if (offset < 0x0f)
23592359            {
2360               k051649_volume_w (drvstate->m_k051649, space, offset - 0xa, val);
2360               drvstate->m_k051649->volume_w (space, offset - 0xa, val);
23612361            }
23622362            else if (offset == 0x0f)
23632363            {
2364               k051649_keyonoff_w (drvstate->m_k051649, space, 0, val);
2364               drvstate->m_k051649->keyonoff_w (space, 0, val);
23652365            }
23662366         }
23672367         else if (offset < 0xe0)
23682368         {
2369            k051649_test_w (drvstate->m_k051649, space, offset, val);
2369            drvstate->m_k051649->test_w (space, offset, val);
23702370         }
23712371      }
23722372   }
r21175r21176
23942394
23952395         if (offset < 0xa0)
23962396         {
2397            k052539_waveform_w (drvstate->m_k051649, space, offset, val);
2397            drvstate->m_k051649->waveform_w (space, offset, val);
23982398         }
23992399         else if (offset < 0xc0)
24002400         {
r21175r21176
24022402
24032403            if (offset < 0x0a)
24042404            {
2405               k051649_frequency_w (drvstate->m_k051649, space, offset, val);
2405               drvstate->m_k051649->frequency_w (space, offset, val);
24062406            }
24072407            else if (offset < 0x0f)
24082408            {
2409               k051649_volume_w (drvstate->m_k051649, space, offset - 0x0a, val);
2409               drvstate->m_k051649->volume_w (space, offset - 0x0a, val);
24102410            }
24112411            else if (offset == 0x0f)
24122412            {
2413               k051649_keyonoff_w (drvstate->m_k051649, space, 0, val);
2413               drvstate->m_k051649->keyonoff_w (space, 0, val);
24142414            }
24152415         }
24162416         else if (offset < 0xe0)
24172417         {
2418            k051649_test_w (drvstate->m_k051649, space, offset, val);
2418            drvstate->m_k051649->test_w (space, offset, val);
24192419         }
24202420      }
24212421   }
trunk/src/mess/includes/msx.h
r21175r21176
143143   required_device<cassette_image_device> m_cass;
144144   required_device<device_t> m_ay8910;
145145   required_device<ym2413_device> m_ym;
146   optional_device<device_t> m_k051649;
146   optional_device<k051649_device> m_k051649;
147147   required_device<dac_device> m_dac;
148148   required_device<centronics_device> m_centronics;
149149   optional_device<rp5c01_device> m_rtc;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team