diff options
author | AJR <ajrhacker@users.noreply.github.com> | 2020-08-29 12:36:31 -0400 |
---|---|---|
committer | AJR <ajrhacker@users.noreply.github.com> | 2020-08-29 12:36:31 -0400 |
commit | e4b567a398ed93e9deaffeb60e3e714bf11068ec (patch) | |
tree | 57d4b4a1642c3206872f480e0b7826e780f2e5ca /src/mame/audio | |
parent | 8fa5f43c9c2c9f58bbb70a98edd83e9d4f99ab4f (diff) |
rax: Modernize RAM allocation and object lookups
Diffstat (limited to 'src/mame/audio')
-rw-r--r-- | src/mame/audio/rax.cpp | 45 | ||||
-rw-r--r-- | src/mame/audio/rax.h | 12 |
2 files changed, 31 insertions, 26 deletions
diff --git a/src/mame/audio/rax.cpp b/src/mame/audio/rax.cpp index 7eabb69f11d..1255be6efa3 100644 --- a/src/mame/audio/rax.cpp +++ b/src/mame/audio/rax.cpp @@ -111,7 +111,7 @@ void acclaim_rax_device::adsp_control_w(offs_t offset, uint16_t data) { m_control_regs[BDMA_WORD_COUNT_REG] = data & 0x3fff; - const uint8_t * adsp_rom = m_rom + m_rom_bank * 0x400000; + const uint8_t *adsp_rom = &m_rom[m_rom_bank * 0x400000]; uint32_t page = (m_control_regs[BDMA_CONTROL_REG] >> 8) & 0xff; uint32_t dir = (m_control_regs[BDMA_CONTROL_REG] >> 2) & 1; @@ -184,7 +184,7 @@ void acclaim_rax_device::adsp_control_w(offs_t offset, uint16_t data) /* autobuffer off: nuke the timer, and disable the DAC */ if ((data & 0x0002) == 0) { - dmadac_enable(&m_dmadac[1], 1, 0); + m_dmadac[1]->enable(0); } break; @@ -192,8 +192,8 @@ void acclaim_rax_device::adsp_control_w(offs_t offset, uint16_t data) /* autobuffer off: nuke the timer, and disable the DAC */ if ((data & 0x0002) == 0) { - dmadac_enable(&m_dmadac[0], 1, 0); - m_reg_timer[0]->reset(); + m_dmadac[0]->enable(0); + m_reg_timer->reset(); } break; @@ -297,19 +297,12 @@ void acclaim_rax_device::adsp_io_map(address_map &map) void acclaim_rax_device::device_start() { - m_rom = (uint8_t *)machine().root_device().memregion("rax")->base(); - m_program = &m_cpu->space(AS_PROGRAM); m_data = &m_cpu->space(AS_DATA); - m_dmadac[0] = subdevice<dmadac_sound_device>("dacl"); - m_dmadac[1] = subdevice<dmadac_sound_device>("dacr"); - - m_reg_timer[0] = subdevice<timer_device>("adsp_reg_timer0"); - m_dma_timer = subdevice<timer_device>("adsp_dma_timer"); - // 1 bank for internal - membank("databank")->configure_entries(0, 5, auto_alloc_array(machine(), uint16_t, 0x2000 * 5), 0x2000*sizeof(uint16_t)); + m_banked_ram = make_unique_clear<uint16_t[]>(0x2000 * 5); + membank("databank")->configure_entries(0, 5, &m_banked_ram[0], 0x2000*sizeof(uint16_t)); } void acclaim_rax_device::device_reset() @@ -362,7 +355,11 @@ void acclaim_rax_device::adsp_irq(int which) reg += m_incs[which]; } - dmadac_transfer(&m_dmadac[0], 2, 1, 2, count/2, buffer); + for (int i = 0; i < 2; i++) + { + m_dmadac[i]->flush(); + m_dmadac[i]->transfer(i, 1, 2, count/2, buffer); + } /* check for wrapping */ if (reg >= m_ireg_base[which] + m_size[which]) @@ -390,14 +387,17 @@ void acclaim_rax_device::recompute_sample_rate(int which) /* now put it down to samples, so we know what the channel frequency has to be */ sample_period = sample_period * (16 * 1); - dmadac_set_frequency(&m_dmadac[0], 2, sample_period.as_hz()); - dmadac_enable(&m_dmadac[0], 2, 1); + for (auto &dmadac : m_dmadac) + { + dmadac->set_frequency(sample_period.as_hz()); + dmadac->enable(1); + } /* fire off a timer which will hit every half-buffer */ if (m_incs[which]) { attotime period = (sample_period * m_size[which]) / (4 * 2 * m_incs[which]); - m_reg_timer[which]->adjust(period, 0, period); + m_reg_timer->adjust(period, 0, period); } } @@ -449,10 +449,11 @@ void acclaim_rax_device::adsp_sound_tx_callback(offs_t offset, uint32_t data) } /* if we get there, something went wrong. Disable playing */ - dmadac_enable(&m_dmadac[0], 2, 0); + for (auto &dmadac : m_dmadac) + dmadac->enable(0); /* remove timer */ - m_reg_timer[which]->reset(); + m_reg_timer->reset(); } void acclaim_rax_device::dmovlay_callback(uint32_t data) @@ -478,8 +479,12 @@ DEFINE_DEVICE_TYPE(ACCLAIM_RAX, acclaim_rax_device, "rax_audio", "Acclaim RAX") acclaim_rax_device::acclaim_rax_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, ACCLAIM_RAX, tag, owner, clock) , m_cpu(*this, "adsp") + , m_dmadac(*this, { "dacl", "dacr" }) + , m_reg_timer(*this, "adsp_reg_timer") + , m_dma_timer(*this, "adsp_dma_timer") , m_adsp_pram(*this, "adsp_pram") , m_adsp_data_bank(*this, "databank") + , m_rom(*this, DEVICE_SELF) , m_data_in(*this, "data_in") , m_data_out(*this, "data_out") { @@ -499,7 +504,7 @@ void acclaim_rax_device::device_add_mconfig(machine_config &config) m_cpu->set_addrmap(AS_DATA, &acclaim_rax_device::adsp_data_map); m_cpu->set_addrmap(AS_IO, &acclaim_rax_device::adsp_io_map); - TIMER(config, "adsp_reg_timer0").configure_generic(FUNC(acclaim_rax_device::adsp_irq0)); + TIMER(config, "adsp_reg_timer").configure_generic(FUNC(acclaim_rax_device::adsp_irq0)); TIMER(config, "adsp_dma_timer").configure_generic(FUNC(acclaim_rax_device::dma_timer_callback)); GENERIC_LATCH_16(config, m_data_in); diff --git a/src/mame/audio/rax.h b/src/mame/audio/rax.h index 362ca555fd7..957fa923b9e 100644 --- a/src/mame/audio/rax.h +++ b/src/mame/audio/rax.h @@ -42,8 +42,12 @@ protected: private: required_device<adsp2181_device> m_cpu; + required_device_array<dmadac_sound_device, 2> m_dmadac; + required_device<timer_device> m_reg_timer; + required_device<timer_device> m_dma_timer; required_shared_ptr<uint32_t> m_adsp_pram; required_memory_bank m_adsp_data_bank; + required_region_ptr<uint8_t> m_rom; uint32_t m_adsp_snd_pf0; @@ -59,15 +63,11 @@ private: address_space *m_data; uint16_t m_control_regs[32]; - uint8_t* m_rom; /* sound output */ uint16_t m_size[2]; uint16_t m_incs[2]; - dmadac_sound_device *m_dmadac[2]; - timer_device *m_reg_timer[2]; - timer_device *m_sport_timer; uint32_t m_ireg[2]; uint16_t m_ireg_base[2]; @@ -75,11 +75,11 @@ private: uint32_t m_rom_bank; uint32_t m_dmovlay_val; + std::unique_ptr<uint16_t[]> m_banked_ram; + required_device<generic_latch_16_device> m_data_in; required_device<generic_latch_16_device> m_data_out; - timer_device *m_dma_timer; - void adsp_sound_tx_callback(offs_t offset, uint32_t data); TIMER_DEVICE_CALLBACK_MEMBER(adsp_irq0); |