famec hack, CPU debug in CD mode
[picodrive.git] / Pico / sound / sound.c
index f43252f..68106bc 100644 (file)
@@ -220,8 +220,14 @@ PICO_INTERNAL void PsndClear(void)
 {\r
   int len = PsndLen;\r
   if (PsndLen_exc_add) len++;\r
-  if (PicoOpt & 8) memset32((int *) PsndOut, 0, len); // clear both channels at once\r
-  else memset(PsndOut, 0, len<<1);\r
+  if (PicoOpt & 8)\r
+    memset32((int *) PsndOut, 0, len); // assume PsndOut to be aligned\r
+  else {\r
+    short *out = PsndOut;\r
+    if ((int)out & 2) { *out++ = 0; len--; }\r
+    memset32((int *) out, 0, len/2);\r
+    if (len & 1) out[len-1] = 0;\r
+  }\r
 }\r
 \r
 \r