@@ -25,7 +25,6 @@ k054539_device::k054539_device(const machine_config &mconfig, const char *tag, d
25
25
, flags(0 )
26
26
, reverb_pos(0 )
27
27
, cur_ptr(0 )
28
- , cur_limit(0 )
29
28
, rom_addr(0 )
30
29
, stream(nullptr )
31
30
, m_timer(nullptr )
@@ -131,7 +130,7 @@ void k054539_device::sound_stream_update(sound_stream &stream, std::vector<read_
131
130
rbase[reverb_pos] = 0 ;
132
131
133
132
for (int ch=0 ; ch<8 ; ch++)
134
- if (regs[0x22c ] & ( 1 << ch)) {
133
+ if (BIT ( regs[0x22c ], ch)) {
135
134
unsigned char *base1 = regs + 0x20 *ch;
136
135
unsigned char *base2 = regs + 0x200 + 0x2 *ch;
137
136
channel *chan = channels + ch;
@@ -318,11 +317,11 @@ void k054539_device::init_chip()
318
317
memset (posreg_latch, 0 , sizeof (posreg_latch)); // *
319
318
flags |= UPDATE_AT_KEYON; // * make it default until proven otherwise
320
319
321
- ram = std::make_unique<uint8_t []>(0x4000 );
320
+ ram = std::make_unique<uint8_t []>(0x8000 );
322
321
323
322
reverb_pos = 0 ;
324
323
cur_ptr = 0 ;
325
- memset (&ram[0 ], 0 , 0x4000 );
324
+ memset (&ram[0 ], 0 , 0x8000 );
326
325
327
326
stream = stream_alloc (0 , 2 , clock () / 384 );
328
327
@@ -333,10 +332,9 @@ void k054539_device::init_chip()
333
332
save_item (NAME (flags));
334
333
335
334
save_item (NAME (regs));
336
- save_pointer (NAME (ram), 0x4000 );
335
+ save_pointer (NAME (ram), 0x8000 );
337
336
save_item (NAME (reverb_pos));
338
337
save_item (NAME (cur_ptr));
339
- save_item (NAME (cur_limit));
340
338
save_item (NAME (rom_addr));
341
339
342
340
save_item (NAME (m_timer_state));
@@ -433,16 +431,15 @@ void k054539_device::write(offs_t offset, u8 data)
433
431
break ;
434
432
435
433
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 ;
441
439
break ;
442
440
443
441
case 0x22e :
444
442
rom_addr = data;
445
- cur_limit = rom_addr == 0x80 ? 0x4000 : 0x20000 ;
446
443
cur_ptr = 0 ;
447
444
break ;
448
445
@@ -477,21 +474,17 @@ void k054539_device::write(offs_t offset, u8 data)
477
474
478
475
void k054539_device::device_post_load ()
479
476
{
480
- cur_limit = rom_addr == 0x80 ? 0x4000 : 0x20000 ;
481
477
}
482
478
483
479
u8 k054539_device::read (offs_t offset)
484
480
{
485
481
switch (offset) {
486
482
case 0x22d :
487
483
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 ;
495
488
return res;
496
489
} else
497
490
return 0 ;
@@ -550,7 +543,7 @@ void k054539_device::device_reset()
550
543
{
551
544
regs[0x22c ] = 0 ;
552
545
regs[0x22f ] = 0 ;
553
- memset (&ram[0 ], 0 , 0x4000 );
546
+ memset (&ram[0 ], 0 , 0x8000 );
554
547
m_timer->enable (false );
555
548
}
556
549
0 commit comments