core: make adpcm cache optional (defaulted to off) temporarily until it can handle streams well. i have a plan for that but i am burnt out on it for now. bind that option into win32 gui
This commit is contained in:
parent
52e26afa32
commit
de794ec6e8
|
@ -356,6 +356,7 @@ extern struct TCommonSettings {
|
|||
, DebugConsole(false)
|
||||
, wifiBridgeAdapterNum(0)
|
||||
, spuInterpolationMode(SPUInterpolation_Linear)
|
||||
, spuAdpcmCache(false)
|
||||
{
|
||||
strcpy(ARM9BIOS, "biosnds9.bin");
|
||||
strcpy(ARM7BIOS, "biosnds7.bin");
|
||||
|
@ -375,7 +376,9 @@ extern struct TCommonSettings {
|
|||
bool DebugConsole;
|
||||
|
||||
int wifiBridgeAdapterNum;
|
||||
|
||||
SPUInterpolationMode spuInterpolationMode;
|
||||
bool spuAdpcmCache;
|
||||
} CommonSettings;
|
||||
|
||||
extern char ROMserial[20];
|
||||
|
|
|
@ -35,10 +35,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
#include "NDSSystem.h"
|
||||
#include "matrix.h"
|
||||
|
||||
//this is fundamentally a runtime option, so it could be dependent on an emulator option.
|
||||
//this define only determines whether the feature is available (and for now the runtime option is always enabled)
|
||||
#define USE_ADPCM_CACHING
|
||||
|
||||
//#undef FORCEINLINE
|
||||
//#define FORCEINLINE
|
||||
|
||||
|
@ -137,6 +133,7 @@ public:
|
|||
u32 addr;
|
||||
s8* raw_copy; //for memcmp
|
||||
u32 raw_len;
|
||||
u32 decode_len;
|
||||
s16* decoded; //s16 decoded samples
|
||||
ADPCMCacheItem *next, *prev; //double linked list
|
||||
};
|
||||
|
@ -157,7 +154,7 @@ public:
|
|||
ADPCMCacheItem *list_front, *list_back;
|
||||
|
||||
//this ought to be enough for anyone
|
||||
static const u32 kMaxCacheSize = 16*1024*1024;
|
||||
static const u32 kMaxCacheSize = 8*1024*1024;
|
||||
//this is not really precise, it is off by a constant factor
|
||||
u32 cache_size;
|
||||
|
||||
|
@ -176,7 +173,7 @@ public:
|
|||
return;
|
||||
}
|
||||
list_remove(oldest);
|
||||
cache_size -= oldest->raw_len*8;
|
||||
cache_size -= oldest->raw_len*2;
|
||||
//printf("evicting! totalsize:%d\n",cache_size);
|
||||
delete oldest;
|
||||
}
|
||||
|
@ -189,16 +186,18 @@ public:
|
|||
{
|
||||
u32 addr = chan->addr;
|
||||
s8* raw = chan->buf8;
|
||||
u32 raw_len = chan->length + chan->loopstart;
|
||||
u32 raw_len = chan->totlength * 4;
|
||||
for(ADPCMCacheItem* curr = list_front;curr;curr=curr->next)
|
||||
{
|
||||
if(curr->addr != addr) continue;
|
||||
if(curr->raw_len != raw_len) continue;
|
||||
if(memcmp(curr->raw_copy,raw,raw_len))
|
||||
{
|
||||
//you might think that you could throw out this item now, to keep the cache tidy.
|
||||
//maybe you could!
|
||||
continue;
|
||||
//we found a cached item for the current address, but the data is stale.
|
||||
//for a variety of complicated reasons, we need to throw it out right this instant.
|
||||
list_remove(curr);
|
||||
delete curr;
|
||||
break;
|
||||
}
|
||||
|
||||
curr->lock();
|
||||
|
@ -215,8 +214,8 @@ public:
|
|||
newitem->raw_len = raw_len;
|
||||
newitem->raw_copy = new s8[raw_len];
|
||||
memcpy(newitem->raw_copy,chan->buf8,raw_len);
|
||||
u32 decode_len = raw_len*8;
|
||||
cache_size += decode_len;
|
||||
u32 decode_len = newitem->decode_len = raw_len*2;
|
||||
cache_size += newitem->decode_len;
|
||||
newitem->decoded = new s16[decode_len];
|
||||
|
||||
int index = chan->buf8[2] & 0x7F;
|
||||
|
@ -482,10 +481,10 @@ void SPU_struct::KeyOn(int channel)
|
|||
// thischan.loopstart = thischan.loopstart << 3;
|
||||
// thischan.length = (thischan.length << 3) + thischan.loopstart;
|
||||
if(thischan.cacheItem) thischan.cacheItem->unlock();
|
||||
#ifdef USE_ADPCM_CACHING
|
||||
if(this != SPU_core)
|
||||
thischan.cacheItem = adpcmCache.scan(&thischan);
|
||||
#endif
|
||||
thischan.cacheItem = NULL;
|
||||
if(CommonSettings.spuAdpcmCache)
|
||||
if(this != SPU_core)
|
||||
thischan.cacheItem = adpcmCache.scan(&thischan);
|
||||
break;
|
||||
}
|
||||
case 3: // PSG
|
||||
|
@ -582,6 +581,7 @@ void SPU_struct::WriteWord(u32 addr, u16 val)
|
|||
thischan.loopstart = val;
|
||||
thischan.totlength = thischan.length + thischan.loopstart;
|
||||
thischan.double_totlength_shifted = (double)(thischan.totlength << format_shift[thischan.format]);
|
||||
printf("%d %d %d\n",thischan.num,thischan.length,thischan.loopstart);
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -633,6 +633,7 @@ void SPU_struct::WriteLong(u32 addr, u32 val)
|
|||
thischan.length = val & 0x3FFFFF;
|
||||
thischan.totlength = thischan.length + thischan.loopstart;
|
||||
thischan.double_totlength_shifted = (double)(thischan.totlength << format_shift[thischan.format]);
|
||||
printf("%d %d %d\n",thischan.num,thischan.length,thischan.loopstart);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -839,8 +840,6 @@ static FORCEINLINE void TestForLoop2(SPU_struct *SPU, channel_struct *chan)
|
|||
chan->pcm16b = (s16)((chan->buf8[1] << 8) | chan->buf8[0]);
|
||||
chan->index = chan->buf8[2] & 0x7F;
|
||||
chan->lastsampcnt = 7;
|
||||
//TODO: ADPCM RESCAN?
|
||||
//this might would help in case streaming adpcm sounds arent working well
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1328,14 +1327,13 @@ bool spu_loadstate(std::istream* is, int size)
|
|||
|
||||
memcpy(SPU_user->channels,SPU_core->channels,sizeof(SPU_core->channels));
|
||||
|
||||
#ifdef USE_ADPCM_CACHING
|
||||
for(int i=0;i<16;i++)
|
||||
{
|
||||
channel_struct &chan = SPU_user->channels[i];
|
||||
if(chan.format == 2)
|
||||
chan.cacheItem = adpcmCache.scan(&chan);
|
||||
}
|
||||
#endif
|
||||
if(CommonSettings.spuAdpcmCache)
|
||||
for(int i=0;i<16;i++)
|
||||
{
|
||||
channel_struct &chan = SPU_user->channels[i];
|
||||
if(chan.format == 2)
|
||||
chan.cacheItem = adpcmCache.scan(&chan);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -6,11 +6,14 @@ EndProject
|
|||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release FastBuild|Win32 = Release FastBuild|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Release FastBuild|Win32.ActiveCfg = Release FastBuild|Win32
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Release FastBuild|Win32.Build.0 = Release FastBuild|Win32
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
AdditionalIncludeDirectories=".;..;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig"
|
||||
PreprocessorDefinitions="DEBUG;_CRT_SECURE_NO_DEPRECATE;WIN32;SPU_INTERPOLATE;HAVE_LIBZ;HAVE_LIBZZIP;NOMINMAX;DEBUG;EXPERIMENTAL_WIFI"
|
||||
ExceptionHandling="1"
|
||||
BasicRuntimeChecks="2"
|
||||
BasicRuntimeChecks="0"
|
||||
BufferSecurityCheck="true"
|
||||
EnableEnhancedInstructionSet="2"
|
||||
FloatingPointModel="2"
|
||||
|
@ -204,6 +204,104 @@
|
|||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release FastBuild|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
WholeProgramOptimization="0"
|
||||
>
|
||||
<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="false"
|
||||
AdditionalIncludeDirectories=".;..;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig"
|
||||
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;SPU_INTERPOLATE;NOMINMAX;NDEBUG;RELEASE;EXPERIMENTAL_WIFI"
|
||||
StringPooling="true"
|
||||
ExceptionHandling="1"
|
||||
BasicRuntimeChecks="0"
|
||||
StructMemberAlignment="0"
|
||||
BufferSecurityCheck="false"
|
||||
EnableFunctionLevelLinking="false"
|
||||
EnableEnhancedInstructionSet="2"
|
||||
FloatingPointModel="2"
|
||||
RuntimeTypeInfo="false"
|
||||
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 shlwapi.lib winpcap\wpcap.lib"
|
||||
OutputFile="$(OutDir)\$(ProjectName)_release.exe"
|
||||
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
|
||||
DelayLoadDLLs="wpcap.dll"
|
||||
GenerateDebugInformation="true"
|
||||
GenerateMapFile="true"
|
||||
EnableCOMDATFolding="0"
|
||||
OptimizeForWindows98="1"
|
||||
LinkTimeCodeGeneration="0"
|
||||
/>
|
||||
<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>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
|
@ -523,6 +621,15 @@
|
|||
XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release FastBuild|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\$(InputName)1.obj"
|
||||
XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\utils\decrypt\decrypt.h"
|
||||
|
@ -560,6 +667,14 @@
|
|||
Name="MASM"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release FastBuild|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="MASM"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\matrix_sse2-x86.asm"
|
||||
|
@ -853,6 +968,14 @@
|
|||
CallingConvention="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release FastBuild|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CallingConvention="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\ROMReader.h"
|
||||
|
@ -877,6 +1000,14 @@
|
|||
CallingConvention="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release FastBuild|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CallingConvention="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\saves.h"
|
||||
|
@ -901,6 +1032,14 @@
|
|||
<File
|
||||
RelativePath="..\SPU.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release FastBuild|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\SPU.h"
|
||||
|
|
|
@ -1834,6 +1834,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
|
|||
sndcoretype = GetPrivateProfileInt("Sound","SoundCore", SNDCORE_DIRECTX, IniName);
|
||||
sndbuffersize = GetPrivateProfileInt("Sound","SoundBufferSize", 735 * 4, IniName);
|
||||
CommonSettings.spuInterpolationMode = (SPUInterpolationMode)GetPrivateProfileInt("Sound","SPUInterpolation", 1, IniName);
|
||||
CommonSettings.spuAdpcmCache = GetPrivateProfileInt("Sound","SPUAdpcmCache",0,IniName)!=0;
|
||||
|
||||
EnterCriticalSection(&win_sync);
|
||||
int spu_ret = SPU_ChangeSoundCore(sndcoretype, sndbuffersize);
|
||||
|
@ -3922,6 +3923,9 @@ LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARA
|
|||
SendDlgItemMessage(hDlg, IDC_SPU_INTERPOLATION_CB, CB_ADDSTRING, 0, (LPARAM)"Cosine (slowest, sounds best)");
|
||||
SendDlgItemMessage(hDlg, IDC_SPU_INTERPOLATION_CB, CB_SETCURSEL, (int)CommonSettings.spuInterpolationMode, 0);
|
||||
|
||||
//setup cache setting
|
||||
CheckDlgButton(hDlg, IDC_SPU_CACHE, CommonSettings.spuAdpcmCache?BST_CHECKED:BST_UNCHECKED );
|
||||
|
||||
// Setup Sound Buffer Size Edit Text
|
||||
sprintf(tempstr, "%d", sndbuffersize);
|
||||
SetDlgItemText(hDlg, IDC_SOUNDBUFFERET, tempstr);
|
||||
|
@ -3981,6 +3985,10 @@ LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARA
|
|||
CommonSettings.spuInterpolationMode = (SPUInterpolationMode)SendDlgItemMessage(hDlg, IDC_SPU_INTERPOLATION_CB, CB_GETCURSEL, 0, 0);
|
||||
WritePrivateProfileInt("Sound","SPUInterpolation",(int)CommonSettings.spuInterpolationMode, IniName);
|
||||
|
||||
//write cache setting
|
||||
CommonSettings.spuAdpcmCache = IsDlgButtonChecked(hDlg, IDC_SPU_CACHE) != 0;
|
||||
WritePrivateProfileInt("Sound","SPUAdpcmCache",CommonSettings.spuAdpcmCache?1:0, IniName);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
case IDCANCEL:
|
||||
|
|
|
@ -248,6 +248,7 @@
|
|||
#define IDC_ROTATE180 1005
|
||||
#define IDC_EDIT12 1006
|
||||
#define IDC_ROTATE270 1006
|
||||
#define IDC_SPU_CACHE 1006
|
||||
#define IDC_ARM7BIOSBROWSE 1007
|
||||
#define IDC_EDIT06 1007
|
||||
#define IDC_EDIT09 1008
|
||||
|
|
|
@ -3557,27 +3557,30 @@ END
|
|||
|
||||
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
IDD_SOUNDSETTINGS DIALOGEX 0, 0, 174, 127
|
||||
IDD_SOUNDSETTINGS DIALOGEX 0, 0, 201, 161
|
||||
STYLE DS_CENTER | DS_MODALFRAME | DS_SETFONT | WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU
|
||||
CAPTION "Sound Settings"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 1
|
||||
BEGIN
|
||||
GROUPBOX "Sound Core Settings", -1, 3, 2, 168, 28
|
||||
GROUPBOX "Sound Core Settings", -1, 3, 2, 192, 28
|
||||
LTEXT "Sound Core", -1, 10, 14, 40, 10, SS_LEFT
|
||||
COMBOBOX IDC_SOUNDCORECB, 54, 13, 110, 33, WS_TABSTOP | WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWNLIST
|
||||
GROUPBOX "Other Settings", -1, 3, 31, 168, 61
|
||||
COMBOBOX IDC_SOUNDCORECB, 54, 13, 132, 33, WS_TABSTOP | WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWNLIST
|
||||
GROUPBOX "Other Settings", -1, 3, 31, 192, 101
|
||||
LTEXT "Buffer Size", -1, 10, 62, 60, 10, SS_LEFT
|
||||
EDITTEXT IDC_SOUNDBUFFERET, 55, 61, 42, 13
|
||||
LTEXT "Volume", -1, 10, 77, 30, 10, SS_LEFT
|
||||
CONTROL "", IDC_SLVOLUME, TRACKBAR_CLASS, 0, 40, 77, 128, 10
|
||||
DEFPUSHBUTTON "&OK", IDOK, 82, 97, 40, 14, BS_DEFPUSHBUTTON
|
||||
PUSHBUTTON "&Cancel", IDCANCEL, 127, 97, 40, 14, BS_PUSHBUTTON
|
||||
DEFPUSHBUTTON "&OK", IDOK, 109, 141, 40, 14, BS_DEFPUSHBUTTON
|
||||
PUSHBUTTON "&Cancel", IDCANCEL, 154, 141, 40, 14, BS_PUSHBUTTON
|
||||
LTEXT "Interpolation", -1, 9, 46, 40, 8, SS_LEFT
|
||||
COMBOBOX IDC_SPU_INTERPOLATION_CB, 55, 42, 110, 33, WS_TABSTOP | WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWNLIST
|
||||
COMBOBOX IDC_SPU_INTERPOLATION_CB, 55, 42, 131, 33, WS_TABSTOP | WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWNLIST
|
||||
AUTOCHECKBOX "Enable ADPCM Caching", IDC_SPU_CACHE, 12, 90, 93, 10, BS_AUTOCHECKBOX
|
||||
LTEXT "This offers a substantial speedup in some cases, but\nbut causes glitches (repeating sounds) in streaming sounds.", IDC_STATIC, 17, 102, 175, 24, SS_LEFT
|
||||
END
|
||||
|
||||
|
||||
|
||||
|
||||
LANGUAGE LANG_DANISH, SUBLANG_DANISH_DENMARK
|
||||
IDD_TILE DIALOGEX 0, 0, 446, 180
|
||||
STYLE DS_SETFONT | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU
|
||||
|
|
Loading…
Reference in New Issue