diff options
| author | 2016-08-30 17:27:24 +0200 | |
|---|---|---|
| committer | 2016-08-30 17:28:06 +0200 | |
| commit | 3cd120638a9cedfb7ee6141d837ef82b0f780c61 (patch) | |
| tree | 73a975c69a8d0f25ff6be730a299ff894a5b9137 | |
| parent | 4d0d5fe1183bd0fbf25f97b17db1e432618b71ab (diff) | |
Add okim6295 to vgmplay driver, nw
| -rw-r--r-- | src/devices/sound/2612intf.cpp | 15 | ||||
| -rw-r--r-- | src/devices/sound/2612intf.h | 3 | ||||
| -rw-r--r-- | src/devices/sound/fm.h | 1 | ||||
| -rw-r--r-- | src/devices/sound/fm2612.cpp | 8 | ||||
| -rw-r--r-- | src/mame/drivers/vgmplay.cpp | 72 |
5 files changed, 86 insertions, 13 deletions
diff --git a/src/devices/sound/2612intf.cpp b/src/devices/sound/2612intf.cpp index c606f4eaece..ed9c8b060b0 100644 --- a/src/devices/sound/2612intf.cpp +++ b/src/devices/sound/2612intf.cpp @@ -117,6 +117,21 @@ void ym2612_device::device_start() assert_always(m_chip != nullptr, "Error creating YM2612 chip"); } +void ym2612_device::device_clock_changed() +{ + calculate_rates(); + ym2612_clock_changed(m_chip, clock(), clock() / 72); +} + +void ym2612_device::calculate_rates() +{ + int rate = clock() / 72; + + if (m_stream != nullptr) + m_stream->set_sample_rate(rate); + else + m_stream = machine().sound().stream_alloc(*this,0,2,rate); +} //------------------------------------------------- // device_stop - device-specific stop diff --git a/src/devices/sound/2612intf.h b/src/devices/sound/2612intf.h index 0dc25ac5b25..7a9751ab9d3 100644 --- a/src/devices/sound/2612intf.h +++ b/src/devices/sound/2612intf.h @@ -36,6 +36,7 @@ protected: virtual void device_post_load() override; virtual void device_stop() override; virtual void device_reset() override; + virtual void device_clock_changed() override; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; @@ -43,6 +44,8 @@ protected: virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override; private: + void calculate_rates(); + sound_stream * m_stream; emu_timer * m_timer[2]; void * m_chip; diff --git a/src/devices/sound/fm.h b/src/devices/sound/fm.h index 8615e83044b..c558331168b 100644 --- a/src/devices/sound/fm.h +++ b/src/devices/sound/fm.h @@ -192,6 +192,7 @@ void ym2610_postload(void *chip); #if (BUILD_YM2612||BUILD_YM3438) void * ym2612_init(void *param, device_t *device, int baseclock, int rate, FM_TIMERHANDLER TimerHandler,FM_IRQHANDLER IRQHandler); +void ym2612_clock_changed(void *chip, int clock, int rate); void ym2612_shutdown(void *chip); void ym2612_reset_chip(void *chip); void ym2612_update_one(void *chip, FMSAMPLE **buffer, int length); diff --git a/src/devices/sound/fm2612.cpp b/src/devices/sound/fm2612.cpp index af75298a59a..22c1cad0f3c 100644 --- a/src/devices/sound/fm2612.cpp +++ b/src/devices/sound/fm2612.cpp @@ -2395,6 +2395,14 @@ void * ym2612_init(void *param, device_t *device, int clock, int rate, return F2612; } +void ym2612_clock_changed(void *chip, int clock, int rate) +{ + YM2612 *F2612 = (YM2612 *)chip; + + F2612->OPN.ST.clock = clock; + F2612->OPN.ST.rate = rate; +} + /* shut down emulator */ void ym2612_shutdown(void *chip) { diff --git a/src/mame/drivers/vgmplay.cpp b/src/mame/drivers/vgmplay.cpp index cd45319720a..0751b961b14 100644 --- a/src/mame/drivers/vgmplay.cpp +++ b/src/mame/drivers/vgmplay.cpp @@ -27,6 +27,7 @@ #include "sound/gb.h" #include "sound/pokey.h" #include "sound/c352.h" +#include "sound/okim6295.h" #define AS_IO16 AS_1 #define MCFG_CPU_IO16_MAP MCFG_CPU_DATA_MAP @@ -49,6 +50,7 @@ public: A_SN76496 = 0x000000a0, A_K053260 = 0x000000b0, A_C6280 = 0x000000e0, + A_OKIM6295 = 0x000000f0, A_SEGAPCM = 0x00001000, A_GAMEBOY = 0x00002000, A_NESAPU = 0x00002030, @@ -89,6 +91,7 @@ public: READ8_MEMBER(multipcma_rom_r); READ8_MEMBER(multipcmb_rom_r); READ8_MEMBER(k053260_rom_r); + READ8_MEMBER(okim6295_rom_r); READ8_MEMBER(c352_rom_r); private: @@ -164,6 +167,7 @@ private: required_device<pokey_device> m_pokeya; required_device<pokey_device> m_pokeyb; required_device<c352_device> m_c352; + required_device<okim6295_device> m_okim6295; UINT32 m_multipcma_bank_l; UINT32 m_multipcma_bank_r; @@ -396,6 +400,7 @@ void vgmplay_device::execute_run() m_io->write_byte(A_YM2612+0, 0x2a); m_io->write_byte(A_YM2612+1, m_data_streams[0][m_ym2612_stream_offset]); + m_ym2612_stream_offset++; } m_pc += 1; m_icount -= code & 0xf; @@ -444,6 +449,11 @@ void vgmplay_device::execute_run() break; } + case 0xb8: + m_io->write_byte(A_OKIM6295 + m_file->read_byte(m_pc+1), m_file->read_byte(m_pc+2)); + m_pc += 3; + break; + case 0xb9: m_io->write_byte(A_C6280 + m_file->read_byte(m_pc+1), m_file->read_byte(m_pc+2)); m_pc += 3; @@ -873,6 +883,11 @@ READ8_MEMBER(vgmplay_device::multipcmb_rom_r) return rom_r(1, 0x89, offset); } +READ8_MEMBER(vgmplay_device::okim6295_rom_r) +{ + return rom_r(0, 0x8b, offset); +} + READ8_MEMBER(vgmplay_device::k053260_rom_r) { return rom_r(0, 0x8e, offset); @@ -908,6 +923,7 @@ vgmplay_state::vgmplay_state(const machine_config &mconfig, device_type type, co , m_pokeya(*this, "pokeya") , m_pokeyb(*this, "pokeyb") , m_c352(*this, "c352") + , m_okim6295(*this, "okim6295") { } @@ -999,10 +1015,6 @@ void vgmplay_state::machine_start() m_sn76496->set_unscaled_clock(r32(0x0c)); if(r32(0x10)) m_ym2413->set_unscaled_clock(r32(0x10)); - if(version <= 0x101 && r32(0x0c)) { - m_ym2612->set_unscaled_clock(r32(0x0c)); - m_ym2151->set_unscaled_clock(r32(0x0c)); - } if(version >= 0x110 && r32(0x2c)) m_ym2612->set_unscaled_clock(r32(0x2c)); if(version >= 0x110 && r32(0x30)) @@ -1017,10 +1029,12 @@ void vgmplay_state::machine_start() logerror("Warning: file requests an unsupported RF5C68\n"); if(version >= 0x151 && r32(0x44)) { UINT32 clock = r32(0x44); + m_ym2203a->set_unscaled_clock(clock & ~0x40000000); if (clock & 0x40000000) + { clock &= ~0x40000000; - m_ym2203a->set_unscaled_clock(clock); - m_ym2203b->set_unscaled_clock(clock); + m_ym2203b->set_unscaled_clock(clock); + } } if(version >= 0x151 && r32(0x48)) logerror("Warning: file requests an unsupported YM2608\n"); @@ -1047,8 +1061,12 @@ void vgmplay_state::machine_start() if(version >= 0x151 && r32(0x70)) logerror("Warning: file requests an unsupported PWM\n"); if(version >= 0x151 && r32(0x74)) { - m_ay8910a->set_unscaled_clock(r32(0x74) & ~0x40000000); - m_ay8910b->set_unscaled_clock(r32(0x74) & ~0x40000000); + UINT32 clock = r32(0x74); + m_ay8910a->set_unscaled_clock(clock & ~0x40000000); + if (clock & 0x40000000) { + clock &= ~0x40000000; + m_ay8910b->set_unscaled_clock(clock); + } } if(version >= 0x151 && r8(0x78)) { UINT8 type = r8(0x78); @@ -1094,8 +1112,22 @@ void vgmplay_state::machine_start() m_nescpu->m_apu->set_unscaled_clock(r32(0x84)); } if(version >= 0x161 && r32(0x88)) { - m_multipcma->set_unscaled_clock(r32(0x88) & ~0x40000000); - m_multipcmb->set_unscaled_clock(r32(0x88) & ~0x40000000); + UINT32 clock = r32(0x88); + m_multipcma->set_unscaled_clock(clock & ~0x40000000); + if (clock & 0x40000000) { + clock &= ~0x40000000; + m_multipcmb->set_unscaled_clock(clock); + } + } + if(version >= 0x161 && r32(0x98)) { + UINT32 clock = r32(0x98); + UINT32 pin7 = 0; + if (clock & 0x80000000) { + clock &= ~0x80000000; + pin7 = 1; + } + okim6295_device::static_set_pin7(*m_okim6295, pin7); + m_okim6295->set_unscaled_clock(clock); } if(version >= 0x161 && r32(0xac)) { m_k053260->set_unscaled_clock(r32(0xac)); @@ -1104,8 +1136,12 @@ void vgmplay_state::machine_start() m_c6280->set_unscaled_clock(r32(0xa4)); } if(version >= 0x161 && r32(0xb0)) { - m_pokeya->set_unscaled_clock(r32(0xb0) & ~0x40000000); - m_pokeyb->set_unscaled_clock(r32(0xb0) & ~0x40000000); + UINT32 clock = r32(0xb0); + m_pokeya->set_unscaled_clock(clock); + if (clock & 0x40000000) { + clock &= ~0x40000000; + m_pokeyb->set_unscaled_clock(clock); + } } } @@ -1198,6 +1234,7 @@ static ADDRESS_MAP_START( soundchips_map, AS_IO, 8, vgmplay_state ) AM_RANGE(vgmplay_device::A_SN76496+1, vgmplay_device::A_SN76496+1) AM_DEVWRITE ("sn76496", sn76496_device, write) AM_RANGE(vgmplay_device::A_K053260, vgmplay_device::A_K053260+0x2f) AM_DEVWRITE ("k053260", k053260_device, write) AM_RANGE(vgmplay_device::A_C6280, vgmplay_device::A_C6280+0xf) AM_DEVWRITE ("c6280", c6280_device, c6280_w) + AM_RANGE(vgmplay_device::A_OKIM6295, vgmplay_device::A_OKIM6295) AM_DEVWRITE ("okim6295", okim6295_device, write) AM_RANGE(vgmplay_device::A_SEGAPCM, vgmplay_device::A_SEGAPCM+0x7ff) AM_DEVWRITE ("segapcm", segapcm_device, sega_pcm_w) AM_RANGE(vgmplay_device::A_GAMEBOY, vgmplay_device::A_GAMEBOY+0x16) AM_DEVWRITE ("dmg", gameboy_sound_device, sound_w) AM_RANGE(vgmplay_device::A_GAMEBOY+0x20, vgmplay_device::A_GAMEBOY+0x2f) AM_DEVWRITE ("dmg", gameboy_sound_device, wave_w) @@ -1229,6 +1266,10 @@ static ADDRESS_MAP_START( k053260_map, AS_0, 8, vgmplay_state ) AM_RANGE(0, 0x1fffff) AM_DEVREAD("vgmplay", vgmplay_device, k053260_rom_r) ADDRESS_MAP_END +static ADDRESS_MAP_START( okim6295_map, AS_0, 8, vgmplay_state ) + AM_RANGE(0, 0x3ffff) AM_DEVREAD("vgmplay", vgmplay_device, okim6295_rom_r) +ADDRESS_MAP_END + static ADDRESS_MAP_START( c352_map, AS_0, 8, vgmplay_state ) AM_RANGE(0, 0xffffff) AM_DEVREAD("vgmplay", vgmplay_device, c352_rom_r) ADDRESS_MAP_END @@ -1347,10 +1388,15 @@ static MACHINE_CONFIG_START( vgmplay, vgmplay_state ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.5) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.5) - MCFG_C352_ADD("c352", 25401600, 288) + MCFG_C352_ADD("c352", 1000000, 288) MCFG_DEVICE_ADDRESS_MAP(AS_0, c352_map) MCFG_SOUND_ROUTE(0, "lspeaker", 1) MCFG_SOUND_ROUTE(1, "rspeaker", 1) + + MCFG_OKIM6295_ADD("okim6295", 1000000, OKIM6295_PIN7_HIGH) + MCFG_DEVICE_ADDRESS_MAP(AS_0, okim6295_map) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.25) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.25) MACHINE_CONFIG_END ROM_START( vgmplay ) |
