- Remove multithreading from windows user interface after finding several synchronization issues

- Add AVI recording to windows
- Rework SPU to run two cores (one for emulation and one for audible output.)
This commit is contained in:
zeromus 2008-09-25 07:44:18 +00:00
parent bd398a715b
commit c42e035d50
16 changed files with 3887 additions and 3243 deletions

View File

@ -17,6 +17,8 @@
- Change savestate code to support loosely bound chunks and more easily other parts of the emu (GE, GPU).
The savestate format is changed, but from now on it is in principle more resilient (it will continue to break though) [zeromus]
- Remove 16MB of WRAM at 0x01****** from arm9. Maped to unusued instead. What was this? [zeromus]
- Change SPU to run two spus in parallel. SPU_core is the official one. SPU_user produces output.
This lets us do inaccurate things with SPU_user which might sound better while being more accurate with SPU_core. [zeromus]
Mac OS X port:
- Fixed: Filenames and paths with unicode characters now work. [Jeff]
- Fixed: Load state from file button works again. [Jeff]
@ -62,6 +64,8 @@
- Fix the buggy auto frameskip logic which made the emu slow to a crawl. Now it runs fast! [zeromus]
- Fix resizing, rotate & aspect ration of main window. Add save window position and parameters [CrazyMax]
- Rewrite all debug tools (autoupdate work now) [CrazyMax]
- Add AVI output [zeromus]
- Remove multithreading from user interface after finding several synchronization issues [zeromus]
0.7.3 -> 0.8
Cocoa:

View File

@ -169,7 +169,7 @@ int NDS_Init( void) {
armcpu_new(&NDS_ARM9,0);
#endif
if (SPU_Init(SNDCORE_DUMMY, 735) != 0)
if (SPU_Init(SNDCORE_DUMMY, 740) != 0)
return -1;
#ifdef EXPERIMENTAL_WIFI

File diff suppressed because it is too large Load Diff

View File

@ -42,7 +42,7 @@ typedef struct
extern SoundInterface_struct SNDDummy;
extern SoundInterface_struct SNDFile;
typedef struct
struct channel_struct
{
u8 vol;
u8 datashift;
@ -64,19 +64,26 @@ typedef struct
int lastsampcnt;
s16 pcm16b, pcm16b_last;
int index;
} channel_struct;
} ;
typedef struct
class SPU_struct
{
public:
SPU_struct(int buffersize);
u32 bufpos;
u32 buflength;
s32 *sndbuf;
s16 *outbuf;
u32 bufsize;
channel_struct chan[16];
} SPU_struct;
channel_struct channels[16];
extern SPU_struct *SPU;
void reset();
~SPU_struct();
void KeyOn(int channel);
void WriteByte(u32 addr, u8 val);
void WriteWord(u32 addr, u16 val);
void WriteLong(u32 addr, u32 val);
};
int SPU_ChangeSoundCore(int coreid, int buffersize);
SoundInterface_struct *SPU_SoundCore();
@ -91,6 +98,10 @@ void SPU_WriteByte(u32 addr, u8 val);
void SPU_WriteWord(u32 addr, u16 val);
void SPU_WriteLong(u32 addr, u32 val);
u32 SPU_ReadLong(u32 addr);
void SPU_Emulate(void);
void SPU_Emulate_core(void);
void SPU_Emulate_user(void);
extern SPU_struct *SPU_core;
extern int spu_core_samples;
#endif

View File

@ -760,7 +760,8 @@ int main(int argc, char ** argv) {
update_keypad(keypad); /* Update keypad */
last_cycle = NDS_exec((560190 << 1) - last_cycle, FALSE);
SPU_Emulate();
SPU_Emulate_user();
SPU_Emulate_core();
#ifdef INCLUDE_OPENGL_2D
if ( my_config.opengl_2d) {

View File

@ -1282,7 +1282,10 @@ bool opengl_init()
[sound_lock lock];
int x;
for(x = 0; x <= frames_to_skip; x++)
SPU_Emulate();
{
SPU_Emulate_user();
SPU_Emulate_core();
}
[sound_lock unlock];
[execution_lock unlock];

View File

@ -117,7 +117,8 @@ void desmume_cycle()
update_keypad(keypad);
desmume_last_cycle = NDS_exec((560190 << 1) - desmume_last_cycle, FALSE);
SPU_Emulate();
SPU_Emulate_user();
SPU_Emulate_core();
}

View File

@ -82,6 +82,7 @@ void desmume_cycle( void)
update_keypad(keypad);
desmume_last_cycle = NDS_exec((560190 << 1) - desmume_last_cycle, FALSE);
SPU_Emulate();
SPU_Emulate_user();
SPU_Emulate_core();
}

View File

@ -73,7 +73,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2005-x32.lib zziplib-2005-x32.lib"
AdditionalDependencies="vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2005-x32.lib zziplib-2005-x32.lib"
OutputFile="$(OutDir)\$(ProjectName)_debug.exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
GenerateDebugInformation="true"
@ -105,6 +105,182 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)\__bins"
IntermediateDirectory="$(SolutionDir)\.VS2005\$(ConfigurationName)\$(PlatformName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="MASM"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="..;.\zlib123;.\zziplib"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;Release\&quot;;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;BETA_VERSION;SPU_INTERPOLATE;NOMINMAX"
StringPooling="true"
ExceptionHandling="1"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="0"
FloatingPointModel="2"
WarningLevel="1"
DebugInformationFormat="3"
CallingConvention="1"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2005-x32.lib zziplib-2005-x32.lib"
OutputFile="$(OutDir)\$(ProjectName).exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
GenerateDebugInformation="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
AdditionalManifestFiles="DeSmuME_x86.manifest"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release (SSE2)|Win32"
OutputDirectory="$(SolutionDir)\__bins"
IntermediateDirectory="$(SolutionDir)\.VS2005\$(ConfigurationName)\$(PlatformName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="MASM"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="..;.\zlib123;.\zziplib"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;Release SSE2\&quot;;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;SSE2;BETA_VERSION;SPU_INTERPOLATE;NOMINMAX"
StringPooling="true"
ExceptionHandling="1"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="2"
FloatingPointModel="2"
WarningLevel="1"
DebugInformationFormat="3"
CallingConvention="1"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="vfw32.lib winmm.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2005-x32.lib zziplib-2005-x32.lib"
OutputFile="$(OutDir)\$(ProjectName)_sse2.exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
GenerateDebugInformation="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
AdditionalManifestFiles="DeSmuME_x86.manifest"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)\__bins"
@ -192,94 +368,6 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)\__bins"
IntermediateDirectory="$(SolutionDir)\.VS2005\$(ConfigurationName)\$(PlatformName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="MASM"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="..;.\zlib123;.\zziplib"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;Release\&quot;;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;BETA_VERSION;SPU_INTERPOLATE;NOMINMAX"
StringPooling="true"
ExceptionHandling="1"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="0"
FloatingPointModel="2"
WarningLevel="1"
DebugInformationFormat="3"
CallingConvention="1"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2005-x32.lib zziplib-2005-x32.lib"
OutputFile="$(OutDir)\$(ProjectName).exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
GenerateDebugInformation="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
AdditionalManifestFiles="DeSmuME_x86.manifest"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)\__bins"
@ -366,94 +454,6 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release (SSE2)|Win32"
OutputDirectory="$(SolutionDir)\__bins"
IntermediateDirectory="$(SolutionDir)\.VS2005\$(ConfigurationName)\$(PlatformName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="MASM"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="..;.\zlib123;.\zziplib"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;Release SSE2\&quot;;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;SSE2;BETA_VERSION;SPU_INTERPOLATE;NOMINMAX"
StringPooling="true"
ExceptionHandling="1"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="2"
FloatingPointModel="2"
WarningLevel="1"
DebugInformationFormat="3"
CallingConvention="1"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2005-x32.lib zziplib-2005-x32.lib"
OutputFile="$(OutDir)\$(ProjectName)_sse2.exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
GenerateDebugInformation="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
AdditionalManifestFiles="DeSmuME_x86.manifest"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release (SSE2)|x64"
OutputDirectory="$(SolutionDir)\__bins"
@ -555,6 +555,10 @@
RelativePath=".\AboutBox.h"
>
</File>
<File
RelativePath=".\aviout.cpp"
>
</File>
<File
RelativePath=".\colorctrl.cpp"
>
@ -891,14 +895,6 @@
Name="MASM"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="MASM"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
@ -911,7 +907,7 @@
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
Name="Release (SSE2)|Win32"
ExcludedFromBuild="true"
>
<Tool
@ -922,7 +918,15 @@
/>
</FileConfiguration>
<FileConfiguration
Name="Release (SSE2)|Win32"
Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="MASM"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
ExcludedFromBuild="true"
>
<Tool
@ -955,7 +959,7 @@
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
@ -963,7 +967,7 @@
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
@ -1019,6 +1023,10 @@
RelativePath="..\NDSSystem.h"
>
</File>
<File
RelativePath=".\NintendoDS(tm)_logo.bmp"
>
</File>
<File
RelativePath="..\OGLRender.cpp"
>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="shift_jis"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Version="9.00"
Name="DeSmuME_VS2008"
ProjectGUID="{9F5F72A1-D3A5-4918-B460-E076B16D10A9}"
RootNamespace="DeSmuME"
@ -74,7 +74,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="comctl32.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib"
AdditionalDependencies="vfw32.lib winmm.lib comctl32.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib"
OutputFile="$(OutDir)\$(ProjectName)_debug.exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
GenerateDebugInformation="true"
@ -105,184 +105,6 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release (SSE2)|Win32"
OutputDirectory="$(SolutionDir)\__bins"
IntermediateDirectory="$(SolutionDir)\.VS2008\$(ConfigurationName)\$(PlatformName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="MASM"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="..;.\zlib123;.\zziplib"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;SSE2\&quot;;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;SSE2;BETA_VERSION;SPU_INTERPOLATE;NOMINMAX"
StringPooling="true"
ExceptionHandling="1"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="2"
FloatingPointModel="2"
WarningLevel="1"
DebugInformationFormat="3"
CallingConvention="1"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="comctl32.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2008-x32.lib zziplib-2008-x32.lib"
OutputFile="$(OutDir)\$(ProjectName)_sse2.exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
GenerateDebugInformation="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
Profile="false"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
AdditionalManifestFiles="DeSmuME_x86.manifest"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)\__bins"
IntermediateDirectory="$(SolutionDir)\.VS2008\$(ConfigurationName)\$(PlatformName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="MASM"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="..;.\zlib123;.\zziplib"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;0.8.0b2\&quot;;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;BETA_VERSION;SPU_INTERPOLATE;NOMINMAX"
StringPooling="true"
ExceptionHandling="1"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="2"
FloatingPointModel="2"
WarningLevel="1"
DebugInformationFormat="3"
CallingConvention="1"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="comctl32.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2008-x32.lib zziplib-2008-x32.lib"
OutputFile="$(OutDir)\$(ProjectName).exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
GenerateDebugInformation="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
Profile="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
AdditionalManifestFiles="DeSmuME_x86.manifest"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)\__bins"
@ -369,6 +191,95 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release (SSE2)|Win32"
OutputDirectory="$(SolutionDir)\__bins"
IntermediateDirectory="$(SolutionDir)\.VS2008\$(ConfigurationName)\$(PlatformName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="MASM"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="..;.\zlib123;.\zziplib"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;SSE2\&quot;;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;SSE2;BETA_VERSION;SPU_INTERPOLATE;NOMINMAX"
StringPooling="true"
ExceptionHandling="1"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="2"
FloatingPointModel="2"
WarningLevel="1"
DebugInformationFormat="3"
CallingConvention="1"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="vfw32.lib winmm.lib comctl32.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2008-x32.lib zziplib-2008-x32.lib"
OutputFile="$(OutDir)\$(ProjectName)_sse2.exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
GenerateDebugInformation="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
Profile="false"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
AdditionalManifestFiles="DeSmuME_x86.manifest"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release (SSE2)|x64"
OutputDirectory="$(SolutionDir)\__bins"
@ -456,6 +367,95 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)\__bins"
IntermediateDirectory="$(SolutionDir)\.VS2008\$(ConfigurationName)\$(PlatformName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="MASM"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="..;.\zlib123;.\zziplib"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;0.8.0b2\&quot;;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;BETA_VERSION;SPU_INTERPOLATE;NOMINMAX"
StringPooling="true"
ExceptionHandling="1"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="2"
FloatingPointModel="2"
WarningLevel="1"
DebugInformationFormat="3"
CallingConvention="1"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="vfw32.lib winmm.lib comctl32.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2008-x32.lib zziplib-2008-x32.lib"
OutputFile="$(OutDir)\$(ProjectName).exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
GenerateDebugInformation="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
Profile="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
AdditionalManifestFiles="DeSmuME_x86.manifest"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)\__bins"
@ -622,6 +622,14 @@
Name="MASM"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="MASM"
/>
</FileConfiguration>
<FileConfiguration
Name="Release (SSE2)|Win32"
ExcludedFromBuild="true"
@ -634,8 +642,7 @@
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
Name="Release (SSE2)|x64"
>
<Tool
Name="VCCustomBuildTool"
@ -645,16 +652,9 @@
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="MASM"
/>
</FileConfiguration>
<FileConfiguration
Name="Release (SSE2)|x64"
>
<Tool
Name="VCCustomBuildTool"
Description="Assembling..."
@ -685,14 +685,6 @@
Name="MASM"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="MASM"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
ExcludedFromBuild="true"
@ -709,6 +701,14 @@
Name="MASM"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="MASM"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
ExcludedFromBuild="true"
@ -770,6 +770,10 @@
RelativePath=".\AboutBox.cpp"
>
</File>
<File
RelativePath=".\aviout.cpp"
>
</File>
<File
RelativePath=".\colorctrl.cpp"
>

View File

@ -0,0 +1,430 @@
#include "types.h"
#include "windriver.h"
#include "console.h"
#include "gfx3d.h"
#include <assert.h>
#include <vfw.h>
#include <stdio.h>
void EMU_PrintError(const char* msg) {
printlog(msg);
}
void EMU_PrintMessage(const char* msg) {
printlog(msg);
}
bool DRV_AviBegin(const char* fname);
void DRV_AviEnd();
void DRV_AviSoundUpdate(void* soundData, int soundLen);
bool DRV_AviIsRecording();
void DRV_AviVideoUpdate(const u16* buffer);
//extern PALETTEENTRY *color_palette;
//extern WAVEFORMATEX wf;
//extern int soundo;
#define VIDEO_STREAM 0
#define AUDIO_STREAM 1
#define VIDEO_WIDTH 256
static struct AVIFile
{
int valid;
int fps;
int fps_scale;
int video_added;
BITMAPINFOHEADER bitmap_format;
int sound_added;
WAVEFORMATEX wave_format;
AVISTREAMINFO avi_video_header;
AVISTREAMINFO avi_sound_header;
PAVIFILE avi_file;
PAVISTREAM streams[2];
PAVISTREAM compressed_streams[2];
AVICOMPRESSOPTIONS compress_options[2];
AVICOMPRESSOPTIONS* compress_options_ptr[2];
int video_frames;
int sound_samples;
u8 convert_buffer[256*384*3];
int start_scanline;
int end_scanline;
long tBytes, ByteBuffer;
} *avi_file = NULL;
struct VideoSystemInfo
{
int start_scanline;
int end_scanline;
int fps;
};
static char saved_cur_avi_fnameandext[MAX_PATH];
static char saved_avi_fname[MAX_PATH];
static char saved_avi_ext[MAX_PATH];
static int avi_segnum=0;
//static FILE* avi_check_file=0;
static struct AVIFile saved_avi_info;
static int use_prev_options=0;
static bool use_sound=false;
static bool truncate_existing(const char* filename)
{
// this is only here because AVIFileOpen doesn't seem to do it for us
FILE* fd = fopen(filename, "wb");
if(fd)
{
fclose(fd);
return 1;
}
return 0;
}
static void avi_create(struct AVIFile** avi_out)
{
*avi_out = (struct AVIFile*)malloc(sizeof(struct AVIFile));
memset(*avi_out, 0, sizeof(struct AVIFile));
AVIFileInit();
}
static void avi_destroy(struct AVIFile** avi_out)
{
if(!(*avi_out))
return;
if((*avi_out)->sound_added)
{
if((*avi_out)->compressed_streams[AUDIO_STREAM])
{
LONG test = AVIStreamClose((*avi_out)->compressed_streams[AUDIO_STREAM]);
(*avi_out)->compressed_streams[AUDIO_STREAM] = NULL;
(*avi_out)->streams[AUDIO_STREAM] = NULL; // compressed_streams[AUDIO_STREAM] is just a copy of streams[AUDIO_STREAM]
}
}
if((*avi_out)->video_added)
{
if((*avi_out)->compressed_streams[VIDEO_STREAM])
{
AVIStreamClose((*avi_out)->compressed_streams[VIDEO_STREAM]);
(*avi_out)->compressed_streams[VIDEO_STREAM] = NULL;
}
if((*avi_out)->streams[VIDEO_STREAM])
{
AVIStreamClose((*avi_out)->streams[VIDEO_STREAM]);
(*avi_out)->streams[VIDEO_STREAM] = NULL;
}
}
if((*avi_out)->avi_file)
{
AVIFileClose((*avi_out)->avi_file);
(*avi_out)->avi_file = NULL;
}
free(*avi_out);
*avi_out = NULL;
}
static void set_video_format(const BITMAPINFOHEADER* bitmap_format, struct AVIFile* avi_out)
{
memcpy(&((*avi_out).bitmap_format), bitmap_format, sizeof(BITMAPINFOHEADER));
(*avi_out).video_added = 1;
}
static void set_sound_format(const WAVEFORMATEX* wave_format, struct AVIFile* avi_out)
{
memcpy(&((*avi_out).wave_format), wave_format, sizeof(WAVEFORMATEX));
(*avi_out).sound_added = 1;
}
static int avi_open(const char* filename, const BITMAPINFOHEADER* pbmih, const WAVEFORMATEX* pwfex)
{
int error = 1;
int result = 0;
do
{
// close existing first
DRV_AviEnd();
if(!truncate_existing(filename))
break;
if(!pbmih)
break;
// create the object
avi_create(&avi_file);
// set video size and framerate
/*avi_file->start_scanline = vsi->start_scanline;
avi_file->end_scanline = vsi->end_scanline;
avi_file->fps = vsi->fps;
avi_file->fps_scale = 16777216-1;
avi_file->convert_buffer = new u8[256*384*3];*/
// open the file
if(FAILED(AVIFileOpen(&avi_file->avi_file, filename, OF_CREATE | OF_WRITE, NULL)))
break;
// create the video stream
set_video_format(pbmih, avi_file);
memset(&avi_file->avi_video_header, 0, sizeof(AVISTREAMINFO));
avi_file->avi_video_header.fccType = streamtypeVIDEO;
avi_file->avi_video_header.dwScale = 65536*256;
avi_file->avi_video_header.dwRate = (int)(59.8261*65536*256);
avi_file->avi_video_header.dwSuggestedBufferSize = avi_file->bitmap_format.biSizeImage;
if(FAILED(AVIFileCreateStream(avi_file->avi_file, &avi_file->streams[VIDEO_STREAM], &avi_file->avi_video_header)))
break;
if(use_prev_options)
{
avi_file->compress_options[VIDEO_STREAM] = saved_avi_info.compress_options[VIDEO_STREAM];
avi_file->compress_options_ptr[VIDEO_STREAM] = &avi_file->compress_options[0];
}
else
{
// get compression options
memset(&avi_file->compress_options[VIDEO_STREAM], 0, sizeof(AVICOMPRESSOPTIONS));
avi_file->compress_options_ptr[VIDEO_STREAM] = &avi_file->compress_options[0];
//retryAviSaveOptions: //mbg merge 7/17/06 removed
error = 0;
if(!AVISaveOptions(MainWindow->getHWnd(), 0, 1, &avi_file->streams[VIDEO_STREAM], &avi_file->compress_options_ptr[VIDEO_STREAM]))
break;
error = 1;
}
// create compressed stream
if(FAILED(AVIMakeCompressedStream(&avi_file->compressed_streams[VIDEO_STREAM], avi_file->streams[VIDEO_STREAM], &avi_file->compress_options[VIDEO_STREAM], NULL)))
break;
// set the stream format
if(FAILED(AVIStreamSetFormat(avi_file->compressed_streams[VIDEO_STREAM], 0, (void*)&avi_file->bitmap_format, avi_file->bitmap_format.biSize)))
break;
// add sound (if requested)
if(pwfex)
{
// add audio format
set_sound_format(pwfex, avi_file);
// create the audio stream
memset(&avi_file->avi_sound_header, 0, sizeof(AVISTREAMINFO));
avi_file->avi_sound_header.fccType = streamtypeAUDIO;
avi_file->avi_sound_header.dwQuality = (DWORD)-1;
avi_file->avi_sound_header.dwScale = avi_file->wave_format.nBlockAlign;
avi_file->avi_sound_header.dwRate = avi_file->wave_format.nAvgBytesPerSec;
avi_file->avi_sound_header.dwSampleSize = avi_file->wave_format.nBlockAlign;
avi_file->avi_sound_header.dwInitialFrames = 1;
if(FAILED(AVIFileCreateStream(avi_file->avi_file, &avi_file->streams[AUDIO_STREAM], &avi_file->avi_sound_header)))
break;
// AVISaveOptions doesn't seem to work for audio streams
// so here we just copy the pointer for the compressed stream
avi_file->compressed_streams[AUDIO_STREAM] = avi_file->streams[AUDIO_STREAM];
// set the stream format
if(FAILED(AVIStreamSetFormat(avi_file->compressed_streams[AUDIO_STREAM], 0, (void*)&avi_file->wave_format, sizeof(WAVEFORMATEX))))
break;
}
// initialize counters
avi_file->video_frames = 0;
avi_file->sound_samples = 0;
avi_file->tBytes = 0;
avi_file->ByteBuffer = 0;
// success
error = 0;
result = 1;
avi_file->valid = 1;
} while(0);
if(!result)
{
avi_destroy(&avi_file);
if(error)
EMU_PrintError("Error writing AVI file");
}
return result;
}
//converts 16bpp to 24bpp and flips
static void do_video_conversion(const u16* buffer)
{
u8* outbuf = avi_file->convert_buffer + 256*(384-1)*3;
for(int y=0;y<384;y++)
{
for(int x=0;x<256;x++)
{
u16 col16 = *buffer++;
col16 &=0x7FFF;
u32 col24 = color_15bit_to_24bit[col16];
*outbuf++ = (col24>>16)&0xFF;
*outbuf++ = (col24>>8)&0xFF;
*outbuf++ = col24&0xFF;
}
outbuf -= 256*3*2;
}
}
static bool AviNextSegment()
{
char avi_fname[MAX_PATH];
strcpy(avi_fname,saved_avi_fname);
char avi_fname_temp[MAX_PATH];
sprintf(avi_fname_temp, "%s_part%d%s", avi_fname, avi_segnum+2, saved_avi_ext);
saved_avi_info=*avi_file;
use_prev_options=1;
avi_segnum++;
bool ret = DRV_AviBegin(avi_fname_temp);
use_prev_options=0;
strcpy(saved_avi_fname,avi_fname);
return ret;
}
bool DRV_AviBegin(const char* fname)
{
DRV_AviEnd();
BITMAPINFOHEADER bi;
memset(&bi, 0, sizeof(bi));
bi.biSize = 0x28;
bi.biPlanes = 1;
bi.biBitCount = 24;
bi.biWidth = 256;
bi.biHeight = 384;
bi.biSizeImage = 3 * 256 * 384;
WAVEFORMATEX wf;
wf.cbSize = sizeof(WAVEFORMATEX);
wf.nAvgBytesPerSec = 44100 * 4;
wf.nBlockAlign = 4;
wf.nChannels = 2;
wf.nSamplesPerSec = 44100;
wf.wBitsPerSample = 16;
wf.wFormatTag = WAVE_FORMAT_PCM;
saved_avi_ext[0]='\0';
//mbg 8/10/08 - decide whether there will be sound in this movie
//if this is a new movie..
/*if(!avi_file) {
if(FSettings.SndRate)
use_sound = true;
else use_sound = false;
}*/
//mbg 8/10/08 - if there is no sound in this movie, then dont open the audio stream
WAVEFORMATEX* pwf = &wf;
//if(!use_sound)
// pwf = 0;
if(!avi_open(fname, &bi, pwf))
{
saved_avi_fname[0]='\0';
return 0;
}
// Don't display at file splits
if(!avi_segnum)
EMU_PrintMessage("AVI recording started.");
strncpy(saved_cur_avi_fnameandext,fname,MAX_PATH);
strncpy(saved_avi_fname,fname,MAX_PATH);
char* dot = strrchr(saved_avi_fname, '.');
if(dot && dot > strrchr(saved_avi_fname, '/') && dot > strrchr(saved_avi_fname, '\\'))
{
strcpy(saved_avi_ext,dot);
dot[0]='\0';
}
return 1;
}
void DRV_AviVideoUpdate(const u16* buffer)
{
if(!avi_file || !avi_file->valid)
return;
do_video_conversion(buffer);
if(FAILED(AVIStreamWrite(avi_file->compressed_streams[VIDEO_STREAM],
avi_file->video_frames, 1, avi_file->convert_buffer,
avi_file->bitmap_format.biSizeImage, AVIIF_KEYFRAME,
NULL, &avi_file->ByteBuffer)))
{
avi_file->valid = 0;
return;
}
avi_file->video_frames++;
avi_file->tBytes += avi_file->ByteBuffer;
// segment / split AVI when it's almost 2 GB (2000MB, to be precise)
if(!(avi_file->video_frames % 60) && avi_file->tBytes > 2097152000)
AviNextSegment();
}
void DRV_AviSoundUpdate(void* soundData, int soundLen)
{
int nBytes;
if(!avi_file || !avi_file->valid || !avi_file->sound_added)
return;
nBytes = soundLen * avi_file->wave_format.nBlockAlign;
if(FAILED(AVIStreamWrite(avi_file->compressed_streams[AUDIO_STREAM],
avi_file->sound_samples, soundLen,
soundData, nBytes, 0, NULL, &avi_file->ByteBuffer)))
{
avi_file->valid = 0;
return;
}
avi_file->sound_samples += soundLen;
avi_file->tBytes += avi_file->ByteBuffer;
}
void DRV_AviEnd()
{
if(!avi_file)
return;
// Don't display if we're just starting another segment
if(avi_file->tBytes <= 2097152000)
EMU_PrintMessage("AVI recording ended.");
avi_destroy(&avi_file);
}
bool DRV_AviIsRecording()
{
if(avi_file)
return true;
return false;
}

File diff suppressed because it is too large Load Diff

View File

@ -324,13 +324,17 @@
#define ID_VIEW_DISPLAYFPS 40010
#define ID_VIS_DISPLAYFPS 40011
#define ID_VIEW_DISPLAYFPS40012 40012
#define ID_FILE_RECORDAVI 40013
#define ID_FILE_STOPAVI 40014
#define IDM_FILE_RECORDAVI 40015
#define IDM_FILE_STOPAVI 40016
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 107
#define _APS_NEXT_COMMAND_VALUE 40013
#define _APS_NEXT_COMMAND_VALUE 40017
#define _APS_NEXT_CONTROL_VALUE 1013
#define _APS_NEXT_SYMED_VALUE 112
#endif

View File

@ -706,6 +706,9 @@ BEGIN
MENUITEM "Save Screenshot &As", IDM_PRINTSCREEN
MENUITEM "&Quick Screenshot", IDM_QUICK_PRINTSCREEN
MENUITEM SEPARATOR
MENUITEM "Record AVI", IDM_FILE_RECORDAVI
MENUITEM "Stop AVI", IDM_FILE_STOPAVI
MENUITEM SEPARATOR
MENUITEM "&Quit", IDM_QUIT
END
POPUP "&Emulation"

View File

@ -65,6 +65,23 @@ static int issoundmuted;
//////////////////////////////////////////////////////////////////////////////
static volatile bool terminate;
static volatile bool terminated;
extern CRITICAL_SECTION win_sync;
extern volatile int win_sound_samplecounter;
DWORD WINAPI SNDDXThread( LPVOID lpParameter)
{
for(;;) {
if(terminate) break;
SPU_Emulate_user();
Sleep(10);
}
terminated = true;
return 0;
}
int SNDDXInit(int buffersize)
{
DSBUFFERDESC dsbdesc;
@ -161,6 +178,10 @@ int SNDDXInit(int buffersize)
soundvolume = DSBVOLUME_MAX;
issoundmuted = 0;
terminate = false;
terminated = false;
CreateThread(0,0,SNDDXThread,0,0,0);
return 0;
}
@ -169,6 +190,11 @@ int SNDDXInit(int buffersize)
void SNDDXDeInit()
{
DWORD status=0;
terminate = true;
while(!terminated) {
Sleep(1);
}
if (lpDSB2)
{
@ -203,6 +229,11 @@ void SNDDXUpdateAudio(s16 *buffer, u32 num_samples)
DWORD buffer1_size, buffer2_size;
DWORD status;
EnterCriticalSection(&win_sync);
int samplecounter = win_sound_samplecounter -= num_samples;
LeaveCriticalSection(&win_sync);
bool silence = (samplecounter<-44100*15/60); //behind by more than a quarter second -> silence
IDirectSoundBuffer8_GetStatus(lpDSB2, &status);
if (status & DSBSTATUS_BUFFERLOST)
@ -210,9 +241,17 @@ void SNDDXUpdateAudio(s16 *buffer, u32 num_samples)
IDirectSoundBuffer8_Lock(lpDSB2, soundoffset, num_samples * sizeof(s16) * 2, &buffer1, &buffer1_size, &buffer2, &buffer2_size, 0);
memcpy(buffer1, buffer, buffer1_size);
if (buffer2)
memcpy(buffer2, ((u8 *)buffer)+buffer1_size, buffer2_size);
if(silence) {
memset(buffer1, 0, buffer1_size);
if(buffer2)
memset(buffer2, 0, buffer2_size);
}
else
{
memcpy(buffer1, buffer, buffer1_size);
if (buffer2)
memcpy(buffer2, ((u8 *)buffer)+buffer1_size, buffer2_size);
}
soundoffset += buffer1_size + buffer2_size;
soundoffset %= soundbufsize;

View File

@ -0,0 +1,10 @@
#ifndef _WINDRIVER_H_
#define _WINDRIVER_H_
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "CWindow.h"
extern WINCLASS *MainWindow;
#endif