changeset 2434:2ee25a487e2b

Fix some Pico ADPCM behaviors
author Michael Pavone <pavone@retrodev.com>
date Thu, 08 Feb 2024 20:44:44 -0800
parents 2907c3312423
children b8d894f7f9dc
files pico_pcm.c
diffstat 1 files changed, 17 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pico_pcm.c	Thu Feb 08 20:24:37 2024 -0800
+++ b/pico_pcm.c	Thu Feb 08 20:44:44 2024 -0800
@@ -101,9 +101,23 @@
 		}
 #endif
 		render_put_mono_sample(pcm->audio, (pcm->output >> shift) * 32);
+		if (pcm->ctrl & PCM_RESET) {
+			//Anpanman Pico: Waku Waku Pan Koujou seems to expect the BUSY/RESET flag
+			//to be set for a while after reset
+			if (pcm->counter) {
+				pcm->counter--;
+				continue;
+			} else {
+				pcm->ctrl &= ~PCM_RESET;
+			}
+		}
+		/*
+		Unclear what this bit is actually supposed to do
+		But some games expect ADPCM to work with it cleared
+		Anpanman Pico: Waku Waku Pan Koujou sets the ctrl reg to $6040
 		if (!(pcm->ctrl & PCM_ENABLED)) {
 			continue;
-		}
+		}*/
 		if (pcm->counter) {
 			pcm->counter--;
 		} else if (pcm->samples) {
@@ -172,9 +186,9 @@
 {
 	if (value & PCM_RESET) {
 		pico_pcm_reset(pcm);
+		pcm->counter = 2;
 	}
-	pcm->ctrl &= 0x8000;
-	pcm->ctrl |= value & ~PCM_RESET;
+	pcm->ctrl = value;
 	//TODO: update low-pass filter
 }