fix audio in jsrf and some other games

This commit is contained in:
izzy2lost
2026-03-02 12:06:59 -05:00
parent 3c6138faae
commit 0277b66f74
+16
View File
@@ -1030,6 +1030,22 @@ static int voice_get_samples(MCPXAPUState *d, uint32_t v, float samples[][2],
linear_addr += 4;
}
}
/* WAR: Deactivate voice if ADPCM header values are non-zero
* and identical. Something overwrites voice memory region
* before NV1BA0_PIO_VOICE_OFF is set. Mitigates loud
* crackling produced by decoding/playing such data.
*/
uint8_t *adpcm_hdr = (uint8_t *)adpcm_block;
if (adpcm_hdr[0] != 0) {
uint32_t diff = 0;
for (uint8_t i = 1; i < 8; i++) {
diff |= adpcm_hdr[i] ^ adpcm_hdr[0];
}
if (diff == 0) {
voice_off(d, v);
return -1;
}
}
adpcm_decode_block(adpcm_decoded, (uint8_t *)adpcm_block,
block_size, channels);
adpcm_block_index = block_index;