win32 stuff, SIMPLE_WRITE_SOUND
[picodrive.git] / Pico / sound / sound.c
index d901a1d..64e172a 100644 (file)
@@ -15,6 +15,8 @@
 #include "../cd/pcm.h"\r
 #include "mix.h"\r
 \r
+void (*PsndMix_32_to_16l)(short *dest, int *src, int count) = mix_32_to_16l_stereo;\r
+\r
 // master int buffer to mix to\r
 static int PsndBuffer[2*44100/50];\r
 \r
@@ -151,6 +153,9 @@ void PsndRerate(int preserve_state)
   memset32(PsndBuffer, 0, sizeof(PsndBuffer)/4);\r
   if (PsndOut)\r
     PsndClear();\r
+\r
+  // set mixer\r
+  PsndMix_32_to_16l = (PicoOpt & 8) ? mix_32_to_16l_stereo : mix_32_to_16_mono;\r
 }\r
 \r
 \r
@@ -227,6 +232,7 @@ PICO_INTERNAL int PsndRender(int offset, int length)
   int do_pcm = (PicoMCD&1) && (PicoOpt&0x400) && (Pico_mcd->pcm.control & 0x80) && Pico_mcd->pcm.enabled;\r
   offset <<= stereo;\r
 \r
+#if !SIMPLE_WRITE_SOUND\r
   if (offset == 0) { // should happen once per frame\r
     // compensate for float part of PsndLen\r
     PsndLen_exc_cnt += PsndLen_exc_add;\r
@@ -235,6 +241,7 @@ PICO_INTERNAL int PsndRender(int offset, int length)
       length++;\r
     }\r
   }\r
+#endif\r
 \r
   // PSG\r
   if (PicoOpt & 2)\r
@@ -260,9 +267,7 @@ PICO_INTERNAL int PsndRender(int offset, int length)
     mp3_update(buf32, length, stereo);\r
 \r
   // convert + limit to normal 16bit output\r
-  if (stereo)\r
-       mix_32_to_16l_stereo(PsndOut+offset, buf32, length);\r
-  else mix_32_to_16_mono   (PsndOut+offset, buf32, length);\r
+  PsndMix_32_to_16l(PsndOut+offset, buf32, length);\r
 \r
   return length;\r
 }\r
@@ -372,7 +377,7 @@ PICO_INTERNAL void z80_init(void)
   memset(&CZ80, 0, sizeof(CZ80));\r
   Cz80_Init(&CZ80);\r
   Cz80_Set_Fetch(&CZ80, 0x0000, 0x1fff, (UINT32)Pico.zram); // main RAM\r
-  Cz80_Set_Fetch(&CZ80, 0x2000, 0x3fff, (UINT32)Pico.zram - 0x2000); // mirror\r
+  Cz80_Set_Fetch(&CZ80, 0x2000, 0x3fff, (UINT32)Pico.zram); // mirror\r
   Cz80_Set_ReadB(&CZ80, (UINT8 (*)(UINT32 address))z80_read); // unused (hacked in)\r
   Cz80_Set_WriteB(&CZ80, z80_write);\r
   Cz80_Set_INPort(&CZ80, z80_in);\r
@@ -395,6 +400,9 @@ PICO_INTERNAL void z80_reset(void)
   drZ80.Z80SP = drZ80.z80_rebaseSP(0x2000); // 0xf000 ?\r
 #elif defined(_USE_CZ80)\r
   Cz80_Reset(&CZ80);\r
+  Cz80_Set_Reg(&CZ80, CZ80_IX, 0xffff);\r
+  Cz80_Set_Reg(&CZ80, CZ80_IY, 0xffff);\r
+  Cz80_Set_Reg(&CZ80, CZ80_SP, 0x2000);\r
 #endif\r
   Pico.m.z80_fakeval = 0; // for faking when Z80 is disabled\r
 }\r