From e0978fa87d22f168ea9c039c6e2c5bf1274ba9e0 Mon Sep 17 00:00:00 2001
From: notaz <notasas@gmail.com>
Date: Tue, 29 Jan 2008 23:29:30 +0000
Subject: [PATCH] bugfix for SIMPLE_WRITE_SOUND

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@342 be3aeb3a-fb24-0410-a615-afba39da0efa
---
 Pico/Pico.c                         | 1 +
 platform/win32/GenaDrive/DSound.cpp | 5 +----
 platform/win32/GenaDrive/Loop.cpp   | 2 +-
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/Pico/Pico.c b/Pico/Pico.c
index 71add131..bf8b707d 100644
--- a/Pico/Pico.c
+++ b/Pico/Pico.c
@@ -256,6 +256,7 @@ static int CheckIdle(void)
 static __inline void getSamples(int y)
 {
 #if SIMPLE_WRITE_SOUND
+  if (y != 224) return;
   PsndRender(0, PsndLen);
   if (PicoWriteSound) PicoWriteSound(PsndLen);
   PsndClear();
diff --git a/platform/win32/GenaDrive/DSound.cpp b/platform/win32/GenaDrive/DSound.cpp
index 05e7f02a..3a38a8d9 100644
--- a/platform/win32/GenaDrive/DSound.cpp
+++ b/platform/win32/GenaDrive/DSound.cpp
@@ -89,10 +89,9 @@ static int WriteSeg()
   // Lock the segment at 'LoopWrite' and copy the next segment in
   LoopBuffer->Lock(LoopWrite<<((PicoOpt&8) ? 2 : 1),PsndLen<<((PicoOpt&8) ? 2 : 1), &mema,&sizea, &memb,&sizeb, 0);
   
-  //dprintf2("lock %p, cpy %x\n", mema, sizea);
-
   if (mema) memcpy(mema,DSoundNext,sizea);
 //  if (memb) memcpy(memb,DSoundNext+sizea,sizeb);
+  if (sizeb != 0) dprintf2("sizeb is not 0! (%i)\n", sizeb);
 
   LoopBuffer->Unlock(mema,sizea, memb,0);
 
@@ -109,8 +108,6 @@ int DSoundUpdate()
   LoopBuffer->GetCurrentPosition(&play,NULL);
   pos=play>>((PicoOpt&8) ? 2 : 1);
 
-  //dprintf2("loop %i pos %i\n", LoopWrite, pos);
-
   // 'LoopWrite' is the next seg in the loop that we want to write
   // First check that the sound 'play' pointer has moved out of it:
   if (pos>=LoopWrite && pos<LoopWrite+PsndLen) return 1; // No, it hasn't
diff --git a/platform/win32/GenaDrive/Loop.cpp b/platform/win32/GenaDrive/Loop.cpp
index b4b3eec3..b19539af 100644
--- a/platform/win32/GenaDrive/Loop.cpp
+++ b/platform/win32/GenaDrive/Loop.cpp
@@ -13,7 +13,7 @@ int LoopInit()
   // bits LSb->MSb:
   // enable_ym2612&dac, enable_sn76496, enable_z80, stereo_sound;
   // alt_renderer, 6button_gamepad, accurate_timing, accurate_sprites
-  PicoOpt=0xbcc7;
+  PicoOpt=0xbccf;
   PsndRate=44100;
 
   // Init Direct3D:
-- 
2.39.5