From 6beaf0b3d77b0087bdfdc1dd00cbc44c7ac4ca02 Mon Sep 17 00:00:00 2001 From: Devin Acker Date: Mon, 19 Dec 2022 21:04:56 -0500 Subject: upd934g: use device_rom_interface instead of a read callback (#10700) --- src/devices/sound/upd934g.cpp | 7 ++---- src/devices/sound/upd934g.h | 7 ++---- src/mame/casio/rz1.cpp | 53 +++++++++++++++++-------------------------- 3 files changed, 25 insertions(+), 42 deletions(-) diff --git a/src/devices/sound/upd934g.cpp b/src/devices/sound/upd934g.cpp index b57886685e1..f3321c70d3d 100644 --- a/src/devices/sound/upd934g.cpp +++ b/src/devices/sound/upd934g.cpp @@ -35,7 +35,7 @@ DEFINE_DEVICE_TYPE(UPD934G, upd934g_device, "upd934g", "NEC uPD934G") upd934g_device::upd934g_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, UPD934G, tag, owner, clock), device_sound_interface(mconfig, *this), - m_data_cb(*this), + device_rom_interface(mconfig, *this), m_stream(nullptr), m_sample(0), m_ready(false) @@ -51,9 +51,6 @@ void upd934g_device::device_start() // create sound stream m_stream = stream_alloc(0, 4, 20000); - // resolve callbacks - m_data_cb.resolve_safe(0); - // register for save states save_pointer(NAME(m_addr), 16); @@ -96,7 +93,7 @@ void upd934g_device::sound_stream_update(sound_stream &stream, std::vector(m_data_cb(m_channel[ch].pos)); + int8_t raw = static_cast(read_byte(m_channel[ch].pos)); // normal, muted, accented const double adjust[] = { 0, 0.7, 0.4, 1.0 }; diff --git a/src/devices/sound/upd934g.h b/src/devices/sound/upd934g.h index 1340dd7bf60..793fa71b162 100644 --- a/src/devices/sound/upd934g.h +++ b/src/devices/sound/upd934g.h @@ -13,12 +13,13 @@ #pragma once +#include "dirom.h" //************************************************************************** // TYPE DEFINITIONS //************************************************************************** -class upd934g_device : public device_t, public device_sound_interface +class upd934g_device : public device_t, public device_sound_interface, public device_rom_interface<16> { public: static constexpr feature_type imperfect_features() { return feature::SOUND; } @@ -26,9 +27,6 @@ public: // construction/destruction upd934g_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - // configuration - auto data_callback() { return m_data_cb.bind(); } - void write(offs_t offset, uint8_t data); protected: @@ -39,7 +37,6 @@ protected: virtual void sound_stream_update(sound_stream &stream, std::vector const &inputs, std::vector &outputs) override; private: - devcb_read8 m_data_cb; sound_stream *m_stream; uint16_t m_addr[16]; diff --git a/src/mame/casio/rz1.cpp b/src/mame/casio/rz1.cpp index aa9eca9848d..ea2c45a3341 100644 --- a/src/mame/casio/rz1.cpp +++ b/src/mame/casio/rz1.cpp @@ -61,7 +61,6 @@ public: m_pg(*this, "pg%u", 0U), m_cassette(*this, "cassette"), m_linein(*this, "linein"), - m_samples(*this, "samples%u", 0U), m_keys(*this, "kc%u", 0U), m_foot(*this, "foot"), m_led_sampling(*this, "led_sampling"), @@ -85,7 +84,6 @@ private: required_device_array m_pg; required_device m_cassette; required_device m_linein; - required_memory_region_array<2> m_samples; required_ioport_array<8> m_keys; required_ioport m_foot; @@ -95,6 +93,8 @@ private: output_finder<> m_led_startstop; void map(address_map &map); + void pg0_map(address_map &map); + void pg1_map(address_map &map); uint8_t key_r(); @@ -102,9 +102,7 @@ private: HD44780_PIXEL_UPDATE(lcd_pixel_update); void leds_w(uint8_t data); - uint8_t upd934g_c_data_r(offs_t offset); void upd934g_c_w(offs_t offset, uint8_t data); - uint8_t upd934g_b_data_r(offs_t offset); void upd934g_b_w(offs_t offset, uint8_t data); uint8_t analog_r(); @@ -136,6 +134,18 @@ void rz1_state::map(address_map &map) map(0xe000, 0xe001).w(FUNC(rz1_state::leds_w)); } +void rz1_state::pg0_map(address_map &map) +{ + map(0x0000, 0x7fff).rom(); + map(0x8000, 0x9fff).ram().share("sample1"); + map(0xa000, 0xbfff).ram().share("sample2"); +} + +void rz1_state::pg1_map(address_map &map) +{ + map(0x0000, 0x7fff).rom(); +} + //************************************************************************** // INPUT PORT DEFINITIONS @@ -277,27 +287,6 @@ void rz1_state::leds_w(uint8_t data) // AUDIO EMULATION //************************************************************************** -uint8_t rz1_state::upd934g_c_data_r(offs_t offset) -{ - if (offset < 0x8000) - return m_samples[1]->base()[offset]; - else - { - if (offset < 0xc000) - return m_maincpu->space(AS_PROGRAM).read_byte(offset + 0x2000); - else - return 0; - } -} - -uint8_t rz1_state::upd934g_b_data_r(offs_t offset) -{ - if (offset < 0x8000) - return m_samples[0]->base()[offset]; - else - return 0; -} - void rz1_state::upd934g_c_w(offs_t offset, uint8_t data) { m_pg[0]->write(offset >> 8, data); @@ -450,10 +439,10 @@ void rz1_state::rz1(machine_config &config) // audio hardware SPEAKER(config, "speaker").front_center(); UPD934G(config, m_pg[0], 1333000); - m_pg[0]->data_callback().set(FUNC(rz1_state::upd934g_c_data_r)); + m_pg[0]->set_addrmap(0, &rz1_state::pg0_map); m_pg[0]->add_route(ALL_OUTPUTS, "speaker", 1.0); UPD934G(config, m_pg[1], 1280000); - m_pg[1]->data_callback().set(FUNC(rz1_state::upd934g_b_data_r)); + m_pg[1]->set_addrmap(0, &rz1_state::pg1_map); m_pg[1]->add_route(ALL_OUTPUTS, "speaker", 1.0); // midi @@ -493,13 +482,13 @@ ROM_START( rz1 ) ROM_REGION(0x4000, "program", 0) ROM_LOAD("program.bin", 0x0000, 0x4000, CRC(b44b2652) SHA1(b77f8daece9adb177b6ce1ef518fc3238b8c0a9c)) - // Toms 1~3, Kick, Snare, Rimshot, Closed Hi-Hat, Open Hi-Hat and Metronome Click - ROM_REGION(0x8000, "samples0", 0) - ROM_LOAD("sound_a.cm5", 0x0000, 0x8000, CRC(c643ff24) SHA1(e886314d22a9a5473bfa2cb237ecafcf0daedfc1)) - // Clap, Ride, Cowbell and Crash - ROM_REGION(0x8000, "samples1", 0) + ROM_REGION(0x8000, "pg0", 0) ROM_LOAD("sound_b.cm6", 0x0000, 0x8000, CRC(ee5b703e) SHA1(cbf2e92c68901f236678d704e9e695a5c84ff49e)) + + // Toms 1~3, Kick, Snare, Rimshot, Closed Hi-Hat, Open Hi-Hat and Metronome Click + ROM_REGION(0x8000, "pg1", 0) + ROM_LOAD("sound_a.cm5", 0x0000, 0x8000, CRC(c643ff24) SHA1(e886314d22a9a5473bfa2cb237ecafcf0daedfc1)) ROM_END -- cgit v1.2.3