From b33b28cb8708e36516061f1f578b44e7f8aba53a Mon Sep 17 00:00:00 2001 From: cam900 Date: Thu, 19 Jul 2018 21:18:16 +0900 Subject: [PATCH] vgmplay.cpp : Add RF5C68/RF5C164 support, Add PCM Write handler (#3756) * vgmplay.cpp : Add RF5C68/RF5C164 support, Add PCM Write handler * vgmplay : Fix pcm write command * vgmplay.cpp : Fix address of chips * vgmplay.cpp : Address space usage reduce * vgmplay.cpp : Reduce Address space usage --- src/mame/drivers/vgmplay.cpp | 121 ++++++++++++++++++++++++++++++++--- src/mame/layout/vgmplay.lay | 8 +++ 2 files changed, 119 insertions(+), 10 deletions(-) diff --git a/src/mame/drivers/vgmplay.cpp b/src/mame/drivers/vgmplay.cpp index 92e261cb907..f71d26c47ed 100644 --- a/src/mame/drivers/vgmplay.cpp +++ b/src/mame/drivers/vgmplay.cpp @@ -28,6 +28,7 @@ #include "sound/okim6295.h" #include "sound/pokey.h" #include "sound/qsound.h" +#include "sound/rf5c68.h" #include "sound/segapcm.h" #include "sound/sn76496.h" #include "sound/ym2151.h" @@ -91,11 +92,15 @@ public: A_YMF271 = 0x00013040, A_YMZ280B = 0x00013050, A_YM2608 = 0x00013060, - A_K054539A = 0x00014000, - A_K054539B = 0x00014400, - A_QSOUND = 0x00013070, - A_K051649 = 0x00013080, - A_GA20 = 0x000130a0 + A_K054539A = 0x00013400, + A_K054539B = 0x00013800, + A_QSOUND = 0x00013c00, + A_K051649 = 0x00013c10, + A_GA20 = 0x00013c20, + A_RF5C68 = 0x00013c40, + A_RF5C164 = 0x00013c50, + A_RF5C68RAM = 0x00014000, + A_RF5C164RAM = 0x00024000 }; enum io16_t @@ -187,6 +192,9 @@ private: LED_GA20, + LED_RF5C68, + LED_RF5C164, + LED_COUNT }; @@ -210,6 +218,7 @@ private: uint8_t rom_r(int chip, uint8_t type, offs_t offset); uint32_t handle_data_block(uint32_t address); + uint32_t handle_pcm_write(uint32_t address); void blocks_clear(); output_finder m_act_leds; @@ -285,6 +294,8 @@ public: void okim6295a_map(address_map &map); void okim6295b_map(address_map &map); void qsound_map(address_map &map); + void rf5c68_map(address_map &map); + void rf5c164_map(address_map &map); void segapcm_map(address_map &map); void soundchips16_map(address_map &map); void soundchips_map(address_map &map); @@ -323,6 +334,10 @@ private: required_device m_qsound; required_device m_k051649; required_device m_ga20; + required_device m_rf5c68; + required_device m_rf5c164; // TODO : !!RF5C164!! + required_shared_ptr m_rf5c68_ram; + required_shared_ptr m_rf5c164_ram; uint32_t m_okim6295_clock[2]; uint32_t m_okim6295_pin7[2]; @@ -482,17 +497,47 @@ uint32_t vgmplay_device::handle_data_block(uint32_t address) for(uint32_t i=0; iread_byte(m_pc+15+i); m_rom_blocks[second][type - 0x80].emplace_front(start, start+size-9, std::move(block)); - } else if(type == 0xc2) { + } else if(type <= 0xc2) { uint16_t start = m_file->read_word(m_pc+7); uint32_t data_size = size - 2; - for (int i = 0; i < data_size; i++) - m_io->write_byte(A_NESRAM + start + i, m_file->read_byte(m_pc + 9 + i)); + if (type == 0xc0) { + for (int i = 0; i < data_size; i++) + m_io->write_byte(A_RF5C68RAM + start + i, m_file->read_byte(m_pc + 9 + i)); + } else if (type == 0xc1) { + for (int i = 0; i < data_size; i++) + m_io->write_byte(A_RF5C164RAM + start + i, m_file->read_byte(m_pc + 9 + i)); + } else if (type == 0xc2) { + for (int i = 0; i < data_size; i++) + m_io->write_byte(A_NESRAM + start + i, m_file->read_byte(m_pc + 9 + i)); + } } else { logerror("ignored ram block size %x type %02x\n", size, type); } return 7+size; } +uint32_t vgmplay_device::handle_pcm_write(uint32_t address) +{ + uint8_t type = m_file->read_byte(m_pc+2); + uint32_t src = m_file->read_dword(m_pc+3) & 0xffffff; + uint32_t dst = m_file->read_dword(m_pc+6) & 0xffffff; + uint32_t size = m_file->read_dword(m_pc+9) & 0xffffff; + + if (type == 0x01) { + for (int i = 0; i < size; i++) + m_io->write_byte(A_RF5C68RAM + dst + i, m_data_streams[type][src + i]); + } else if (type == 0x02) { + for (int i = 0; i < size; i++) + m_io->write_byte(A_RF5C164RAM + dst + i, m_data_streams[type][src + i]); + } else if (type == 0x07) { + for (int i = 0; i < size; i++) + m_io->write_byte(A_NESRAM + dst + i, m_data_streams[type][src + i]); + } else { + logerror("ignored pcm ram writes src %x dst %x size %x type %02x\n", src, dst, size, type); + } + return 12; +} + void vgmplay_device::execute_run() { while(m_icount > 0) { @@ -641,6 +686,10 @@ void vgmplay_device::execute_run() m_pc += handle_data_block(m_pc); break; + case 0x68: + m_pc += handle_pcm_write(m_pc); + break; + case 0x70: case 0x71: case 0x72: case 0x73: case 0x74: case 0x75: case 0x76: case 0x77: case 0x78: case 0x79: case 0x7a: case 0x7b: case 0x7c: case 0x7d: case 0x7e: case 0x7f: m_icount -= 1+(code & 0xf); @@ -676,6 +725,18 @@ void vgmplay_device::execute_run() break; } + case 0xb0: + pulse_act_led(LED_RF5C68); + m_io->write_byte(A_RF5C68 + m_file->read_byte(m_pc+1), m_file->read_byte(m_pc+2)); + m_pc += 3; + break; + + case 0xb1: + pulse_act_led(LED_RF5C164); + m_io->write_byte(A_RF5C164 + m_file->read_byte(m_pc+1), m_file->read_byte(m_pc+2)); + m_pc += 3; + break; + case 0xb3: pulse_act_led(LED_GAMEBOY); m_io->write_byte(A_GAMEBOY + m_file->read_byte(m_pc+1), m_file->read_byte(m_pc+2)); @@ -746,6 +807,18 @@ void vgmplay_device::execute_run() m_pc += 4; break; + case 0xc1: + pulse_act_led(LED_RF5C68); + m_io->write_byte(A_RF5C68RAM + m_file->read_word(m_pc+1), m_file->read_byte(m_pc+3)); + m_pc += 4; + break; + + case 0xc2: + pulse_act_led(LED_RF5C164); + m_io->write_byte(A_RF5C164RAM + m_file->read_word(m_pc+1), m_file->read_byte(m_pc+3)); + m_pc += 4; + break; + case 0xc3: { pulse_act_led(LED_MULTIPCM); uint8_t offset = m_file->read_byte(m_pc+1); @@ -1304,6 +1377,10 @@ vgmplay_state::vgmplay_state(const machine_config &mconfig, device_type type, co , m_qsound(*this, "qsound") , m_k051649(*this, "k051649") , m_ga20(*this, "ga20") + , m_rf5c68(*this, "rf5c68") + , m_rf5c164(*this, "rf5c164") + , m_rf5c68_ram(*this, "rf5c68_ram") + , m_rf5c164_ram(*this, "rf5c164_ram") { } @@ -1413,7 +1490,7 @@ void vgmplay_state::machine_start() if (data_start > 0x40) { if(version >= 0x151 && r32(0x40)) - logerror("Warning: file requests an unsupported RF5C68\n"); + m_rf5c68->set_unscaled_clock(r32(0x40)); if(version >= 0x151 && r32(0x44)) { uint32_t clock = r32(0x44); m_ym2203[0]->set_unscaled_clock(clock & ~0x40000000); @@ -1446,7 +1523,7 @@ void vgmplay_state::machine_start() m_ymz280b->set_unscaled_clock(r32(0x68)); } if(version >= 0x151 && r32(0x6c)) - logerror("Warning: file requests an unsupported RF5C164\n"); + m_rf5c164->set_unscaled_clock(r32(0x6c)); if(version >= 0x151 && r32(0x70)) logerror("Warning: file requests an unsupported PWM\n"); if(version >= 0x151 && r32(0x74)) { @@ -1782,6 +1859,10 @@ void vgmplay_state::soundchips_map(address_map &map) map(vgmplay_device::A_QSOUND, vgmplay_device::A_QSOUND+0x2).w(m_qsound, FUNC(qsound_device::qsound_w)); map(vgmplay_device::A_K051649, vgmplay_device::A_K051649+0xf).w(FUNC(vgmplay_state::scc_w)); map(vgmplay_device::A_GA20, vgmplay_device::A_GA20+0x1f).w(m_ga20, FUNC(iremga20_device::irem_ga20_w)); + map(vgmplay_device::A_RF5C68, vgmplay_device::A_RF5C68+0xf).w(m_rf5c68, FUNC(rf5c68_device::rf5c68_w)); + map(vgmplay_device::A_RF5C164, vgmplay_device::A_RF5C164+0xf).w(m_rf5c164, FUNC(rf5c68_device::rf5c68_w)); + map(vgmplay_device::A_RF5C68RAM, vgmplay_device::A_RF5C68RAM+0xffff).w(m_rf5c68, FUNC(rf5c68_device::rf5c68_mem_w)); + map(vgmplay_device::A_RF5C164RAM, vgmplay_device::A_RF5C164RAM+0xffff).w(m_rf5c164, FUNC(rf5c68_device::rf5c68_mem_w)); } void vgmplay_state::segapcm_map(address_map &map) @@ -1854,6 +1935,16 @@ void vgmplay_state::nescpu_map(address_map &map) map(0, 0xffff).ram().share("nesapu_ram"); } +void vgmplay_state::rf5c68_map(address_map &map) +{ + map(0, 0xffff).ram().share("rf5c68_ram"); +} + +void vgmplay_state::rf5c164_map(address_map &map) +{ + map(0, 0xffff).ram().share("rf5c164_ram"); +} + void vgmplay_state::h6280_map(address_map &map) { map(0, 0xffff).noprw(); @@ -2023,6 +2114,16 @@ MACHINE_CONFIG_START(vgmplay_state::vgmplay) m_ga20->set_addrmap(0, &vgmplay_state::ga20_map); m_ga20->add_route(0, "lspeaker", 1); m_ga20->add_route(1, "rspeaker", 1); + + RF5C68(config, m_rf5c68, 12500000); + m_rf5c68->set_addrmap(0, &vgmplay_state::rf5c68_map); + m_rf5c68->add_route(0, "lspeaker", 1); + m_rf5c68->add_route(1, "rspeaker", 1); + + RF5C68(config, m_rf5c164, 12500000); // TODO : !!RF5C164!! + m_rf5c164->set_addrmap(0, &vgmplay_state::rf5c164_map); + m_rf5c164->add_route(0, "lspeaker", 1); + m_rf5c164->add_route(1, "rspeaker", 1); MACHINE_CONFIG_END ROM_START( vgmplay ) diff --git a/src/mame/layout/vgmplay.lay b/src/mame/layout/vgmplay.lay index 5e4b50b7f55..fce8e1a2dfa 100644 --- a/src/mame/layout/vgmplay.lay +++ b/src/mame/layout/vgmplay.lay @@ -59,6 +59,8 @@ + + @@ -116,6 +118,9 @@ + + + @@ -143,6 +148,9 @@ + + +