win32 stuff, SIMPLE_WRITE_SOUND
[picodrive.git] / platform / win32 / GenaDrive / DSound.cpp
index 5c9cc0c..05e7f02 100644 (file)
@@ -45,7 +45,7 @@ int DSoundInit()
   wfx.nAvgBytesPerSec=wfx.nBlockAlign*wfx.nSamplesPerSec;\r
 \r
   // Make buffer for the next seg to put into the loop:\r
-  DSoundNext=(short *)malloc(PsndLen<<2); if (DSoundNext==NULL) return 1;\r
+  DSoundNext=(short *)malloc((PsndLen<<2)+64); if (DSoundNext==NULL) return 1;\r
   memset(DSoundNext,0,PsndLen<<2);\r
 \r
   // Create the DirectSound interface:\r
@@ -89,7 +89,10 @@ static int WriteSeg()
   // Lock the segment at 'LoopWrite' and copy the next segment in\r
   LoopBuffer->Lock(LoopWrite<<((PicoOpt&8) ? 2 : 1),PsndLen<<((PicoOpt&8) ? 2 : 1), &mema,&sizea, &memb,&sizeb, 0);\r
   \r
+  //dprintf2("lock %p, cpy %x\n", mema, sizea);\r
+\r
   if (mema) memcpy(mema,DSoundNext,sizea);\r
+//  if (memb) memcpy(memb,DSoundNext+sizea,sizeb);\r
 \r
   LoopBuffer->Unlock(mema,sizea, memb,0);\r
 \r
@@ -106,6 +109,8 @@ int DSoundUpdate()
   LoopBuffer->GetCurrentPosition(&play,NULL);\r
   pos=play>>((PicoOpt&8) ? 2 : 1);\r
 \r
+  //dprintf2("loop %i pos %i\n", LoopWrite, pos);\r
+\r
   // 'LoopWrite' is the next seg in the loop that we want to write\r
   // First check that the sound 'play' pointer has moved out of it:\r
   if (pos>=LoopWrite && pos<LoopWrite+PsndLen) return 1; // No, it hasn't\r