Skip to content

Commit b4587b3

Browse files
authored
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.
1 parent 3633adc commit b4587b3

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

src/devices/sound/k054539.cpp

+14-21
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ k054539_device::k054539_device(const machine_config &mconfig, const char *tag, d
2525
, flags(0)
2626
, reverb_pos(0)
2727
, cur_ptr(0)
28-
, cur_limit(0)
2928
, rom_addr(0)
3029
, stream(nullptr)
3130
, m_timer(nullptr)
@@ -131,7 +130,7 @@ void k054539_device::sound_stream_update(sound_stream &stream, std::vector<read_
131130
rbase[reverb_pos] = 0;
132131

133132
for(int ch=0; ch<8; ch++)
134-
if(regs[0x22c] & (1<<ch)) {
133+
if(BIT(regs[0x22c], ch)) {
135134
unsigned char *base1 = regs + 0x20*ch;
136135
unsigned char *base2 = regs + 0x200 + 0x2*ch;
137136
channel *chan = channels + ch;
@@ -318,11 +317,11 @@ void k054539_device::init_chip()
318317
memset(posreg_latch, 0, sizeof(posreg_latch)); //*
319318
flags |= UPDATE_AT_KEYON; //* make it default until proven otherwise
320319

321-
ram = std::make_unique<uint8_t []>(0x4000);
320+
ram = std::make_unique<uint8_t []>(0x8000);
322321

323322
reverb_pos = 0;
324323
cur_ptr = 0;
325-
memset(&ram[0], 0, 0x4000);
324+
memset(&ram[0], 0, 0x8000);
326325

327326
stream = stream_alloc(0, 2, clock() / 384);
328327

@@ -333,10 +332,9 @@ void k054539_device::init_chip()
333332
save_item(NAME(flags));
334333

335334
save_item(NAME(regs));
336-
save_pointer(NAME(ram), 0x4000);
335+
save_pointer(NAME(ram), 0x8000);
337336
save_item(NAME(reverb_pos));
338337
save_item(NAME(cur_ptr));
339-
save_item(NAME(cur_limit));
340338
save_item(NAME(rom_addr));
341339

342340
save_item(NAME(m_timer_state));
@@ -433,16 +431,15 @@ void k054539_device::write(offs_t offset, u8 data)
433431
break;
434432

435433
case 0x22d:
436-
if(rom_addr == 0x80)
437-
ram[cur_ptr] = data;
438-
cur_ptr++;
439-
if(cur_ptr == cur_limit)
440-
cur_ptr = 0;
434+
if(rom_addr == 0x80) {
435+
offs_t const addr = (cur_ptr & 0x3fff) | ((cur_ptr & 0x10000) >> 2);
436+
ram[addr] = data;
437+
}
438+
cur_ptr = (cur_ptr + 1) & 0x1ffff;
441439
break;
442440

443441
case 0x22e:
444442
rom_addr = data;
445-
cur_limit = rom_addr == 0x80 ? 0x4000 : 0x20000;
446443
cur_ptr = 0;
447444
break;
448445

@@ -477,21 +474,17 @@ void k054539_device::write(offs_t offset, u8 data)
477474

478475
void k054539_device::device_post_load()
479476
{
480-
cur_limit = rom_addr == 0x80 ? 0x4000 : 0x20000;
481477
}
482478

483479
u8 k054539_device::read(offs_t offset)
484480
{
485481
switch(offset) {
486482
case 0x22d:
487483
if(regs[0x22f] & 0x10) {
488-
uint8_t res = (rom_addr == 0x80) ? ram[cur_ptr] : read_byte((0x20000*rom_addr)+cur_ptr);
489-
if (!machine().side_effects_disabled())
490-
{
491-
cur_ptr++;
492-
if(cur_ptr == cur_limit)
493-
cur_ptr = 0;
494-
}
484+
offs_t const addr = (cur_ptr & 0x3fff) | ((cur_ptr & 0x10000) >> 2);
485+
uint8_t res = (rom_addr == 0x80) ? ram[ram_addr] : read_byte((0x20000*rom_addr) + cur_ptr);
486+
if(!machine().side_effects_disabled())
487+
cur_ptr = (cur_ptr + 1) & 0x1ffff;
495488
return res;
496489
} else
497490
return 0;
@@ -550,7 +543,7 @@ void k054539_device::device_reset()
550543
{
551544
regs[0x22c] = 0;
552545
regs[0x22f] = 0;
553-
memset(&ram[0], 0, 0x4000);
546+
memset(&ram[0], 0, 0x8000);
554547
m_timer->enable(false);
555548
}
556549

src/devices/sound/k054539.h

-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ class k054539_device : public device_t,
9393
int reverb_pos;
9494

9595
int32_t cur_ptr;
96-
int cur_limit;
9796
uint32_t rom_addr;
9897

9998
channel channels[8];

0 commit comments

Comments
 (0)