From b4587b38ac86fcb5ba9637cbb4969e3ea350efb5 Mon Sep 17 00:00:00 2001 From: JOTEGO Date: Sun, 6 Oct 2024 16:45:50 +0200 Subject: sound/k054539.cpp: Corrected reverb RAM size and addressing. (#12856) Top address bit for the 32K RAM is bit 16, rather than the intuitive bit 14. --- src/devices/sound/k054539.cpp | 35 ++++++++++++++--------------------- src/devices/sound/k054539.h | 1 - 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/devices/sound/k054539.cpp b/src/devices/sound/k054539.cpp index 59f9cf2ae2e..126141c9a9c 100644 --- a/src/devices/sound/k054539.cpp +++ b/src/devices/sound/k054539.cpp @@ -25,7 +25,6 @@ k054539_device::k054539_device(const machine_config &mconfig, const char *tag, d , flags(0) , reverb_pos(0) , cur_ptr(0) - , cur_limit(0) , rom_addr(0) , stream(nullptr) , m_timer(nullptr) @@ -131,7 +130,7 @@ void k054539_device::sound_stream_update(sound_stream &stream, std::vector(0x4000); + ram = std::make_unique(0x8000); reverb_pos = 0; cur_ptr = 0; - memset(&ram[0], 0, 0x4000); + memset(&ram[0], 0, 0x8000); stream = stream_alloc(0, 2, clock() / 384); @@ -333,10 +332,9 @@ void k054539_device::init_chip() save_item(NAME(flags)); save_item(NAME(regs)); - save_pointer(NAME(ram), 0x4000); + save_pointer(NAME(ram), 0x8000); save_item(NAME(reverb_pos)); save_item(NAME(cur_ptr)); - save_item(NAME(cur_limit)); save_item(NAME(rom_addr)); save_item(NAME(m_timer_state)); @@ -433,16 +431,15 @@ void k054539_device::write(offs_t offset, u8 data) break; case 0x22d: - if(rom_addr == 0x80) - ram[cur_ptr] = data; - cur_ptr++; - if(cur_ptr == cur_limit) - cur_ptr = 0; + if(rom_addr == 0x80) { + offs_t const addr = (cur_ptr & 0x3fff) | ((cur_ptr & 0x10000) >> 2); + ram[addr] = data; + } + cur_ptr = (cur_ptr + 1) & 0x1ffff; break; case 0x22e: rom_addr = data; - cur_limit = rom_addr == 0x80 ? 0x4000 : 0x20000; cur_ptr = 0; break; @@ -477,7 +474,6 @@ void k054539_device::write(offs_t offset, u8 data) void k054539_device::device_post_load() { - cur_limit = rom_addr == 0x80 ? 0x4000 : 0x20000; } u8 k054539_device::read(offs_t offset) @@ -485,13 +481,10 @@ u8 k054539_device::read(offs_t offset) switch(offset) { case 0x22d: if(regs[0x22f] & 0x10) { - uint8_t res = (rom_addr == 0x80) ? ram[cur_ptr] : read_byte((0x20000*rom_addr)+cur_ptr); - if (!machine().side_effects_disabled()) - { - cur_ptr++; - if(cur_ptr == cur_limit) - cur_ptr = 0; - } + offs_t const addr = (cur_ptr & 0x3fff) | ((cur_ptr & 0x10000) >> 2); + uint8_t res = (rom_addr == 0x80) ? ram[ram_addr] : read_byte((0x20000*rom_addr) + cur_ptr); + if(!machine().side_effects_disabled()) + cur_ptr = (cur_ptr + 1) & 0x1ffff; return res; } else return 0; @@ -550,7 +543,7 @@ void k054539_device::device_reset() { regs[0x22c] = 0; regs[0x22f] = 0; - memset(&ram[0], 0, 0x4000); + memset(&ram[0], 0, 0x8000); m_timer->enable(false); } diff --git a/src/devices/sound/k054539.h b/src/devices/sound/k054539.h index 4f7615a3769..70df821dd2f 100644 --- a/src/devices/sound/k054539.h +++ b/src/devices/sound/k054539.h @@ -93,7 +93,6 @@ private: int reverb_pos; int32_t cur_ptr; - int cur_limit; uint32_t rom_addr; channel channels[8]; -- cgit v1.2.3