ks0164: Fix registers on nonloop so that the voice is freed correctly. Bonus usage debug output, to be removed at some point

This commit is contained in:
Olivier Galibert 2023-10-29 18:56:35 +01:00
parent 2d318f541a
commit 29f91ef4ec
2 changed files with 27 additions and 2 deletions

View File

@ -608,7 +608,7 @@ void ks0164_cpu_device::execute_run()
case 1: { case 1: {
// Neg/not // Neg/not
// 1101 .rrr Ssss .101 // 1101 .rrr S... .101
u16 v = m_r[(opcode >> 8) & 7]; u16 v = m_r[(opcode >> 8) & 7];
if(opcode & 0x0080) if(opcode & 0x0080)

View File

@ -463,12 +463,31 @@ void ks0164_device::cpu_map(address_map &map)
void ks0164_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) void ks0164_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{ {
static std::string rrx = "";
for(int sample = 0; sample != outputs[0].samples(); sample++) { for(int sample = 0; sample != outputs[0].samples(); sample++) {
s32 suml = 0, sumr = 0; s32 suml = 0, sumr = 0;
std::string rrr = "";
for(int voice = 0; voice < 0x20; voice++) { for(int voice = 0; voice < 0x20; voice++) {
{
int adr = 0xe000 + 0x8e * voice;
u16 org = m_cpu->space(AS_PROGRAM).read_word(adr + 4);
if(org == 0x0000)
rrr += '?';
else if(org == 0xf1de)
rrr += '.';
else if(org == 0xf1e2)
rrr += '#';
else if(org == 0xf1ea)
rrr += '3';
else if(org == 0xf1e6)
rrr += '4';
else {
logerror("%04x\n", org);
exit(0);
}
}
u16 *regs = m_sregs[voice]; u16 *regs = m_sregs[voice];
if(regs[0] & 0x0001) { if(regs[0] & 0x0001) {
u64 current = (u64(regs[1]) << 32) | (u64(regs[2]) << 16) | regs[3]; u64 current = (u64(regs[1]) << 32) | (u64(regs[2]) << 16) | regs[3];
u32 adr = current >> 16; u32 adr = current >> 16;
s16 samp0, samp1; s16 samp0, samp1;
@ -504,6 +523,8 @@ void ks0164_device::sound_stream_update(sound_stream &stream, std::vector<read_s
current = current - end + loop; current = current - end + loop;
} else { } else {
regs[0] = ~1; regs[0] = ~1;
regs[0xc] = 0;
regs[0x10] = regs[0x12] = regs[0x14] = regs[0x16] = 0;
} }
} }
regs[1] = current >> 32; regs[1] = current >> 32;
@ -522,6 +543,10 @@ void ks0164_device::sound_stream_update(sound_stream &stream, std::vector<read_s
} }
} }
} }
if(rrr != rrx) {
logerror("inuse %s\n", rrr);
rrx = rrr;
}
outputs[0].put_int(sample, suml, 32768 * 32); outputs[0].put_int(sample, suml, 32768 * 32);
outputs[1].put_int(sample, sumr, 32768 * 32); outputs[1].put_int(sample, sumr, 32768 * 32);
} }